Always include Jsdoc comment in getTouchingPropertyName (#23379)
This commit is contained in:
parent
a641e6f85f
commit
b3a4b72a16
|
@ -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 {
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* @internal */
|
||||
namespace ts.DocumentHighlights {
|
||||
export function getDocumentHighlights(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: ReadonlyArray<SourceFile>): 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.
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace ts.FindAllReferences {
|
|||
}
|
||||
|
||||
export function findReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray<SourceFile>, 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<SymbolAndEntries, ReferencedSymbol>(referencedSymbols, ({ definition, references }) =>
|
||||
|
@ -52,8 +52,7 @@ namespace ts.FindAllReferences {
|
|||
}
|
||||
|
||||
export function getImplementationsAtPosition(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray<SourceFile>, 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: 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<Node> {
|
||||
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<number> {
|
||||
|
@ -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
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue