mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-21 18:22:58 -05:00
[Interactive inlay hints] Get source file from parameter node (#55476)
This commit is contained in:
committed by
GitHub
parent
12d9f04d33
commit
5fe88ea044
@@ -62,7 +62,6 @@ import {
|
||||
Signature,
|
||||
skipParentheses,
|
||||
some,
|
||||
SourceFile,
|
||||
Symbol,
|
||||
SymbolFlags,
|
||||
SyntaxKind,
|
||||
@@ -157,11 +156,11 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
|
||||
return isArrowFunction(node) || isFunctionExpression(node) || isFunctionDeclaration(node) || isMethodDeclaration(node) || isGetAccessorDeclaration(node);
|
||||
}
|
||||
|
||||
function addParameterHints(text: string, parameter: Identifier, position: number, isFirstVariadicArgument: boolean, sourceFile: SourceFile | undefined) {
|
||||
function addParameterHints(text: string, parameter: Identifier, position: number, isFirstVariadicArgument: boolean) {
|
||||
let hintText = `${isFirstVariadicArgument ? "..." : ""}${text}`;
|
||||
let displayParts: InlayHintDisplayPart[] | undefined;
|
||||
if (shouldUseInteractiveInlayHints(preferences)) {
|
||||
displayParts = [getNodeDisplayPart(hintText, parameter, sourceFile!), { text: ":" }];
|
||||
displayParts = [getNodeDisplayPart(hintText, parameter), { text: ":" }];
|
||||
hintText = "";
|
||||
}
|
||||
else {
|
||||
@@ -247,8 +246,6 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
|
||||
return;
|
||||
}
|
||||
|
||||
const sourceFile = shouldUseInteractiveInlayHints(preferences) ? expr.getSourceFile() : undefined;
|
||||
|
||||
let signatureParamPos = 0;
|
||||
for (const originalArg of args) {
|
||||
const arg = skipParentheses(originalArg);
|
||||
@@ -287,7 +284,7 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
|
||||
continue;
|
||||
}
|
||||
|
||||
addParameterHints(name, parameter, originalArg.getStart(), isFirstVariadicArgument, sourceFile);
|
||||
addParameterHints(name, parameter, originalArg.getStart(), isFirstVariadicArgument);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -437,7 +434,8 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
|
||||
return true;
|
||||
}
|
||||
|
||||
function getNodeDisplayPart(text: string, node: Node, sourceFile: SourceFile): InlayHintDisplayPart {
|
||||
function getNodeDisplayPart(text: string, node: Node): InlayHintDisplayPart {
|
||||
const sourceFile = node.getSourceFile();
|
||||
return {
|
||||
text,
|
||||
span: createTextSpanFromNode(node, sourceFile),
|
||||
|
||||
Reference in New Issue
Block a user