Skip to content

Commit 9d42ab9

Browse files
author
Andy
authored
implementations: Use declaration name for the span (#24537)
* implementations: Use declaration name for the span * Always get name in nodeEntry
1 parent 997991f commit 9d42ab9

File tree

48 files changed

+111
-126
lines changed

Some content is hidden

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

48 files changed

+111
-126
lines changed

src/services/findAllReferences.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace ts.FindAllReferences {
2424
textSpan: TextSpan;
2525
}
2626
export function nodeEntry(node: Node, isInString?: true): NodeEntry {
27-
return { type: "node", node, isInString };
27+
return { type: "node", node: (node as NamedDeclaration).name || node, isInString };
2828
}
2929

3030
export interface Options {
@@ -1096,7 +1096,7 @@ namespace ts.FindAllReferences.Core {
10961096
function addImplementationReferences(refNode: Node, addReference: (node: Node) => void, state: State): void {
10971097
// Check if we found a function/propertyAssignment/method with an implementation or initializer
10981098
if (isDeclarationName(refNode) && isImplementation(refNode.parent)) {
1099-
addReference(refNode.parent);
1099+
addReference(refNode);
11001100
return;
11011101
}
11021102

tests/cases/fourslash/goToImplementationClassMethod_00.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Should handle calls made on members declared in a class
44

55
//// class Bar {
6-
//// [|{|"parts": ["(","method",")"," ","Bar",".","hello","(",")",":"," ","void"], "kind": "method"|}hello() {}|]
6+
//// [|{|"parts": ["(","method",")"," ","Bar",".","hello","(",")",":"," ","void"], "kind": "method"|}hello|]() {}
77
//// }
88
////
99
//// new Bar().hel/*reference*/lo;

tests/cases/fourslash/goToImplementationClassMethod_01.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//// }
88
////
99
//// class Bar extends AbstractBar{
10-
//// [|hello() {}|]
10+
//// [|hello|]() {}
1111
//// }
1212
////
1313
//// function whatever(x: AbstractBar) {

tests/cases/fourslash/goToImplementationEnum_00.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Should handle calls made on members of an enum
44

55
//// enum Foo {
6-
//// [|Foo1 = function initializer() { return 5 } ()|],
6+
//// [|Foo1|] = function initializer() { return 5 } (),
77
//// Foo2 = 6
88
//// }
99
////

tests/cases/fourslash/goToImplementationEnum_01.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
// Should handle calls made on enum name
44

5-
//// [|enum Foo {
5+
//// enum [|Foo|] {
66
//// Foo1 = function initializer() { return 5 } (),
77
//// Foo2 = 6
8-
//// }|]
8+
//// }
99
////
1010
//// Fo/*reference*/o;
1111

tests/cases/fourslash/goToImplementationInterfaceMethod_00.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
//// he/*declaration*/llo: () => void
77
//// }
88
////
9-
//// var bar: Foo = { [|hello: helloImpl|] };
10-
//// var baz: Foo = { [|"hello": helloImpl|] };
9+
//// var bar: Foo = { [|hello|]: helloImpl };
10+
//// var baz: Foo = { "[|hello|]": helloImpl };
1111
////
1212
//// function helloImpl () {}
1313
////
14-
//// function whatever(x: Foo = { [|hello() {/**1*/}|] }) {
14+
//// function whatever(x: Foo = { [|hello|]() {/**1*/} }) {
1515
//// x.he/*function_call*/llo()
1616
//// }
1717
////
1818
//// class Bar {
19-
//// x: Foo = { [|hello() {/*2*/}|] }
19+
//// x: Foo = { [|hello|]() {/*2*/} }
2020
////
21-
//// constructor(public f: Foo = { [|hello() {/**3*/}|] } ) {}
21+
//// constructor(public f: Foo = { [|hello|]() {/**3*/} } ) {}
2222
//// }
2323

2424
verify.allRangesAppearInImplementationList("function_call");

tests/cases/fourslash/goToImplementationInterfaceMethod_01.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//// }
99
////
1010
//// class Bar implements Foo {
11-
//// [|hello() {}|]
11+
//// [|hello|]() {}
1212
//// public sure() {}
1313
//// }
1414
////

tests/cases/fourslash/goToImplementationInterfaceMethod_02.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//// }
1212
////
1313
//// class Bar extends AbstractBar {
14-
//// [|hello() {}|]
14+
//// [|hello|]() {}
1515
//// }
1616
////
1717
//// function whatever(a: AbstractBar) {

tests/cases/fourslash/goToImplementationInterfaceMethod_03.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//// }
88
////
99
//// class Bar extends SuperBar {
10-
//// [|hello() {}|]
10+
//// [|hello|]() {}
1111
//// }
1212
////
1313
//// class SuperBar implements Foo {

tests/cases/fourslash/goToImplementationInterfaceMethod_04.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
//// }
88
////
99
//// class Bar extends SuperBar {
10-
//// [|hello() {}|]
10+
//// [|hello|]() {}
1111
//// }
1212
////
1313
//// class SuperBar implements Foo {
14-
//// [|hello() {}|]
14+
//// [|hello|]() {}
1515
//// }
1616
////
1717
//// class OtherBar implements Foo {

0 commit comments

Comments
 (0)