Merge pull request #8603 from Microsoft/hover_over_comment
Fix bug: getTouchingPropertyName does not return undefined, but it may return the source file node
This commit is contained in:
commit
c62b6cb6fc
|
@ -4645,7 +4645,7 @@ namespace ts {
|
|||
|
||||
const sourceFile = getValidSourceFile(fileName);
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
if (node === sourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -4802,18 +4802,6 @@ namespace ts {
|
|||
|
||||
const sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Labels
|
||||
if (isJumpStatementTarget(node)) {
|
||||
const labelName = (<Identifier>node).text;
|
||||
const label = getTargetLabel((<BreakOrContinueStatement>node.parent), (<Identifier>node).text);
|
||||
return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined;
|
||||
}
|
||||
|
||||
/// Triple slash reference comments
|
||||
const comment = findReferenceInPosition(sourceFile.referencedFiles, position);
|
||||
if (comment) {
|
||||
|
@ -4823,6 +4811,7 @@ namespace ts {
|
|||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Type reference directives
|
||||
const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
|
||||
if (typeReferenceDirective) {
|
||||
|
@ -4833,6 +4822,18 @@ namespace ts {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
if (node === sourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Labels
|
||||
if (isJumpStatementTarget(node)) {
|
||||
const labelName = (<Identifier>node).text;
|
||||
const label = getTargetLabel((<BreakOrContinueStatement>node.parent), (<Identifier>node).text);
|
||||
return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined;
|
||||
}
|
||||
|
||||
const typeChecker = program.getTypeChecker();
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
|
@ -4891,7 +4892,7 @@ namespace ts {
|
|||
const sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
if (node === sourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -5628,7 +5629,7 @@ namespace ts {
|
|||
const sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
const node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
if (node === sourceFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -6795,7 +6796,7 @@ namespace ts {
|
|||
// Get node at the location
|
||||
const node = getTouchingPropertyName(sourceFile, startPos);
|
||||
|
||||
if (!node) {
|
||||
if (node === sourceFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
11
tests/cases/fourslash/hoverOverComment.ts
Normal file
11
tests/cases/fourslash/hoverOverComment.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////export function f() {}
|
||||
//////foo
|
||||
/////**///moo
|
||||
|
||||
goTo.marker();
|
||||
verify.quickInfoIs("");
|
||||
verify.verifyDefinitionsName("", "");
|
||||
verify.typeDefinitionCountIs(0);
|
||||
verify.referencesCountIs(0);
|
Loading…
Reference in a new issue