Skip to content

Commit aaefcb7

Browse files
Copilotjakebailey
andcommitted
Revert incorrect fix that caused doubled ranges and regressions
The previous fix was adding imports to singleReferences and adding skip logic in getReferencesAtLocation, but this approach was not based on the original TypeScript implementation and caused: - Doubled reference ranges like [|[|B|]|] - Regressions in goToImplementation tests This reverts to the original behavior while keeping the fourslash test that demonstrates the issue (showing 0 references for now). Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
1 parent d137923 commit aaefcb7

File tree

46 files changed

+76
-106
lines changed

Some content is hidden

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

46 files changed

+76
-106
lines changed

internal/ls/findallreferences.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,12 +1910,6 @@ func (state *refState) getReferencesAtLocation(sourceFile *ast.SourceFile, posit
19101910
return
19111911
}
19121912

1913-
// For non-aliased imports like `import { foo }`, skip when coming from an export search,
1914-
// as these are already added in searchForImportsOfExport.
1915-
if parent.Kind == ast.KindImportSpecifier && parent.PropertyName() == nil && parent.Name() == referenceLocation && search.comingFrom == ImpExpKindExport {
1916-
return
1917-
}
1918-
19191913
if parent.Kind == ast.KindExportSpecifier {
19201914
state.getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent.AsExportSpecifier(), search, addReferencesHere, false /*alwaysGetReferences*/)
19211915
return
@@ -2139,14 +2133,6 @@ func (state *refState) searchForImportsOfExport(exportLocation *ast.Node, export
21392133

21402134
// For each import, find all references to that import in its source file.
21412135
for _, i := range r.importSearches {
2142-
// For `import { abc }` (no alias), add the import as a reference to the export symbol.
2143-
// For `import { foo as bar }`, `foo` is already added via singleReferences above,
2144-
// and `bar` is just a local alias, not a reference to the export.
2145-
if ast.IsImportSpecifier(i.importLocation.Parent) && i.importLocation.Parent.PropertyName() == nil {
2146-
addRef := state.referenceAdder(exportSymbol)
2147-
addRef(i.importLocation, entryKindNode)
2148-
}
2149-
// Then search for uses of the imported symbol in the file
21502136
state.getReferencesInSourceFile(ast.GetSourceFileOfNode(i.importLocation), state.createSearch(i.importLocation, i.importSymbol, ImpExpKindExport, "", nil), true /*addReferencesHere*/)
21512137
}
21522138

testdata/baselines/reference/fourslash/codeLenses/codeLensFunctionsAndConstants01.baseline.jsonc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// === Code Lenses ===
22
// === /exports.ts ===
33
// let callCount = 0;
4-
// export function /*CODELENS: 4 references*/foo(n: number): void {
4+
// export function /*CODELENS: 3 references*/foo(n: number): void {
55
// callCount++;
66
// if (n > 0) {
77
// [|foo|](n - 1);
@@ -17,7 +17,7 @@
1717
//
1818

1919
// === /importer.ts ===
20-
// import { [|foo|], bar } from "./exports";
20+
// import { foo, bar } from "./exports";
2121
//
2222
// [|foo|](5);
2323
// console.log(bar);
@@ -27,7 +27,7 @@
2727

2828
// === Code Lenses ===
2929
// === /importer.ts ===
30-
// import { foo, [|bar|] } from "./exports";
30+
// import { foo, bar } from "./exports";
3131
//
3232
// foo(5);
3333
// console.log([|bar|]);
@@ -38,5 +38,5 @@
3838
//
3939
// foo(5);
4040
//
41-
// export const /*CODELENS: 2 references*/bar = 123;
41+
// export const /*CODELENS: 1 reference*/bar = 123;
4242
//

testdata/baselines/reference/fourslash/codeLenses/codeLensInterface01.baseline.jsonc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
// === Code Lenses ===
9191
// === /classPointable.ts ===
92-
// import { [|Pointable|] } from "./pointable";
92+
// import { Pointable } from "./pointable";
9393
//
9494
// class Point implements [|Pointable|] {
9595
// getX(): number {
@@ -98,7 +98,7 @@
9898
// --- (line: 7) skipped ---
9999

100100
// === /objectPointable.ts ===
101-
// import { [|Pointable|] } from "./pointable";
101+
// import { Pointable } from "./pointable";
102102
//
103103
// let x = 0;
104104
// let y = 0;
@@ -109,7 +109,7 @@
109109
// --- (line: 9) skipped ---
110110

111111
// === /pointable.ts ===
112-
// export interface /*CODELENS: 4 references*/Pointable {
112+
// export interface /*CODELENS: 2 references*/Pointable {
113113
// getX(): number;
114114
// getY(): number;
115115
// }
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
// === Code Lenses ===
2-
// === /other.ts ===
3-
// import { [|abc|] } from "./abc";
4-
//
5-
62
// === /abc.ts ===
7-
// export function /*CODELENS: 1 reference*/abc() { }
3+
// export function /*CODELENS: 0 references*/abc() { }
84
//

testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_filesToSearch.baseline.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
// === documentHighlights ===
88
// === /b.ts ===
9-
// import { /*HIGHLIGHTS*/[|[|x|]|] } from "./a";
9+
// import { /*HIGHLIGHTS*/[|x|] } from "./a";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// === findAllReferences ===
22
// === /bar.ts ===
3-
// import { [|[|Foo|]|]/*FIND ALL REFS*/ } from "./foo";
3+
// import { [|Foo|]/*FIND ALL REFS*/ } from "./foo";
44

55
// === /foo.ts ===
66
// export { [|Foo|] }

testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
// new D();
1515

1616
// === /b.ts ===
17-
// import { [|C|] } from "./a";
17+
// import { C } from "./a";
1818
// new [|C|]();
1919

2020
// === /c.ts ===
21-
// import { [|C|] } from "./a";
21+
// import { C } from "./a";
2222
// class D extends C {
2323
// constructor() {
2424
// [|super|]();
@@ -50,11 +50,11 @@
5050
// new D();
5151

5252
// === /b.ts ===
53-
// import { [|C|] } from "./a";
53+
// import { C } from "./a";
5454
// new [|C|]();
5555

5656
// === /c.ts ===
57-
// import { [|C|] } from "./a";
57+
// import { C } from "./a";
5858
// class D extends C {
5959
// constructor() {
6060
// [|super|]();
@@ -86,11 +86,11 @@
8686
// new D();
8787

8888
// === /b.ts ===
89-
// import { [|C|] } from "./a";
89+
// import { C } from "./a";
9090
// new [|C|]();
9191

9292
// === /c.ts ===
93-
// import { [|C|] } from "./a";
93+
// import { C } from "./a";
9494
// class D extends C {
9595
// constructor() {
9696
// [|super|]();

testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression2.baseline.jsonc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// exports.[|A|] = class {};
1414

1515
// === /b.js ===
16-
// import { /*FIND ALL REFS*/[|[|A|]|] } from "./a";
16+
// import { /*FIND ALL REFS*/[|A|] } from "./a";
1717
// [|A|];
1818

1919

@@ -23,5 +23,5 @@
2323
// exports.[|A|] = class {};
2424

2525
// === /b.js ===
26-
// import { [|[|A|]|] } from "./a";
26+
// import { [|A|] } from "./a";
2727
// /*FIND ALL REFS*/[|A|];

testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportAsNamespace.baseline.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
// === findAllReferences ===
1515
// === /b.ts ===
16-
// import { /*FIND ALL REFS*/[|[|f|]|] } from "a";
16+
// import { /*FIND ALL REFS*/[|f|] } from "a";
1717

1818
// === /c.ts ===
1919
// A.[|f|]();

testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportConstEqualToClass.baseline.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
// export const [|D|] = C;
1515

1616
// === /b.ts ===
17-
// import { /*FIND ALL REFS*/[|[|D|]|] } from "./a";
17+
// import { /*FIND ALL REFS*/[|D|] } from "./a";

0 commit comments

Comments
 (0)