From 5e922ac014a117ef13fe68600a21225376766333 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 14 Nov 2025 12:09:49 +0000 Subject: [PATCH 1/4] Initial plan From 9e3e34a026eee50436272b67442f0073a00ef59c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 14 Nov 2025 12:24:19 +0000 Subject: [PATCH 2/4] Fix panic in getAdjustedLocation for documentHighlight requests Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/ls/utilities.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/ls/utilities.go b/internal/ls/utilities.go index 480bf0ebc2..399f35c25b 100644 --- a/internal/ls/utilities.go +++ b/internal/ls/utilities.go @@ -905,8 +905,10 @@ func getAdjustedLocation(node *ast.Node, forRename bool, sourceFile *ast.SourceF // import /**/type { propertyName as [|name|] } from ...; // import /**/type ... from "[|module|]"; if ast.IsImportClause(parent) && parent.IsTypeOnly() { - if location := getAdjustedLocationForImportDeclaration(parent.Parent.AsImportDeclaration(), forRename); location != nil { - return location + if parent.Parent != nil { + if location := getAdjustedLocationForImportDeclaration(parent.Parent.AsImportDeclaration(), forRename); location != nil { + return location + } } } // export /**/type { [|name|] } from ...; @@ -914,7 +916,7 @@ func getAdjustedLocation(node *ast.Node, forRename bool, sourceFile *ast.SourceF // export /**/type * from "[|module|]"; // export /**/type * as ... from "[|module|]"; if ast.IsExportDeclaration(parent) && parent.IsTypeOnly() { - if location := getAdjustedLocationForExportDeclaration(parent.Parent.AsExportDeclaration(), forRename); location != nil { + if location := getAdjustedLocationForExportDeclaration(parent.AsExportDeclaration(), forRename); location != nil { return location } } From 51b3e5eb10ad98cfe1c2f88004299107b7d78c1d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 14 Nov 2025 13:05:49 +0000 Subject: [PATCH 3/4] Update failing test list after getAdjustedLocation fix Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/fourslash/_scripts/failingTests.txt | 1 - .../referencesForStatementKeywords_test.go | 2 +- ...erencesForStatementKeywords.baseline.jsonc | 526 ++++++++++++++++++ 3 files changed, 527 insertions(+), 2 deletions(-) create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index 5db600146a..7db9cd9788 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -534,7 +534,6 @@ TestQuickinfoForNamespaceMergeWithClassConstrainedToSelf TestQuickinfoForUnionProperty TestQuickinfoWrongComment TestRecursiveInternalModuleImport -TestReferencesForStatementKeywords TestReferencesInEmptyFile TestRegexDetection TestRenameForAliasingExport02 diff --git a/internal/fourslash/tests/gen/referencesForStatementKeywords_test.go b/internal/fourslash/tests/gen/referencesForStatementKeywords_test.go index fcec2a2070..bde9db9024 100644 --- a/internal/fourslash/tests/gen/referencesForStatementKeywords_test.go +++ b/internal/fourslash/tests/gen/referencesForStatementKeywords_test.go @@ -9,7 +9,7 @@ import ( func TestReferencesForStatementKeywords(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @filename: /main.ts // import ... = ... diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc new file mode 100644 index 0000000000..9bf5d0afe3 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc @@ -0,0 +1,526 @@ +// === findAllReferences === +// === /main.ts === +// // import ... = ... +// /*FIND ALL REFS*/import [|A|] = require("./a"); +// namespace N { } +// import N2 = N; +// +// // --- (line: 6) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// // import ... = ... +// import A = /*FIND ALL REFS*/require("[|./a|]"); +// namespace N { } +// import N2 = N; +// +// // --- (line: 6) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// // import ... = ... +// import A = require("./a"); +// namespace N { } +// /*FIND ALL REFS*/import [|N2|] = N; +// +// // import ... from ... +// import type B from "./b"; +// // --- (line: 8) skipped --- + + + +// === findAllReferences === +// === /b.ts === +// export default class [|B|] {} + +// === /main.ts === +// --- (line: 3) skipped --- +// import N2 = N; +// +// // import ... from ... +// /*FIND ALL REFS*/import type [|B|] from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// // --- (line: 11) skipped --- + + + +// === findAllReferences === +// === /b.ts === +// export default class [|B|] {} + +// === /main.ts === +// --- (line: 3) skipped --- +// import N2 = N; +// +// // import ... from ... +// import /*FIND ALL REFS*/type [|B|] from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// // --- (line: 11) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 3) skipped --- +// import N2 = N; +// +// // import ... from ... +// import type B /*FIND ALL REFS*/from "[|./b|]"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// // --- (line: 11) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// /*FIND ALL REFS*/import type * as [|C|] from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// import /*FIND ALL REFS*/type * as [|C|] from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// import type * /*FIND ALL REFS*/as [|C|] from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// import type * as C /*FIND ALL REFS*/from "[|./c|]"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /d.ts === +// export class [|D|] {} + +// === /main.ts === +// --- (line: 5) skipped --- +// // import ... from ... +// import type B from "./b"; +// import type * as C from "./c"; +// /*FIND ALL REFS*/import type { [|D|] } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// // --- (line: 13) skipped --- + + + +// === findAllReferences === +// === /d.ts === +// export class [|D|] {} + +// === /main.ts === +// --- (line: 5) skipped --- +// // import ... from ... +// import type B from "./b"; +// import type * as C from "./c"; +// import /*FIND ALL REFS*/type { [|D|] } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// // --- (line: 13) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 5) skipped --- +// // import ... from ... +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } /*FIND ALL REFS*/from "[|./d|]"; +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// // --- (line: 13) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// /*FIND ALL REFS*/import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// import "./f"; +// // --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import /*FIND ALL REFS*/type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// import "./f"; +// // --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } /*FIND ALL REFS*/from "[|./e|]"; +// +// // import "module" +// import "./f"; +// // --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 /*FIND ALL REFS*/as [|e3|] } from "./e"; +// +// // import "module" +// import "./f"; +// // --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 9) skipped --- +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// /*FIND ALL REFS*/import "[|./f|]"; +// +// // export ... from ... +// export type * from "./g"; +// // --- (line: 17) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 12) skipped --- +// import "./f"; +// +// // export ... from ... +// /*FIND ALL REFS*/export type * from "[|./g|]"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// // --- (line: 20) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 12) skipped --- +// import "./f"; +// +// // export ... from ... +// export /*FIND ALL REFS*/type * from "[|./g|]"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// // --- (line: 20) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 12) skipped --- +// import "./f"; +// +// // export ... from ... +// export type * /*FIND ALL REFS*/from "[|./g|]"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// // --- (line: 20) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 13) skipped --- +// +// // export ... from ... +// export type * from "./g"; +// /*FIND ALL REFS*/export type * as [|H|] from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// // --- (line: 21) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 13) skipped --- +// +// // export ... from ... +// export type * from "./g"; +// export /*FIND ALL REFS*/type * as [|H|] from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// // --- (line: 21) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 13) skipped --- +// +// // export ... from ... +// export type * from "./g"; +// export type * /*FIND ALL REFS*/as [|H|] from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// // --- (line: 21) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 13) skipped --- +// +// // export ... from ... +// export type * from "./g"; +// export type * as H /*FIND ALL REFS*/from "[|./h|]"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// // --- (line: 21) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 14) skipped --- +// // export ... from ... +// export type * from "./g"; +// export type * as H from "./h"; +// /*FIND ALL REFS*/export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// // --- (line: 22) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 14) skipped --- +// // export ... from ... +// export type * from "./g"; +// export type * as H from "./h"; +// export /*FIND ALL REFS*/type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// // --- (line: 22) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 14) skipped --- +// // export ... from ... +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } /*FIND ALL REFS*/from "[|./i|]"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// // --- (line: 22) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 15) skipped --- +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// /*FIND ALL REFS*/export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 15) skipped --- +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export /*FIND ALL REFS*/type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 15) skipped --- +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } /*FIND ALL REFS*/from "[|./j|]"; +// type Z1 = 1; +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 15) skipped --- +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 /*FIND ALL REFS*/as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 16) skipped --- +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type [|Z1|] = 1; +// /*FIND ALL REFS*/export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 16) skipped --- +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type [|Z1|] = 1; +// export /*FIND ALL REFS*/type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 20) skipped --- +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// /*FIND ALL REFS*/export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 20) skipped --- +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export /*FIND ALL REFS*/type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 20) skipped --- +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 /*FIND ALL REFS*/as z4 }; + + + +// === findAllReferences === +// === /main2.ts === +// const [|x|] = {}; +// /*FIND ALL REFS*/export = [|x|]; + + + +// === findAllReferences === +// === /main3.ts === +// const [|y|] = {}; +// /*FIND ALL REFS*/export default [|y|]; \ No newline at end of file From abea7a8a962857060b9e7eab69069a34df9d1611 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 14 Nov 2025 13:22:22 +0000 Subject: [PATCH 4/4] Remove unnecessary nil check for ImportClause parent Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/ls/utilities.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/ls/utilities.go b/internal/ls/utilities.go index 399f35c25b..c2554cb1db 100644 --- a/internal/ls/utilities.go +++ b/internal/ls/utilities.go @@ -905,10 +905,8 @@ func getAdjustedLocation(node *ast.Node, forRename bool, sourceFile *ast.SourceF // import /**/type { propertyName as [|name|] } from ...; // import /**/type ... from "[|module|]"; if ast.IsImportClause(parent) && parent.IsTypeOnly() { - if parent.Parent != nil { - if location := getAdjustedLocationForImportDeclaration(parent.Parent.AsImportDeclaration(), forRename); location != nil { - return location - } + if location := getAdjustedLocationForImportDeclaration(parent.Parent.AsImportDeclaration(), forRename); location != nil { + return location } } // export /**/type { [|name|] } from ...;