diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index d2aaeecbb9..2ace3df3b4 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1090,7 +1090,7 @@ namespace FourSlash { } private getNode(): ts.Node { - return ts.getTouchingPropertyName(this.getSourceFile(), this.currentCaretPosition, /*includeJsDocComment*/ false); + return ts.getTouchingPropertyName(this.getSourceFile(), this.currentCaretPosition); } private goToAndGetNode(range: Range): ts.Node { diff --git a/src/services/completions.ts b/src/services/completions.ts index 9f1a7cf068..d83e86ab4a 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -875,7 +875,7 @@ namespace ts.Completions { let isStartingCloseTag = false; let isJsxInitializer: IsJsxInitializer = false; - let location = getTouchingPropertyName(sourceFile, position, insideJsDocTagTypeExpression); // TODO: GH#15853 + let location = getTouchingPropertyName(sourceFile, position); if (contextToken) { // Bail out if this is a known invalid completion location if (isCompletionListBlocker(contextToken)) { diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index d4199d80d8..458b12c2ad 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -1,7 +1,7 @@ /* @internal */ namespace ts.DocumentHighlights { export function getDocumentHighlights(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: ReadonlyArray): DocumentHighlights[] | undefined { - const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); + const node = getTouchingPropertyName(sourceFile, position); if (node.parent && (isJsxOpeningElement(node.parent) && node.parent.tagName === node || isJsxClosingElement(node.parent))) { // For a JSX element, just highlight the matching tag, not all references. diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index c87bdb5e92..394e487e2f 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -40,7 +40,7 @@ namespace ts.FindAllReferences { } export function findReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number): ReferencedSymbol[] | undefined { - const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); + const node = getTouchingPropertyName(sourceFile, position); const referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken); const checker = program.getTypeChecker(); return !referencedSymbols || !referencedSymbols.length ? undefined : mapDefined(referencedSymbols, ({ definition, references }) => @@ -52,8 +52,7 @@ namespace ts.FindAllReferences { } export function getImplementationsAtPosition(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number): ImplementationLocation[] | undefined { - // A node in a JSDoc comment can't have an implementation anyway. - const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ false); + const node = getTouchingPropertyName(sourceFile, position); const referenceEntries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); const checker = program.getTypeChecker(); return map(referenceEntries, entry => toImplementationLocation(entry, checker)); @@ -85,7 +84,7 @@ namespace ts.FindAllReferences { } export function findReferencedEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number, options?: Options): ReferenceEntry[] | undefined { - const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); + const node = getTouchingPropertyName(sourceFile, position); return map(flattenEntries(Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options)), toReferenceEntry); } @@ -732,7 +731,7 @@ namespace ts.FindAllReferences.Core { } function getPossibleSymbolReferenceNodes(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile): ReadonlyArray { - return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(pos => getTouchingPropertyName(sourceFile, pos, /*includeJsDocComment*/ true)); + return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(pos => getTouchingPropertyName(sourceFile, pos)); } function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile): ReadonlyArray { @@ -836,7 +835,7 @@ namespace ts.FindAllReferences.Core { } function getReferencesAtLocation(sourceFile: SourceFile, position: number, search: Search, state: State, addReferencesHere: boolean): void { - const referenceLocation = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); + const referenceLocation = getTouchingPropertyName(sourceFile, position); if (!isValidReferencePosition(referenceLocation, search.text)) { // This wasn't the start of a token. Check to see if it might be a diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index e9937549e2..1281f30d73 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -6,7 +6,7 @@ namespace ts.GoToDefinition { return [getDefinitionInfoForFileReference(reference.fileName, reference.file.fileName)]; } - const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); + const node = getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { return undefined; } @@ -112,7 +112,7 @@ namespace ts.GoToDefinition { /// Goto type export function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile: SourceFile, position: number): DefinitionInfo[] | undefined { - const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); + const node = getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { return undefined; } @@ -143,7 +143,7 @@ namespace ts.GoToDefinition { return { definitions, textSpan: createTextSpanFromRange(comment) }; } - const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); + const node = getTouchingPropertyName(sourceFile, position); const textSpan = createTextSpan(node.getStart(), node.getWidth()); return { definitions, textSpan }; diff --git a/src/services/rename.ts b/src/services/rename.ts index ab83baf167..cd557f5aaa 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -2,7 +2,7 @@ namespace ts.Rename { export function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: GetCanonicalFileName, sourceFile: SourceFile, position: number): RenameInfo { const getCanonicalDefaultLibName = memoize(() => getCanonicalFileName(normalizePath(defaultLibFileName))); - const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); + const node = getTouchingPropertyName(sourceFile, position); const renameInfo = node && nodeIsEligibleForRename(node) ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) : undefined; diff --git a/src/services/services.ts b/src/services/services.ts index 603206e52d..6d89dcb702 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1466,7 +1466,7 @@ namespace ts { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); - const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); + const node = getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { // Avoid giving quickInfo for the sourceFile as a whole. return undefined; @@ -1784,7 +1784,7 @@ namespace ts { const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); // Get node at the location - const node = getTouchingPropertyName(sourceFile, startPos, /*includeJsDocComment*/ false); + const node = getTouchingPropertyName(sourceFile, startPos); if (node === sourceFile) { return undefined; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index fa795f359f..786de97f20 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -648,8 +648,8 @@ namespace ts { * Gets the token whose text has range [start, end) and * position >= start and (position < end or (position === end && token is literal or keyword or identifier)) */ - export function getTouchingPropertyName(sourceFile: SourceFile, position: number, includeJsDocComment: boolean): Node { - return getTouchingToken(sourceFile, position, includeJsDocComment, n => isPropertyNameLiteral(n) || isKeyword(n.kind)); + export function getTouchingPropertyName(sourceFile: SourceFile, position: number): Node { + return getTouchingToken(sourceFile, position, /*includeJsDocComment*/ true, n => isPropertyNameLiteral(n) || isKeyword(n.kind)); } /**