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 {

tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts

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

tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
//// }
1212
////
1313
//// class Bar implements Foo {
14-
//// [|hello() {}|]
14+
//// [|hello|]() {}
1515
//// someOtherFunction() {}
1616
//// }
1717
////
1818
//// function createFoo(): Foo {
1919
//// return {
20-
//// [|hello() {}|],
20+
//// [|hello|]() {},
2121
//// someOtherFunction() {}
2222
//// };
2323
//// }
2424
////
2525
//// var y: Foo = {
26-
//// [|hello() {}|],
26+
//// [|hello|]() {},
2727
//// someOtherFunction() {}
2828
//// };
2929
////

tests/cases/fourslash/goToImplementationInterfaceMethod_08.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
//// }
88
////
99
//// class SuperBar implements Foo {
10-
//// [|hello() {}|]
10+
//// [|hello|]() {}
1111
//// }
1212
////
1313
//// class Bar extends SuperBar {
1414
//// whatever() { this.he/*function_call*/llo(); }
1515
//// }
1616
////
1717
//// class SubBar extends Bar {
18-
//// [|hello() {}|]
18+
//// [|hello|]() {}
1919
//// }
2020

2121

tests/cases/fourslash/goToImplementationInterfaceMethod_09.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//// }
2121
////
2222
//// class SuperBar extends MegaBar {
23-
//// [|hello() {}|]
23+
//// [|hello|]() {}
2424
//// }
2525
////
2626
//// class MegaBar implements Foo {

tests/cases/fourslash/goToImplementationInterfaceMethod_10.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//// }
1717
////
1818
//// class FooImpl implements Foo {
19-
//// [|hello() {/**FooImpl*/}|]
19+
//// [|hello|]() {/**FooImpl*/}
2020
//// aloha() {}
2121
//// }
2222
////
@@ -25,12 +25,12 @@
2525
//// }
2626
////
2727
//// class BarImpl implements Bar {
28-
//// [|hello() {/**BarImpl*/}|]
28+
//// [|hello|]() {/**BarImpl*/}
2929
//// goodbye() {}
3030
//// }
3131
////
3232
//// class FooAndBarImpl implements Foo, Bar {
33-
//// [|hello() {/**FooAndBarImpl*/}|]
33+
//// [|hello|]() {/**FooAndBarImpl*/}
3434
//// aloha() {}
3535
//// goodbye() {}
3636
//// }

tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//// hel/*reference*/lo(): void;
77
//// }
88
////
9-
//// var x = <Foo> { [|hello: () => {}|] };
10-
//// var y = <Foo> (((({ [|hello: () => {}|] }))));
9+
//// var x = <Foo> { [|hello|]: () => {} };
10+
//// var y = <Foo> (((({ [|hello|]: () => {} }))));
1111

1212
verify.allRangesAppearInImplementationList("reference");

tests/cases/fourslash/goToImplementationInterfaceProperty_00.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
//// hello: number
77
//// }
88
////
9-
//// var bar: Foo = { [|hello: 5|] };
9+
//// var bar: Foo = { [|hello|]: 5 };
1010
////
1111
////
12-
//// function whatever(x: Foo = { [|hello: 5 * 9|] }) {
12+
//// function whatever(x: Foo = { [|hello|]: 5 * 9 }) {
1313
//// x.he/*reference*/llo
1414
//// }
1515
////
1616
//// class Bar {
17-
//// x: Foo = { [|hello: 6|] }
17+
//// x: Foo = { [|hello|]: 6 }
1818
////
19-
//// constructor(public f: Foo = { [|hello: 7|] } ) {}
19+
//// constructor(public f: Foo = { [|hello|]: 7 } ) {}
2020
//// }
2121

2222
verify.allRangesAppearInImplementationList("reference");

tests/cases/fourslash/goToImplementationInterfaceProperty_01.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//// interface Foo { hello: number }
66
////
77
//// class Bar implements Foo {
8-
//// [|hello = 5 * 9;|]
8+
//// [|hello|] = 5 * 9;
99
//// }
1010
////
1111
//// function whatever(foo: Foo) {

tests/cases/fourslash/goToImplementationInterface_01.ts

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

33
//// interface Fo/*interface_definition*/o { hello(): void }
44
////
5-
//// [|class SuperBar implements Foo {
5+
//// class [|SuperBar|] implements Foo {
66
//// hello () {}
7-
//// }|]
7+
//// }
88
////
9-
//// [|abstract class AbstractBar implements Foo {
9+
//// abstract class [|AbstractBar|] implements Foo {
1010
//// abstract hello (): void;
11-
//// }|]
11+
//// }
1212
////
1313
//// class Bar extends SuperBar {
1414
//// }

tests/cases/fourslash/goToImplementationInterface_07.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
//// let x8: Foo[] = [|[{ hello () { /**arrayType*/} }]|];
2121
//// let x9: { y: Foo } = [|{ y: { hello () { /**typeLiteral*/} } }|];
2222
//// let x10 = [|{|"parts": ["(","anonymous local class",")"], "kind": "local class"|}class implements Foo { hello() {} }|]
23-
//// let x11 = [|{|"parts": ["(","local class",")"," ","C"], "kind": "local class"|}class C implements Foo { hello() {} }|]
23+
//// let x11 = class [|{|"parts": ["(","local class",")"," ","C"], "kind": "local class"|}C|] implements Foo { hello() {} }
2424
////
2525
//// // Should not do anything for type predicates
2626
//// function isFoo(a: any): a is Foo {
2727
//// return true;
2828
//// }
2929

30-
verify.allRangesAppearInImplementationList("interface_definition");
30+
verify.allRangesAppearInImplementationList("interface_definition");

tests/cases/fourslash/goToImplementationInterface_08.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//// interface C extends B, A {}
1212
////
1313
//// class X implements B {
14-
//// [|hello() {}|]
14+
//// [|hello|]() {}
1515
//// }
1616
////
1717
//// function someFunction(d : A) {

tests/cases/fourslash/goToImplementationLocal_00.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
// Should return definition of locally declared functions
44

55
//// he/*function_call*/llo();
6-
//// [|function hello() {}|]
6+
//// function [|hello|]() {}
77

8-
verify.allRangesAppearInImplementationList("function_call");
8+
verify.allRangesAppearInImplementationList("function_call");

tests/cases/fourslash/goToImplementationLocal_01.ts

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

33
// Should return the defintion of locally defined variables
44

5-
//// const [|hello = function() {}|];
5+
//// const [|hello|] = function() {};
66
//// he/*function_call*/llo();
77

8-
verify.allRangesAppearInImplementationList("function_call");
8+
verify.allRangesAppearInImplementationList("function_call");
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/// <reference path='fourslash.ts'/>
22

3-
//// const x = { [|hello: () => {}|] };
3+
//// const x = { [|hello|]: () => {} };
44
////
55
//// x.he/*function_call*/llo();
66
////
77

8-
verify.allRangesAppearInImplementationList("function_call");
8+
verify.allRangesAppearInImplementationList("function_call");

tests/cases/fourslash/goToImplementationLocal_03.ts

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

33
// Should return the definition when invoked on variable assignment
44

5-
//// let [|he/*local_var*/llo = {}|];
5+
//// let [|he/*local_var*/llo|] = {};
66
////
77
//// x.hello();
88
////
99
//// hello = {};
1010
////
1111

12-
verify.allRangesAppearInImplementationList("local_var");
12+
verify.allRangesAppearInImplementationList("local_var");

tests/cases/fourslash/goToImplementationLocal_04.ts

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

33
// Should return definition of function when invoked on the declaration
44

5-
//// [|function he/*local_var*/llo() {}|]
5+
//// function [|he/*local_var*/llo|]() {}
66
////
77
//// hello();
88
////
99

10-
verify.allRangesAppearInImplementationList("local_var");
10+
verify.allRangesAppearInImplementationList("local_var");

tests/cases/fourslash/goToImplementationLocal_05.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//// public hello() {}
77
//// }
88
////
9-
//// var [|someVar = new Bar()|];
9+
//// var [|someVar|] = new Bar();
1010
//// someVa/*reference*/r.hello();
1111

12-
verify.allRangesAppearInImplementationList("reference");
12+
verify.allRangesAppearInImplementationList("reference");

tests/cases/fourslash/goToImplementationLocal_06.ts

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

33
// Should be able to go to ambient variable declarations
44

5-
//// declare var [|someVar: string|];
5+
//// declare var [|someVar|]: string;
66
//// someVa/*reference*/r
77

8-
verify.allRangesAppearInImplementationList("reference");
8+
verify.allRangesAppearInImplementationList("reference");

tests/cases/fourslash/goToImplementationLocal_07.ts

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

33
// Should be able to go to ambient function declarations
44

5-
//// [|declare function someFunction(): () => void;|]
5+
//// declare function [|someFunction|](): () => void;
66
//// someFun/*reference*/ction();
77

8-
verify.allRangesAppearInImplementationList("reference");
8+
verify.allRangesAppearInImplementationList("reference");

tests/cases/fourslash/goToImplementationLocal_08.ts

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

33
// Should be able to go to ambient function declarations
44

5-
//// [|declare function someFunction(): () => void;|]
5+
//// declare function [|someFunction|](): () => void;
66
//// someFun/*reference*/ction();
77

8-
verify.allRangesAppearInImplementationList("reference");
8+
verify.allRangesAppearInImplementationList("reference");

0 commit comments

Comments
 (0)