Skip to content

Commit 13bc46d

Browse files
author
Andy
authored
getTokenAtPosition: default includeJsDocComment to true (microsoft#25015)
* getTokenAtPosition: default includeJsDocComment to true * Update API (microsoft#24966) * Flip meaning of parameter * Update API (microsoft#24966) * Remove all `ignoreJsDocComment` uses (fixes microsoft#25162)
1 parent f4a2ee4 commit 13bc46d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+84
-115
lines changed

src/compiler/binder.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,11 @@ namespace ts {
697697
bindJSDocTypeAlias(node as JSDocTypedefTag | JSDocCallbackTag);
698698
break;
699699
// In source files and blocks, bind functions first to match hoisting that occurs at runtime
700-
case SyntaxKind.SourceFile:
700+
case SyntaxKind.SourceFile: {
701701
bindEachFunctionsFirst((node as SourceFile).statements);
702702
bind((node as SourceFile).endOfFileToken);
703703
break;
704+
}
704705
case SyntaxKind.Block:
705706
case SyntaxKind.ModuleBlock:
706707
bindEachFunctionsFirst((node as Block).statements);
@@ -1975,7 +1976,10 @@ namespace ts {
19751976
}
19761977
else if (!skipTransformFlagAggregation && (node.transformFlags & TransformFlags.HasComputedFlags) === 0) {
19771978
subtreeTransformFlags |= computeTransformFlagsForNode(node, 0);
1979+
const saveParent = parent;
1980+
if (node.kind === SyntaxKind.EndOfFileToken) parent = node;
19781981
bindJSDoc(node);
1982+
parent = saveParent;
19791983
}
19801984
inStrictMode = saveInStrictMode;
19811985
}

src/services/breakpoints.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace ts.BreakpointResolver {
99
return undefined;
1010
}
1111

12-
let tokenAtLocation = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false);
12+
let tokenAtLocation = getTokenAtPosition(sourceFile, position);
1313
const lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
1414
if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) {
1515
// Get previous token if the token is returned starts on new line

src/services/codefixes/addMissingInvocationForDecorator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace ts.codefix {
1313
});
1414

1515
function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number) {
16-
const token = getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
16+
const token = getTokenAtPosition(sourceFile, pos);
1717
const decorator = findAncestor(token, isDecorator)!;
1818
Debug.assert(!!decorator, "Expected position to be owned by a decorator.");
1919
const replacement = createCall(decorator.expression, /*typeArguments*/ undefined, /*argumentsArray*/ undefined);

src/services/codefixes/annotateWithTypeFromJSDoc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace ts.codefix {
1818
});
1919

2020
function getDeclaration(file: SourceFile, pos: number): DeclarationWithType | undefined {
21-
const name = getTokenAtPosition(file, pos, /*includeJsDocComment*/ false);
21+
const name = getTokenAtPosition(file, pos);
2222
// For an arrow function with no name, 'name' lands on the first parameter.
2323
return tryCast(isParameter(name.parent) ? name.parent.parent : name.parent, parameterShouldGetTypeFromJSDoc);
2424
}

src/services/codefixes/convertFunctionToEs6Class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace ts.codefix {
1414

1515
function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, position: number, checker: TypeChecker): void {
1616
const deletedNodes: { node: Node, inList: boolean }[] = [];
17-
const ctorSymbol = checker.getSymbolAtLocation(getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false))!;
17+
const ctorSymbol = checker.getSymbolAtLocation(getTokenAtPosition(sourceFile, position))!;
1818

1919
if (!ctorSymbol || !(ctorSymbol.flags & (SymbolFlags.Function | SymbolFlags.Variable))) {
2020
// Bad input

src/services/codefixes/convertToMappedObjectType.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace ts.codefix {
2525

2626
interface Info { readonly indexSignature: IndexSignatureDeclaration; readonly container: FixableDeclaration; }
2727
function getInfo(sourceFile: SourceFile, pos: number): Info | undefined {
28-
const token = getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
28+
const token = getTokenAtPosition(sourceFile, pos);
2929
const indexSignature = cast(token.parent.parent, isIndexSignatureDeclaration);
3030
if (isClassDeclaration(indexSignature.parent)) return undefined;
3131
const container = isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : cast(indexSignature.parent.parent, isTypeAliasDeclaration);

src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace ts.codefix {
2121
});
2222

2323
function getQualifiedName(sourceFile: SourceFile, pos: number): QualifiedName & { left: Identifier } | undefined {
24-
const qualifiedName = findAncestor(getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ true), isQualifiedName)!;
24+
const qualifiedName = findAncestor(getTokenAtPosition(sourceFile, pos), isQualifiedName)!;
2525
Debug.assert(!!qualifiedName, "Expected position to be owned by a qualified name.");
2626
return isIdentifier(qualifiedName.left) ? qualifiedName as QualifiedName & { left: Identifier } : undefined;
2727
}

src/services/codefixes/fixAddMissingMember.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace ts.codefix {
5252
// The identifier of the missing property. eg:
5353
// this.missing = 1;
5454
// ^^^^^^^
55-
const token = getTokenAtPosition(tokenSourceFile, tokenPos, /*includeJsDocComment*/ false);
55+
const token = getTokenAtPosition(tokenSourceFile, tokenPos);
5656
if (!isIdentifier(token)) {
5757
return undefined;
5858
}

src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace ts.codefix {
1717
});
1818

1919
function getImportTypeNode(sourceFile: SourceFile, pos: number): ImportTypeNode {
20-
const token = getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false);
20+
const token = getTokenAtPosition(sourceFile, pos);
2121
Debug.assert(token.kind === SyntaxKind.ImportKeyword);
2222
Debug.assert(token.parent.kind === SyntaxKind.ImportType);
2323
return <ImportTypeNode>token.parent;

src/services/codefixes/fixAwaitInSyncFunction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace ts.codefix {
3434
}
3535

3636
function getNodes(sourceFile: SourceFile, start: number): { insertBefore: Node, returnType: TypeNode | undefined } | undefined {
37-
const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false);
37+
const token = getTokenAtPosition(sourceFile, start);
3838
const containingFunction = getContainingFunction(token);
3939
if (!containingFunction) {
4040
return;

0 commit comments

Comments
 (0)