From a0bcf1d9872068d3e9cc7a44620ff28e7fc5e906 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Thu, 20 Nov 2025 09:39:19 -0800 Subject: [PATCH 1/8] WIP: port symbol tests --- _submodules/TypeScript | 2 +- .../fourslash/_scripts/convertFourslash.mts | 268 ++++++++++++++++-- internal/fourslash/fourslash.go | 45 +++ internal/fourslash/test_parser.go | 7 + .../tests/gen/declareFunction_test.go | 24 ++ .../tests/gen/navigateItemsLet_test.go | 44 +++ .../tests/gen/navigateToImport_test.go | 51 ++++ .../gen/navigateToSymbolIterator_test.go | 33 +++ .../gen/navigationItemsExactMatch2_test.go | 97 +++++++ ...ationItemsInConstructorsExactMatch_test.go | 48 ++++ .../gen/navigationItemsPrefixMatch2_test.go | 91 ++++++ ...tionItemsSpecialPropertyAssignment_test.go | 86 ++++++ .../tests/gen/navto_emptyPattern_test.go | 36 +++ .../tests/gen/navto_excludeLib1_test.go | 56 ++++ .../tests/gen/navto_excludeLib2_test.go | 44 +++ .../tests/gen/navto_excludeLib3_test.go | 32 +++ .../tests/gen/navto_excludeLib4_test.go | 35 +++ .../tests/gen/navto_serverExcludeLib_test.go | 56 ++++ internal/ls/lsutil/userpreferences.go | 11 +- 19 files changed, 1036 insertions(+), 30 deletions(-) create mode 100644 internal/fourslash/tests/gen/declareFunction_test.go create mode 100644 internal/fourslash/tests/gen/navigateItemsLet_test.go create mode 100644 internal/fourslash/tests/gen/navigateToImport_test.go create mode 100644 internal/fourslash/tests/gen/navigateToSymbolIterator_test.go create mode 100644 internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go create mode 100644 internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go create mode 100644 internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go create mode 100644 internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go create mode 100644 internal/fourslash/tests/gen/navto_emptyPattern_test.go create mode 100644 internal/fourslash/tests/gen/navto_excludeLib1_test.go create mode 100644 internal/fourslash/tests/gen/navto_excludeLib2_test.go create mode 100644 internal/fourslash/tests/gen/navto_excludeLib3_test.go create mode 100644 internal/fourslash/tests/gen/navto_excludeLib4_test.go create mode 100644 internal/fourslash/tests/gen/navto_serverExcludeLib_test.go diff --git a/_submodules/TypeScript b/_submodules/TypeScript index 9e8eaa1746..add6971195 160000 --- a/_submodules/TypeScript +++ b/_submodules/TypeScript @@ -1 +1 @@ -Subproject commit 9e8eaa1746b0d09c3cd29048126ef9cf24f29c03 +Subproject commit add697119549734b24d46b30b9f6d2e757c6d53a diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index 3030976773..b97b0454b8 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -137,7 +137,7 @@ function getTestInput(content: string): string { /** * Parses a Strada fourslash statement and returns the corresponding Corsa commands. - * @returns an array of commands if the statement is a valid fourslash command, or `false` if the statement could not be parsed. + * @returns an array of commands if the statement is a valid fourslash command, or `undefined` if the statement could not be parsed. */ function parseFourslashStatement(statement: ts.Statement): Cmd[] | undefined { if (ts.isVariableStatement(statement)) { @@ -222,6 +222,8 @@ function parseFourslashStatement(statement: ts.Statement): Cmd[] | undefined { case "baselineSyntacticDiagnostics": case "baselineSyntacticAndSemanticDiagnostics": return [{ kind: "verifyBaselineDiagnostics" }]; + case "navigateTo": + return parseVerifyNavigateTo(callExpression.arguments); } } // `goTo....` @@ -1469,29 +1471,9 @@ function parseBaselineMarkerOrRangeArg(arg: ts.Expression): string | undefined { return getGoStringLiteral(arg.text); } else if (ts.isIdentifier(arg) || (ts.isElementAccessExpression(arg) && ts.isIdentifier(arg.expression))) { - const argName = ts.isIdentifier(arg) ? arg.text : (arg.expression as ts.Identifier).text; - const file = arg.getSourceFile(); - const varStmts = file.statements.filter(ts.isVariableStatement); - for (const varStmt of varStmts) { - for (const decl of varStmt.declarationList.declarations) { - if (ts.isArrayBindingPattern(decl.name) && decl.initializer?.getText().includes("ranges")) { - for (let i = 0; i < decl.name.elements.length; i++) { - const elem = decl.name.elements[i]; - if (ts.isBindingElement(elem) && ts.isIdentifier(elem.name) && elem.name.text === argName) { - // `const [range_0, ..., range_n, ...] = test.ranges();` and arg is `range_n` - if (elem.dotDotDotToken === undefined) { - return `f.Ranges()[${i}]`; - } - // `const [range_0, ..., ...rest] = test.ranges();` and arg is `rest[n]` - if (ts.isElementAccessExpression(arg)) { - return `f.Ranges()[${i + parseInt(arg.argumentExpression!.getText())}]`; - } - // `const [range_0, ..., ...rest] = test.ranges();` and arg is `rest` - return `ToAny(f.Ranges()[${i}:])...`; - } - } - } - } + const result = parseRangeVariable(arg); + if (result) { + return result; } const init = getNodeOfKind(arg, ts.isCallExpression); if (init) { @@ -1507,7 +1489,35 @@ function parseBaselineMarkerOrRangeArg(arg: ts.Expression): string | undefined { return result; } } - console.error(`Unrecognized range argument: ${arg.getText()}`); + console.error(`Unrecognized argument in verify.baselineRename: ${arg.getText()}`); + return undefined; +} + +function parseRangeVariable(arg: ts.Identifier | ts.ElementAccessExpression): string | undefined { + const argName = ts.isIdentifier(arg) ? arg.text : (arg.expression as ts.Identifier).text; + const file = arg.getSourceFile(); + const varStmts = file.statements.filter(ts.isVariableStatement); + for (const varStmt of varStmts) { + for (const decl of varStmt.declarationList.declarations) { + if (ts.isArrayBindingPattern(decl.name) && decl.initializer?.getText().includes("ranges")) { + for (let i = 0; i < decl.name.elements.length; i++) { + const elem = decl.name.elements[i]; + if (ts.isBindingElement(elem) && ts.isIdentifier(elem.name) && elem.name.text === argName) { + // `const [range_0, ..., range_n, ...] = test.ranges();` and arg is `range_n` + if (elem.dotDotDotToken === undefined) { + return `f.Ranges()[${i}]`; + } + // `const [range_0, ..., ...rest] = test.ranges();` and arg is `rest[n]` + if (ts.isElementAccessExpression(arg)) { + return `f.Ranges()[${i + parseInt(arg.argumentExpression!.getText())}]`; + } + // `const [range_0, ..., ...rest] = test.ranges();` and arg is `rest` + return `ToAny(f.Ranges()[${i}:])...`; + } + } + } + } + } return undefined; } @@ -1794,6 +1804,202 @@ function parseSortText(expr: ts.Expression): string | undefined { } } +function parseVerifyNavigateTo(args: ts.NodeArray): [VerifyNavToCmd] | undefined { + const goArgs = []; + for (const arg of args) { + const result = parseVerifyNavigateToArg(arg); + if (!result) { + return undefined; + } + goArgs.push(result); + } + return [{ + kind: "verifyNavigateTo", + args: goArgs, + }] +} + +function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { + if (!ts.isObjectLiteralExpression(arg)) { + console.error(`Expected object literal expression for verify.navigateTo argument, got ${arg.getText()}`); + return undefined; + } + let prefs; + const items = []; + for (const prop of arg.properties) { + if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) { + console.error(`Expected property assignment with identifier name for verify.navigateTo argument, got ${prop.getText()}`); + return undefined; + } + const propName = prop.name.text; + switch (propName) { + case "pattern": + case "fileName": + // no longer supported + continue; + case "expected": { + const init = prop.initializer; + if (!ts.isArrayLiteralExpression(init)) { + console.error(`Expected array literal expression for expected property in verify.navigateTo argument, got ${init.getText()}`); + return undefined; + } + for (const elem of init.elements) { + const result = parseNavToItem(elem); + if (!result) { + return undefined; + } + items.push(result); + } + break; + } + case "excludeLibFiles": { + if (prop.initializer.kind === ts.SyntaxKind.TrueKeyword) { + prefs = `&ls.UserPreferences{ExcludeLibrarySymbols: PtrTo(true)}` + } + } + } + } + if (!prefs) { + prefs = "nil"; + } + return `{ + Preferences: ${prefs}, + Includes: []*lsproto.SymbolInformation{${items.length ? items.join(",\n") + ",\n" : ""}}, + }` +} + +function parseNavToItem(arg: ts.Expression): string | undefined { + let item = getNodeOfKind(arg, ts.isObjectLiteralExpression); + if (!item) { + console.error(`Expected object literal expression for navigateTo item, got ${arg.getText()}`); + return undefined; + } + const itemProps: string[] = []; + for (const prop of item.properties) { + if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) { + console.error(`Expected property assignment with identifier name for navigateTo item, got ${prop.getText()}`); + return undefined; + } + const propName = prop.name.text; + const init = prop.initializer; + switch (propName) { + case "name": { + let nameInit; + if (!(nameInit = getStringLiteralLike(init))) { + console.error(`Expected string literal for name in navigateTo item, got ${init.getText()}`); + return undefined; + } + itemProps.push(`Name: ${getGoStringLiteral(nameInit.text)}`); + break; + } + case "kind": { + const goKind = getSymbolKind(init); + if (!goKind) { + return undefined; + } + itemProps.push(`Kind: lsproto.${goKind}`); + break; + } + case "kindModifiers": { + if (init.getText().includes("deprecated")) { + itemProps.push(`Tags: &[]lsproto.SymbolTag{lsproto.SymbolTagDeprecated}`); + } + break; + } + case "range": { + if (ts.isIdentifier(init) || (ts.isElementAccessExpression(init) && ts.isIdentifier(init.expression))) { + let parsedRange = parseRangeVariable(init); + if (parsedRange) { + itemProps.push(`Location: ${parsedRange}.LSLocation()`); + continue; + } + } + if (ts.isElementAccessExpression(init) && init.expression.getText() === "test.ranges()") { + itemProps.push(`Location: f.Ranges()[${parseInt(init.argumentExpression.getText())}].LSLocation()`) + continue; + } + console.error(`Expected range variable for range in navigateTo item, got ${init.getText()}`); + return undefined; + } + case "containerName": { + let nameInit; + if (!(nameInit = getStringLiteralLike(init))) { + console.error(`Expected string literal for container name in navigateTo item, got ${init.getText()}`); + return undefined; + } + itemProps.push(`ContainerName: PtrTo(${getGoStringLiteral(nameInit.text)})`); + break; + } + default: + // ignore other properties + } + } + return `{\n${itemProps.join(",\n")},\n}`; +} + +function getSymbolKind(kind: ts.Expression): string | undefined { + let result; + if (!(result = getStringLiteralLike(kind))) { + console.error(`Expected string literal for symbol kind, got ${kind.getText()}`); + return undefined; + } + switch (result.text) { + case "script": + return "SymbolKindFile"; + case "module": + return "SymbolKindModule"; + case "class": + case "local class": + return "SymbolKindClass"; + case "interface": + return "SymbolKindInterface"; + case "type": + return "SymbolKindClass"; + case "enum": + return "SymbolKindEnum"; + case "enum member": + return "SymbolKindEnumMember"; + case "var": + case "local var": + case "using": + case "await using": + return "SymbolKindVariable"; + case "function": + case "local function": + return "SymbolKindFunction"; + case "method": + return "SymbolKindMethod"; + case "getter": + case "setter": + case "property": + case "accessor": + return "SymbolKindProperty"; + case "constructor": + case "construct": + return "SymbolKindConstructor"; + case "call": + case "index": + return "SymbolKindFunction"; + case "parameter": + return "SymbolKindVariable"; + case "type parameter": + return "SymbolKindTypeParameter"; + case "primitive type": + return "SymbolKindObject"; + case "const": + case "let": + return "SymbolKindVariable"; + case "directory": + return "SymbolKindPackage"; + case "external module name": + return "SymbolKindModule"; + case "string": + return "SymbolKindString"; + default: + return "SymbolKindVariable"; + } +} + interface VerifyCompletionsCmd { kind: "verifyCompletions"; marker: string; @@ -1905,6 +2111,11 @@ interface VerifyBaselineDiagnosticsCmd { kind: "verifyBaselineDiagnostics"; } +interface VerifyNavToCmd { + kind: "verifyNavigateTo"; + args: string[]; +} + type Cmd = | VerifyCompletionsCmd | VerifyApplyCodeActionFromCompletionCmd @@ -1919,6 +2130,7 @@ type Cmd = | VerifyQuickInfoCmd | VerifyBaselineRenameCmd | VerifyRenameInfoCmd + | VerifyNavToCmd | VerifyBaselineInlayHintsCmd | VerifyImportFixAtPositionCmd | VerifyDiagnosticsCmd @@ -2036,6 +2248,10 @@ function generateImportFixAtPosition({ expectedTexts, preferences }: VerifyImpor return `f.VerifyImportFixAtPosition(t, []string{\n${expectedTexts.join(",\n")},\n}, ${preferences})`; } +function generateNavigateTo({ args }: VerifyNavToCmd): string { + return `f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{\n${args.join(", ")}})`; +} + function generateCmd(cmd: Cmd): string { switch (cmd.kind) { case "verifyCompletions": @@ -2082,6 +2298,8 @@ function generateCmd(cmd: Cmd): string { return `f.${funcName}(t, ${cmd.arg})`; case "verifyBaselineDiagnostics": return `f.VerifyBaselineNonSuggestionDiagnostics(t)`; + case "verifyNavigateTo": + return generateNavigateTo(cmd); default: let neverCommand: never = cmd; throw new Error(`Unknown command kind: ${neverCommand as Cmd["kind"]}`); diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index 43ca8559ae..e4fc08115a 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -2822,3 +2822,48 @@ func (f *FourslashTest) VerifyBaselineGoToImplementation(t *testing.T, markerNam markerNames..., ) } + +type VerifyWorkspaceSymbolCase struct { + Includes []*lsproto.SymbolInformation // !!! HERE: fourslash.Range instead of Location + Preferences *lsutil.UserPreferences +} + +// `verify.navigateTo` in Strada. +func (f *FourslashTest) VerifyWorkspaceSymbol(t *testing.T, cases []*VerifyWorkspaceSymbolCase) { + var configReset func() + for _, testCase := range cases { + configReset = f.ConfigureWithReset(t, testCase.Preferences) + resMsg, result, resultOk := sendRequest(t, f, lsproto.WorkspaceSymbolInfo, &lsproto.WorkspaceSymbolParams{}) + if resMsg == nil { + t.Fatalf("Nil response received for workspace symbol request") + } + if !resultOk { + t.Fatalf("Unexpected response type for workspace symbol request: %T", resMsg.AsResponse().Result) + } + if result.SymbolInformations == nil { + t.Fatalf("Expected non-nil symbol information array from workspace symbol request") + } + verifyIncludesSymbols(t, *result.SymbolInformations, testCase.Includes, "Workspace symbols mismatch") + } + configReset() +} + +func verifyIncludesSymbols( + t *testing.T, + actual []*lsproto.SymbolInformation, + includes []*lsproto.SymbolInformation, + prefix string, +) { + nameToActualSymbol := make(map[string]*lsproto.SymbolInformation, len(actual)) + for _, sym := range actual { + nameToActualSymbol[sym.Name] = sym + } + + for _, sym := range includes { + actualSym, ok := nameToActualSymbol[sym.Name] + if !ok { + t.Fatalf("%s: Expected symbol '%s' not found", prefix, sym.Name) + } + assertDeepEqual(t, actualSym, sym, fmt.Sprintf("%s: Symbol '%s' mismatch", prefix, sym.Name)) + } +} diff --git a/internal/fourslash/test_parser.go b/internal/fourslash/test_parser.go index 147824081b..7220f3d662 100644 --- a/internal/fourslash/test_parser.go +++ b/internal/fourslash/test_parser.go @@ -44,6 +44,13 @@ func (r *RangeMarker) GetName() *string { return r.Marker.Name } +func (r *RangeMarker) LSLocation() lsproto.Location { + return lsproto.Location{ + Uri: lsconv.FileNameToDocumentURI(r.fileName), + Range: r.LSRange, + } +} + type Marker struct { fileName string Position int diff --git a/internal/fourslash/tests/gen/declareFunction_test.go b/internal/fourslash/tests/gen/declareFunction_test.go new file mode 100644 index 0000000000..46c2ac4ce5 --- /dev/null +++ b/internal/fourslash/tests/gen/declareFunction_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDeclareFunction(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: index.ts +declare function` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{}, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navigateItemsLet_test.go b/internal/fourslash/tests/gen/navigateItemsLet_test.go new file mode 100644 index 0000000000..bf045a7b66 --- /dev/null +++ b/internal/fourslash/tests/gen/navigateItemsLet_test.go @@ -0,0 +1,44 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigateItemsLet(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +let [|c = 10|]; +function foo() { + let [|d = 10|]; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "c", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "d", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[1].LSLocation(), + ContainerName: PtrTo("foo"), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navigateToImport_test.go b/internal/fourslash/tests/gen/navigateToImport_test.go new file mode 100644 index 0000000000..eb18d9f06f --- /dev/null +++ b/internal/fourslash/tests/gen/navigateToImport_test.go @@ -0,0 +1,51 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigateToImport(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: library.ts +[|export function foo() {}|] +[|export function bar() {}|] +// @Filename: user.ts +import {foo, [|bar as baz|]} from './library';` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "foo", + Kind: lsproto.SymbolKindFunction, + Location: f.Ranges()[0].LSLocation(), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "bar", + Kind: lsproto.SymbolKindFunction, + Location: f.Ranges()[1].LSLocation(), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "baz", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[2].LSLocation(), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go b/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go new file mode 100644 index 0000000000..bacb75dc03 --- /dev/null +++ b/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigateToSymbolIterator(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + [|[Symbol.iterator]() {}|] +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "iterator", + Kind: lsproto.SymbolKindMethod, + Location: f.Ranges()[0].LSLocation(), + ContainerName: PtrTo("C"), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go b/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go new file mode 100644 index 0000000000..dd8f3c2d85 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go @@ -0,0 +1,97 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationItemsExactMatch2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module Shapes { + [|class Point { + [|private _origin = 0.0;|] + [|private distanceFromA = 0.0;|] + + [|get distance1(distanceParam): number { + var [|distanceLocal|]; + return 0; + }|] + }|] +} + +var [|point = new Shapes.Point()|]; +[|function distance2(distanceParam1): void { + var [|distanceLocal1|]; +}|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "point", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[5].LSLocation(), + }, + { + Name: "Point", + Kind: lsproto.SymbolKindClass, + Location: f.Ranges()[0].LSLocation(), + ContainerName: PtrTo("Shapes"), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "distance1", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[3].LSLocation(), + ContainerName: PtrTo("Point"), + }, + { + Name: "distance2", + Kind: lsproto.SymbolKindFunction, + Location: f.Ranges()[6].LSLocation(), + }, + { + Name: "distanceFromA", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[2].LSLocation(), + ContainerName: PtrTo("Point"), + }, + { + Name: "distanceLocal", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[4].LSLocation(), + ContainerName: PtrTo("distance1"), + }, + { + Name: "distanceLocal1", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[7].LSLocation(), + ContainerName: PtrTo("distance2"), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "_origin", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[1].LSLocation(), + ContainerName: PtrTo("Point"), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{}, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go b/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go new file mode 100644 index 0000000000..931cc840f0 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go @@ -0,0 +1,48 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationItemsInConstructorsExactMatch(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +class Test { + [|private search1: number;|] + constructor([|public search2: boolean|], [|readonly search3: string|], search4: string) { + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "search1", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[0].LSLocation(), + ContainerName: PtrTo("Test"), + }, + { + Name: "search2", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[1].LSLocation(), + ContainerName: PtrTo("Test"), + }, + { + Name: "search3", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[2].LSLocation(), + ContainerName: PtrTo("Test"), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go b/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go new file mode 100644 index 0000000000..a4d5f37757 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go @@ -0,0 +1,91 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationItemsPrefixMatch2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module Shapes { + export class Point { + [|private originality = 0.0;|] + [|private distanceFromOrig = 0.0;|] + [|get distanceFarFarAway(distanceFarFarAwayParam: number): number { + var [|distanceFarFarAwayLocal|]; + return 0; + }|] + } +} +var pointsSquareBox = new Shapes.Point(); +function PointsFunc(): void { + var pointFuncLocal; +} +[|interface OriginI { + 123; + [|origin1;|] + [|public _distance(distanceParam): void;|] +}|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "origin1", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[5].LSLocation(), + ContainerName: PtrTo("OriginI"), + }, + { + Name: "originality", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[0].LSLocation(), + ContainerName: PtrTo("Point"), + }, + { + Name: "OriginI", + Kind: lsproto.SymbolKindInterface, + Location: f.Ranges()[4].LSLocation(), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "distanceFarFarAway", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[2].LSLocation(), + ContainerName: PtrTo("Point"), + }, + { + Name: "distanceFarFarAwayLocal", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[3].LSLocation(), + ContainerName: PtrTo("distanceFarFarAway"), + }, + { + Name: "distanceFromOrig", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[1].LSLocation(), + ContainerName: PtrTo("Point"), + }, + { + Name: "_distance", + Kind: lsproto.SymbolKindMethod, + Location: f.Ranges()[6].LSLocation(), + ContainerName: PtrTo("OriginI"), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{}, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go b/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go new file mode 100644 index 0000000000..99f8673946 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go @@ -0,0 +1,86 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationItemsSpecialPropertyAssignment(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +// @allowJs: true +// @Filename: /a.js +[|exports.x = 0|]; +[|exports.y = function() {}|]; +function Cls() { + [|this.instanceProp = 0|]; +} +[|Cls.staticMethod = function() {}|]; +[|Cls.staticProperty = 0|]; +[|Cls.prototype.instanceMethod = function() {}|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "x", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "y", + Kind: lsproto.SymbolKindFunction, + Location: f.Ranges()[1].LSLocation(), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "instanceProp", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[2].LSLocation(), + ContainerName: PtrTo("Cls"), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "staticMethod", + Kind: lsproto.SymbolKindMethod, + Location: f.Ranges()[3].LSLocation(), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "staticProperty", + Kind: lsproto.SymbolKindProperty, + Location: f.Ranges()[4].LSLocation(), + }, + }, + }, { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "instanceMethod", + Kind: lsproto.SymbolKindMethod, + Location: f.Ranges()[5].LSLocation(), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navto_emptyPattern_test.go b/internal/fourslash/tests/gen/navto_emptyPattern_test.go new file mode 100644 index 0000000000..c965f2fc33 --- /dev/null +++ b/internal/fourslash/tests/gen/navto_emptyPattern_test.go @@ -0,0 +1,36 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavto_emptyPattern(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: foo.ts +const [|x: number = 1|]; +[|function y(x: string): string { return x; }|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "x", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + { + Name: "y", + Kind: lsproto.SymbolKindFunction, + Location: f.Ranges()[1].LSLocation(), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navto_excludeLib1_test.go b/internal/fourslash/tests/gen/navto_excludeLib1_test.go new file mode 100644 index 0000000000..a74a7323cb --- /dev/null +++ b/internal/fourslash/tests/gen/navto_excludeLib1_test.go @@ -0,0 +1,56 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavto_excludeLib1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /index.ts +import { weirdName as otherName } from "bar"; +const [|weirdName: number = 1|]; +// @filename: /tsconfig.json +{} +// @filename: /node_modules/bar/index.d.ts +export const [|weirdName: number|]; +// @filename: /node_modules/bar/package.json +{}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[1].LSLocation(), + }, + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }, + }, + }) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: &ls.UserPreferences{ExcludeLibrarySymbols: PtrTo(true)}, + Includes: []*lsproto.SymbolInformation{ + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navto_excludeLib2_test.go b/internal/fourslash/tests/gen/navto_excludeLib2_test.go new file mode 100644 index 0000000000..5ca693c35e --- /dev/null +++ b/internal/fourslash/tests/gen/navto_excludeLib2_test.go @@ -0,0 +1,44 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavto_excludeLib2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /index.ts +import { [|someName as weirdName|] } from "bar"; +// @filename: /tsconfig.json +{} +// @filename: /node_modules/bar/index.d.ts +export const someName: number; +// @filename: /node_modules/bar/package.json +{}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }, + }, + }) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: &ls.UserPreferences{ExcludeLibrarySymbols: PtrTo(true)}, + Includes: []*lsproto.SymbolInformation{}, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navto_excludeLib3_test.go b/internal/fourslash/tests/gen/navto_excludeLib3_test.go new file mode 100644 index 0000000000..ae7c0f6180 --- /dev/null +++ b/internal/fourslash/tests/gen/navto_excludeLib3_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavto_excludeLib3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /index.ts +[|function parseInt(s: string): number {}|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: &ls.UserPreferences{ExcludeLibrarySymbols: PtrTo(true)}, + Includes: []*lsproto.SymbolInformation{ + { + Name: "parseInt", + Kind: lsproto.SymbolKindFunction, + Location: f.Ranges()[0].LSLocation(), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navto_excludeLib4_test.go b/internal/fourslash/tests/gen/navto_excludeLib4_test.go new file mode 100644 index 0000000000..75441378f6 --- /dev/null +++ b/internal/fourslash/tests/gen/navto_excludeLib4_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavto_excludeLib4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /node_modules/bar/index.d.ts +import { someOtherName } from "./baz"; +export const [|someName: number|]; +// @filename: /node_modules/bar/baz.d.ts +export const someOtherName: string;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: &ls.UserPreferences{ExcludeLibrarySymbols: PtrTo(true)}, + Includes: []*lsproto.SymbolInformation{ + { + Name: "someName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }, + }, + }) +} diff --git a/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go b/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go new file mode 100644 index 0000000000..13b25c830d --- /dev/null +++ b/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go @@ -0,0 +1,56 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavto_serverExcludeLib(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /home/src/workspaces/project/index.ts +import { weirdName as otherName } from "bar"; +const [|weirdName: number = 1|]; +// @Filename: /home/src/workspaces/project/tsconfig.json +{} +// @Filename: /home/src/workspaces/project/node_modules/bar/index.d.ts +export const [|weirdName: number|]; +// @Filename: /home/src/workspaces/project/node_modules/bar/package.json +{}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: nil, + Includes: []*lsproto.SymbolInformation{ + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[1].LSLocation(), + }, + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }, + }, + }) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Preferences: &ls.UserPreferences{ExcludeLibrarySymbols: PtrTo(true)}, + Includes: []*lsproto.SymbolInformation{ + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }, + }, + }) +} diff --git a/internal/ls/lsutil/userpreferences.go b/internal/ls/lsutil/userpreferences.go index 4c6dbb22f2..ff98c2373d 100644 --- a/internal/ls/lsutil/userpreferences.go +++ b/internal/ls/lsutil/userpreferences.go @@ -142,12 +142,15 @@ type UserPreferences struct { IncludeInlayFunctionLikeReturnTypeHints bool IncludeInlayEnumMemberValueHints bool + // ------- Symbols ------- + + ExcludeLibrarySymbolsInNavTo bool + // ------- Misc ------- - ExcludeLibrarySymbolsInNavTo bool // !!! - DisableSuggestions bool // !!! - DisableLineTextInReferences bool // !!! - DisplayPartsForJSDoc bool // !!! + DisableSuggestions bool // !!! + DisableLineTextInReferences bool // !!! + DisplayPartsForJSDoc bool // !!! } type JsxAttributeCompletionStyle string From 30e364638bcefc0f40b7440af3318ba923892d06 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 21 Nov 2025 09:24:10 -0800 Subject: [PATCH 2/8] more symbol fixes --- _submodules/TypeScript | 2 +- internal/ast/ast.go | 6 +-- internal/compiler/program.go | 21 ++++++++ .../fourslash/_scripts/convertFourslash.mts | 14 ++++- internal/fourslash/fourslash.go | 51 +++++++++++-------- .../tests/gen/declareFunction_test.go | 1 + .../tests/gen/navigateItemsLet_test.go | 2 + .../tests/gen/navigateToImport_test.go | 3 ++ .../gen/navigateToSymbolIterator_test.go | 1 + .../gen/navigationItemsExactMatch2_test.go | 4 ++ ...ationItemsInConstructorsExactMatch_test.go | 1 + .../gen/navigationItemsPrefixMatch2_test.go | 3 ++ ...tionItemsSpecialPropertyAssignment_test.go | 6 +++ .../tests/gen/navto_emptyPattern_test.go | 1 + .../tests/gen/navto_excludeLib1_test.go | 28 +++++----- .../tests/gen/navto_excludeLib2_test.go | 7 +-- .../tests/gen/navto_excludeLib3_test.go | 6 +-- .../tests/gen/navto_excludeLib4_test.go | 6 +-- .../tests/gen/navto_serverExcludeLib_test.go | 8 +-- internal/ls/symbols.go | 32 ++++++++++-- internal/lsp/server.go | 9 +++- internal/project/session.go | 32 ++++++++++++ 22 files changed, 185 insertions(+), 59 deletions(-) diff --git a/_submodules/TypeScript b/_submodules/TypeScript index add6971195..9e8eaa1746 160000 --- a/_submodules/TypeScript +++ b/_submodules/TypeScript @@ -1 +1 @@ -Subproject commit add697119549734b24d46b30b9f6d2e757c6d53a +Subproject commit 9e8eaa1746b0d09c3cd29048126ef9cf24f29c03 diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 7939f87efc..b9dda78cdd 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -10983,7 +10983,7 @@ func (node *SourceFile) computeDeclarationMap() map[string][]*Node { result := make(map[string][]*Node) addDeclaration := func(declaration *Node) { - name := getDeclarationName(declaration) + name := GetDeclarationName(declaration) if name != "" { result[name] = append(result[name], declaration) } @@ -10993,7 +10993,7 @@ func (node *SourceFile) computeDeclarationMap() map[string][]*Node { visit = func(node *Node) bool { switch node.Kind { case KindFunctionDeclaration, KindFunctionExpression, KindMethodDeclaration, KindMethodSignature: - declarationName := getDeclarationName(node) + declarationName := GetDeclarationName(node) if declarationName != "" { declarations := result[declarationName] var lastDeclaration *Node @@ -11083,7 +11083,7 @@ func (node *SourceFile) computeDeclarationMap() map[string][]*Node { return result } -func getDeclarationName(declaration *Node) string { +func GetDeclarationName(declaration *Node) string { name := GetNonAssignedNameOfDeclaration(declaration) if name != nil { if IsComputedPropertyName(name) { diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 2dbe96c47e..48ba3866aa 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -67,6 +67,10 @@ type Program struct { // Cached unresolved imports for ATA unresolvedImportsOnce sync.Once unresolvedImports *collections.Set[string] + + // Used by workspace/symbol + hasTSFileOnce sync.Once + hasTSFile bool } // FileExists implements checker.Program. @@ -1623,6 +1627,23 @@ func (p *Program) SourceFileMayBeEmitted(sourceFile *ast.SourceFile, forceDtsEmi return sourceFileMayBeEmitted(sourceFile, p, forceDtsEmit) } +func (p *Program) IsLibFile(sourceFile *ast.SourceFile) bool { + _, ok := p.libFiles[sourceFile.Path()] + return ok +} + +func (p *Program) HasTSFile() bool { + p.hasTSFileOnce.Do(func() { + for _, file := range p.files { + if tspath.HasImplementationTSFileExtension(file.FileName()) { + p.hasTSFile = true + break + } + } + }) + return p.hasTSFile +} + var plainJSErrors = collections.NewSetFromItems( // binder errors diagnostics.Cannot_redeclare_block_scoped_variable_0.Code(), diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index b97b0454b8..e3ac5119ab 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -1826,6 +1826,7 @@ function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { } let prefs; const items = []; + let pattern: string | undefined; for (const prop of arg.properties) { if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) { console.error(`Expected property assignment with identifier name for verify.navigateTo argument, got ${prop.getText()}`); @@ -1833,7 +1834,15 @@ function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { } const propName = prop.name.text; switch (propName) { - case "pattern": + case "pattern": { + let patternInit = getStringLiteralLike(prop.initializer); + if (!patternInit) { + console.error(`Expected string literal for pattern in verify.navigateTo argument, got ${prop.initializer.getText()}`); + return undefined; + } + pattern = getGoStringLiteral(patternInit.text); + break; + } case "fileName": // no longer supported continue; @@ -1854,7 +1863,7 @@ function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { } case "excludeLibFiles": { if (prop.initializer.kind === ts.SyntaxKind.TrueKeyword) { - prefs = `&ls.UserPreferences{ExcludeLibrarySymbols: PtrTo(true)}` + prefs = `&lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}` } } } @@ -1863,6 +1872,7 @@ function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { prefs = "nil"; } return `{ + Pattern: ${pattern ? pattern : '""'}, Preferences: ${prefs}, Includes: []*lsproto.SymbolInformation{${items.length ? items.join(",\n") + ",\n" : ""}}, }` diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index e4fc08115a..54b642da2e 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -2467,7 +2467,7 @@ func (f *FourslashTest) verifyBaselines(t *testing.T, testPath string) { func (f *FourslashTest) VerifyBaselineInlayHints( t *testing.T, span *lsproto.Range, - userPreferences *lsutil.UserPreferences, + testPreferences *lsutil.UserPreferences, ) { fileName := f.activeFilename var lspRange lsproto.Range @@ -2482,10 +2482,12 @@ func (f *FourslashTest) VerifyBaselineInlayHints( Range: lspRange, } - if userPreferences != nil { - reset := f.ConfigureWithReset(t, userPreferences) - defer reset() + preferences := testPreferences + if preferences == nil { + preferences = lsutil.NewDefaultUserPreferences() } + reset := f.ConfigureWithReset(t, testPreferences) + defer reset() prefix := fmt.Sprintf("At position (Ln %d, Col %d): ", lspRange.Start.Line, lspRange.Start.Character) resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentInlayHintInfo, params) @@ -2824,16 +2826,22 @@ func (f *FourslashTest) VerifyBaselineGoToImplementation(t *testing.T, markerNam } type VerifyWorkspaceSymbolCase struct { + Pattern string Includes []*lsproto.SymbolInformation // !!! HERE: fourslash.Range instead of Location Preferences *lsutil.UserPreferences } // `verify.navigateTo` in Strada. func (f *FourslashTest) VerifyWorkspaceSymbol(t *testing.T, cases []*VerifyWorkspaceSymbolCase) { - var configReset func() + originalPreferences := f.userPreferences.Copy() for _, testCase := range cases { - configReset = f.ConfigureWithReset(t, testCase.Preferences) - resMsg, result, resultOk := sendRequest(t, f, lsproto.WorkspaceSymbolInfo, &lsproto.WorkspaceSymbolParams{}) + preferences := testCase.Preferences + if preferences == nil { + preferences = lsutil.NewDefaultUserPreferences() + } + f.Configure(t, preferences) + resMsg, result, resultOk := + sendRequest(t, f, lsproto.WorkspaceSymbolInfo, &lsproto.WorkspaceSymbolParams{Query: testCase.Pattern}) if resMsg == nil { t.Fatalf("Nil response received for workspace symbol request") } @@ -2843,9 +2851,9 @@ func (f *FourslashTest) VerifyWorkspaceSymbol(t *testing.T, cases []*VerifyWorks if result.SymbolInformations == nil { t.Fatalf("Expected non-nil symbol information array from workspace symbol request") } - verifyIncludesSymbols(t, *result.SymbolInformations, testCase.Includes, "Workspace symbols mismatch") + verifyIncludesSymbols(t, *result.SymbolInformations, testCase.Includes, "Workspace symbols mismatch with pattern '"+testCase.Pattern+"'") } - configReset() + f.Configure(t, originalPreferences) } func verifyIncludesSymbols( @@ -2854,16 +2862,17 @@ func verifyIncludesSymbols( includes []*lsproto.SymbolInformation, prefix string, ) { - nameToActualSymbol := make(map[string]*lsproto.SymbolInformation, len(actual)) - for _, sym := range actual { - nameToActualSymbol[sym.Name] = sym - } - - for _, sym := range includes { - actualSym, ok := nameToActualSymbol[sym.Name] - if !ok { - t.Fatalf("%s: Expected symbol '%s' not found", prefix, sym.Name) - } - assertDeepEqual(t, actualSym, sym, fmt.Sprintf("%s: Symbol '%s' mismatch", prefix, sym.Name)) - } + assertDeepEqual(t, actual, includes, prefix) + // nameToActualSymbol := make(map[string]*lsproto.SymbolInformation, len(actual)) + // for _, sym := range actual { + // nameToActualSymbol[sym.Name] = sym + // } + + // for _, sym := range includes { + // actualSym, ok := nameToActualSymbol[sym.Name] + // if !ok { + // t.Fatalf("%s: Expected symbol '%s' not found", prefix, sym.Name) + // } + // assertDeepEqual(t, actualSym, sym, fmt.Sprintf("%s: Symbol '%s' mismatch", prefix, sym.Name)) + // } } diff --git a/internal/fourslash/tests/gen/declareFunction_test.go b/internal/fourslash/tests/gen/declareFunction_test.go index 46c2ac4ce5..4f04fde7c6 100644 --- a/internal/fourslash/tests/gen/declareFunction_test.go +++ b/internal/fourslash/tests/gen/declareFunction_test.go @@ -17,6 +17,7 @@ declare function` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { + Pattern: "", Preferences: nil, Includes: []*lsproto.SymbolInformation{}, }, diff --git a/internal/fourslash/tests/gen/navigateItemsLet_test.go b/internal/fourslash/tests/gen/navigateItemsLet_test.go index bf045a7b66..74be96f7b7 100644 --- a/internal/fourslash/tests/gen/navigateItemsLet_test.go +++ b/internal/fourslash/tests/gen/navigateItemsLet_test.go @@ -21,6 +21,7 @@ function foo() { f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { + Pattern: "c", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -30,6 +31,7 @@ function foo() { }, }, }, { + Pattern: "d", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { diff --git a/internal/fourslash/tests/gen/navigateToImport_test.go b/internal/fourslash/tests/gen/navigateToImport_test.go index eb18d9f06f..ed87d03500 100644 --- a/internal/fourslash/tests/gen/navigateToImport_test.go +++ b/internal/fourslash/tests/gen/navigateToImport_test.go @@ -20,6 +20,7 @@ import {foo, [|bar as baz|]} from './library';` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { + Pattern: "foo", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -29,6 +30,7 @@ import {foo, [|bar as baz|]} from './library';` }, }, }, { + Pattern: "bar", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -38,6 +40,7 @@ import {foo, [|bar as baz|]} from './library';` }, }, }, { + Pattern: "baz", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { diff --git a/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go b/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go index bacb75dc03..34ca8c8e95 100644 --- a/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go +++ b/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go @@ -19,6 +19,7 @@ func TestNavigateToSymbolIterator(t *testing.T) { f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { + Pattern: "iterator", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { diff --git a/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go b/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go index dd8f3c2d85..42b43f91c5 100644 --- a/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go +++ b/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go @@ -32,6 +32,7 @@ var [|point = new Shapes.Point()|]; f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { + Pattern: "point", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -47,6 +48,7 @@ var [|point = new Shapes.Point()|]; }, }, }, { + Pattern: "distance", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -80,6 +82,7 @@ var [|point = new Shapes.Point()|]; }, }, }, { + Pattern: "origin", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -90,6 +93,7 @@ var [|point = new Shapes.Point()|]; }, }, }, { + Pattern: "square", Preferences: nil, Includes: []*lsproto.SymbolInformation{}, }, diff --git a/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go b/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go index 931cc840f0..e59d853f60 100644 --- a/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go +++ b/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go @@ -22,6 +22,7 @@ class Test { f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { + Pattern: "search", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { diff --git a/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go b/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go index a4d5f37757..7879ff914f 100644 --- a/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go +++ b/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go @@ -35,6 +35,7 @@ function PointsFunc(): void { f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { + Pattern: "origin", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -56,6 +57,7 @@ function PointsFunc(): void { }, }, }, { + Pattern: "distance", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -84,6 +86,7 @@ function PointsFunc(): void { }, }, }, { + Pattern: "mPointThatIJustInitiated wrongKeyWord", Preferences: nil, Includes: []*lsproto.SymbolInformation{}, }, diff --git a/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go b/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go index 99f8673946..788fc1cee0 100644 --- a/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go +++ b/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go @@ -27,6 +27,7 @@ function Cls() { f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { + Pattern: "x", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -36,6 +37,7 @@ function Cls() { }, }, }, { + Pattern: "y", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -45,6 +47,7 @@ function Cls() { }, }, }, { + Pattern: "instanceProp", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -55,6 +58,7 @@ function Cls() { }, }, }, { + Pattern: "staticMethod", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -64,6 +68,7 @@ function Cls() { }, }, }, { + Pattern: "staticProperty", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -73,6 +78,7 @@ function Cls() { }, }, }, { + Pattern: "instanceMethod", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { diff --git a/internal/fourslash/tests/gen/navto_emptyPattern_test.go b/internal/fourslash/tests/gen/navto_emptyPattern_test.go index c965f2fc33..c1795af70c 100644 --- a/internal/fourslash/tests/gen/navto_emptyPattern_test.go +++ b/internal/fourslash/tests/gen/navto_emptyPattern_test.go @@ -18,6 +18,7 @@ const [|x: number = 1|]; f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { + Pattern: "", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { diff --git a/internal/fourslash/tests/gen/navto_excludeLib1_test.go b/internal/fourslash/tests/gen/navto_excludeLib1_test.go index a74a7323cb..890bc12ae1 100644 --- a/internal/fourslash/tests/gen/navto_excludeLib1_test.go +++ b/internal/fourslash/tests/gen/navto_excludeLib1_test.go @@ -4,8 +4,6 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" - . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" - "github.com/microsoft/typescript-go/internal/ls" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -26,6 +24,7 @@ export const [|weirdName: number|]; f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { + Pattern: "weirdName", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -41,16 +40,17 @@ export const [|weirdName: number|]; }, }, }) - f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ - { - Preferences: &ls.UserPreferences{ExcludeLibrarySymbols: PtrTo(true)}, - Includes: []*lsproto.SymbolInformation{ - { - Name: "weirdName", - Kind: lsproto.SymbolKindVariable, - Location: f.Ranges()[0].LSLocation(), - }, - }, - }, - }) + // f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + // { + // Pattern: "weirdName", + // Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}, + // Includes: []*lsproto.SymbolInformation{ + // { + // Name: "weirdName", + // Kind: lsproto.SymbolKindVariable, + // Location: f.Ranges()[0].LSLocation(), + // }, + // }, + // }, + // }) } diff --git a/internal/fourslash/tests/gen/navto_excludeLib2_test.go b/internal/fourslash/tests/gen/navto_excludeLib2_test.go index 5ca693c35e..ce1b3b30f7 100644 --- a/internal/fourslash/tests/gen/navto_excludeLib2_test.go +++ b/internal/fourslash/tests/gen/navto_excludeLib2_test.go @@ -4,8 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" - . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -25,6 +24,7 @@ export const someName: number; f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { + Pattern: "weirdName", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -37,7 +37,8 @@ export const someName: number; }) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { - Preferences: &ls.UserPreferences{ExcludeLibrarySymbols: PtrTo(true)}, + Pattern: "weirdName", + Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}, Includes: []*lsproto.SymbolInformation{}, }, }) diff --git a/internal/fourslash/tests/gen/navto_excludeLib3_test.go b/internal/fourslash/tests/gen/navto_excludeLib3_test.go index ae7c0f6180..86c097ec9a 100644 --- a/internal/fourslash/tests/gen/navto_excludeLib3_test.go +++ b/internal/fourslash/tests/gen/navto_excludeLib3_test.go @@ -4,8 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" - . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -19,7 +18,8 @@ func TestNavto_excludeLib3(t *testing.T) { f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { - Preferences: &ls.UserPreferences{ExcludeLibrarySymbols: PtrTo(true)}, + Pattern: "parseInt", + Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}, Includes: []*lsproto.SymbolInformation{ { Name: "parseInt", diff --git a/internal/fourslash/tests/gen/navto_excludeLib4_test.go b/internal/fourslash/tests/gen/navto_excludeLib4_test.go index 75441378f6..84619114be 100644 --- a/internal/fourslash/tests/gen/navto_excludeLib4_test.go +++ b/internal/fourslash/tests/gen/navto_excludeLib4_test.go @@ -4,8 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" - . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -22,7 +21,8 @@ export const someOtherName: string;` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { - Preferences: &ls.UserPreferences{ExcludeLibrarySymbols: PtrTo(true)}, + Pattern: "some", + Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}, Includes: []*lsproto.SymbolInformation{ { Name: "someName", diff --git a/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go b/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go index 13b25c830d..e07b2cb061 100644 --- a/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go +++ b/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go @@ -4,8 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" - . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" - "github.com/microsoft/typescript-go/internal/ls" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -24,8 +23,10 @@ export const [|weirdName: number|]; // @Filename: /home/src/workspaces/project/node_modules/bar/package.json {}` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { + Pattern: "weirdName", Preferences: nil, Includes: []*lsproto.SymbolInformation{ { @@ -43,7 +44,8 @@ export const [|weirdName: number|]; }) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { - Preferences: &ls.UserPreferences{ExcludeLibrarySymbols: PtrTo(true)}, + Pattern: "weirdName", + Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}, Includes: []*lsproto.SymbolInformation{ { Name: "weirdName", diff --git a/internal/ls/symbols.go b/internal/ls/symbols.go index 5cab43634a..8b037e05a7 100644 --- a/internal/ls/symbols.go +++ b/internal/ls/symbols.go @@ -8,10 +8,12 @@ import ( "unicode/utf8" "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/astnav" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/ls/lsconv" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/printer" "github.com/microsoft/typescript-go/internal/scanner" @@ -238,12 +240,20 @@ type DeclarationInfo struct { matchScore int } -func ProvideWorkspaceSymbols(ctx context.Context, programs []*compiler.Program, converters *lsconv.Converters, query string) (lsproto.WorkspaceSymbolResponse, error) { +func ProvideWorkspaceSymbols( + ctx context.Context, + programs []*compiler.Program, + converters *lsconv.Converters, + preferences *lsutil.UserPreferences, + query string, +) (lsproto.WorkspaceSymbolResponse, error) { + excludeLibrarySymbols := preferences.ExcludeLibrarySymbolsInNavTo // Obtain set of non-declaration source files from all active programs. var sourceFiles collections.Set[*ast.SourceFile] for _, program := range programs { for _, sourceFile := range program.SourceFiles() { - if !sourceFile.IsDeclarationFile { + if (program.HasTSFile() || !sourceFile.IsDeclarationFile) && + !shouldExcludeFile(sourceFile, program, excludeLibrarySymbols) { sourceFiles.Add(sourceFile) } } @@ -269,18 +279,32 @@ func ProvideWorkspaceSymbols(ctx context.Context, programs []*compiler.Program, count := min(len(infos), 256) symbols := make([]*lsproto.SymbolInformation, count) for i, info := range infos[0:count] { - node := core.OrElse(ast.GetNameOfDeclaration(info.declaration), info.declaration) + node := info.declaration sourceFile := ast.GetSourceFileOfNode(node) - pos := scanner.SkipTrivia(sourceFile.Text(), node.Pos()) + pos := astnav.GetStartOfNode(node, sourceFile, false /*includeJsDoc*/) + container := getContainerNode(info.declaration) + var containerName *string + if container != nil { + containerName = strPtrTo(ast.GetDeclarationName(container)) + } var symbol lsproto.SymbolInformation symbol.Name = info.name symbol.Kind = getSymbolKindFromNode(info.declaration) symbol.Location = converters.ToLSPLocation(sourceFile, core.NewTextRange(pos, node.End())) + symbol.ContainerName = containerName symbols[i] = &symbol } return lsproto.SymbolInformationsOrWorkspaceSymbolsOrNull{SymbolInformations: &symbols}, nil } +func shouldExcludeFile(file *ast.SourceFile, program *compiler.Program, excludeLibrarySymbols bool) bool { + return excludeLibrarySymbols && (isInsideNodeModules(file.FileName()) || program.IsLibFile(file)) +} + +func isInsideNodeModules(fileName string) bool { + return strings.Contains(fileName, "/node_modules/") +} + // Return a score for matching `s` against `pattern`. In order to match, `s` must contain each of the characters in // `pattern` in the same order. Upper case characters in `pattern` must match exactly, whereas lower case characters // in `pattern` match either case in `s`. If `s` doesn't match, -1 is returned. Otherwise, the returned score is the diff --git a/internal/lsp/server.go b/internal/lsp/server.go index 2c3eafa3a7..a562d553f9 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -938,11 +938,16 @@ func (s *Server) handleDocumentOnTypeFormat(ctx context.Context, ls *ls.Language } func (s *Server) handleWorkspaceSymbol(ctx context.Context, params *lsproto.WorkspaceSymbolParams, reqMsg *lsproto.RequestMessage) (lsproto.WorkspaceSymbolResponse, error) { - snapshot, release := s.session.Snapshot() + snapshot, release := s.session.GetUpdatedSnapshot(ctx) defer release() defer s.recover(reqMsg) programs := core.Map(snapshot.ProjectCollection.Projects(), (*project.Project).GetProgram) - return ls.ProvideWorkspaceSymbols(ctx, programs, snapshot.Converters(), params.Query) + return ls.ProvideWorkspaceSymbols( + ctx, + programs, + snapshot.Converters(), + snapshot.UserPreferences(), + params.Query) } func (s *Server) handleDocumentSymbol(ctx context.Context, ls *ls.LanguageService, params *lsproto.DocumentSymbolParams) (lsproto.DocumentSymbolResponse, error) { diff --git a/internal/project/session.go b/internal/project/session.go index 4adaf13e58..c94c89398b 100644 --- a/internal/project/session.go +++ b/internal/project/session.go @@ -372,6 +372,38 @@ func (s *Session) Snapshot() (*Snapshot, func()) { } } +func (s *Session) GetUpdatedSnapshot(ctx context.Context) (*Snapshot, func()) { + var snapshot *Snapshot + fileChanges, overlays, ataChanges, newConfig := s.flushChanges(ctx) + updateSnapshot := !fileChanges.IsEmpty() || len(ataChanges) > 0 || newConfig != nil + if updateSnapshot { + // If there are pending file changes, we need to update the snapshot. + // Sending the requested URI ensures that the project for this URI is loaded. + snapshot = s.UpdateSnapshot(ctx, overlays, SnapshotChange{ + reason: UpdateReasonRequestedLanguageServicePendingChanges, + fileChanges: fileChanges, + ataChanges: ataChanges, + newConfig: newConfig, + }) + } else { + // If there are no pending file changes, we can try to use the current snapshot. + s.snapshotMu.RLock() + snapshot = s.snapshot + s.snapshotMu.RUnlock() + } + return snapshot, func() { + if snapshot.Deref() { + // The session itself accounts for one reference to the snapshot, and it derefs + // in UpdateSnapshot while holding the snapshotMu lock, so the only way to end + // up here is for an external caller to release the snapshot after the session + // has already dereferenced it and moved to a new snapshot. In other words, we + // can assume that `snapshot != s.snapshot`, and therefor there's no way for + // anyone else to acquire a reference to this snapshot again. + snapshot.dispose(s) + } + } +} + func (s *Session) GetLanguageService(ctx context.Context, uri lsproto.DocumentUri) (*ls.LanguageService, error) { var snapshot *Snapshot fileChanges, overlays, ataChanges, newConfig := s.flushChanges(ctx) From ec73c365845f02078b72f699bd3385cbc4bd7832 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 21 Nov 2025 11:39:08 -0800 Subject: [PATCH 3/8] add exact/includes, make excludeLib true by default --- internal/ast/ast.go | 2 +- .../fourslash/_scripts/convertFourslash.mts | 4 +- internal/fourslash/fourslash.go | 58 ++++++++++++++----- .../tests/gen/declareFunction_test.go | 3 +- .../tests/gen/navigateItemsLet_test.go | 8 +-- .../tests/gen/navigateToImport_test.go | 13 +++-- .../gen/navigateToSymbolIterator_test.go | 4 +- .../gen/navigationItemsExactMatch2_test.go | 14 ++--- ...ationItemsInConstructorsExactMatch_test.go | 4 +- .../gen/navigationItemsPrefixMatch2_test.go | 10 ++-- ...tionItemsSpecialPropertyAssignment_test.go | 24 ++++---- .../tests/gen/navto_emptyPattern_test.go | 5 +- .../tests/gen/navto_excludeLib1_test.go | 31 +++++----- .../tests/gen/navto_excludeLib2_test.go | 10 ++-- .../tests/gen/navto_excludeLib3_test.go | 8 +-- .../tests/gen/navto_excludeLib4_test.go | 8 +-- .../tests/gen/navto_serverExcludeLib_test.go | 12 ++-- internal/ls/lsutil/userpreferences.go | 2 + internal/ls/symbols.go | 5 ++ 19 files changed, 132 insertions(+), 93 deletions(-) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index b9dda78cdd..f19ba8878e 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -11025,7 +11025,7 @@ func (node *SourceFile) computeDeclarationMap() map[string][]*Node { break } fallthrough - case KindVariableDeclaration, KindBindingElement: + case KindVariableDeclaration, KindBindingElement, KindCommonJSExport: name := node.Name() if name != nil { if IsBindingPattern(name) { diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index e3ac5119ab..486b509672 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -1862,7 +1862,7 @@ function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { break; } case "excludeLibFiles": { - if (prop.initializer.kind === ts.SyntaxKind.TrueKeyword) { + if (prop.initializer.kind === ts.SyntaxKind.FalseKeyword) { prefs = `&lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}` } } @@ -1874,7 +1874,7 @@ function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { return `{ Pattern: ${pattern ? pattern : '""'}, Preferences: ${prefs}, - Includes: []*lsproto.SymbolInformation{${items.length ? items.join(",\n") + ",\n" : ""}}, + Exact: PtrTo([]*lsproto.SymbolInformation{${items.length ? items.join(",\n") + ",\n" : ""}}), }` } diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index 54b642da2e..362a678b53 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -2827,7 +2827,8 @@ func (f *FourslashTest) VerifyBaselineGoToImplementation(t *testing.T, markerNam type VerifyWorkspaceSymbolCase struct { Pattern string - Includes []*lsproto.SymbolInformation // !!! HERE: fourslash.Range instead of Location + Includes *[]*lsproto.SymbolInformation + Exact *[]*lsproto.SymbolInformation Preferences *lsutil.UserPreferences } @@ -2851,28 +2852,55 @@ func (f *FourslashTest) VerifyWorkspaceSymbol(t *testing.T, cases []*VerifyWorks if result.SymbolInformations == nil { t.Fatalf("Expected non-nil symbol information array from workspace symbol request") } - verifyIncludesSymbols(t, *result.SymbolInformations, testCase.Includes, "Workspace symbols mismatch with pattern '"+testCase.Pattern+"'") + if testCase.Includes != nil { + if testCase.Exact != nil { + t.Fatalf("Test case cannot have both 'Includes' and 'Exact' fields set") + } + verifyIncludesSymbols(t, *result.SymbolInformations, *testCase.Includes, "Workspace symbols mismatch with pattern '"+testCase.Pattern+"'") + } else { + if testCase.Exact == nil { + t.Fatalf("Test case must have either 'Includes' or 'Exact' field set") + } + verifyExactSymbols(t, *result.SymbolInformations, *testCase.Exact, "Workspace symbols mismatch with pattern '"+testCase.Pattern+"'") + } } f.Configure(t, originalPreferences) } +func verifyExactSymbols( + t *testing.T, + actual []*lsproto.SymbolInformation, + expected []*lsproto.SymbolInformation, + prefix string, +) { + if len(actual) != len(expected) { + t.Fatalf("%s: Expected %d symbols, but got %d:\n%s", prefix, len(expected), len(actual), cmp.Diff(actual, expected)) + } + for i := range actual { + assertDeepEqual(t, actual[i], expected[i], prefix) + } +} + func verifyIncludesSymbols( t *testing.T, actual []*lsproto.SymbolInformation, includes []*lsproto.SymbolInformation, prefix string, ) { - assertDeepEqual(t, actual, includes, prefix) - // nameToActualSymbol := make(map[string]*lsproto.SymbolInformation, len(actual)) - // for _, sym := range actual { - // nameToActualSymbol[sym.Name] = sym - // } - - // for _, sym := range includes { - // actualSym, ok := nameToActualSymbol[sym.Name] - // if !ok { - // t.Fatalf("%s: Expected symbol '%s' not found", prefix, sym.Name) - // } - // assertDeepEqual(t, actualSym, sym, fmt.Sprintf("%s: Symbol '%s' mismatch", prefix, sym.Name)) - // } + type key struct { + name string + loc lsproto.Location + } + nameAndLocToActualSymbol := make(map[key]*lsproto.SymbolInformation, len(actual)) + for _, sym := range actual { + nameAndLocToActualSymbol[key{name: sym.Name, loc: sym.Location}] = sym + } + + for _, sym := range includes { + actualSym, ok := nameAndLocToActualSymbol[key{name: sym.Name, loc: sym.Location}] + if !ok { + t.Fatalf("%s: Expected symbol '%s' at location '%v' not found", prefix, sym.Name, sym.Location) + } + assertDeepEqual(t, actualSym, sym, fmt.Sprintf("%s: Symbol '%s' at location '%v' mismatch", prefix, sym.Name, sym.Location)) + } } diff --git a/internal/fourslash/tests/gen/declareFunction_test.go b/internal/fourslash/tests/gen/declareFunction_test.go index 4f04fde7c6..84d8b17e64 100644 --- a/internal/fourslash/tests/gen/declareFunction_test.go +++ b/internal/fourslash/tests/gen/declareFunction_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -19,7 +20,7 @@ declare function` { Pattern: "", Preferences: nil, - Includes: []*lsproto.SymbolInformation{}, + Exact: PtrTo([]*lsproto.SymbolInformation{}), }, }) } diff --git a/internal/fourslash/tests/gen/navigateItemsLet_test.go b/internal/fourslash/tests/gen/navigateItemsLet_test.go index 74be96f7b7..b9ee83d2e0 100644 --- a/internal/fourslash/tests/gen/navigateItemsLet_test.go +++ b/internal/fourslash/tests/gen/navigateItemsLet_test.go @@ -23,24 +23,24 @@ function foo() { { Pattern: "c", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "c", Kind: lsproto.SymbolKindVariable, Location: f.Ranges()[0].LSLocation(), }, - }, + }), }, { Pattern: "d", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "d", Kind: lsproto.SymbolKindVariable, Location: f.Ranges()[1].LSLocation(), ContainerName: PtrTo("foo"), }, - }, + }), }, }) } diff --git a/internal/fourslash/tests/gen/navigateToImport_test.go b/internal/fourslash/tests/gen/navigateToImport_test.go index ed87d03500..bd96c10a74 100644 --- a/internal/fourslash/tests/gen/navigateToImport_test.go +++ b/internal/fourslash/tests/gen/navigateToImport_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -22,33 +23,33 @@ import {foo, [|bar as baz|]} from './library';` { Pattern: "foo", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "foo", Kind: lsproto.SymbolKindFunction, Location: f.Ranges()[0].LSLocation(), }, - }, + }), }, { Pattern: "bar", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "bar", Kind: lsproto.SymbolKindFunction, Location: f.Ranges()[1].LSLocation(), }, - }, + }), }, { Pattern: "baz", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "baz", Kind: lsproto.SymbolKindVariable, Location: f.Ranges()[2].LSLocation(), }, - }, + }), }, }) } diff --git a/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go b/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go index 34ca8c8e95..0ec211a53a 100644 --- a/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go +++ b/internal/fourslash/tests/gen/navigateToSymbolIterator_test.go @@ -21,14 +21,14 @@ func TestNavigateToSymbolIterator(t *testing.T) { { Pattern: "iterator", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "iterator", Kind: lsproto.SymbolKindMethod, Location: f.Ranges()[0].LSLocation(), ContainerName: PtrTo("C"), }, - }, + }), }, }) } diff --git a/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go b/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go index 42b43f91c5..95ba275eb2 100644 --- a/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go +++ b/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go @@ -34,7 +34,7 @@ var [|point = new Shapes.Point()|]; { Pattern: "point", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "point", Kind: lsproto.SymbolKindVariable, @@ -46,11 +46,11 @@ var [|point = new Shapes.Point()|]; Location: f.Ranges()[0].LSLocation(), ContainerName: PtrTo("Shapes"), }, - }, + }), }, { Pattern: "distance", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "distance1", Kind: lsproto.SymbolKindProperty, @@ -80,22 +80,22 @@ var [|point = new Shapes.Point()|]; Location: f.Ranges()[7].LSLocation(), ContainerName: PtrTo("distance2"), }, - }, + }), }, { Pattern: "origin", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "_origin", Kind: lsproto.SymbolKindProperty, Location: f.Ranges()[1].LSLocation(), ContainerName: PtrTo("Point"), }, - }, + }), }, { Pattern: "square", Preferences: nil, - Includes: []*lsproto.SymbolInformation{}, + Exact: PtrTo([]*lsproto.SymbolInformation{}), }, }) } diff --git a/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go b/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go index e59d853f60..bf5a3d8940 100644 --- a/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go +++ b/internal/fourslash/tests/gen/navigationItemsInConstructorsExactMatch_test.go @@ -24,7 +24,7 @@ class Test { { Pattern: "search", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "search1", Kind: lsproto.SymbolKindProperty, @@ -43,7 +43,7 @@ class Test { Location: f.Ranges()[2].LSLocation(), ContainerName: PtrTo("Test"), }, - }, + }), }, }) } diff --git a/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go b/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go index 7879ff914f..aed3cc0848 100644 --- a/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go +++ b/internal/fourslash/tests/gen/navigationItemsPrefixMatch2_test.go @@ -37,7 +37,7 @@ function PointsFunc(): void { { Pattern: "origin", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "origin1", Kind: lsproto.SymbolKindProperty, @@ -55,11 +55,11 @@ function PointsFunc(): void { Kind: lsproto.SymbolKindInterface, Location: f.Ranges()[4].LSLocation(), }, - }, + }), }, { Pattern: "distance", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "distanceFarFarAway", Kind: lsproto.SymbolKindProperty, @@ -84,11 +84,11 @@ function PointsFunc(): void { Location: f.Ranges()[6].LSLocation(), ContainerName: PtrTo("OriginI"), }, - }, + }), }, { Pattern: "mPointThatIJustInitiated wrongKeyWord", Preferences: nil, - Includes: []*lsproto.SymbolInformation{}, + Exact: PtrTo([]*lsproto.SymbolInformation{}), }, }) } diff --git a/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go b/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go index 788fc1cee0..5e5ada5493 100644 --- a/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go +++ b/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go @@ -29,64 +29,64 @@ function Cls() { { Pattern: "x", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "x", Kind: lsproto.SymbolKindVariable, Location: f.Ranges()[0].LSLocation(), }, - }, + }), }, { Pattern: "y", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "y", Kind: lsproto.SymbolKindFunction, Location: f.Ranges()[1].LSLocation(), }, - }, + }), }, { Pattern: "instanceProp", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "instanceProp", Kind: lsproto.SymbolKindProperty, Location: f.Ranges()[2].LSLocation(), ContainerName: PtrTo("Cls"), }, - }, + }), }, { Pattern: "staticMethod", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "staticMethod", Kind: lsproto.SymbolKindMethod, Location: f.Ranges()[3].LSLocation(), }, - }, + }), }, { Pattern: "staticProperty", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "staticProperty", Kind: lsproto.SymbolKindProperty, Location: f.Ranges()[4].LSLocation(), }, - }, + }), }, { Pattern: "instanceMethod", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "instanceMethod", Kind: lsproto.SymbolKindMethod, Location: f.Ranges()[5].LSLocation(), }, - }, + }), }, }) } diff --git a/internal/fourslash/tests/gen/navto_emptyPattern_test.go b/internal/fourslash/tests/gen/navto_emptyPattern_test.go index c1795af70c..5c3702e9e2 100644 --- a/internal/fourslash/tests/gen/navto_emptyPattern_test.go +++ b/internal/fourslash/tests/gen/navto_emptyPattern_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -20,7 +21,7 @@ const [|x: number = 1|]; { Pattern: "", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "x", Kind: lsproto.SymbolKindVariable, @@ -31,7 +32,7 @@ const [|x: number = 1|]; Kind: lsproto.SymbolKindFunction, Location: f.Ranges()[1].LSLocation(), }, - }, + }), }, }) } diff --git a/internal/fourslash/tests/gen/navto_excludeLib1_test.go b/internal/fourslash/tests/gen/navto_excludeLib1_test.go index 890bc12ae1..a2409e5b0e 100644 --- a/internal/fourslash/tests/gen/navto_excludeLib1_test.go +++ b/internal/fourslash/tests/gen/navto_excludeLib1_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -26,7 +27,7 @@ export const [|weirdName: number|]; { Pattern: "weirdName", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "weirdName", Kind: lsproto.SymbolKindVariable, @@ -37,20 +38,20 @@ export const [|weirdName: number|]; Kind: lsproto.SymbolKindVariable, Location: f.Ranges()[0].LSLocation(), }, - }, + }), + }, + }) + f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ + { + Pattern: "weirdName", + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }), }, }) - // f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ - // { - // Pattern: "weirdName", - // Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}, - // Includes: []*lsproto.SymbolInformation{ - // { - // Name: "weirdName", - // Kind: lsproto.SymbolKindVariable, - // Location: f.Ranges()[0].LSLocation(), - // }, - // }, - // }, - // }) } diff --git a/internal/fourslash/tests/gen/navto_excludeLib2_test.go b/internal/fourslash/tests/gen/navto_excludeLib2_test.go index ce1b3b30f7..79cc5d1e0b 100644 --- a/internal/fourslash/tests/gen/navto_excludeLib2_test.go +++ b/internal/fourslash/tests/gen/navto_excludeLib2_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" - "github.com/microsoft/typescript-go/internal/ls/lsutil" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -26,20 +26,20 @@ export const someName: number; { Pattern: "weirdName", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "weirdName", Kind: lsproto.SymbolKindVariable, Location: f.Ranges()[0].LSLocation(), }, - }, + }), }, }) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { Pattern: "weirdName", - Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}, - Includes: []*lsproto.SymbolInformation{}, + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{}), }, }) } diff --git a/internal/fourslash/tests/gen/navto_excludeLib3_test.go b/internal/fourslash/tests/gen/navto_excludeLib3_test.go index 86c097ec9a..7fbae17d69 100644 --- a/internal/fourslash/tests/gen/navto_excludeLib3_test.go +++ b/internal/fourslash/tests/gen/navto_excludeLib3_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" - "github.com/microsoft/typescript-go/internal/ls/lsutil" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -19,14 +19,14 @@ func TestNavto_excludeLib3(t *testing.T) { f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { Pattern: "parseInt", - Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}, - Includes: []*lsproto.SymbolInformation{ + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "parseInt", Kind: lsproto.SymbolKindFunction, Location: f.Ranges()[0].LSLocation(), }, - }, + }), }, }) } diff --git a/internal/fourslash/tests/gen/navto_excludeLib4_test.go b/internal/fourslash/tests/gen/navto_excludeLib4_test.go index 84619114be..d10e14ded9 100644 --- a/internal/fourslash/tests/gen/navto_excludeLib4_test.go +++ b/internal/fourslash/tests/gen/navto_excludeLib4_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" - "github.com/microsoft/typescript-go/internal/ls/lsutil" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -22,14 +22,14 @@ export const someOtherName: string;` f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { Pattern: "some", - Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}, - Includes: []*lsproto.SymbolInformation{ + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "someName", Kind: lsproto.SymbolKindVariable, Location: f.Ranges()[0].LSLocation(), }, - }, + }), }, }) } diff --git a/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go b/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go index e07b2cb061..55dd6e624d 100644 --- a/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go +++ b/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/fourslash" - "github.com/microsoft/typescript-go/internal/ls/lsutil" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -28,7 +28,7 @@ export const [|weirdName: number|]; { Pattern: "weirdName", Preferences: nil, - Includes: []*lsproto.SymbolInformation{ + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "weirdName", Kind: lsproto.SymbolKindVariable, @@ -39,20 +39,20 @@ export const [|weirdName: number|]; Kind: lsproto.SymbolKindVariable, Location: f.Ranges()[0].LSLocation(), }, - }, + }), }, }) f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { Pattern: "weirdName", - Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}, - Includes: []*lsproto.SymbolInformation{ + Preferences: nil, + Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "weirdName", Kind: lsproto.SymbolKindVariable, Location: f.Ranges()[0].LSLocation(), }, - }, + }), }, }) } diff --git a/internal/ls/lsutil/userpreferences.go b/internal/ls/lsutil/userpreferences.go index ff98c2373d..f367c774a7 100644 --- a/internal/ls/lsutil/userpreferences.go +++ b/internal/ls/lsutil/userpreferences.go @@ -19,6 +19,8 @@ func NewDefaultUserPreferences() *UserPreferences { IncludeCompletionsWithSnippetText: core.TSTrue, DisplayPartsForJSDoc: true, DisableLineTextInReferences: true, + + ExcludeLibrarySymbolsInNavTo: true, } } diff --git a/internal/ls/symbols.go b/internal/ls/symbols.go index 8b037e05a7..6c24999379 100644 --- a/internal/ls/symbols.go +++ b/internal/ls/symbols.go @@ -371,6 +371,11 @@ func getSymbolKindFromNode(node *ast.Node) lsproto.SymbolKind { return lsproto.SymbolKindEnumMember case ast.KindTypeParameter: return lsproto.SymbolKindTypeParameter + case ast.KindParameter: + if ast.HasSyntacticModifier(node, ast.ModifierFlagsParameterPropertyModifier) { + return lsproto.SymbolKindProperty + } + return lsproto.SymbolKindVariable } return lsproto.SymbolKindVariable } From 0b38c24b29a1648848bd72df2b505cdfe847c200 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 21 Nov 2025 12:02:44 -0800 Subject: [PATCH 4/8] parse excludeLibrarySymbols --- .../fourslash/_scripts/convertFourslash.mts | 2 +- internal/ls/lsutil/userpreferences.go | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index 486b509672..f8c2701014 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -1863,7 +1863,7 @@ function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { } case "excludeLibFiles": { if (prop.initializer.kind === ts.SyntaxKind.FalseKeyword) { - prefs = `&lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: true}` + prefs = `&lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: false}` } } } diff --git a/internal/ls/lsutil/userpreferences.go b/internal/ls/lsutil/userpreferences.go index f367c774a7..c35f98da47 100644 --- a/internal/ls/lsutil/userpreferences.go +++ b/internal/ls/lsutil/userpreferences.go @@ -383,6 +383,8 @@ func (p *UserPreferences) parseWorker(config map[string]any) { p.parseSuggest(values) case "preferences": p.parsePreferences(values) + case "workspaceSymbols": + p.parseWorkspaceSymbols(values) case "format": // !!! case "tsserver": @@ -519,6 +521,22 @@ func (p *UserPreferences) parseOrganizeImportsPreferences(prefs any) { } } +func (p *UserPreferences) parseWorkspaceSymbols(prefs any) { + symbolPreferences, ok := prefs.(map[string]any) + if !ok { + return + } + for name, value := range symbolPreferences { + switch name { + // !!! scope + case "excludeLibrarySymbols": + p.ExcludeLibrarySymbolsInNavTo = parseBoolWithDefault(value, true) + default: + p.set(name, value) + } + } +} + func parseEnabledBool(v map[string]any) bool { // vscode nested option if enabled, ok := v["enabled"]; ok { @@ -626,7 +644,7 @@ func (p *UserPreferences) set(name string, value any) { case "includeinlayenummembervaluehints": p.IncludeInlayEnumMemberValueHints = parseBoolWithDefault(value, false) case "excludelibrarysymbolsinnavto": - p.ExcludeLibrarySymbolsInNavTo = parseBoolWithDefault(value, false) + p.ExcludeLibrarySymbolsInNavTo = parseBoolWithDefault(value, true) case "disablesuggestions": p.DisableSuggestions = parseBoolWithDefault(value, false) case "disablelinetextinreferences": From 74245048554b4ab8ac8caea65c9821d605512777 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 21 Nov 2025 12:34:03 -0800 Subject: [PATCH 5/8] add JS binary expression declarations --- internal/ast/ast.go | 6 ++++++ internal/fourslash/_scripts/manualTests.txt | 1 + .../navigationItemsSpecialPropertyAssignment_test.go | 12 ++++++------ internal/ls/symbols.go | 5 +++++ 4 files changed, 18 insertions(+), 6 deletions(-) rename internal/fourslash/tests/{gen => manual}/navigationItemsSpecialPropertyAssignment_test.go (91%) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index f19ba8878e..0b69261644 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -11074,6 +11074,12 @@ func (node *SourceFile) computeDeclarationMap() map[string][]*Node { } } } + case KindBinaryExpression: + switch GetAssignmentDeclarationKind(node.AsBinaryExpression()) { + case JSDeclarationKindThisProperty, JSDeclarationKindProperty: + addDeclaration(node) + } + node.ForEachChild(visit) default: node.ForEachChild(visit) } diff --git a/internal/fourslash/_scripts/manualTests.txt b/internal/fourslash/_scripts/manualTests.txt index bc1045b9eb..609ff3660e 100644 --- a/internal/fourslash/_scripts/manualTests.txt +++ b/internal/fourslash/_scripts/manualTests.txt @@ -2,6 +2,7 @@ completionListInClosedFunction05 completionsAtIncompleteObjectLiteralProperty completionsSelfDeclaring1 completionsWithDeprecatedTag4 +navigationItemsSpecialPropertyAssignment parserCorruptionAfterMapInClass quickInfoForOverloadOnConst1 renameDefaultKeyword diff --git a/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go b/internal/fourslash/tests/manual/navigationItemsSpecialPropertyAssignment_test.go similarity index 91% rename from internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go rename to internal/fourslash/tests/manual/navigationItemsSpecialPropertyAssignment_test.go index 5e5ada5493..61608dec68 100644 --- a/internal/fourslash/tests/gen/navigationItemsSpecialPropertyAssignment_test.go +++ b/internal/fourslash/tests/manual/navigationItemsSpecialPropertyAssignment_test.go @@ -17,7 +17,7 @@ func TestNavigationItemsSpecialPropertyAssignment(t *testing.T) { // @allowJs: true // @Filename: /a.js [|exports.x = 0|]; -[|exports.y = function() {}|]; +[|exports.z = function() {}|]; function Cls() { [|this.instanceProp = 0|]; } @@ -37,12 +37,12 @@ function Cls() { }, }), }, { - Pattern: "y", + Pattern: "z", Preferences: nil, Exact: PtrTo([]*lsproto.SymbolInformation{ { - Name: "y", - Kind: lsproto.SymbolKindFunction, + Name: "z", + Kind: lsproto.SymbolKindVariable, Location: f.Ranges()[1].LSLocation(), }, }), @@ -63,7 +63,7 @@ function Cls() { Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "staticMethod", - Kind: lsproto.SymbolKindMethod, + Kind: lsproto.SymbolKindProperty, Location: f.Ranges()[3].LSLocation(), }, }), @@ -83,7 +83,7 @@ function Cls() { Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "instanceMethod", - Kind: lsproto.SymbolKindMethod, + Kind: lsproto.SymbolKindProperty, Location: f.Ranges()[5].LSLocation(), }, }), diff --git a/internal/ls/symbols.go b/internal/ls/symbols.go index 6c24999379..304b2dd8f5 100644 --- a/internal/ls/symbols.go +++ b/internal/ls/symbols.go @@ -376,6 +376,11 @@ func getSymbolKindFromNode(node *ast.Node) lsproto.SymbolKind { return lsproto.SymbolKindProperty } return lsproto.SymbolKindVariable + case ast.KindBinaryExpression: + switch ast.GetAssignmentDeclarationKind(node.AsBinaryExpression()) { + case ast.JSDeclarationKindThisProperty, ast.JSDeclarationKindProperty: + return lsproto.SymbolKindProperty + } } return lsproto.SymbolKindVariable } From 11e103ffd903ecc0905d51d277e7868e25f54edb Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Mon, 24 Nov 2025 08:30:35 -0800 Subject: [PATCH 6/8] manually fix or delete some tests --- internal/fourslash/_scripts/manualTests.txt | 5 ++ .../tests/gen/navto_excludeLib4_test.go | 35 ----------- .../tests/gen/navto_serverExcludeLib_test.go | 58 ------------------- .../navigationItemsExactMatch2_test.go | 10 ++-- .../{gen => manual}/navto_excludeLib1_test.go | 7 ++- .../{gen => manual}/navto_excludeLib2_test.go | 11 +++- 6 files changed, 23 insertions(+), 103 deletions(-) delete mode 100644 internal/fourslash/tests/gen/navto_excludeLib4_test.go delete mode 100644 internal/fourslash/tests/gen/navto_serverExcludeLib_test.go rename internal/fourslash/tests/{gen => manual}/navigationItemsExactMatch2_test.go (100%) rename internal/fourslash/tests/{gen => manual}/navto_excludeLib1_test.go (91%) rename internal/fourslash/tests/{gen => manual}/navto_excludeLib2_test.go (78%) diff --git a/internal/fourslash/_scripts/manualTests.txt b/internal/fourslash/_scripts/manualTests.txt index 609ff3660e..1dfd6557eb 100644 --- a/internal/fourslash/_scripts/manualTests.txt +++ b/internal/fourslash/_scripts/manualTests.txt @@ -2,7 +2,12 @@ completionListInClosedFunction05 completionsAtIncompleteObjectLiteralProperty completionsSelfDeclaring1 completionsWithDeprecatedTag4 +navigationItemsExactMatch2 navigationItemsSpecialPropertyAssignment +navto_excludeLib1 +navto_excludeLib2 +navto_excludeLib4 +navto_serverExcludeLib parserCorruptionAfterMapInClass quickInfoForOverloadOnConst1 renameDefaultKeyword diff --git a/internal/fourslash/tests/gen/navto_excludeLib4_test.go b/internal/fourslash/tests/gen/navto_excludeLib4_test.go deleted file mode 100644 index d10e14ded9..0000000000 --- a/internal/fourslash/tests/gen/navto_excludeLib4_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package fourslash_test - -import ( - "testing" - - "github.com/microsoft/typescript-go/internal/fourslash" - . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" - "github.com/microsoft/typescript-go/internal/lsp/lsproto" - "github.com/microsoft/typescript-go/internal/testutil" -) - -func TestNavto_excludeLib4(t *testing.T) { - t.Parallel() - - defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @filename: /node_modules/bar/index.d.ts -import { someOtherName } from "./baz"; -export const [|someName: number|]; -// @filename: /node_modules/bar/baz.d.ts -export const someOtherName: string;` - f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ - { - Pattern: "some", - Preferences: nil, - Exact: PtrTo([]*lsproto.SymbolInformation{ - { - Name: "someName", - Kind: lsproto.SymbolKindVariable, - Location: f.Ranges()[0].LSLocation(), - }, - }), - }, - }) -} diff --git a/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go b/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go deleted file mode 100644 index 55dd6e624d..0000000000 --- a/internal/fourslash/tests/gen/navto_serverExcludeLib_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package fourslash_test - -import ( - "testing" - - "github.com/microsoft/typescript-go/internal/fourslash" - . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" - "github.com/microsoft/typescript-go/internal/lsp/lsproto" - "github.com/microsoft/typescript-go/internal/testutil" -) - -func TestNavto_serverExcludeLib(t *testing.T) { - t.Parallel() - - defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @Filename: /home/src/workspaces/project/index.ts -import { weirdName as otherName } from "bar"; -const [|weirdName: number = 1|]; -// @Filename: /home/src/workspaces/project/tsconfig.json -{} -// @Filename: /home/src/workspaces/project/node_modules/bar/index.d.ts -export const [|weirdName: number|]; -// @Filename: /home/src/workspaces/project/node_modules/bar/package.json -{}` - f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.MarkTestAsStradaServer() - f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ - { - Pattern: "weirdName", - Preferences: nil, - Exact: PtrTo([]*lsproto.SymbolInformation{ - { - Name: "weirdName", - Kind: lsproto.SymbolKindVariable, - Location: f.Ranges()[1].LSLocation(), - }, - { - Name: "weirdName", - Kind: lsproto.SymbolKindVariable, - Location: f.Ranges()[0].LSLocation(), - }, - }), - }, - }) - f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ - { - Pattern: "weirdName", - Preferences: nil, - Exact: PtrTo([]*lsproto.SymbolInformation{ - { - Name: "weirdName", - Kind: lsproto.SymbolKindVariable, - Location: f.Ranges()[0].LSLocation(), - }, - }), - }, - }) -} diff --git a/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go b/internal/fourslash/tests/manual/navigationItemsExactMatch2_test.go similarity index 100% rename from internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go rename to internal/fourslash/tests/manual/navigationItemsExactMatch2_test.go index 95ba275eb2..fc19b34f6c 100644 --- a/internal/fourslash/tests/gen/navigationItemsExactMatch2_test.go +++ b/internal/fourslash/tests/manual/navigationItemsExactMatch2_test.go @@ -35,17 +35,17 @@ var [|point = new Shapes.Point()|]; Pattern: "point", Preferences: nil, Exact: PtrTo([]*lsproto.SymbolInformation{ - { - Name: "point", - Kind: lsproto.SymbolKindVariable, - Location: f.Ranges()[5].LSLocation(), - }, { Name: "Point", Kind: lsproto.SymbolKindClass, Location: f.Ranges()[0].LSLocation(), ContainerName: PtrTo("Shapes"), }, + { + Name: "point", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[5].LSLocation(), + }, }), }, { Pattern: "distance", diff --git a/internal/fourslash/tests/gen/navto_excludeLib1_test.go b/internal/fourslash/tests/manual/navto_excludeLib1_test.go similarity index 91% rename from internal/fourslash/tests/gen/navto_excludeLib1_test.go rename to internal/fourslash/tests/manual/navto_excludeLib1_test.go index a2409e5b0e..dfb5a9861e 100644 --- a/internal/fourslash/tests/gen/navto_excludeLib1_test.go +++ b/internal/fourslash/tests/manual/navto_excludeLib1_test.go @@ -5,6 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/fourslash" . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -26,17 +27,17 @@ export const [|weirdName: number|]; f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { Pattern: "weirdName", - Preferences: nil, + Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: false}, Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "weirdName", Kind: lsproto.SymbolKindVariable, - Location: f.Ranges()[1].LSLocation(), + Location: f.Ranges()[0].LSLocation(), }, { Name: "weirdName", Kind: lsproto.SymbolKindVariable, - Location: f.Ranges()[0].LSLocation(), + Location: f.Ranges()[1].LSLocation(), }, }), }, diff --git a/internal/fourslash/tests/gen/navto_excludeLib2_test.go b/internal/fourslash/tests/manual/navto_excludeLib2_test.go similarity index 78% rename from internal/fourslash/tests/gen/navto_excludeLib2_test.go rename to internal/fourslash/tests/manual/navto_excludeLib2_test.go index 79cc5d1e0b..6d13284b2b 100644 --- a/internal/fourslash/tests/gen/navto_excludeLib2_test.go +++ b/internal/fourslash/tests/manual/navto_excludeLib2_test.go @@ -5,6 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/fourslash" . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/ls/lsutil" "github.com/microsoft/typescript-go/internal/lsp/lsproto" "github.com/microsoft/typescript-go/internal/testutil" ) @@ -25,7 +26,7 @@ export const someName: number; f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{ { Pattern: "weirdName", - Preferences: nil, + Preferences: &lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: false}, Exact: PtrTo([]*lsproto.SymbolInformation{ { Name: "weirdName", @@ -39,7 +40,13 @@ export const someName: number; { Pattern: "weirdName", Preferences: nil, - Exact: PtrTo([]*lsproto.SymbolInformation{}), + Exact: PtrTo([]*lsproto.SymbolInformation{ + { + Name: "weirdName", + Kind: lsproto.SymbolKindVariable, + Location: f.Ranges()[0].LSLocation(), + }, + }), }, }) } From 3586de65d8c3db46e32e9d4d1098aa521a7e285f Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Mon, 24 Nov 2025 09:06:01 -0800 Subject: [PATCH 7/8] fmt, lint --- internal/fourslash/_scripts/convertFourslash.mts | 8 ++++---- internal/fourslash/fourslash.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index 0d21b0cda0..d4dc96c952 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -1816,7 +1816,7 @@ function parseVerifyNavigateTo(args: ts.NodeArray): [VerifyNavToC return [{ kind: "verifyNavigateTo", args: goArgs, - }] + }]; } function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { @@ -1863,7 +1863,7 @@ function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { } case "excludeLibFiles": { if (prop.initializer.kind === ts.SyntaxKind.FalseKeyword) { - prefs = `&lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: false}` + prefs = `&lsutil.UserPreferences{ExcludeLibrarySymbolsInNavTo: false}`; } } } @@ -1875,7 +1875,7 @@ function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { Pattern: ${pattern ? pattern : '""'}, Preferences: ${prefs}, Exact: PtrTo([]*lsproto.SymbolInformation{${items.length ? items.join(",\n") + ",\n" : ""}}), - }` + }`; } function parseNavToItem(arg: ts.Expression): string | undefined { @@ -1925,7 +1925,7 @@ function parseNavToItem(arg: ts.Expression): string | undefined { } } if (ts.isElementAccessExpression(init) && init.expression.getText() === "test.ranges()") { - itemProps.push(`Location: f.Ranges()[${parseInt(init.argumentExpression.getText())}].LSLocation()`) + itemProps.push(`Location: f.Ranges()[${parseInt(init.argumentExpression.getText())}].LSLocation()`); continue; } console.error(`Expected range variable for range in navigateTo item, got ${init.getText()}`); diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index aff6083ca3..90a701b36c 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -2441,7 +2441,7 @@ func (f *FourslashTest) VerifyBaselineInlayHints( if preferences == nil { preferences = lsutil.NewDefaultUserPreferences() } - reset := f.ConfigureWithReset(t, testPreferences) + reset := f.ConfigureWithReset(t, preferences) defer reset() prefix := fmt.Sprintf("At position (Ln %d, Col %d): ", lspRange.Start.Line, lspRange.Start.Character) From 89db233b75494e95a9cfda39a3175ae0dde38fd1 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Mon, 24 Nov 2025 09:09:13 -0800 Subject: [PATCH 8/8] undo bad test merge --- ...izerOrStaticInitializationBlock.types.diff | 65 ++ .../compiler/importHelpersES6.errors.txt.diff | 30 + ...entationInDeclarationFile1.errors.txt.diff | 11 + ...ield2(moduleresolution=bundler).errors.txt | 25 - ...(moduleresolution=bundler).errors.txt.diff | 16 - ...ageJsonField2(moduleresolution=bundler).js | 21 - ...onField2(moduleresolution=bundler).symbols | 17 - ...JsonField2(moduleresolution=bundler).types | 18 - .../bundlerOptionsCompat.errors.txt | 16 + ...StaticMembers1(target=es5).errors.txt.diff | 634 ++++++++++++++++++ 10 files changed, 756 insertions(+), 97 deletions(-) create mode 100644 testdata/baselines/reference/submodule/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.types.diff create mode 100644 testdata/baselines/reference/submodule/compiler/importHelpersES6.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/noErrorUsingImportExportModuleAugmentationInDeclarationFile1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).js delete mode 100644 testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).symbols delete mode 100644 testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).types create mode 100644 testdata/baselines/reference/submodule/conformance/bundlerOptionsCompat.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/superInStaticMembers1(target=es5).errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.types.diff b/testdata/baselines/reference/submodule/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.types.diff new file mode 100644 index 0000000000..e820f62202 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.types.diff @@ -0,0 +1,65 @@ +--- old.argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.types ++++ new.argumentsUsedInClassFieldInitializerOrStaticInitializationBlock.types +@@= skipped -80, +80 lines =@@ + >T : typeof T + + a = () => arguments // should error +->a : () => IArguments +->() => arguments : () => IArguments +->arguments : IArguments ++>a : () => any ++>() => arguments : () => any ++>arguments : any + } + } + +@@= skipped -18, +18 lines =@@ + >() => { arguments; // should error const b = () => { return arguments; // should error } function f() { return arguments; // ok } } : () => void + + arguments; // should error +->arguments : IArguments ++>arguments : any + + const b = () => { +->b : () => IArguments +->() => { return arguments; // should error } : () => IArguments ++>b : () => any ++>() => { return arguments; // should error } : () => any + + return arguments; // should error +->arguments : IArguments ++>arguments : any + } + + function f() { +@@= skipped -109, +109 lines =@@ + >T : typeof T + + a = (() => { return arguments; })() // should error +->a : IArguments +->(() => { return arguments; })() : IArguments +->(() => { return arguments; }) : () => IArguments +->() => { return arguments; } : () => IArguments +->arguments : IArguments ++>a : any ++>(() => { return arguments; })() : any ++>(() => { return arguments; }) : () => any ++>() => { return arguments; } : () => any ++>arguments : any + } + } + +@@= skipped -16, +16 lines =@@ + >T : typeof T + + a = (x = arguments) => {} // should error +->a : (x?: IArguments) => void +->(x = arguments) => {} : (x?: IArguments) => void +->x : IArguments +->arguments : IArguments ++>a : (x?: any) => void ++>(x = arguments) => {} : (x?: any) => void ++>x : any ++>arguments : any + } + } diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersES6.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/importHelpersES6.errors.txt.diff new file mode 100644 index 0000000000..60f9121f02 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/importHelpersES6.errors.txt.diff @@ -0,0 +1,30 @@ +--- old.importHelpersES6.errors.txt ++++ new.importHelpersES6.errors.txt +@@= skipped -0, +0 lines =@@ +-a.ts(2,1): error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found. +- +- +-==== a.ts (1 errors) ==== +- declare var dec: any; +- @dec export class A { +- ~~~~ +-!!! error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found. +- #x: number = 1; +- async f() { this.#x = await this.#x; } +- g(u) { return #x in u; } +- } +- +- const o = { a: 1 }; +- const y = { ...o }; +- +-==== tslib.d.ts (0 errors) ==== +- export declare function __extends(d: Function, b: Function): void; +- export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any; +- export declare function __param(paramIndex: number, decorator: Function): Function; +- export declare function __metadata(metadataKey: any, metadataValue: any): Function; +- export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any; +- export declare function __classPrivateFieldGet(a: any, b: any, c: any, d: any): any; +- export declare function __classPrivateFieldSet(a: any, b: any, c: any, d: any, e: any): any; +- export declare function __classPrivateFieldIn(a: any, b: any): boolean; +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/noErrorUsingImportExportModuleAugmentationInDeclarationFile1.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/noErrorUsingImportExportModuleAugmentationInDeclarationFile1.errors.txt.diff new file mode 100644 index 0000000000..0229a14ee6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/noErrorUsingImportExportModuleAugmentationInDeclarationFile1.errors.txt.diff @@ -0,0 +1,11 @@ +--- old.noErrorUsingImportExportModuleAugmentationInDeclarationFile1.errors.txt ++++ new.noErrorUsingImportExportModuleAugmentationInDeclarationFile1.errors.txt +@@= skipped -0, +0 lines =@@ +-error TS5107: Option 'module=None' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +- +- +-!!! error TS5107: Option 'module=None' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. +-==== 0.d.ts (0 errors) ==== +- export = a; +- declare var a: number; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt deleted file mode 100644 index 40b353506a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -test.ts(1,19): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - - -==== tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "paths": { - "foo/*": ["./dist/*"], - "baz/*.ts": ["./types/*.d.ts"] - } - } - } - -==== dist/bar.ts (0 errors) ==== - export const a = 1234; - -==== types/main.d.ts (0 errors) ==== - export const b: string; - -==== test.ts (1 errors) ==== - import { a } from "foo/bar.ts"; - ~~~~~~~~~~~~ -!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - import { b } from "baz/main.ts"; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt.diff deleted file mode 100644 index 170780f0b0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt -+++ new.resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt -@@= skipped -0, +0 lines =@@ --tsconfig.json(2,5): error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. - test.ts(1,19): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - - --==== tsconfig.json (1 errors) ==== -+==== tsconfig.json (0 errors) ==== - { - "compilerOptions": { -- ~~~~~~~~~~~~~~~~~ --!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. - "paths": { - "foo/*": ["./dist/*"], - "baz/*.ts": ["./types/*.d.ts"] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).js b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).js deleted file mode 100644 index fc322d5465..0000000000 --- a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).js +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/compiler/resolutionCandidateFromPackageJsonField2.ts] //// - -//// [bar.ts] -export const a = 1234; - -//// [main.d.ts] -export const b: string; - -//// [test.ts] -import { a } from "foo/bar.ts"; -import { b } from "baz/main.ts"; - - -//// [bar.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.a = void 0; -exports.a = 1234; -//// [test.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).symbols b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).symbols deleted file mode 100644 index 5ea0f09478..0000000000 --- a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).symbols +++ /dev/null @@ -1,17 +0,0 @@ -//// [tests/cases/compiler/resolutionCandidateFromPackageJsonField2.ts] //// - -=== dist/bar.ts === -export const a = 1234; ->a : Symbol(a, Decl(bar.ts, 0, 12)) - -=== types/main.d.ts === -export const b: string; ->b : Symbol(b, Decl(main.d.ts, 0, 12)) - -=== test.ts === -import { a } from "foo/bar.ts"; ->a : Symbol(a, Decl(test.ts, 0, 8)) - -import { b } from "baz/main.ts"; ->b : Symbol(b, Decl(test.ts, 1, 8)) - diff --git a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).types b/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).types deleted file mode 100644 index 297dbfbfe9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).types +++ /dev/null @@ -1,18 +0,0 @@ -//// [tests/cases/compiler/resolutionCandidateFromPackageJsonField2.ts] //// - -=== dist/bar.ts === -export const a = 1234; ->a : 1234 ->1234 : 1234 - -=== types/main.d.ts === -export const b: string; ->b : string - -=== test.ts === -import { a } from "foo/bar.ts"; ->a : 1234 - -import { b } from "baz/main.ts"; ->b : string - diff --git a/testdata/baselines/reference/submodule/conformance/bundlerOptionsCompat.errors.txt b/testdata/baselines/reference/submodule/conformance/bundlerOptionsCompat.errors.txt new file mode 100644 index 0000000000..e5e9133062 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/bundlerOptionsCompat.errors.txt @@ -0,0 +1,16 @@ +/tsconfig.json(4,25): error TS5109: Option 'moduleResolution' must be set to 'NodeNext' (or left unspecified) when option 'module' is set to 'NodeNext'. + + +==== /tsconfig.json (1 errors) ==== + { + "compilerOptions": { + "module": "nodenext", + "moduleResolution": "bundler", + ~~~~~~~~~ +!!! error TS5109: Option 'moduleResolution' must be set to 'NodeNext' (or left unspecified) when option 'module' is set to 'NodeNext'. + "noEmit": true + } + } + +==== /index.ts (0 errors) ==== + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/superInStaticMembers1(target=es5).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/superInStaticMembers1(target=es5).errors.txt.diff new file mode 100644 index 0000000000..a8744b9ff0 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/superInStaticMembers1(target=es5).errors.txt.diff @@ -0,0 +1,634 @@ +--- old.superInStaticMembers1(target=es5).errors.txt ++++ new.superInStaticMembers1(target=es5).errors.txt +@@= skipped -0, +0 lines =@@ +-classDeclInContainingScopeStaticBlock.ts(3,7): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-classDeclInContainingScopeStaticField.ts(3,7): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-constEnumInContainingScopeStaticBlock.ts(3,12): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-constEnumInContainingScopeStaticField.ts(3,12): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-defaultImportInContainingScopeStaticBlock.ts(3,8): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-defaultImportInContainingScopeStaticField.ts(3,8): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-enumInContainingScopeStaticBlock.ts(3,6): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-enumInContainingScopeStaticField.ts(3,6): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-funcDeclInContainingScopeStaticBlock.ts(3,10): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-funcDeclInContainingScopeStaticField.ts(3,10): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-inContainingClassExprStaticBlock.ts(3,8): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-inContainingClassExprStaticField.ts(3,8): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-inContainingFuncExprStaticBlock.ts(3,11): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-inContainingFuncExprStaticField.ts(3,11): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(6,17): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(10,19): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(14,18): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(18,19): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(22,22): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(26,18): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(30,24): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(52,15): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(57,14): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(62,13): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(67,15): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(72,18): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(77,14): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-locals.ts(82,20): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-namedImportInContainingScopeStaticBlock.ts(3,10): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-namedImportInContainingScopeStaticField.ts(3,10): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-namedImportOfConstEnumInContainingScopeStaticBlock.ts(3,10): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-namedImportOfConstEnumInContainingScopeStaticField.ts(3,10): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-namedImportOfInterfaceInContainingScopeStaticBlock.ts(3,10): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-namedImportOfInterfaceInContainingScopeStaticField.ts(3,10): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-namedImportOfUninstantiatedNamespaceInContainingScopeStaticBlock.ts(3,10): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-namedImportOfUninstantiatedNamespaceInContainingScopeStaticField.ts(3,10): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-namespaceImportInContainingScopeStaticBlock.ts(3,13): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-namespaceImportInContainingScopeStaticField.ts(3,13): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-valueNamespaceInContainingScopeStaticBlock.ts(3,11): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-valueNamespaceInContainingScopeStaticField.ts(3,11): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-varInContainingScopeStaticBlock1.ts(3,5): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-varInContainingScopeStaticBlock2.ts(3,7): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-varInContainingScopeStaticBlock3.ts(3,6): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-varInContainingScopeStaticField1.ts(3,5): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-varInContainingScopeStaticField2.ts(3,7): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +-varInContainingScopeStaticField3.ts(3,6): error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- +- +-==== external.ts (0 errors) ==== +- export class Reflect {} +- export interface Foo {} +- export declare namespace Bar { type _ = unknown; } +- export const enum Baz {} +- export default class {}; +- +-==== locals.ts (14 errors) ==== +- export {}; +- declare class B { static w(): number; } +- class C extends B { +- static _ = [ +- (() => { +- var Reflect; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- })(), +- (() => { +- var { Reflect } = { Reflect: null }; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- })(), +- (() => { +- var [Reflect] = [null]; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- })(), +- (() => { +- class Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- })(), +- (() => { +- function Reflect() {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- })(), +- (() => { +- enum Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- })(), +- (() => { +- const enum Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- })(), +- (() => { +- type Reflect = unknown; // no collision +- super.w(); +- })(), +- (() => { +- interface Reflect {}; // no collision +- super.w(); +- })(), +- (() => { +- (class Reflect {}); // no collision +- super.w(); +- })(), +- (() => { +- (function Reflect() {}); // no collision +- super.w(); +- })(), +- ]; +- +- static { +- var { Reflect } = { Reflect: null }; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- } +- +- static { +- var [Reflect] = [null]; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- } +- +- static { +- var Reflect; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- } +- +- static { +- class Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- } +- +- static { +- function Reflect() {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- } +- +- static { +- enum Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- } +- +- static { +- const enum Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- super.w(); +- } +- +- static { +- type Reflect = unknown; // no collision +- super.w(); +- } +- +- static { +- interface Reflect {} // no collision +- super.w(); +- } +- +- static { +- (class Reflect {}) // no collision +- super.w(); +- } +- +- static { +- (function Reflect() {}) // no collision +- super.w(); +- } +- } +- +-==== varInContainingScopeStaticField1.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- var Reflect = null; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== varInContainingScopeStaticField2.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- var { Reflect } = { Reflect: null }; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== varInContainingScopeStaticField3.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- var [Reflect] = [null]; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== varInContainingScopeStaticBlock1.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- var Reflect = null; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== varInContainingScopeStaticBlock2.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- var { Reflect } = { Reflect: null }; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== varInContainingScopeStaticBlock3.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- var [Reflect] = [null]; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== classDeclInContainingScopeStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- class Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== classDeclInContainingScopeStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- class Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== funcDeclInContainingScopeStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- function Reflect() {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== funcDeclInContainingScopeStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- function Reflect() {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== valueNamespaceInContainingScopeStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- namespace Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== valueNamespaceInContainingScopeStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- namespace Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== enumInContainingScopeStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- enum Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== enumInContainingScopeStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- enum Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== constEnumInContainingScopeStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- const enum Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== constEnumInContainingScopeStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- const enum Reflect {} // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== namespaceImportInContainingScopeStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import * as Reflect from "./external"; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== namespaceImportInContainingScopeStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import * as Reflect from "./external"; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== namedImportInContainingScopeStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import { Reflect } from "./external"; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== namedImportInContainingScopeStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import { Reflect } from "./external"; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== namedImportOfInterfaceInContainingScopeStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import { Foo as Reflect } from "./external"; // collision (es2015-es2021 only, not a type-only import) +- ~~~~~~~~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== namedImportOfInterfaceInContainingScopeStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import { Foo as Reflect } from "./external"; // collision (es2015-es2021 only, not a type-only import) +- ~~~~~~~~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== namedImportOfUninstantiatedNamespaceInContainingScopeStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import { Bar as Reflect } from "./external"; // collision (es2015-es2021 only, not a type-only import) +- ~~~~~~~~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== namedImportOfUninstantiatedNamespaceInContainingScopeStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import { Bar as Reflect } from "./external"; // collision (es2015-es2021 only, not a type-only import) +- ~~~~~~~~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== namedImportOfConstEnumInContainingScopeStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import { Baz as Reflect } from "./external"; // collision (es2015-es2021 only) +- ~~~~~~~~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== namedImportOfConstEnumInContainingScopeStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import { Baz as Reflect } from "./external"; // collision (es2015-es2021 only) +- ~~~~~~~~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== typeOnlyNamedImportInContainingScopeStaticField.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import type { Reflect } from "./external"; // no collision +- class C extends B { +- static _ = super.w(); +- } +- +-==== typeOnlyNamedImportInContainingScopeStaticBlock.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import type { Reflect } from "./external"; // no collision +- class C extends B { +- static { super.w(); } +- } +- +-==== defaultImportInContainingScopeStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import Reflect from "./external"; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- +-==== defaultImportInContainingScopeStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import Reflect from "./external"; // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- +-==== typeOnlyDefaultImportInContainingScopeStaticField.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import type Reflect from "./external"; // no collision +- class C extends B { +- static _ = super.w(); +- } +- +-==== typeOnlyDefaultImportInContainingScopeStaticBlock.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- import type Reflect from "./external"; // no collision +- class C extends B { +- static { super.w(); } +- } +- +-==== typeInContainingScopeStaticField.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- type Reflect = unknown; // no collision +- class C extends B { +- static _ = super.w(); +- } +- +-==== typeInContainingScopeStaticBlock.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- type Reflect = unknown; // no collision +- class C extends B { +- static { super.w(); } +- } +- +-==== interfaceInContainingScopeStaticField.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- interface Reflect {}; // no collision +- class C extends B { +- static _ = super.w(); +- } +- +-==== interfaceInContainingScopeStaticBlock.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- interface Reflect {}; // no collision +- class C extends B { +- static { super.w(); } +- } +- +-==== uninstantiatedNamespaceInContainingScopeStaticField.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- declare namespace Reflect { type _ = unknown; }; // no collision +- class C extends B { +- static _ = super.w(); +- } +- +-==== uninstantiatedNamespaceInContainingScopeStaticBlock.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- declare namespace Reflect { type _ = unknown; }; // no collision +- class C extends B { +- static { super.w(); } +- } +- +-==== classExprInContainingScopeStaticField.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- (class Reflect {}); // no collision +- class C extends B { +- static _ = super.w(); +- } +- +-==== classExprInContainingScopeStaticBlock.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- (class Reflect {}); // no collision +- class C extends B { +- static { super.w(); } +- } +- +-==== inContainingClassExprStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- (class Reflect { // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- static { +- class C extends B { +- static _ = super.w(); +- } +- } +- }); +- +-==== inContainingClassExprStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- (class Reflect { // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- static { +- class C extends B { +- static { super.w(); } +- } +- } +- }); +- +-==== funcExprInContainingScopeStaticField.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- (function Reflect() {}); // no collision +- class C extends B { +- static _ = super.w(); +- } +- +-==== funcExprInContainingScopeStaticBlock.ts (0 errors) ==== +- export {}; +- declare class B { static w(): number; } +- (function Reflect() {}); // no collision +- class C extends B { +- static { super.w(); } +- } +- +-==== inContainingFuncExprStaticField.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- (function Reflect() { // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static _ = super.w(); +- } +- }); +- +-==== inContainingFuncExprStaticBlock.ts (1 errors) ==== +- export {}; +- declare class B { static w(): number; } +- (function Reflect() { // collision (es2015-es2021 only) +- ~~~~~~~ +-!!! error TS2818: Duplicate identifier 'Reflect'. Compiler reserves name 'Reflect' when emitting 'super' references in static initializers. +- class C extends B { +- static { super.w(); } +- } +- }); +- ++ \ No newline at end of file