From c206f0016db5ad5adf77fe9eb21283801ba97ede Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 14:35:33 +0000 Subject: [PATCH 01/15] Initial plan From 51d5fe508ca2ae643f831e9ad169b3c1d7f71648 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 14:47:52 +0000 Subject: [PATCH 02/15] Initial analysis and test case for document highlight crash Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- .../gen/documentHighlightImportPath_test.go | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 internal/fourslash/tests/gen/documentHighlightImportPath_test.go diff --git a/internal/fourslash/tests/gen/documentHighlightImportPath_test.go b/internal/fourslash/tests/gen/documentHighlightImportPath_test.go new file mode 100644 index 0000000000..0242f7e94b --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightImportPath_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightImportPath(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.d.ts +declare module "my-module" { + export const foo: number; +} + +// @Filename: /b.ts +import { foo } from "[|my-module|]";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[0]) +} From 6e12a02f7e72676a297ec4deb7a7721d2374ea49 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 14:52:57 +0000 Subject: [PATCH 03/15] Fix inverted condition for module references in document highlights The condition checking whether to return early for module references was inverted. The TypeScript implementation returns early when the symbol is NOT transient, but the Go code was returning early only when it IS transient. This caused module symbols (whose declarations are SourceFiles with no parent) to be passed to getReferencedSymbolsForSymbol, which then called skipPastExportOrImportSpecifierOrUnion. That function would panic when encountering a declaration without a parent for a non-transient symbol. The fix aligns the Go implementation with the TypeScript source by checking for `== 0` instead of `!= 0` on the transient flag. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/ls/findallreferences.go | 2 +- .../documentHighlightImportPath.baseline.jsonc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index d30a4035cf..fdab709334 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -673,7 +673,7 @@ func (l *LanguageService) getReferencedSymbolsForNode(ctx context.Context, posit } moduleReferences := l.getReferencedSymbolsForModuleIfDeclaredBySourceFile(ctx, symbol, program, sourceFiles, checker, options, sourceFilesSet) // !!! cancellationToken - if moduleReferences != nil && symbol.Flags&ast.SymbolFlagsTransient != 0 { + if moduleReferences != nil && symbol.Flags&ast.SymbolFlagsTransient == 0 { return moduleReferences } diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc new file mode 100644 index 0000000000..7c436f4abc --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc @@ -0,0 +1,3 @@ +// === documentHighlights === +// === /b.ts === +// import { foo } from "/*HIGHLIGHTS*/my-module"; \ No newline at end of file From d0dfb3374c87f4b5b287fa5cf390460164e7a2cd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 15:12:30 +0000 Subject: [PATCH 04/15] Move documentHighlightImportPath_test.go to parent directory The test should be in internal/fourslash/tests/ instead of the gen/ subdirectory, as the gen/ directory is only for generated tests. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- .../fourslash/tests/{gen => }/documentHighlightImportPath_test.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename internal/fourslash/tests/{gen => }/documentHighlightImportPath_test.go (100%) diff --git a/internal/fourslash/tests/gen/documentHighlightImportPath_test.go b/internal/fourslash/tests/documentHighlightImportPath_test.go similarity index 100% rename from internal/fourslash/tests/gen/documentHighlightImportPath_test.go rename to internal/fourslash/tests/documentHighlightImportPath_test.go From 96e16e38864ffdb5ed93888d277a1469d66876b2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 17:36:56 +0000 Subject: [PATCH 05/15] Remove test that doesn't reproduce the crash The test cannot reproduce the crash because getReferencedSymbolsForModule is not yet implemented. The fix is correct (matches TypeScript source), but cannot be verified with a test until that function is implemented. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- .../tests/documentHighlightImportPath_test.go | 23 ------------------- ...documentHighlightImportPath.baseline.jsonc | 3 --- 2 files changed, 26 deletions(-) delete mode 100644 internal/fourslash/tests/documentHighlightImportPath_test.go delete mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc diff --git a/internal/fourslash/tests/documentHighlightImportPath_test.go b/internal/fourslash/tests/documentHighlightImportPath_test.go deleted file mode 100644 index 0242f7e94b..0000000000 --- a/internal/fourslash/tests/documentHighlightImportPath_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package fourslash_test - -import ( - "testing" - - "github.com/microsoft/typescript-go/internal/fourslash" - "github.com/microsoft/typescript-go/internal/testutil" -) - -func TestDocumentHighlightImportPath(t *testing.T) { - t.Parallel() - - defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `// @Filename: /a.d.ts -declare module "my-module" { - export const foo: number; -} - -// @Filename: /b.ts -import { foo } from "[|my-module|]";` - f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[0]) -} diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc deleted file mode 100644 index 7c436f4abc..0000000000 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc +++ /dev/null @@ -1,3 +0,0 @@ -// === documentHighlights === -// === /b.ts === -// import { foo } from "/*HIGHLIGHTS*/my-module"; \ No newline at end of file From e3d8249b75ae75fc9f7dc2b1cdfc347d15a862c7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 18:00:28 +0000 Subject: [PATCH 06/15] Implement minimal getReferencedSymbolsForModule to fix crash Implemented a minimal version of getReferencedSymbolsForModule that returns module declarations as references. This, combined with the corrected condition (checking for non-transient instead of transient), prevents the crash when highlighting import paths. The crash occurred because: 1. GetSymbolAtLocation on an import string returns a module symbol 2. getReferencedSymbolsForModuleIfDeclaredBySourceFile is called and now returns results 3. The old condition checked for transient symbols, causing non-transient module symbols to fall through to getReferencedSymbolsForSymbol 4. That function calls skipPastExportOrImportSpecifierOrUnion which panics on SourceFile declarations without parents The fix ensures non-transient module symbols return early with the module references, preventing the panic. Added test TestDocumentHighlightImportPath that verifies document highlights work on import paths and would hang/crash with the old condition. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- .../tests/documentHighlightImportPath_test.go | 21 ++++++++++ internal/ls/findallreferences.go | 40 ++++++++++++++++++- ...documentHighlightImportPath.baseline.jsonc | 3 ++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 internal/fourslash/tests/documentHighlightImportPath_test.go create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc diff --git a/internal/fourslash/tests/documentHighlightImportPath_test.go b/internal/fourslash/tests/documentHighlightImportPath_test.go new file mode 100644 index 0000000000..229d8b5a13 --- /dev/null +++ b/internal/fourslash/tests/documentHighlightImportPath_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightImportPath(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const x = 0; + +// @Filename: /b.ts +import { x } from "[|./a|]";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[0]) +} diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index fdab709334..bb234673cc 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -976,8 +976,44 @@ func getMergedAliasedSymbolOfNamespaceExportDeclaration(node *ast.Node, symbol * } func getReferencedSymbolsForModule(program *compiler.Program, symbol *ast.Symbol, excludeImportTypeOfExportEquals bool, sourceFiles []*ast.SourceFile, sourceFilesSet *collections.Set[string]) []*SymbolAndEntries { - // !!! not implemented - return nil + // Minimal implementation to prevent crashes when highlighting import paths. + // This returns module declarations as references, which allows the early return + // in getReferencedSymbolsForNode to work properly and avoid the panic in + // skipPastExportOrImportSpecifierOrUnion. + + var references []*referenceEntry + + // Add the module declarations themselves as references + if symbol.Declarations != nil { + for _, decl := range symbol.Declarations { + switch decl.Kind { + case ast.KindSourceFile: + // Don't include the source file itself + case ast.KindModuleDeclaration: + sourceFile := ast.GetSourceFileOfNode(decl) + if sourceFilesSet.Has(sourceFile.FileName()) { + references = append(references, &referenceEntry{ + kind: entryKindNode, + node: decl.AsModuleDeclaration().Name(), + fileName: sourceFile.FileName(), + }) + } + default: + // This may be merged with something + // TypeScript: Debug.assert(!!(symbol.flags & SymbolFlags.Transient)) + } + } + } + + // Return as SymbolAndEntries even if there are no references + // This ensures the condition check in getReferencedSymbolsForNode works properly + return []*SymbolAndEntries{{ + definition: &Definition{ + Kind: definitionKindSymbol, + symbol: symbol, + }, + references: references, + }} } func getReferenceAtPosition(sourceFile *ast.SourceFile, position int, program *compiler.Program) *refInfo { diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc new file mode 100644 index 0000000000..e4448cdf1a --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc @@ -0,0 +1,3 @@ +// === documentHighlights === +// === /b.ts === +// import { x } from "/*HIGHLIGHTS*/./a"; \ No newline at end of file From 35c7b97ee1eb6c9909fac68f7bade24791df2dae Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 2 Oct 2025 18:22:07 -0700 Subject: [PATCH 07/15] revert --- internal/ls/findallreferences.go | 42 +++----------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index bb234673cc..d30a4035cf 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -673,7 +673,7 @@ func (l *LanguageService) getReferencedSymbolsForNode(ctx context.Context, posit } moduleReferences := l.getReferencedSymbolsForModuleIfDeclaredBySourceFile(ctx, symbol, program, sourceFiles, checker, options, sourceFilesSet) // !!! cancellationToken - if moduleReferences != nil && symbol.Flags&ast.SymbolFlagsTransient == 0 { + if moduleReferences != nil && symbol.Flags&ast.SymbolFlagsTransient != 0 { return moduleReferences } @@ -976,44 +976,8 @@ func getMergedAliasedSymbolOfNamespaceExportDeclaration(node *ast.Node, symbol * } func getReferencedSymbolsForModule(program *compiler.Program, symbol *ast.Symbol, excludeImportTypeOfExportEquals bool, sourceFiles []*ast.SourceFile, sourceFilesSet *collections.Set[string]) []*SymbolAndEntries { - // Minimal implementation to prevent crashes when highlighting import paths. - // This returns module declarations as references, which allows the early return - // in getReferencedSymbolsForNode to work properly and avoid the panic in - // skipPastExportOrImportSpecifierOrUnion. - - var references []*referenceEntry - - // Add the module declarations themselves as references - if symbol.Declarations != nil { - for _, decl := range symbol.Declarations { - switch decl.Kind { - case ast.KindSourceFile: - // Don't include the source file itself - case ast.KindModuleDeclaration: - sourceFile := ast.GetSourceFileOfNode(decl) - if sourceFilesSet.Has(sourceFile.FileName()) { - references = append(references, &referenceEntry{ - kind: entryKindNode, - node: decl.AsModuleDeclaration().Name(), - fileName: sourceFile.FileName(), - }) - } - default: - // This may be merged with something - // TypeScript: Debug.assert(!!(symbol.flags & SymbolFlags.Transient)) - } - } - } - - // Return as SymbolAndEntries even if there are no references - // This ensures the condition check in getReferencedSymbolsForNode works properly - return []*SymbolAndEntries{{ - definition: &Definition{ - Kind: definitionKindSymbol, - symbol: symbol, - }, - references: references, - }} + // !!! not implemented + return nil } func getReferenceAtPosition(sourceFile *ast.SourceFile, position int, program *compiler.Program) *refInfo { From 4980bf46320648fdb84c6cd11775c023ac87ca67 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 2 Oct 2025 18:39:44 -0700 Subject: [PATCH 08/15] more --- internal/ls/findallreferences.go | 88 +++++++++++++++++++++++++++++++- internal/ls/importTracker.go | 72 ++++++++++++++++++++++++++ 2 files changed, 159 insertions(+), 1 deletion(-) diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index d30a4035cf..8d80dcbedc 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -976,7 +976,93 @@ func getMergedAliasedSymbolOfNamespaceExportDeclaration(node *ast.Node, symbol * } func getReferencedSymbolsForModule(program *compiler.Program, symbol *ast.Symbol, excludeImportTypeOfExportEquals bool, sourceFiles []*ast.SourceFile, sourceFilesSet *collections.Set[string]) []*SymbolAndEntries { - // !!! not implemented + debug.Assert(symbol.ValueDeclaration != nil) + + checker, done := program.GetTypeChecker(nil) + defer done() + + references := core.MapNonNil(findModuleReferences(program, sourceFiles, symbol, checker), func(reference ModuleReference) *referenceEntry { + switch reference.kind { + case ModuleReferenceKindImport: + parent := reference.literal.Parent + if ast.IsLiteralTypeNode(parent) { + importType := parent.Parent + if ast.IsImportTypeNode(importType) { + importTypeNode := importType.AsImportTypeNode() + if excludeImportTypeOfExportEquals && importTypeNode.Qualifier == nil { + return nil + } + } + } + // import("foo") with no qualifier will reference the `export =` of the module, which may be referenced anyway. + return newNodeEntry(reference.literal) + case ModuleReferenceKindImplicit: + // For implicit references (e.g., JSX runtime imports), return the first statement or the whole file. + // We skip the complex JSX detection for now and just use the first statement or the file itself. + var rangeNode *ast.Node + if reference.referencingFile.Statements != nil && len(reference.referencingFile.Statements.Nodes) > 0 { + rangeNode = reference.referencingFile.Statements.Nodes[0] + } else { + rangeNode = reference.referencingFile.AsNode() + } + return newNodeEntry(rangeNode) + case ModuleReferenceKindReference: + // or + // We can't easily create a proper range entry here without access to LanguageService, + // but we can create a node-based entry pointing to the source file which will be resolved later + return newNodeEntry(reference.referencingFile.AsNode()) + } + return nil + }) + + // Add references to the module declarations themselves + if len(symbol.Declarations) > 0 { + for _, decl := range symbol.Declarations { + switch decl.Kind { + case ast.KindSourceFile: + // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) + continue + case ast.KindModuleDeclaration: + if sourceFilesSet.Has(ast.GetSourceFileOfNode(decl).FileName()) { + references = append(references, newNodeEntry(decl.AsModuleDeclaration().Name())) + } + default: + // This may be merged with something. + debug.Assert(symbol.Flags&ast.SymbolFlagsTransient != 0, "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration.") + } + } + } + + // Handle export equals declarations + exported := symbol.Exports[ast.InternalSymbolNameExportEquals] + if exported != nil && len(exported.Declarations) > 0 { + for _, decl := range exported.Declarations { + sourceFile := ast.GetSourceFileOfNode(decl) + if sourceFilesSet.Has(sourceFile.FileName()) { + var node *ast.Node + // At `module.exports = ...`, reference node is `module` + if ast.IsBinaryExpression(decl) && ast.IsPropertyAccessExpression(decl.AsBinaryExpression().Left) { + node = decl.AsBinaryExpression().Left.AsPropertyAccessExpression().Expression + } else if ast.IsExportAssignment(decl) { + // Find the export keyword - for now, just use the declaration itself + node = decl + } else { + node = ast.GetNameOfDeclaration(decl) + if node == nil { + node = decl + } + } + references = append(references, newNodeEntry(node)) + } + } + } + + if len(references) > 0 { + return []*SymbolAndEntries{{ + definition: &Definition{Kind: definitionKindSymbol, symbol: symbol}, + references: references, + }} + } return nil } diff --git a/internal/ls/importTracker.go b/internal/ls/importTracker.go index ac434e638d..e4a70d62d7 100644 --- a/internal/ls/importTracker.go +++ b/internal/ls/importTracker.go @@ -6,6 +6,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/checker" "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/debug" ) @@ -42,6 +43,22 @@ type ImportsResult struct { type ImportTracker func(exportSymbol *ast.Symbol, exportInfo *ExportInfo, isForRename bool) *ImportsResult +type ModuleReferenceKind int32 + +const ( + ModuleReferenceKindImport ModuleReferenceKind = iota + ModuleReferenceKindReference + ModuleReferenceKindImplicit +) + +// ModuleReference represents a reference to a module, either via import, , or implicit reference +type ModuleReference struct { + kind ModuleReferenceKind + literal *ast.Node // for import and implicit kinds (StringLiteralLike) + referencingFile *ast.SourceFile + ref *ast.FileReference // for reference kind +} + // Creates the imports map and returns an ImportTracker that uses it. Call this lazily to avoid calling `getDirectImportsMap` unnecessarily. func createImportTracker(sourceFiles []*ast.SourceFile, sourceFilesSet *collections.Set[string], checker *checker.Checker) ImportTracker { allDirectImports := getDirectImportsMap(sourceFiles, checker) @@ -654,3 +671,58 @@ func symbolNameNoDefault(symbol *ast.Symbol) string { } return "" } + +// findModuleReferences finds all references to a module symbol across the given source files. +// This includes import statements, directives, and implicit references (e.g., JSX runtime imports). +func findModuleReferences(program *compiler.Program, sourceFiles []*ast.SourceFile, searchModuleSymbol *ast.Symbol, checker *checker.Checker) []ModuleReference { + refs := []ModuleReference{} + + for _, referencingFile := range sourceFiles { + searchSourceFile := searchModuleSymbol.ValueDeclaration + if searchSourceFile != nil && searchSourceFile.Kind == ast.KindSourceFile { + // Check directives + for _, ref := range referencingFile.ReferencedFiles { + if program.GetSourceFileFromReference(referencingFile, ref) == searchSourceFile.AsSourceFile() { + refs = append(refs, ModuleReference{ + kind: ModuleReferenceKindReference, + referencingFile: referencingFile, + ref: ref, + }) + } + } + + // Check directives + for _, ref := range referencingFile.TypeReferenceDirectives { + referenced := program.GetResolvedTypeReferenceDirectiveFromTypeReferenceDirective(ref, referencingFile) + if referenced != nil && referenced.ResolvedFileName == searchSourceFile.AsSourceFile().FileName() { + refs = append(refs, ModuleReference{ + kind: ModuleReferenceKindReference, + referencingFile: referencingFile, + ref: ref, + }) + } + } + } + + // Check all imports (including require() calls) + forEachImport(referencingFile, func(importDecl *ast.Node, moduleSpecifier *ast.Node) { + moduleSymbol := checker.GetSymbolAtLocation(moduleSpecifier) + if moduleSymbol == searchModuleSymbol { + if ast.NodeIsSynthesized(importDecl) { + refs = append(refs, ModuleReference{ + kind: ModuleReferenceKindImplicit, + literal: moduleSpecifier, + referencingFile: referencingFile, + }) + } else { + refs = append(refs, ModuleReference{ + kind: ModuleReferenceKindImport, + literal: moduleSpecifier, + }) + } + } + }) + } + + return refs +} From 3250b316022eddffd3198dee21dd7a7fa4fd15c9 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 2 Oct 2025 19:00:43 -0700 Subject: [PATCH 09/15] more --- internal/ls/documenthighlights.go | 3 +- internal/ls/findallreferences.go | 15 ++++----- ...documentHighlightImportPath.baseline.jsonc | 2 +- ...AllReferencesDynamicImport1.baseline.jsonc | 5 +++ ...encesUmdModuleAsGlobalConst.baseline.jsonc | 4 +++ .../findAllRefsExportEquals.baseline.jsonc | 31 +++++++++++++++++++ ...ndAllRefsForDefaultExport03.baseline.jsonc | 25 +++++++++++++++ ...findAllRefsModuleDotExports.baseline.jsonc | 3 ++ ...efs_importType_typeofImport.baseline.jsonc | 4 +++ 9 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc diff --git a/internal/ls/documenthighlights.go b/internal/ls/documenthighlights.go index 8469c0935d..d536e2e744 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -47,7 +47,8 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen documentHighlights = l.getSyntacticDocumentHighlights(node, sourceFile) } // if nil is passed here we never generate an error, just pass an empty higlight - return lsproto.DocumentHighlightsOrNull{DocumentHighlights: &documentHighlights}, nil + resp := lsproto.DocumentHighlightsOrNull{DocumentHighlights: &documentHighlights} + return resp, nil } func (l *LanguageService) getSemanticDocumentHighlights(ctx context.Context, position int, node *ast.Node, program *compiler.Program, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index 8d80dcbedc..c169935e76 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -621,7 +621,7 @@ func (l *LanguageService) getReferencedSymbolsForNode(ctx context.Context, posit } if moduleSymbol := checker.GetMergedSymbol(resolvedRef.file.Symbol); moduleSymbol != nil { - return getReferencedSymbolsForModule(program, moduleSymbol /*excludeImportTypeOfExportEquals*/, false, sourceFiles, sourceFilesSet) + return getReferencedSymbolsForModule(ctx, program, moduleSymbol /*excludeImportTypeOfExportEquals*/, false, sourceFiles, sourceFilesSet) } // !!! not implemented @@ -669,11 +669,11 @@ func (l *LanguageService) getReferencedSymbolsForNode(ctx context.Context, posit } if symbol.Name == ast.InternalSymbolNameExportEquals { - return getReferencedSymbolsForModule(program, symbol.Parent, false /*excludeImportTypeOfExportEquals*/, sourceFiles, sourceFilesSet) + return getReferencedSymbolsForModule(ctx, program, symbol.Parent, false /*excludeImportTypeOfExportEquals*/, sourceFiles, sourceFilesSet) } moduleReferences := l.getReferencedSymbolsForModuleIfDeclaredBySourceFile(ctx, symbol, program, sourceFiles, checker, options, sourceFilesSet) // !!! cancellationToken - if moduleReferences != nil && symbol.Flags&ast.SymbolFlagsTransient != 0 { + if moduleReferences != nil && symbol.Flags&ast.SymbolFlagsTransient == 0 { return moduleReferences } @@ -696,7 +696,7 @@ func (l *LanguageService) getReferencedSymbolsForModuleIfDeclaredBySourceFile(ct } exportEquals := symbol.Exports[ast.InternalSymbolNameExportEquals] // If exportEquals != nil, we're about to add references to `import("mod")` anyway, so don't double-count them. - moduleReferences := getReferencedSymbolsForModule(program, symbol, exportEquals != nil, sourceFiles, sourceFilesSet) + moduleReferences := getReferencedSymbolsForModule(ctx, program, symbol, exportEquals != nil, sourceFiles, sourceFilesSet) if exportEquals == nil || !sourceFilesSet.Has(moduleSourceFileName) { return moduleReferences } @@ -975,13 +975,14 @@ func getMergedAliasedSymbolOfNamespaceExportDeclaration(node *ast.Node, symbol * return nil } -func getReferencedSymbolsForModule(program *compiler.Program, symbol *ast.Symbol, excludeImportTypeOfExportEquals bool, sourceFiles []*ast.SourceFile, sourceFilesSet *collections.Set[string]) []*SymbolAndEntries { +func getReferencedSymbolsForModule(ctx context.Context, program *compiler.Program, symbol *ast.Symbol, excludeImportTypeOfExportEquals bool, sourceFiles []*ast.SourceFile, sourceFilesSet *collections.Set[string]) []*SymbolAndEntries { debug.Assert(symbol.ValueDeclaration != nil) - checker, done := program.GetTypeChecker(nil) + checker, done := program.GetTypeChecker(ctx) defer done() - references := core.MapNonNil(findModuleReferences(program, sourceFiles, symbol, checker), func(reference ModuleReference) *referenceEntry { + moduleRefs := findModuleReferences(program, sourceFiles, symbol, checker) + references := core.MapNonNil(moduleRefs, func(reference ModuleReference) *referenceEntry { switch reference.kind { case ModuleReferenceKindImport: parent := reference.literal.Parent diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc index e4448cdf1a..9990790b26 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightImportPath.baseline.jsonc @@ -1,3 +1,3 @@ // === documentHighlights === // === /b.ts === -// import { x } from "/*HIGHLIGHTS*/./a"; \ No newline at end of file +// import { x } from "/*HIGHLIGHTS*/[|./a|]"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc new file mode 100644 index 0000000000..34dc2eb859 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc @@ -0,0 +1,5 @@ +// === findAllReferences === +// === /foo.ts === +// export function foo() { return "foo"; } +// /*FIND ALL REFS*/import("./foo") +// var x = import("./foo") \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc new file mode 100644 index 0000000000..1dfc7592df --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc @@ -0,0 +1,4 @@ +// === findAllReferences === +// === /node_modules/@types/three/index.d.ts === +// export * from "./three-core"; +// export as namespace /*FIND ALL REFS*/[|THREE|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc new file mode 100644 index 0000000000..32cc5e88c6 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc @@ -0,0 +1,31 @@ +// === findAllReferences === +// === /a.ts === +// type /*FIND ALL REFS*/[|T|] = number; +// export = T; + + + +// === findAllReferences === +// === /a.ts === +// type T = number; +// /*FIND ALL REFS*/export = T; + + + +// === findAllReferences === +// === /a.ts === +// type T = number; +// export = /*FIND ALL REFS*/[|T|]; + +// === /b.ts === +// import [|T|] = require("./a"); + + + +// === findAllReferences === +// === /a.ts === +// type [|T|] = number; +// export = [|T|]; + +// === /b.ts === +// import /*FIND ALL REFS*/[|T|] = require("./a"); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc new file mode 100644 index 0000000000..04c0f47d08 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc @@ -0,0 +1,25 @@ +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// /*FIND ALL REFS*/function f() { +// return 100; +// } +// +// // --- (line: 5) skipped --- + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function /*FIND ALL REFS*/[|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc new file mode 100644 index 0000000000..ff5bbc30c4 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc @@ -0,0 +1,3 @@ +// === findAllReferences === +// === /a.js === +// /*FIND ALL REFS*/const b = require("./b"); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc new file mode 100644 index 0000000000..45853d59a2 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc @@ -0,0 +1,4 @@ +// === findAllReferences === +// === /b.ts === +// /*FIND ALL REFS*/const x: typeof import("./a") = { x: 0 }; +// const y: typeof import("./a") = { x: 0 }; \ No newline at end of file From c808430e516e9703bbb91e27bbc13b452945b0cd Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 2 Oct 2025 19:02:30 -0700 Subject: [PATCH 10/15] redo files --- internal/fourslash/_scripts/failingTests.txt | 7 - .../findAllReferencesDynamicImport1_test.go | 2 +- ...llReferencesUmdModuleAsGlobalConst_test.go | 2 +- .../tests/gen/findAllRefsExportEquals_test.go | 2 +- ...indAllRefs_importType_typeofImport_test.go | 2 +- ...eferencesOnRuntimeImportWithPaths1_test.go | 2 +- ...cesIsAvailableThroughGlobalNoCrash_test.go | 2 +- ...eferencesOnRuntimeImportWithPaths1_test.go | 2 +- .../findAllRefsForModule.baseline.jsonc | 9 + .../getOccurrencesIfElseBroken.baseline.jsonc | 57 ++ ...AllReferencesDynamicImport1.baseline.jsonc | 26 +- ...encesUmdModuleAsGlobalConst.baseline.jsonc | 37 +- .../findAllRefsExportEquals.baseline.jsonc | 17 +- .../findAllRefsForModule.baseline.jsonc | 33 ++ ...efs_importType_typeofImport.baseline.jsonc | 23 +- ...esOnRuntimeImportWithPaths1.baseline.jsonc | 3 + ...erencesForStatementKeywords.baseline.jsonc | 505 ++++++++++++++++++ ...ailableThroughGlobalNoCrash.baseline.jsonc | 13 + ...esOnRuntimeImportWithPaths1.baseline.jsonc | 3 + 19 files changed, 728 insertions(+), 19 deletions(-) create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/tslibFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index 24d93fb43a..a3851e759e 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -168,13 +168,9 @@ TestDoubleUnderscoreCompletions TestEditJsdocType TestExportDefaultClass TestExportDefaultFunction -TestFindAllReferencesDynamicImport1 -TestFindAllReferencesUmdModuleAsGlobalConst -TestFindAllRefsExportEquals TestFindAllRefsForDefaultExport03 TestFindAllRefsForModule TestFindAllRefsModuleDotExports -TestFindAllRefs_importType_typeofImport TestFindReferencesBindingPatternInJsdocNoCrash1 TestFindReferencesBindingPatternInJsdocNoCrash2 TestGenericCombinatorWithConstraints1 @@ -262,7 +258,6 @@ TestJsdocTypedefTag TestJsdocTypedefTag2 TestJsdocTypedefTagNamespace TestJsdocTypedefTagServices -TestJsxFindAllReferencesOnRuntimeImportWithPaths1 TestLetQuickInfoAndCompletionList TestLocalFunction TestMemberListInReopenedEnum @@ -436,7 +431,6 @@ TestQuickinfoWrongComment TestRecursiveInternalModuleImport TestReferencesForStatementKeywords TestReferencesInEmptyFile -TestReferencesIsAvailableThroughGlobalNoCrash TestRegexDetection TestRenameForAliasingExport02 TestRenameFromNodeModulesDep1 @@ -461,7 +455,6 @@ TestTripleSlashRefPathCompletionExtensionsAllowJSFalse TestTripleSlashRefPathCompletionExtensionsAllowJSTrue TestTripleSlashRefPathCompletionHiddenFile TestTripleSlashRefPathCompletionRootdirs -TestTslibFindAllReferencesOnRuntimeImportWithPaths1 TestTsxCompletion14 TestTsxCompletion15 TestTsxCompletionNonTagLessThan diff --git a/internal/fourslash/tests/gen/findAllReferencesDynamicImport1_test.go b/internal/fourslash/tests/gen/findAllReferencesDynamicImport1_test.go index a3cbb55949..a6637254e1 100644 --- a/internal/fourslash/tests/gen/findAllReferencesDynamicImport1_test.go +++ b/internal/fourslash/tests/gen/findAllReferencesDynamicImport1_test.go @@ -9,7 +9,7 @@ import ( func TestFindAllReferencesDynamicImport1(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @Filename: foo.ts export function foo() { return "foo"; } diff --git a/internal/fourslash/tests/gen/findAllReferencesUmdModuleAsGlobalConst_test.go b/internal/fourslash/tests/gen/findAllReferencesUmdModuleAsGlobalConst_test.go index 2000320574..c0a0b67b70 100644 --- a/internal/fourslash/tests/gen/findAllReferencesUmdModuleAsGlobalConst_test.go +++ b/internal/fourslash/tests/gen/findAllReferencesUmdModuleAsGlobalConst_test.go @@ -9,7 +9,7 @@ import ( func TestFindAllReferencesUmdModuleAsGlobalConst(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @Filename: /node_modules/@types/three/three-core.d.ts export class Vector3 { diff --git a/internal/fourslash/tests/gen/findAllRefsExportEquals_test.go b/internal/fourslash/tests/gen/findAllRefsExportEquals_test.go index dfee6a23bf..56070c7f4e 100644 --- a/internal/fourslash/tests/gen/findAllRefsExportEquals_test.go +++ b/internal/fourslash/tests/gen/findAllRefsExportEquals_test.go @@ -9,7 +9,7 @@ import ( func TestFindAllRefsExportEquals(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @Filename: /a.ts type /*0*/T = number; diff --git a/internal/fourslash/tests/gen/findAllRefs_importType_typeofImport_test.go b/internal/fourslash/tests/gen/findAllRefs_importType_typeofImport_test.go index 08792f35a8..02e749e266 100644 --- a/internal/fourslash/tests/gen/findAllRefs_importType_typeofImport_test.go +++ b/internal/fourslash/tests/gen/findAllRefs_importType_typeofImport_test.go @@ -9,7 +9,7 @@ import ( func TestFindAllRefs_importType_typeofImport(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @Filename: /a.ts export const x = 0; diff --git a/internal/fourslash/tests/gen/jsxFindAllReferencesOnRuntimeImportWithPaths1_test.go b/internal/fourslash/tests/gen/jsxFindAllReferencesOnRuntimeImportWithPaths1_test.go index 21d0c0ed94..83a9c2d649 100644 --- a/internal/fourslash/tests/gen/jsxFindAllReferencesOnRuntimeImportWithPaths1_test.go +++ b/internal/fourslash/tests/gen/jsxFindAllReferencesOnRuntimeImportWithPaths1_test.go @@ -9,7 +9,7 @@ import ( func TestJsxFindAllReferencesOnRuntimeImportWithPaths1(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @Filename: project/src/foo.ts import * as x from /**/"@foo/dir/jsx-runtime"; diff --git a/internal/fourslash/tests/gen/referencesIsAvailableThroughGlobalNoCrash_test.go b/internal/fourslash/tests/gen/referencesIsAvailableThroughGlobalNoCrash_test.go index 0ea3c6e347..d7f6558e51 100644 --- a/internal/fourslash/tests/gen/referencesIsAvailableThroughGlobalNoCrash_test.go +++ b/internal/fourslash/tests/gen/referencesIsAvailableThroughGlobalNoCrash_test.go @@ -9,7 +9,7 @@ import ( func TestReferencesIsAvailableThroughGlobalNoCrash(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @Filename: /packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts declare var debug: debug.Debug & { debug: debug.Debug; default: debug.Debug }; diff --git a/internal/fourslash/tests/gen/tslibFindAllReferencesOnRuntimeImportWithPaths1_test.go b/internal/fourslash/tests/gen/tslibFindAllReferencesOnRuntimeImportWithPaths1_test.go index 872403577e..0abd8e3240 100644 --- a/internal/fourslash/tests/gen/tslibFindAllReferencesOnRuntimeImportWithPaths1_test.go +++ b/internal/fourslash/tests/gen/tslibFindAllReferencesOnRuntimeImportWithPaths1_test.go @@ -9,7 +9,7 @@ import ( func TestTslibFindAllReferencesOnRuntimeImportWithPaths1(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @Filename: project/src/foo.ts import * as x from /**/"tslib"; diff --git a/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc new file mode 100644 index 0000000000..35e8e3f07c --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc @@ -0,0 +1,9 @@ +// === documentHighlights === +// === /b.ts === +// import { x } from "/*HIGHLIGHTS*/[|./a|]"; + + + +// === documentHighlights === +// === /c/sub.js === +// const a = require("/*HIGHLIGHTS*/[|../a|]"); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc new file mode 100644 index 0000000000..c1c381e16a --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc @@ -0,0 +1,57 @@ +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// /*HIGHLIGHTS*/[|if|] (true) { +// var x = 1; +// } +// [|else if|] () +// [|else if|] +// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) +// else + + + +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// [|if|] (true) { +// var x = 1; +// } +// /*HIGHLIGHTS*/[|else if|] () +// [|else if|] +// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) +// else + + + +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// [|if|] (true) { +// var x = 1; +// } +// [|else if|] () +// /*HIGHLIGHTS*/[|else if|] +// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) +// else + + + +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// [|if|] (true) { +// var x = 1; +// } +// [|else if|] () +// [|else if|] +// /*HIGHLIGHTS*/[|else|] /* whar garbl */ [|if|] (if (true) { } else { }) +// else + + + +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// [|if|] (true) { +// var x = 1; +// } +// [|else if|] () +// [|else if|] +// [|else|] /* whar garbl */ /*HIGHLIGHTS*/[|if|] (if (true) { } else { }) +// else \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc index 34dc2eb859..cf2a41e027 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesDynamicImport1.baseline.jsonc @@ -2,4 +2,28 @@ // === /foo.ts === // export function foo() { return "foo"; } // /*FIND ALL REFS*/import("./foo") -// var x = import("./foo") \ No newline at end of file +// var x = import("./foo") + + + +// === findAllReferences === +// === /foo.ts === +// export function foo() { return "foo"; } +// import("/*FIND ALL REFS*/[|./foo|]") +// var x = import("[|./foo|]") + + + +// === findAllReferences === +// === /foo.ts === +// export function foo() { return "foo"; } +// import("./foo") +// /*FIND ALL REFS*/var x = import("./foo") + + + +// === findAllReferences === +// === /foo.ts === +// export function foo() { return "foo"; } +// import("[|./foo|]") +// var x = import("/*FIND ALL REFS*/[|./foo|]") \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc index 1dfc7592df..63169a81fa 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc @@ -1,4 +1,39 @@ // === findAllReferences === // === /node_modules/@types/three/index.d.ts === // export * from "./three-core"; -// export as namespace /*FIND ALL REFS*/[|THREE|]; \ No newline at end of file +// export as namespace /*FIND ALL REFS*/[|THREE|]; + + + +// === findAllReferences === +// === /typings/global.d.ts === +// import * as _THREE from '/*FIND ALL REFS*/[|three|]'; +// declare global { +// const THREE: typeof _THREE; +// } + + + +// === findAllReferences === +// === /src/index.ts === +// export const a = {}; +// let v = new [|THREE|].Vector2(); + +// === /typings/global.d.ts === +// import * as _THREE from 'three'; +// declare global { +// const /*FIND ALL REFS*/[|THREE|]: typeof _THREE; +// } + + + +// === findAllReferences === +// === /src/index.ts === +// export const a = {}; +// let v = new /*FIND ALL REFS*/[|THREE|].Vector2(); + +// === /typings/global.d.ts === +// import * as _THREE from 'three'; +// declare global { +// const [|THREE|]: typeof _THREE; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc index 32cc5e88c6..2dad021159 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc @@ -8,7 +8,10 @@ // === findAllReferences === // === /a.ts === // type T = number; -// /*FIND ALL REFS*/export = T; +// /*FIND ALL REFS*/[|export = T;|] + +// === /b.ts === +// import T = require("[|./a|]"); @@ -28,4 +31,14 @@ // export = [|T|]; // === /b.ts === -// import /*FIND ALL REFS*/[|T|] = require("./a"); \ No newline at end of file +// import /*FIND ALL REFS*/[|T|] = require("./a"); + + + +// === findAllReferences === +// === /a.ts === +// type [|T|] = number; +// [|export = [|T|];|] + +// === /b.ts === +// import [|T|] = require("/*FIND ALL REFS*/[|./a|]"); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc new file mode 100644 index 0000000000..9ffdfecb1a --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc @@ -0,0 +1,33 @@ +// === findAllReferences === +// === /b.ts === +// import { x } from "/*FIND ALL REFS*/[|./a|]"; + +// === /c/sub.js === +// const a = require("[|../a|]"); + +// === /d.ts === +// /// [||] + + + +// === findAllReferences === +// === /b.ts === +// import { x } from "[|./a|]"; + +// === /c/sub.js === +// const a = require("/*FIND ALL REFS*/[|../a|]"); + +// === /d.ts === +// /// [||] + + + +// === findAllReferences === +// === /b.ts === +// import { x } from "[|./a|]"; + +// === /c/sub.js === +// const a = require("[|../a|]"); + +// === /d.ts === +// /// [||] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc index 45853d59a2..33e67cb257 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefs_importType_typeofImport.baseline.jsonc @@ -1,4 +1,25 @@ // === findAllReferences === // === /b.ts === // /*FIND ALL REFS*/const x: typeof import("./a") = { x: 0 }; -// const y: typeof import("./a") = { x: 0 }; \ No newline at end of file +// const y: typeof import("./a") = { x: 0 }; + + + +// === findAllReferences === +// === /b.ts === +// const x: typeof import("/*FIND ALL REFS*/[|./a|]") = { x: 0 }; +// const y: typeof import("[|./a|]") = { x: 0 }; + + + +// === findAllReferences === +// === /b.ts === +// const x: typeof import("./a") = { x: 0 }; +// /*FIND ALL REFS*/const y: typeof import("./a") = { x: 0 }; + + + +// === findAllReferences === +// === /b.ts === +// const x: typeof import("[|./a|]") = { x: 0 }; +// const y: typeof import("/*FIND ALL REFS*/[|./a|]") = { x: 0 }; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc new file mode 100644 index 0000000000..392e16b4b2 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc @@ -0,0 +1,3 @@ +// === findAllReferences === +// === /project/src/foo.ts === +// import * as x from /*FIND ALL REFS*/"[|@foo/dir/jsx-runtime|]"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc new file mode 100644 index 0000000000..f922007bc3 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc @@ -0,0 +1,505 @@ +// === findAllReferences === +// === /main.ts === +// // import ... = ... +// /*FIND ALL REFS*/import A = require("./a"); +// namespace N { } +// import N2 = N; +// +// // --- (line: 6) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// // import ... = ... +// import A = /*FIND ALL REFS*/require("./a"); +// namespace N { } +// import N2 = N; +// +// // --- (line: 6) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// // import ... = ... +// import A = require("./a"); +// namespace N { } +// /*FIND ALL REFS*/import N2 = N; +// +// // import ... from ... +// import type B from "./b"; +// // --- (line: 8) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 3) skipped --- +// import N2 = N; +// +// // import ... from ... +// /*FIND ALL REFS*/import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// // --- (line: 11) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 3) skipped --- +// import N2 = N; +// +// // import ... from ... +// import /*FIND ALL REFS*/type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// // --- (line: 11) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 3) skipped --- +// import N2 = N; +// +// // import ... from ... +// import type B /*FIND ALL REFS*/from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// // --- (line: 11) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// /*FIND ALL REFS*/import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// import /*FIND ALL REFS*/type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// import type * /*FIND ALL REFS*/as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// import type * as C /*FIND ALL REFS*/from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 5) skipped --- +// // import ... from ... +// import type B from "./b"; +// import type * as C from "./c"; +// /*FIND ALL REFS*/import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// // --- (line: 13) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 5) skipped --- +// // import ... from ... +// import type B from "./b"; +// import type * as C from "./c"; +// import /*FIND ALL REFS*/type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// // --- (line: 13) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 5) skipped --- +// // import ... from ... +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } /*FIND ALL REFS*/from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// // --- (line: 13) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// /*FIND ALL REFS*/import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// import "./f"; +// // --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import /*FIND ALL REFS*/type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// import "./f"; +// // --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } /*FIND ALL REFS*/from "./e"; +// +// // import "module" +// import "./f"; +// // --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 /*FIND ALL REFS*/as e3 } from "./e"; +// +// // import "module" +// import "./f"; +// // --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 9) skipped --- +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// /*FIND ALL REFS*/import "./f"; +// +// // export ... from ... +// export type * from "./g"; +// // --- (line: 17) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 12) skipped --- +// import "./f"; +// +// // export ... from ... +// /*FIND ALL REFS*/export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// // --- (line: 20) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 12) skipped --- +// import "./f"; +// +// // export ... from ... +// export /*FIND ALL REFS*/type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// // --- (line: 20) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 12) skipped --- +// import "./f"; +// +// // export ... from ... +// export type * /*FIND ALL REFS*/from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// // --- (line: 20) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 13) skipped --- +// +// // export ... from ... +// export type * from "./g"; +// /*FIND ALL REFS*/export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// // --- (line: 21) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 13) skipped --- +// +// // export ... from ... +// export type * from "./g"; +// export /*FIND ALL REFS*/type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// // --- (line: 21) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 13) skipped --- +// +// // export ... from ... +// export type * from "./g"; +// export type * /*FIND ALL REFS*/as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// // --- (line: 21) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 13) skipped --- +// +// // export ... from ... +// export type * from "./g"; +// export type * as H /*FIND ALL REFS*/from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// // --- (line: 21) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 14) skipped --- +// // export ... from ... +// export type * from "./g"; +// export type * as H from "./h"; +// /*FIND ALL REFS*/export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// // --- (line: 22) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 14) skipped --- +// // export ... from ... +// export type * from "./g"; +// export type * as H from "./h"; +// export /*FIND ALL REFS*/type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// // --- (line: 22) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 14) skipped --- +// // export ... from ... +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } /*FIND ALL REFS*/from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// // --- (line: 22) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 15) skipped --- +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// /*FIND ALL REFS*/export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 15) skipped --- +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export /*FIND ALL REFS*/type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 15) skipped --- +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } /*FIND ALL REFS*/from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 15) skipped --- +// export type * from "./g"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 /*FIND ALL REFS*/as j3 } from "./j"; +// type Z1 = 1; +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 17) skipped --- +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// /*FIND ALL REFS*/export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 17) skipped --- +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// type Z1 = 1; +// export /*FIND ALL REFS*/type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 20) skipped --- +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// /*FIND ALL REFS*/export type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 20) skipped --- +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export /*FIND ALL REFS*/type { z2, z3 as z4 }; + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 20) skipped --- +// export type { Z1 }; +// type Z2 = 2; +// type Z3 = 3; +// export type { z2, z3 /*FIND ALL REFS*/as z4 }; + + + +// === findAllReferences === +// === /main2.ts === +// const x = {}; +// /*FIND ALL REFS*/[|export = x;|] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc new file mode 100644 index 0000000000..0cc4913a20 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc @@ -0,0 +1,13 @@ +// === findAllReferences === +// === /packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts === +// declare var [|debug|]: [|debug|].Debug & { debug: [|debug|].Debug; default: [|debug|].Debug }; +// [|export = [|debug|];|] +// export as namespace debug; +// declare namespace [|debug|] { +// interface Debug { +// coerce: (val: any) => any; +// } +// } + +// === /packages/playwright-core/src/index.ts === +// export const debug: typeof import('[|../bundles/utils/node_modules//*FIND ALL REFS*/@types/debug|]') = require('./utilsBundleImpl').debug; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tslibFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tslibFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc new file mode 100644 index 0000000000..5276f7a8d4 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/tslibFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc @@ -0,0 +1,3 @@ +// === findAllReferences === +// === /project/src/foo.ts === +// import * as x from /*FIND ALL REFS*/"[|tslib|]"; \ No newline at end of file From 5c986313db98bfd33c4959c94d368de9e8395efd Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 2 Oct 2025 19:15:46 -0700 Subject: [PATCH 11/15] more maybe --- internal/fourslash/_scripts/failingTests.txt | 2 + internal/ls/findallreferences.go | 61 ++++++++++-- .../documentHighlightInExport1.baseline.jsonc | 2 +- ...sClassExpressionConstructor.baseline.jsonc | 52 ++++++----- .../getOccurrencesConstructor.baseline.jsonc | 52 ++++++----- .../getOccurrencesConstructor2.baseline.jsonc | 7 +- ...eDefaultImportDifferentName.baseline.jsonc | 2 +- ...nstructorFindAllReferences3.baseline.jsonc | 4 +- .../findAllReferencesLinkTag1.baseline.jsonc | 34 +------ .../findAllReferencesLinkTag2.baseline.jsonc | 24 +---- .../findAllReferencesLinkTag3.baseline.jsonc | 24 +---- ...dAllReferencesOfConstructor.baseline.jsonc | 93 ++----------------- ...esOfConstructor_badOverload.baseline.jsonc | 4 +- ...findAllRefsClassExpression0.baseline.jsonc | 8 +- ...findAllRefsClassExpression1.baseline.jsonc | 2 +- ...fsClassWithStaticThisAccess.baseline.jsonc | 2 +- .../findAllRefsDeclareClass.baseline.jsonc | 2 +- ...ndAllRefsForDefaultExport01.baseline.jsonc | 6 +- .../findAllRefsIsDefinition.baseline.jsonc | 7 +- ...sOfConstructor_withModifier.baseline.jsonc | 4 +- .../findAllRefsOnImportAliases.baseline.jsonc | 7 +- ...findAllRefsOnImportAliases2.baseline.jsonc | 10 +- ...encesDefinitionDisplayParts.baseline.jsonc | 2 +- ...urrencesIsDefinitionOfClass.baseline.jsonc | 6 +- ...nitionOfInterfaceClassMerge.baseline.jsonc | 12 +-- ...ThrowsTag_findAllReferences.baseline.jsonc | 2 +- .../referenceToClass.baseline.jsonc | 17 +--- .../referencesForGlobals2.baseline.jsonc | 5 +- ...sForGlobalsInExternalModule.baseline.jsonc | 7 +- ...encesForMergedDeclarations3.baseline.jsonc | 15 +-- ...encesForMergedDeclarations4.baseline.jsonc | 18 +--- .../remoteGetReferences.baseline.jsonc | 61 +----------- ...eDefaultImportDifferentName.baseline.jsonc | 7 +- .../renameJsExports02.baseline.jsonc | 2 +- .../renameJsExports03.baseline.jsonc | 8 +- .../tsxFindAllReferences4.baseline.jsonc | 7 +- ...fsClassWithStaticThisAccess.baseline.jsonc | 2 +- ...ssWithStaticThisAccess.baseline.jsonc.diff | 6 +- ...findAllRefsOnImportAliases2.baseline.jsonc | 6 +- ...llRefsOnImportAliases2.baseline.jsonc.diff | 17 ++++ .../jsdocThrowsTag_rename.baseline.jsonc | 2 +- .../jsdocThrowsTag_rename.baseline.jsonc.diff | 6 +- .../renameAlias3.baseline.jsonc | 2 +- .../renameAlias3.baseline.jsonc.diff | 6 +- .../renameAliasExternalModule3.baseline.jsonc | 2 +- ...meAliasExternalModule3.baseline.jsonc.diff | 11 ++- ...eDefaultImportDifferentName.baseline.jsonc | 2 +- ...ultImportDifferentName.baseline.jsonc.diff | 8 ++ .../renameForDefaultExport01.baseline.jsonc | 8 +- ...nameForDefaultExport01.baseline.jsonc.diff | 16 ++-- ...cationsForClassExpression01.baseline.jsonc | 12 +-- ...nsForClassExpression01.baseline.jsonc.diff | 21 ++++- ...ameModuleExportsProperties1.baseline.jsonc | 4 +- ...duleExportsProperties1.baseline.jsonc.diff | 12 +++ ...ameModuleExportsProperties2.baseline.jsonc | 4 +- ...duleExportsProperties2.baseline.jsonc.diff | 11 +++ ...ameModuleExportsProperties3.baseline.jsonc | 4 +- ...duleExportsProperties3.baseline.jsonc.diff | 12 +++ 58 files changed, 307 insertions(+), 445 deletions(-) create mode 100644 testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc.diff diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index a3851e759e..e18cf9e14a 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -198,6 +198,7 @@ TestGetJavaScriptQuickInfo8 TestGetJavaScriptSyntacticDiagnostics24 TestGetOccurrencesIfElseBroken TestGetQuickInfoForIntersectionTypes +TestGetRenameInfoTests1 TestHoverOverComment TestImportCompletionsPackageJsonExportsSpecifierEndsInTs TestImportCompletionsPackageJsonExportsTrailingSlash1 @@ -433,6 +434,7 @@ TestReferencesForStatementKeywords TestReferencesInEmptyFile TestRegexDetection TestRenameForAliasingExport02 +TestRenameForDefaultExport04 TestRenameFromNodeModulesDep1 TestRenameFromNodeModulesDep2 TestRenameFromNodeModulesDep3 diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index c169935e76..d0e6417487 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -727,8 +727,7 @@ func getReferencedSymbolsSpecial(node *ast.Node, sourceFiles []*ast.SourceFile) } if ast.IsImportMeta(node.Parent) && node.Parent.Name() == node { - // !!! unimplemented - return nil // getAllReferencesForImportMeta(sourceFiles /*, cancellationToken*/) + return getAllReferencesForImportMeta(sourceFiles) } if node.Kind == ast.KindStaticKeyword && node.Parent.Kind == ast.KindClassStaticBlockDeclaration { @@ -887,6 +886,22 @@ func getReferencesForSuperKeyword(superKeyword *ast.Node) []*SymbolAndEntries { return []*SymbolAndEntries{NewSymbolAndEntries(definitionKindSymbol, nil, searchSpaceNode.Symbol(), references)} } +func getAllReferencesForImportMeta(sourceFiles []*ast.SourceFile) []*SymbolAndEntries { + references := core.FlatMap(sourceFiles, func(sourceFile *ast.SourceFile) []*referenceEntry { + return core.MapNonNil(getPossibleSymbolReferenceNodes(sourceFile, "meta", sourceFile.AsNode()), func(node *ast.Node) *referenceEntry { + parent := node.Parent + if ast.IsImportMeta(parent) { + return newNodeEntry(parent) + } + return nil + }) + }) + if len(references) == 0 { + return nil + } + return []*SymbolAndEntries{{definition: &Definition{Kind: definitionKindKeyword, node: references[0].node}, references: references}} +} + func getAllReferencesForKeyword(sourceFiles []*ast.SourceFile, keywordKind ast.Kind, filterReadOnlyTypeOperator bool) []*SymbolAndEntries { // references is a list of NodeEntry references := core.FlatMap(sourceFiles, func(sourceFile *ast.SourceFile) []*referenceEntry { @@ -1117,6 +1132,24 @@ func getReferenceAtPosition(sourceFile *ast.SourceFile, position int, program *c } // -- Core algorithm for find all references -- +func getSpecialSearchKind(node *ast.Node) string { + if node == nil { + return "none" + } + switch node.Kind { + case ast.KindConstructor, ast.KindConstructorKeyword: + return "constructor" + case ast.KindIdentifier: + if ast.IsClassLike(node.Parent) { + debug.Assert(node.Parent.Name() == node) + return "class" + } + fallthrough + default: + return "none" + } +} + func getReferencedSymbolsForSymbol(originalSymbol *ast.Symbol, node *ast.Node, sourceFiles []*ast.SourceFile, sourceFilesSet *collections.Set[string], checker *checker.Checker, options refOptions) []*SymbolAndEntries { // Core find-all-references algorithm for a normal symbol. @@ -1137,8 +1170,7 @@ func getReferencedSymbolsForSymbol(originalSymbol *ast.Symbol, node *ast.Node, s // state.getReferencesAtExportSpecifier(exportSpecifier.Name(), symbol, exportSpecifier.AsExportSpecifier(), state.createSearch(node, originalSymbol, comingFromUnknown /*comingFrom*/, "", nil), true /*addReferencesHere*/, true /*alwaysGetReferences*/) } else if node != nil && node.Kind == ast.KindDefaultKeyword && symbol.Name == ast.InternalSymbolNameDefault && symbol.Parent != nil { state.addReference(node, symbol, entryKindNone) - // !!! not implemented - // state.searchForImportsOfExport(node, symbol, &ExportInfo{exportingModuleSymbol: symbol.Parent, exportKind: ExportKindDefault}) + state.searchForImportsOfExport(node, symbol, &ExportInfo{exportingModuleSymbol: symbol.Parent, exportKind: ExportKindDefault}) } else { search := state.createSearch(node, symbol, ImpExpKindUnknown /*comingFrom*/, "", state.populateSearchSymbolSet(symbol, node, options.use == referenceUseRename, options.useAliasesForRename, options.implementations)) state.getReferencesInContainerOrFiles(symbol, search) @@ -1193,7 +1225,7 @@ func newState(sourceFiles []*ast.SourceFile, sourceFilesSet *collections.Set[str return &refState{ sourceFiles: sourceFiles, sourceFilesSet: sourceFilesSet, - specialSearchKind: "none", // !!! other search kinds not implemented + specialSearchKind: getSpecialSearchKind(node), checker: checker, searchMeaning: searchMeaning, options: options, @@ -1275,6 +1307,21 @@ func (state *refState) addReference(referenceLocation *ast.Node, symbol *ast.Sym } } +func getReferenceEntriesForShorthandPropertyAssignment(node *ast.Node, checker *checker.Checker, addReference func(*ast.Node)) { + refSymbol := checker.GetSymbolAtLocation(node) + if refSymbol == nil || refSymbol.ValueDeclaration == nil { + return + } + shorthandSymbol := checker.GetShorthandAssignmentValueSymbol(refSymbol.ValueDeclaration) + if shorthandSymbol != nil && len(shorthandSymbol.Declarations) > 0 { + for _, declaration := range shorthandSymbol.Declarations { + if getMeaningFromDeclaration(declaration)&ast.SemanticMeaningValue != 0 { + addReference(declaration) + } + } + } +} + func (state *refState) addImplementationReferences(refNode *ast.Node, addRef func(*ast.Node)) { // Check if we found a function/propertyAssignment/method with an implementation or initializer if ast.IsDeclarationName(refNode) && isImplementation(refNode.Parent) { @@ -1288,9 +1335,7 @@ func (state *refState) addImplementationReferences(refNode *ast.Node, addRef fun if refNode.Parent.Kind == ast.KindShorthandPropertyAssignment { // Go ahead and dereference the shorthand assignment by going to its definition - - // !!! not implemented - // getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addRef); + getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addRef) } // Check if the node is within an extends or implements clause diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightInExport1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightInExport1.baseline.jsonc index 22a8f5e37a..8df18a2662 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightInExport1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightInExport1.baseline.jsonc @@ -1,6 +1,6 @@ // === documentHighlights === // === /documentHighlightInExport1.ts === -// class /*HIGHLIGHTS*/[|C|] {} +// class /*HIGHLIGHTS*/C {} // export { C as D }; diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionConstructor.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionConstructor.baseline.jsonc index fd11e991f0..7b5c4730a1 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionConstructor.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionConstructor.baseline.jsonc @@ -1,46 +1,52 @@ // === documentHighlights === // === /getOccurrencesClassExpressionConstructor.ts === -// let A = class [|Foo|] { -// /*HIGHLIGHTS*/constructor(); -// constructor(x: number); -// constructor(y: string); -// constructor(a?: any) { -// // --- (line: 6) skipped --- +// let A = class Foo { +// /*HIGHLIGHTS*/[|constructor|](); +// [|constructor|](x: number); +// [|constructor|](y: string); +// [|constructor|](a?: any) { +// } +// } +// +// // --- (line: 9) skipped --- // === documentHighlights === // === /getOccurrencesClassExpressionConstructor.ts === -// let A = class [|Foo|] { -// constructor(); -// /*HIGHLIGHTS*/constructor(x: number); -// constructor(y: string); -// constructor(a?: any) { +// let A = class Foo { +// [|constructor|](); +// /*HIGHLIGHTS*/[|constructor|](x: number); +// [|constructor|](y: string); +// [|constructor|](a?: any) { // } -// // --- (line: 7) skipped --- +// } +// +// // --- (line: 9) skipped --- // === documentHighlights === // === /getOccurrencesClassExpressionConstructor.ts === -// let A = class [|Foo|] { -// constructor(); -// constructor(x: number); -// /*HIGHLIGHTS*/constructor(y: string); -// constructor(a?: any) { +// let A = class Foo { +// [|constructor|](); +// [|constructor|](x: number); +// /*HIGHLIGHTS*/[|constructor|](y: string); +// [|constructor|](a?: any) { // } // } -// // --- (line: 8) skipped --- +// +// // --- (line: 9) skipped --- // === documentHighlights === // === /getOccurrencesClassExpressionConstructor.ts === -// let A = class [|Foo|] { -// constructor(); -// constructor(x: number); -// constructor(y: string); -// /*HIGHLIGHTS*/constructor(a?: any) { +// let A = class Foo { +// [|constructor|](); +// [|constructor|](x: number); +// [|constructor|](y: string); +// /*HIGHLIGHTS*/[|constructor|](a?: any) { // } // } // diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConstructor.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConstructor.baseline.jsonc index 9931401544..9a0d835004 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConstructor.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConstructor.baseline.jsonc @@ -1,46 +1,52 @@ // === documentHighlights === // === /getOccurrencesConstructor.ts === -// class [|C|] { -// /*HIGHLIGHTS*/constructor(); -// constructor(x: number); -// constructor(y: string, x: number); -// constructor(a?: any, ...r: any[]) { -// // --- (line: 6) skipped --- +// class C { +// /*HIGHLIGHTS*/[|constructor|](); +// [|constructor|](x: number); +// [|constructor|](y: string, x: number); +// [|constructor|](a?: any, ...r: any[]) { +// if (a === undefined && r.length === 0) { +// return; +// } +// // --- (line: 9) skipped --- // === documentHighlights === // === /getOccurrencesConstructor.ts === -// class [|C|] { -// constructor(); -// /*HIGHLIGHTS*/constructor(x: number); -// constructor(y: string, x: number); -// constructor(a?: any, ...r: any[]) { +// class C { +// [|constructor|](); +// /*HIGHLIGHTS*/[|constructor|](x: number); +// [|constructor|](y: string, x: number); +// [|constructor|](a?: any, ...r: any[]) { // if (a === undefined && r.length === 0) { -// // --- (line: 7) skipped --- +// return; +// } +// // --- (line: 9) skipped --- // === documentHighlights === // === /getOccurrencesConstructor.ts === -// class [|C|] { -// constructor(); -// constructor(x: number); -// /*HIGHLIGHTS*/constructor(y: string, x: number); -// constructor(a?: any, ...r: any[]) { +// class C { +// [|constructor|](); +// [|constructor|](x: number); +// /*HIGHLIGHTS*/[|constructor|](y: string, x: number); +// [|constructor|](a?: any, ...r: any[]) { // if (a === undefined && r.length === 0) { // return; -// // --- (line: 8) skipped --- +// } +// // --- (line: 9) skipped --- // === documentHighlights === // === /getOccurrencesConstructor.ts === -// class [|C|] { -// constructor(); -// constructor(x: number); -// constructor(y: string, x: number); -// /*HIGHLIGHTS*/constructor(a?: any, ...r: any[]) { +// class C { +// [|constructor|](); +// [|constructor|](x: number); +// [|constructor|](y: string, x: number); +// /*HIGHLIGHTS*/[|constructor|](a?: any, ...r: any[]) { // if (a === undefined && r.length === 0) { // return; // } diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConstructor2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConstructor2.baseline.jsonc index 6f531d7015..786cff277a 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConstructor2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConstructor2.baseline.jsonc @@ -1,10 +1,9 @@ // === documentHighlights === // === /getOccurrencesConstructor2.ts === -// --- (line: 10) skipped --- -// } +// --- (line: 11) skipped --- // } // -// class [|D|] { -// /*HIGHLIGHTS*/constructor(public x: number, public y: number) { +// class D { +// /*HIGHLIGHTS*/[|constructor|](public x: number, public y: number) { // } // } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/renameDefaultImportDifferentName.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/renameDefaultImportDifferentName.baseline.jsonc index 6d4f8ba8f7..23c567dcbf 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/renameDefaultImportDifferentName.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/renameDefaultImportDifferentName.baseline.jsonc @@ -1,6 +1,6 @@ // === documentHighlights === // === /B.ts === -// export default class /*HIGHLIGHTS*/[|C|] { +// export default class /*HIGHLIGHTS*/C { // test() { // } // } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences3.baseline.jsonc index 9876967d32..8158a44663 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences3.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /constructorFindAllReferences3.ts === -// export class [|C|] { +// export class C { // /*FIND ALL REFS*/constructor() { } // public foo() { } // } // -// new [|C|]().foo(); \ No newline at end of file +// new C().foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag1.baseline.jsonc index 8db971a964..39c857ea28 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag1.baseline.jsonc @@ -141,41 +141,11 @@ // === findAllReferences === // === /findAllReferencesLinkTag1.ts === -// class [|C|]/*FIND ALL REFS*/ { +// class C/*FIND ALL REFS*/ { // m() { } // n = 1 // static s() { } -// /** -// * {@link m} -// * @see {m} -// * {@link [|C|].m} -// * @see {[|C|].m} -// * {@link [|C|]#m} -// * @see {[|C|]#m} -// * {@link [|C|].prototype.m} -// * @see {[|C|].prototype.m} -// */ -// p() { } -// /** -// * {@link n} -// * @see {n} -// * {@link [|C|].n} -// * @see {[|C|].n} -// * {@link [|C|]#n} -// * @see {[|C|]#n} -// * {@link [|C|].prototype.n} -// * @see {[|C|].prototype.n} -// */ -// q() { } -// /** -// * {@link s} -// * @see {s} -// * {@link [|C|].s} -// * @see {[|C|].s} -// */ -// r() { } -// } -// // --- (line: 35) skipped --- +// // --- (line: 5) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag2.baseline.jsonc index 164c894c14..5d9d479916 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag2.baseline.jsonc @@ -82,31 +82,11 @@ // === findAllReferences === // === /findAllReferencesLinkTag2.ts === // namespace NPR { -// export class [|Consider|]/*FIND ALL REFS*/ { +// export class Consider/*FIND ALL REFS*/ { // This = class { // show() { } // } -// m() { } -// } -// /** -// * @see {[|Consider|].prototype.m} -// * {@link [|Consider|]#m} -// * @see {[|Consider|]#This#show} -// * {@link [|Consider|].This.show} -// * @see {NPR.[|Consider|]#This#show} -// * {@link NPR.[|Consider|].This#show} -// * @see {NPR.[|Consider|]#This.show} # doesn't parse trailing . -// * @see {NPR.[|Consider|].This.show} -// */ -// export function ref() { } -// } -// /** -// * {@link NPR.[|Consider|]#This#show hello hello} -// * {@link NPR.[|Consider|].This#show} -// * @see {NPR.[|Consider|]#This.show} # doesn't parse trailing . -// * @see {NPR.[|Consider|].This.show} -// */ -// export function outerref() { } +// // --- (line: 6) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag3.baseline.jsonc index 37e0a9e126..0aacf76725 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag3.baseline.jsonc @@ -82,31 +82,11 @@ // === findAllReferences === // === /findAllReferencesLinkTag3.ts === // namespace NPR { -// export class [|Consider|]/*FIND ALL REFS*/ { +// export class Consider/*FIND ALL REFS*/ { // This = class { // show() { } // } -// m() { } -// } -// /** -// * {@linkcode [|Consider|].prototype.m} -// * {@linkplain [|Consider|]#m} -// * {@linkcode [|Consider|]#This#show} -// * {@linkplain [|Consider|].This.show} -// * {@linkcode NPR.[|Consider|]#This#show} -// * {@linkplain NPR.[|Consider|].This#show} -// * {@linkcode NPR.[|Consider|]#This.show} # doesn't parse trailing . -// * {@linkcode NPR.[|Consider|].This.show} -// */ -// export function ref() { } -// } -// /** -// * {@linkplain NPR.[|Consider|]#This#show hello hello} -// * {@linkplain NPR.[|Consider|].This#show} -// * {@linkcode NPR.[|Consider|]#This.show} # doesn't parse trailing . -// * {@linkcode NPR.[|Consider|].This.show} -// */ -// export function outerref() { } +// // --- (line: 6) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc index 8b8c2b5574..2f86c46092 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc @@ -1,114 +1,33 @@ // === findAllReferences === // === /a.ts === -// export class [|C|] { +// export class C { // /*FIND ALL REFS*/constructor(n: number); // constructor(); // constructor(n?: number){} // static f() { -// this.f(); -// new this(); -// } -// } -// new [|C|](); -// const D = [|C|]; -// new D(); - -// === /b.ts === -// import { [|C|] } from "./a"; -// new [|C|](); - -// === /c.ts === -// import { [|C|] } from "./a"; -// class D extends [|C|] { -// constructor() { -// super(); -// super.method(); -// } -// method() { super(); } -// } -// class E implements [|C|] { -// constructor() { super(); } -// } - -// === /d.ts === -// import * as a from "./a"; -// new a.[|C|](); -// class d extends a.[|C|] { constructor() { super(); } +// // --- (line: 6) skipped --- // === findAllReferences === // === /a.ts === -// export class [|C|] { +// export class C { // constructor(n: number); // /*FIND ALL REFS*/constructor(); // constructor(n?: number){} // static f() { // this.f(); -// new this(); -// } -// } -// new [|C|](); -// const D = [|C|]; -// new D(); - -// === /b.ts === -// import { [|C|] } from "./a"; -// new [|C|](); - -// === /c.ts === -// import { [|C|] } from "./a"; -// class D extends [|C|] { -// constructor() { -// super(); -// super.method(); -// } -// method() { super(); } -// } -// class E implements [|C|] { -// constructor() { super(); } -// } - -// === /d.ts === -// import * as a from "./a"; -// new a.[|C|](); -// class d extends a.[|C|] { constructor() { super(); } +// // --- (line: 7) skipped --- // === findAllReferences === // === /a.ts === -// export class [|C|] { +// export class C { // constructor(n: number); // constructor(); // /*FIND ALL REFS*/constructor(n?: number){} // static f() { // this.f(); // new this(); -// } -// } -// new [|C|](); -// const D = [|C|]; -// new D(); - -// === /b.ts === -// import { [|C|] } from "./a"; -// new [|C|](); - -// === /c.ts === -// import { [|C|] } from "./a"; -// class D extends [|C|] { -// constructor() { -// super(); -// super.method(); -// } -// method() { super(); } -// } -// class E implements [|C|] { -// constructor() { super(); } -// } - -// === /d.ts === -// import * as a from "./a"; -// new a.[|C|](); -// class d extends a.[|C|] { constructor() { super(); } \ No newline at end of file +// // --- (line: 8) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor_badOverload.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor_badOverload.baseline.jsonc index 4c9e2f0c7e..537d665657 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor_badOverload.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor_badOverload.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /findAllReferencesOfConstructor_badOverload.ts === -// class [|C|] { +// class C { // /*FIND ALL REFS*/constructor(n: number); // constructor(){} // } @@ -9,7 +9,7 @@ // === findAllReferences === // === /findAllReferencesOfConstructor_badOverload.ts === -// class [|C|] { +// class C { // constructor(n: number); // /*FIND ALL REFS*/constructor(){} // } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression0.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression0.baseline.jsonc index 29550fa58b..a080ea120c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression0.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression0.baseline.jsonc @@ -1,13 +1,9 @@ // === findAllReferences === // === /a.ts === -// export = class /*FIND ALL REFS*/[|A|] { -// m() { [|A|]; } +// export = class /*FIND ALL REFS*/A { +// m() { A; } // }; -// === /b.ts === -// import [|A|] = require("./a"); -// [|A|]; - // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression1.baseline.jsonc index 28ff6fba96..30b6befd3e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression1.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /a.js === -// module.exports = class /*FIND ALL REFS*/[|A|] {}; +// module.exports = class /*FIND ALL REFS*/A {}; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassWithStaticThisAccess.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassWithStaticThisAccess.baseline.jsonc index 6a8b752253..6b2c6881a3 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassWithStaticThisAccess.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassWithStaticThisAccess.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /findAllRefsClassWithStaticThisAccess.ts === -// class /*FIND ALL REFS*/[|C|] { +// class /*FIND ALL REFS*/C { // static s() { // this; // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc index a0e7b903e9..a9656aba0e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc @@ -8,6 +8,6 @@ // === findAllReferences === // === /findAllRefsDeclareClass.ts === -// declare class /*FIND ALL REFS*/[|C|] { +// declare class /*FIND ALL REFS*/C { // static m(): void; // } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc index a7e3cdedf6..7753cfcbce 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc @@ -11,12 +11,12 @@ // === findAllReferences === // === /findAllRefsForDefaultExport01.ts === -// export default class /*FIND ALL REFS*/[|DefaultExportedClass|] { +// export default class /*FIND ALL REFS*/DefaultExportedClass { // } // -// var x: [|DefaultExportedClass|]; +// var x: DefaultExportedClass; // -// var y = new [|DefaultExportedClass|]; +// var y = new DefaultExportedClass; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsIsDefinition.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsIsDefinition.baseline.jsonc index 40a30963df..30e0fbdd46 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsIsDefinition.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsIsDefinition.baseline.jsonc @@ -73,11 +73,8 @@ // === findAllReferences === // === /findAllRefsIsDefinition.ts === -// --- (line: 15) skipped --- -// interface IFoo { -// foo(): void; -// } -// class [|Foo|] implements IFoo { +// --- (line: 18) skipped --- +// class Foo implements IFoo { // constructor(n: number) // constructor() // /*FIND ALL REFS*/constructor(n: number?) { } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor_withModifier.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor_withModifier.baseline.jsonc index 109ee85c9a..7986a7a190 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor_withModifier.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor_withModifier.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /findAllRefsOfConstructor_withModifier.ts === -// class [|X|] { +// class X { // public /*FIND ALL REFS*/constructor() {} // } -// var x = new [|X|](); \ No newline at end of file +// var x = new X(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases.baseline.jsonc index 0074e398ae..fc81fc9a66 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases.baseline.jsonc @@ -1,13 +1,8 @@ // === findAllReferences === // === /a.ts === -// export class /*FIND ALL REFS*/[|Class|] { +// export class /*FIND ALL REFS*/Class { // } -// === /b.ts === -// import { [|Class|] } from "./a"; -// -// var c = new [|Class|](); - // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases2.baseline.jsonc index 78284dcace..24264cbb57 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases2.baseline.jsonc @@ -1,14 +1,14 @@ // === findAllReferences === -// === /a.ts === -// export class /*FIND ALL REFS*/[|Class|] {} - // === /b.ts === -// import { [|Class|] as [|C2|] } from "./a"; -// var c = new [|C2|](); +// import { [|Class|] as C2 } from "./a"; +// var c = new C2(); // === /c.ts === // export { [|Class|] as C3 } from "./a"; +// === /a.ts === +// export class /*FIND ALL REFS*/Class {} + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc index 01bbfdfb3a..7353cd36d6 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /findReferencesDefinitionDisplayParts.ts === -// class [|Gre/*FIND ALL REFS*/eter|] { +// class Gre/*FIND ALL REFS*/eter { // someFunction() { this; } // } // diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc index 66aa26aa9b..b4a92b4433 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc @@ -10,13 +10,11 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfClass.ts === -// class /*FIND ALL REFS*/[|C|] { +// class /*FIND ALL REFS*/C { // n: number; // constructor() { // this.n = 12; -// } -// } -// let c = new [|C|](); +// // --- (line: 5) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc index 0482d27845..149bb36401 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc @@ -73,19 +73,15 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfInterfaceClassMerge.ts === -// interface [|Numbers|] { -// p: number; -// } -// interface [|Numbers|] { +// --- (line: 3) skipped --- +// interface Numbers { // m: number; // } -// class /*FIND ALL REFS*/[|Numbers|] { +// class /*FIND ALL REFS*/Numbers { // f(n: number) { // return this.p + this.m + n; // } -// } -// let i: [|Numbers|] = new [|Numbers|](); -// let x = i.f(i.p + i.m); +// // --- (line: 11) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/jsdocThrowsTag_findAllReferences.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/jsdocThrowsTag_findAllReferences.baseline.jsonc index d399b6dc09..e63335df14 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/jsdocThrowsTag_findAllReferences.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/jsdocThrowsTag_findAllReferences.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /jsdocThrowsTag_findAllReferences.ts === -// class /*FIND ALL REFS*/[|E|] extends Error {} +// class /*FIND ALL REFS*/E extends Error {} // /** // * @throws {E} // */ diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referenceToClass.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referenceToClass.baseline.jsonc index 039a517c5f..a2f1eee4ac 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referenceToClass.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referenceToClass.baseline.jsonc @@ -1,21 +1,10 @@ // === findAllReferences === // === /referenceToClass_1.ts === -// class /*FIND ALL REFS*/[|foo|] { -// public n: [|foo|]; +// class /*FIND ALL REFS*/foo { +// public n: foo; // public foo: number; // } -// -// class bar { -// public n: [|foo|]; -// public k = new [|foo|](); -// } -// -// module mod { -// var k: [|foo|] = null; -// } - -// === /referenceToClass_2.ts === -// var k: [|foo|]; +// // --- (line: 5) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc index 31467511fe..2d552fc3b6 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc @@ -8,13 +8,10 @@ // === findAllReferences === // === /referencesForGlobals_1.ts === -// class /*FIND ALL REFS*/[|globalClass|] { +// class /*FIND ALL REFS*/globalClass { // public f() { } // } -// === /referencesForGlobals_2.ts === -// var c = [|globalClass|](); - // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc index 73e1bc6410..763559f012 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc @@ -48,12 +48,11 @@ // var topLevelVar = 2; // var topLevelVar2 = topLevelVar; // -// class /*FIND ALL REFS*/[|topLevelClass|] { } -// var c = new [|topLevelClass|](); +// class /*FIND ALL REFS*/topLevelClass { } +// var c = new topLevelClass(); // // interface topLevelInterface { } -// var i: topLevelInterface; -// // --- (line: 9) skipped --- +// // --- (line: 8) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations3.baseline.jsonc index 1fc1969780..9f6f4b5434 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations3.baseline.jsonc @@ -22,19 +22,8 @@ // === findAllReferences === // === /referencesForMergedDeclarations3.ts === -// class /*FIND ALL REFS*/[|testClass|] { +// class /*FIND ALL REFS*/testClass { // static staticMethod() { } // method() { } // } -// // --- (line: 5) skipped --- - -// --- (line: 8) skipped --- -// } -// } -// -// var c1: [|testClass|]; -// var c2: testClass.Bar; -// [|testClass|].staticMethod(); -// [|testClass|].prototype.method(); -// [|testClass|].bind(this); -// new [|testClass|](); \ No newline at end of file +// // --- (line: 5) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc index fc54de7f4b..70648e2d99 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc @@ -10,25 +10,11 @@ // === findAllReferences === // === /referencesForMergedDeclarations4.ts === -// class /*FIND ALL REFS*/[|testClass|] { +// class /*FIND ALL REFS*/testClass { // static staticMethod() { } // method() { } // } -// -// module [|testClass|] { -// export interface Bar { -// -// } -// export var s = 0; -// } -// -// var c1: [|testClass|]; -// var c2: [|testClass|].Bar; -// [|testClass|].staticMethod(); -// [|testClass|].prototype.method(); -// [|testClass|].bind(this); -// [|testClass|].s; -// new [|testClass|](); +// // --- (line: 5) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc index 2515a755e4..d67947baf9 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc @@ -773,71 +773,14 @@ // === findAllReferences === -// === /remoteGetReferences_1.ts === -// --- (line: 82) skipped --- -// -// //Remotes -// //Type test -// var remoteclsTest: [|remotefooCls|]; -// -// //Arguments -// remoteclsTest = new [|remotefooCls|](remoteglobalVar); -// remotefoo(remoteglobalVar); -// -// //Increments -// [|remotefooCls|].remoteclsSVar++; -// remotemodTest.remotemodVar++; -// remoteglobalVar = remoteglobalVar + remoteglobalVar; -// -// // --- (line: 97) skipped --- - // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; // -// class /*FIND ALL REFS*/[|remotefooCls|] { +// class /*FIND ALL REFS*/remotefooCls { // //Declare // remoteclsVar = 1; // static remoteclsSVar = 1; -// -// constructor(public remoteclsParam: number) { -// //Increments -// remoteglobalVar++; -// this.remoteclsVar++; -// [|remotefooCls|].remoteclsSVar++; -// this.remoteclsParam++; -// remotemodTest.remotemodVar++; -// } -// // --- (line: 16) skipped --- - -// --- (line: 19) skipped --- -// var remotefnVar = 1; -// -// //Increments -// [|remotefooCls|].remoteclsSVar++; -// remoteglobalVar++; -// remotemodTest.remotemodVar++; -// remotefnVar++; -// // --- (line: 27) skipped --- - -// --- (line: 34) skipped --- -// -// //Increments -// remoteglobalVar++; -// [|remotefooCls|].remoteclsSVar++; -// remotemodVar++; -// -// class remotetestCls { -// // --- (line: 42) skipped --- - -// --- (line: 46) skipped --- -// -// //Increments -// remoteglobalVar++; -// [|remotefooCls|].remoteclsSVar++; -// remotemodVar++; -// } -// -// // --- (line: 54) skipped --- +// // --- (line: 7) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc index 4ae1126485..411bc485a0 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc @@ -1,11 +1,6 @@ // === findAllReferences === -// === /A.ts === -// import [|B|] from "./B"; -// let b = new [|B|](); -// b.test(); - // === /B.ts === -// export default class /*FIND ALL REFS*/[|C|] { +// export default class /*FIND ALL REFS*/C { // test() { // } // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports02.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports02.baseline.jsonc index eab27fdda9..3a68efe58a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports02.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports02.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /a.js === -// module.exports = class /*FIND ALL REFS*/[|A|] {} +// module.exports = class /*FIND ALL REFS*/A {} diff --git a/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports03.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports03.baseline.jsonc index e7589d64b6..aeb69b3d9b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports03.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports03.baseline.jsonc @@ -1,18 +1,18 @@ // === findAllReferences === // === /a.js === -// class /*FIND ALL REFS*/[|A|] { +// class /*FIND ALL REFS*/A { // constructor() { } // } -// module.exports = [|A|]; +// module.exports = A; // === findAllReferences === // === /a.js === -// class [|A|] { +// class A { // /*FIND ALL REFS*/constructor() { } // } -// module.exports = [|A|]; +// module.exports = A; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc index a65332382e..4fea343433 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc @@ -18,14 +18,11 @@ // } // interface ElementAttributesProperty { props } // } -// class /*FIND ALL REFS*/[|MyClass|] { +// class /*FIND ALL REFS*/MyClass { // props: { // name?: string; // size?: number; -// } -// -// -// var x = <[|MyClass|] name='hello'>; +// // --- (line: 11) skipped --- diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc index f96fbc5b1d..72614e24d4 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc @@ -1,6 +1,6 @@ // === findRenameLocations === // === /findAllRefsClassWithStaticThisAccess.ts === -// class /*RENAME*/[|CRENAME|] { +// class /*RENAME*/C { // static s() { // this; // } diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc.diff index 29eec4cdc0..444eee2131 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc.diff @@ -1,6 +1,10 @@ --- old.findAllRefsClassWithStaticThisAccess.baseline.jsonc +++ new.findAllRefsClassWithStaticThisAccess.baseline.jsonc -@@= skipped -3, +3 lines =@@ +@@= skipped -0, +0 lines =@@ + // === findRenameLocations === + // === /findAllRefsClassWithStaticThisAccess.ts === +-// class /*RENAME*/[|CRENAME|] { ++// class /*RENAME*/C { // static s() { // this; // } diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc index ef489e4c5e..473b644781 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc @@ -1,7 +1,4 @@ // === findRenameLocations === -// === /a.ts === -// export class /*RENAME*/[|ClassRENAME|] {} - // === /b.ts === // import { [|ClassRENAME|] as C2 } from "./a"; // var c = new C2(); @@ -9,6 +6,9 @@ // === /c.ts === // export { [|ClassRENAME|] as C3 } from "./a"; +// === /a.ts === +// export class /*RENAME*/Class {} + // === findRenameLocations === diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc.diff index 293d6126e0..b18e813f92 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc.diff @@ -1,5 +1,22 @@ --- old.findAllRefsOnImportAliases2.baseline.jsonc +++ new.findAllRefsOnImportAliases2.baseline.jsonc +@@= skipped -0, +0 lines =@@ + // === findRenameLocations === +-// === /a.ts === +-// export class /*RENAME*/[|ClassRENAME|] {} +- + // === /b.ts === + // import { [|ClassRENAME|] as C2 } from "./a"; + // var c = new C2(); + + // === /c.ts === + // export { [|ClassRENAME|] as C3 } from "./a"; ++ ++// === /a.ts === ++// export class /*RENAME*/Class {} + + + @@= skipped -52, +52 lines =@@ // === findRenameLocations === diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc index c7fe097fcc..bb21cfb060 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc @@ -1,6 +1,6 @@ // === findRenameLocations === // === /jsdocThrowsTag_rename.ts === -// class /*RENAME*/[|ERENAME|] extends Error {} +// class /*RENAME*/E extends Error {} // /** // * @throws {E} // */ diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc.diff index a579e74bae..97a325b8da 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc.diff @@ -1,8 +1,10 @@ --- old.jsdocThrowsTag_rename.baseline.jsonc +++ new.jsdocThrowsTag_rename.baseline.jsonc -@@= skipped -1, +1 lines =@@ +@@= skipped -0, +0 lines =@@ + // === findRenameLocations === // === /jsdocThrowsTag_rename.ts === - // class /*RENAME*/[|ERENAME|] extends Error {} +-// class /*RENAME*/[|ERENAME|] extends Error {} ++// class /*RENAME*/E extends Error {} // /** -// * @throws {[|ERENAME|]} +// * @throws {E} diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc index af74bffd51..48be1703e2 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc @@ -1,6 +1,6 @@ // === findRenameLocations === // === /renameAlias3.ts === -// module SomeModule { export class /*RENAME*/[|SomeClassRENAME|] { } } +// module SomeModule { export class /*RENAME*/SomeClass { } } // import M = SomeModule; // import C = M.SomeClass; diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc.diff index 24d0d63d58..c92d4b87ee 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc.diff @@ -1,8 +1,10 @@ --- old.renameAlias3.baseline.jsonc +++ new.renameAlias3.baseline.jsonc -@@= skipped -1, +1 lines =@@ +@@= skipped -0, +0 lines =@@ + // === findRenameLocations === // === /renameAlias3.ts === - // module SomeModule { export class /*RENAME*/[|SomeClassRENAME|] { } } +-// module SomeModule { export class /*RENAME*/[|SomeClassRENAME|] { } } ++// module SomeModule { export class /*RENAME*/SomeClass { } } // import M = SomeModule; -// import C = M.[|SomeClassRENAME|]; +// import C = M.SomeClass; diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc index c9f18c5c49..316dd2000d 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc @@ -1,6 +1,6 @@ // === findRenameLocations === // === /a.ts === -// module SomeModule { export class /*RENAME*/[|SomeClassRENAME|] { } } +// module SomeModule { export class /*RENAME*/SomeClass { } } // export = SomeModule; diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc.diff index b3dc143222..a4dc9653a3 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc.diff @@ -1,13 +1,16 @@ --- old.renameAliasExternalModule3.baseline.jsonc +++ new.renameAliasExternalModule3.baseline.jsonc -@@= skipped -2, +2 lines =@@ - // module SomeModule { export class /*RENAME*/[|SomeClassRENAME|] { } } +@@= skipped -0, +0 lines =@@ + // === findRenameLocations === + // === /a.ts === +-// module SomeModule { export class /*RENAME*/[|SomeClassRENAME|] { } } ++// module SomeModule { export class /*RENAME*/SomeClass { } } // export = SomeModule; - +- -// === /b.ts === -// import M = require("./a"); -// import C = M.[|SomeClassRENAME|]; -- + // === findRenameLocations === diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc index 3cde049d52..fd986a30f5 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc @@ -1,6 +1,6 @@ // === findRenameLocations === // === /B.ts === -// export default class /*RENAME*/[|CRENAME|] { +// export default class /*RENAME*/C { // test() { // } // } diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff index f45fc22589..0af855ef3f 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff @@ -1,5 +1,13 @@ --- old.renameDefaultImportDifferentName.baseline.jsonc +++ new.renameDefaultImportDifferentName.baseline.jsonc +@@= skipped -0, +0 lines =@@ + // === findRenameLocations === + // === /B.ts === +-// export default class /*RENAME*/[|CRENAME|] { ++// export default class /*RENAME*/C { + // test() { + // } + // } @@= skipped -19, +19 lines =@@ // import [|BRENAME|] from "./B"; // let b = new /*RENAME*/[|BRENAME|](); diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc index 906a20df00..0c2a544d01 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc @@ -1,14 +1,10 @@ // === findRenameLocations === // === /renameForDefaultExport01.ts === -// export default class /*RENAME*/[|DefaultExportedClassRENAME|] { +// export default class /*RENAME*/DefaultExportedClass { // } // /* // * Commenting DefaultExportedClass -// */ -// -// var x: [|DefaultExportedClassRENAME|]; -// -// var y = new [|DefaultExportedClassRENAME|]; +// // --- (line: 5) skipped --- diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc.diff index 57beca9cff..a70e604497 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc.diff @@ -4,15 +4,19 @@ // === findRenameLocations === - // === /renameForDefaultExport01.ts === - // export default class /*RENAME*/[|DefaultExportedClassRENAME|] { +-// export default class /*RENAME*/[|DefaultExportedClassRENAME|] { ++// export default class /*RENAME*/DefaultExportedClass { // } // /* -// * Commenting [|DefaultExportedClassRENAME|] +-// */ +-// +-// var x: [|DefaultExportedClassRENAME|]; +-// +-// var y = new [|DefaultExportedClassRENAME|]; +// * Commenting DefaultExportedClass - // */ - // - // var x: [|DefaultExportedClassRENAME|]; -@@= skipped -13, +12 lines =@@ ++// // --- (line: 5) skipped --- + // === findRenameLocations === @@ -26,7 +30,7 @@ // */ // // var x: /*RENAME*/[|DefaultExportedClassRENAME|]; -@@= skipped -15, +14 lines =@@ +@@= skipped -28, +22 lines =@@ // === findRenameLocations === diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc index 176f9c4566..4146f1221e 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc @@ -3,17 +3,11 @@ // class Foo { // } // -// var x = class /*RENAME*/[|FooRENAME|] { +// var x = class /*RENAME*/Foo { // doIt() { -// return [|FooRENAME|]; -// } -// -// static doItStatically() { -// return [|FooRENAME|].y; +// return Foo; // } -// } -// -// // --- (line: 14) skipped --- +// // --- (line: 8) skipped --- diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc.diff index c2ad5857b3..55e25fe61c 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc.diff @@ -1,17 +1,30 @@ --- old.renameLocationsForClassExpression01.baseline.jsonc +++ new.renameLocationsForClassExpression01.baseline.jsonc -@@= skipped -12, +12 lines =@@ - // } +@@= skipped -2, +2 lines =@@ + // class Foo { // } // +-// var x = class /*RENAME*/[|FooRENAME|] { ++// var x = class /*RENAME*/Foo { + // doIt() { +-// return [|FooRENAME|]; +-// } +-// +-// static doItStatically() { +-// return [|FooRENAME|].y; +-// } +-// } +-// -// var y = class { -// getSomeName() { -// --- (line: 16) skipped --- -+// // --- (line: 14) skipped --- ++// return Foo; ++// } ++// // --- (line: 8) skipped --- -@@= skipped -21, +19 lines =@@ +@@= skipped -31, +23 lines =@@ // } // } // diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc index 93eaefdfbb..7ef8b355cb 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc @@ -2,8 +2,8 @@ // @useAliasesForRename: true // === /renameModuleExportsProperties1.ts === -// class /*RENAME*/[|ARENAME|] {} -// module.exports = { /*START PREFIX*/A: [|ARENAME|] } +// class /*RENAME*/A {} +// module.exports = { A } diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc.diff new file mode 100644 index 0000000000..90c5272879 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc.diff @@ -0,0 +1,12 @@ +--- old.renameModuleExportsProperties1.baseline.jsonc ++++ new.renameModuleExportsProperties1.baseline.jsonc +@@= skipped -1, +1 lines =@@ + // @useAliasesForRename: true + + // === /renameModuleExportsProperties1.ts === +-// class /*RENAME*/[|ARENAME|] {} +-// module.exports = { /*START PREFIX*/A: [|ARENAME|] } ++// class /*RENAME*/A {} ++// module.exports = { A } + + diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc index 848173961a..5fb48b23de 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc @@ -1,7 +1,7 @@ // === findRenameLocations === // === /renameModuleExportsProperties2.ts === -// class /*RENAME*/[|ARENAME|] {} -// module.exports = { B: [|ARENAME|] } +// class /*RENAME*/A {} +// module.exports = { B: A } diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc.diff new file mode 100644 index 0000000000..f83b1bfc70 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc.diff @@ -0,0 +1,11 @@ +--- old.renameModuleExportsProperties2.baseline.jsonc ++++ new.renameModuleExportsProperties2.baseline.jsonc +@@= skipped -0, +0 lines =@@ + // === findRenameLocations === + // === /renameModuleExportsProperties2.ts === +-// class /*RENAME*/[|ARENAME|] {} +-// module.exports = { B: [|ARENAME|] } ++// class /*RENAME*/A {} ++// module.exports = { B: A } + + diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc index d195c0d246..a9d33a983c 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc @@ -2,8 +2,8 @@ // @useAliasesForRename: true // === /a.js === -// class /*RENAME*/[|ARENAME|] {} -// module.exports = { /*START PREFIX*/A: [|ARENAME|] } +// class /*RENAME*/A {} +// module.exports = { A } diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc.diff new file mode 100644 index 0000000000..747957ca57 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc.diff @@ -0,0 +1,12 @@ +--- old.renameModuleExportsProperties3.baseline.jsonc ++++ new.renameModuleExportsProperties3.baseline.jsonc +@@= skipped -1, +1 lines =@@ + // @useAliasesForRename: true + + // === /a.js === +-// class /*RENAME*/[|ARENAME|] {} +-// module.exports = { /*START PREFIX*/A: [|ARENAME|] } ++// class /*RENAME*/A {} ++// module.exports = { A } + + From f6f429bfe671ead372b6b2f1f4b4c72db9ca0237 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 2 Oct 2025 19:28:48 -0700 Subject: [PATCH 12/15] more --- internal/fourslash/_scripts/failingTests.txt | 2 - internal/ls/findallreferences.go | 177 +++++++++++++++++- .../documentHighlightInExport1.baseline.jsonc | 2 +- ...eDefaultImportDifferentName.baseline.jsonc | 2 +- ...nstructorFindAllReferences3.baseline.jsonc | 4 +- .../findAllReferencesLinkTag1.baseline.jsonc | 34 +++- .../findAllReferencesLinkTag2.baseline.jsonc | 24 ++- .../findAllReferencesLinkTag3.baseline.jsonc | 24 ++- ...dAllReferencesOfConstructor.baseline.jsonc | 98 ++++++++-- ...esOfConstructor_badOverload.baseline.jsonc | 8 +- ...findAllRefsClassExpression0.baseline.jsonc | 8 +- ...findAllRefsClassExpression1.baseline.jsonc | 2 +- ...fsClassWithStaticThisAccess.baseline.jsonc | 12 +- .../findAllRefsDeclareClass.baseline.jsonc | 2 +- ...ndAllRefsForDefaultExport01.baseline.jsonc | 6 +- .../findAllRefsIsDefinition.baseline.jsonc | 12 +- ...sOfConstructor_withModifier.baseline.jsonc | 4 +- .../findAllRefsOnImportAliases.baseline.jsonc | 7 +- ...findAllRefsOnImportAliases2.baseline.jsonc | 10 +- ...encesDefinitionDisplayParts.baseline.jsonc | 2 +- ...urrencesIsDefinitionOfClass.baseline.jsonc | 6 +- ...nitionOfInterfaceClassMerge.baseline.jsonc | 12 +- ...ThrowsTag_findAllReferences.baseline.jsonc | 2 +- .../referenceToClass.baseline.jsonc | 17 +- .../referencesForGlobals2.baseline.jsonc | 5 +- ...sForGlobalsInExternalModule.baseline.jsonc | 7 +- ...encesForMergedDeclarations3.baseline.jsonc | 15 +- ...encesForMergedDeclarations4.baseline.jsonc | 18 +- .../remoteGetReferences.baseline.jsonc | 61 +++++- ...eDefaultImportDifferentName.baseline.jsonc | 7 +- .../renameJsExports02.baseline.jsonc | 2 +- .../renameJsExports03.baseline.jsonc | 6 +- .../tsxFindAllReferences4.baseline.jsonc | 7 +- ...fsClassWithStaticThisAccess.baseline.jsonc | 2 +- ...ssWithStaticThisAccess.baseline.jsonc.diff | 6 +- ...findAllRefsOnImportAliases2.baseline.jsonc | 6 +- ...llRefsOnImportAliases2.baseline.jsonc.diff | 17 -- .../jsdocThrowsTag_rename.baseline.jsonc | 2 +- .../jsdocThrowsTag_rename.baseline.jsonc.diff | 6 +- .../renameAlias3.baseline.jsonc | 2 +- .../renameAlias3.baseline.jsonc.diff | 6 +- .../renameAliasExternalModule3.baseline.jsonc | 2 +- ...meAliasExternalModule3.baseline.jsonc.diff | 11 +- ...eDefaultImportDifferentName.baseline.jsonc | 2 +- ...ultImportDifferentName.baseline.jsonc.diff | 8 - .../renameForDefaultExport01.baseline.jsonc | 8 +- ...nameForDefaultExport01.baseline.jsonc.diff | 16 +- ...cationsForClassExpression01.baseline.jsonc | 12 +- ...nsForClassExpression01.baseline.jsonc.diff | 21 +-- ...ameModuleExportsProperties1.baseline.jsonc | 4 +- ...duleExportsProperties1.baseline.jsonc.diff | 12 -- ...ameModuleExportsProperties2.baseline.jsonc | 4 +- ...duleExportsProperties2.baseline.jsonc.diff | 11 -- ...ameModuleExportsProperties3.baseline.jsonc | 4 +- ...duleExportsProperties3.baseline.jsonc.diff | 12 -- 55 files changed, 569 insertions(+), 210 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc.diff delete mode 100644 testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc.diff delete mode 100644 testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc.diff diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index e18cf9e14a..a3851e759e 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -198,7 +198,6 @@ TestGetJavaScriptQuickInfo8 TestGetJavaScriptSyntacticDiagnostics24 TestGetOccurrencesIfElseBroken TestGetQuickInfoForIntersectionTypes -TestGetRenameInfoTests1 TestHoverOverComment TestImportCompletionsPackageJsonExportsSpecifierEndsInTs TestImportCompletionsPackageJsonExportsTrailingSlash1 @@ -434,7 +433,6 @@ TestReferencesForStatementKeywords TestReferencesInEmptyFile TestRegexDetection TestRenameForAliasingExport02 -TestRenameForDefaultExport04 TestRenameFromNodeModulesDep1 TestRenameFromNodeModulesDep2 TestRenameFromNodeModulesDep3 diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index d0e6417487..7446ab3384 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -1322,6 +1322,105 @@ func getReferenceEntriesForShorthandPropertyAssignment(node *ast.Node, checker * } } +func climbPastPropertyAccess(node *ast.Node) *ast.Node { + if isRightSideOfPropertyAccess(node) { + return node.Parent + } + return node +} + +func isNewExpressionTarget(node *ast.Node) bool { + if node.Parent == nil { + return false + } + return node.Parent.Kind == ast.KindNewExpression && node.Parent.AsNewExpression().Expression == node +} + +func isCallExpressionTarget(node *ast.Node) bool { + if node.Parent == nil { + return false + } + return node.Parent.Kind == ast.KindCallExpression && node.Parent.AsCallExpression().Expression == node +} + +func isMethodOrAccessor(node *ast.Node) bool { + return node.Kind == ast.KindMethodDeclaration || node.Kind == ast.KindGetAccessor || node.Kind == ast.KindSetAccessor +} + +func tryGetClassByExtendingIdentifier(node *ast.Node) *ast.ClassLikeDeclaration { + return ast.TryGetClassExtendingExpressionWithTypeArguments(climbPastPropertyAccess(node).Parent) +} + +func getClassConstructorSymbol(classSymbol *ast.Symbol) *ast.Symbol { + if classSymbol.Members == nil { + return nil + } + return classSymbol.Members[ast.InternalSymbolNameConstructor] +} + +func hasOwnConstructor(classDeclaration *ast.ClassLikeDeclaration) bool { + return getClassConstructorSymbol(classDeclaration.Symbol()) != nil +} + +func findOwnConstructorReferences(classSymbol *ast.Symbol, sourceFile *ast.SourceFile, addNode func(*ast.Node)) { + constructorSymbol := getClassConstructorSymbol(classSymbol) + if constructorSymbol != nil && len(constructorSymbol.Declarations) > 0 { + for _, decl := range constructorSymbol.Declarations { + if decl.Kind == ast.KindConstructor { + if ctrKeyword := findChildOfKind(decl, ast.KindConstructorKeyword, sourceFile); ctrKeyword != nil { + addNode(ctrKeyword) + } + } + } + } + + if classSymbol.Exports != nil { + for _, member := range classSymbol.Exports { + decl := member.ValueDeclaration + if decl != nil && decl.Kind == ast.KindMethodDeclaration { + body := decl.Body() + if body != nil { + forEachDescendantOfKind(body, ast.KindThisKeyword, func(thisKeyword *ast.Node) { + if isNewExpressionTarget(thisKeyword) { + addNode(thisKeyword) + } + }) + } + } + } + } +} + +func findSuperConstructorAccesses(classDeclaration *ast.ClassLikeDeclaration, addNode func(*ast.Node)) { + constructorSymbol := getClassConstructorSymbol(classDeclaration.Symbol()) + if constructorSymbol == nil || len(constructorSymbol.Declarations) == 0 { + return + } + + for _, decl := range constructorSymbol.Declarations { + if decl.Kind == ast.KindConstructor { + body := decl.Body() + if body != nil { + forEachDescendantOfKind(body, ast.KindSuperKeyword, func(node *ast.Node) { + if isCallExpressionTarget(node) { + addNode(node) + } + }) + } + } + } +} + +func forEachDescendantOfKind(node *ast.Node, kind ast.Kind, action func(*ast.Node)) { + node.ForEachChild(func(child *ast.Node) bool { + if child.Kind == kind { + action(child) + } + forEachDescendantOfKind(child, kind, action) + return false + }) +} + func (state *refState) addImplementationReferences(refNode *ast.Node, addRef func(*ast.Node)) { // Check if we found a function/propertyAssignment/method with an implementation or initializer if ast.IsDeclarationName(refNode) && isImplementation(refNode.Parent) { @@ -1483,11 +1582,9 @@ func (state *refState) getReferencesAtLocation(sourceFile *ast.SourceFile, posit state.addReference(referenceLocation, relatedSymbol, relatedSymbolKind) } case "constructor": - // !!! not implemented - // state.addConstructorReferences(referenceLocation, sourceFile, search) + state.addConstructorReferences(referenceLocation, relatedSymbol, search, addReferencesHere) case "class": - // !!! not implemented - // state.addClassStaticThisReferences(referenceLocation, search) + state.addClassStaticThisReferences(referenceLocation, relatedSymbol, search, addReferencesHere) } // Use the parent symbol if the location is commonjs require syntax on javascript files only. @@ -1504,6 +1601,78 @@ func (state *refState) getReferencesAtLocation(sourceFile *ast.SourceFile, posit state.getImportOrExportReferences(referenceLocation, referenceSymbol, search) } +func (state *refState) addConstructorReferences(referenceLocation *ast.Node, symbol *ast.Symbol, search *refSearch, addReferencesHere bool) { + if isNewExpressionTarget(referenceLocation) && addReferencesHere { + state.addReference(referenceLocation, symbol, entryKindNone) + } + + pusher := func() func(*ast.Node, entryKind) { + return state.referenceAdder(search.symbol) + } + + if ast.IsClassLike(referenceLocation.Parent) { + // This is the class declaration containing the constructor. + sourceFile := ast.GetSourceFileOfNode(referenceLocation) + findOwnConstructorReferences(search.symbol, sourceFile, func(n *ast.Node) { + pusher()(n, entryKindNone) + }) + } else { + // If this class appears in `extends C`, then the extending class' "super" calls are references. + if classExtending := tryGetClassByExtendingIdentifier(referenceLocation); classExtending != nil { + findSuperConstructorAccesses(classExtending, func(n *ast.Node) { + pusher()(n, entryKindNone) + }) + state.findInheritedConstructorReferences(classExtending) + } + } +} + +func (state *refState) addClassStaticThisReferences(referenceLocation *ast.Node, symbol *ast.Symbol, search *refSearch, addReferencesHere bool) { + if addReferencesHere { + state.addReference(referenceLocation, symbol, entryKindNone) + } + + classLike := referenceLocation.Parent + if state.options.use == referenceUseRename || !ast.IsClassLike(classLike) { + return + } + + addRef := state.referenceAdder(search.symbol) + members := classLike.Members() + if members == nil { + return + } + for _, member := range members { + if !(isMethodOrAccessor(member) && ast.HasStaticModifier(member)) { + continue + } + body := member.Body() + if body != nil { + var cb func(*ast.Node) + cb = func(node *ast.Node) { + if node.Kind == ast.KindThisKeyword { + addRef(node, entryKindNone) + } else if !ast.IsFunctionLike(node) && !ast.IsClassLike(node) { + node.ForEachChild(func(child *ast.Node) bool { + cb(child) + return false + }) + } + } + cb(body) + } + } +} + +func (state *refState) findInheritedConstructorReferences(classDeclaration *ast.ClassLikeDeclaration) { + if hasOwnConstructor(classDeclaration) { + return + } + classSymbol := classDeclaration.Symbol() + search := state.createSearch(nil, classSymbol, ImpExpKindUnknown, "", nil) + state.getReferencesInContainerOrFiles(classSymbol, search) +} + func (state *refState) getImportOrExportReferences(referenceLocation *ast.Node, referenceSymbol *ast.Symbol, search *refSearch) { importOrExport := getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom == ImpExpKindExport) if importOrExport == nil { diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightInExport1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightInExport1.baseline.jsonc index 8df18a2662..22a8f5e37a 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightInExport1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightInExport1.baseline.jsonc @@ -1,6 +1,6 @@ // === documentHighlights === // === /documentHighlightInExport1.ts === -// class /*HIGHLIGHTS*/C {} +// class /*HIGHLIGHTS*/[|C|] {} // export { C as D }; diff --git a/testdata/baselines/reference/fourslash/documentHighlights/renameDefaultImportDifferentName.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/renameDefaultImportDifferentName.baseline.jsonc index 23c567dcbf..6d4f8ba8f7 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/renameDefaultImportDifferentName.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/renameDefaultImportDifferentName.baseline.jsonc @@ -1,6 +1,6 @@ // === documentHighlights === // === /B.ts === -// export default class /*HIGHLIGHTS*/C { +// export default class /*HIGHLIGHTS*/[|C|] { // test() { // } // } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences3.baseline.jsonc index 8158a44663..79b101605b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/constructorFindAllReferences3.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /constructorFindAllReferences3.ts === // export class C { -// /*FIND ALL REFS*/constructor() { } +// /*FIND ALL REFS*/[|constructor|]() { } // public foo() { } // } // -// new C().foo(); \ No newline at end of file +// new [|C|]().foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag1.baseline.jsonc index 39c857ea28..8db971a964 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag1.baseline.jsonc @@ -141,11 +141,41 @@ // === findAllReferences === // === /findAllReferencesLinkTag1.ts === -// class C/*FIND ALL REFS*/ { +// class [|C|]/*FIND ALL REFS*/ { // m() { } // n = 1 // static s() { } -// // --- (line: 5) skipped --- +// /** +// * {@link m} +// * @see {m} +// * {@link [|C|].m} +// * @see {[|C|].m} +// * {@link [|C|]#m} +// * @see {[|C|]#m} +// * {@link [|C|].prototype.m} +// * @see {[|C|].prototype.m} +// */ +// p() { } +// /** +// * {@link n} +// * @see {n} +// * {@link [|C|].n} +// * @see {[|C|].n} +// * {@link [|C|]#n} +// * @see {[|C|]#n} +// * {@link [|C|].prototype.n} +// * @see {[|C|].prototype.n} +// */ +// q() { } +// /** +// * {@link s} +// * @see {s} +// * {@link [|C|].s} +// * @see {[|C|].s} +// */ +// r() { } +// } +// // --- (line: 35) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag2.baseline.jsonc index 5d9d479916..164c894c14 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag2.baseline.jsonc @@ -82,11 +82,31 @@ // === findAllReferences === // === /findAllReferencesLinkTag2.ts === // namespace NPR { -// export class Consider/*FIND ALL REFS*/ { +// export class [|Consider|]/*FIND ALL REFS*/ { // This = class { // show() { } // } -// // --- (line: 6) skipped --- +// m() { } +// } +// /** +// * @see {[|Consider|].prototype.m} +// * {@link [|Consider|]#m} +// * @see {[|Consider|]#This#show} +// * {@link [|Consider|].This.show} +// * @see {NPR.[|Consider|]#This#show} +// * {@link NPR.[|Consider|].This#show} +// * @see {NPR.[|Consider|]#This.show} # doesn't parse trailing . +// * @see {NPR.[|Consider|].This.show} +// */ +// export function ref() { } +// } +// /** +// * {@link NPR.[|Consider|]#This#show hello hello} +// * {@link NPR.[|Consider|].This#show} +// * @see {NPR.[|Consider|]#This.show} # doesn't parse trailing . +// * @see {NPR.[|Consider|].This.show} +// */ +// export function outerref() { } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag3.baseline.jsonc index 0aacf76725..37e0a9e126 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesLinkTag3.baseline.jsonc @@ -82,11 +82,31 @@ // === findAllReferences === // === /findAllReferencesLinkTag3.ts === // namespace NPR { -// export class Consider/*FIND ALL REFS*/ { +// export class [|Consider|]/*FIND ALL REFS*/ { // This = class { // show() { } // } -// // --- (line: 6) skipped --- +// m() { } +// } +// /** +// * {@linkcode [|Consider|].prototype.m} +// * {@linkplain [|Consider|]#m} +// * {@linkcode [|Consider|]#This#show} +// * {@linkplain [|Consider|].This.show} +// * {@linkcode NPR.[|Consider|]#This#show} +// * {@linkplain NPR.[|Consider|].This#show} +// * {@linkcode NPR.[|Consider|]#This.show} # doesn't parse trailing . +// * {@linkcode NPR.[|Consider|].This.show} +// */ +// export function ref() { } +// } +// /** +// * {@linkplain NPR.[|Consider|]#This#show hello hello} +// * {@linkplain NPR.[|Consider|].This#show} +// * {@linkcode NPR.[|Consider|]#This.show} # doesn't parse trailing . +// * {@linkcode NPR.[|Consider|].This.show} +// */ +// export function outerref() { } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc index 2f86c46092..fc41d645a1 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc @@ -1,33 +1,105 @@ // === findAllReferences === // === /a.ts === // export class C { -// /*FIND ALL REFS*/constructor(n: number); -// constructor(); -// constructor(n?: number){} +// /*FIND ALL REFS*/[|constructor|](n: number); +// [|constructor|](); +// [|constructor|](n?: number){} // static f() { -// // --- (line: 6) skipped --- +// this.f(); +// new [|this|](); +// } +// } +// new [|C|](); +// const D = C; +// new D(); + +// === /b.ts === +// import { C } from "./a"; +// new [|C|](); + +// === /c.ts === +// import { C } from "./a"; +// class D extends C { +// constructor() { +// [|super|](); +// super.method(); +// } +// method() { super(); } +// // --- (line: 8) skipped --- + +// === /d.ts === +// import * as a from "./a"; +// new a.C(); +// class d extends a.C { constructor() { [|super|](); } // === findAllReferences === // === /a.ts === // export class C { -// constructor(n: number); -// /*FIND ALL REFS*/constructor(); -// constructor(n?: number){} +// [|constructor|](n: number); +// /*FIND ALL REFS*/[|constructor|](); +// [|constructor|](n?: number){} // static f() { // this.f(); -// // --- (line: 7) skipped --- +// new [|this|](); +// } +// } +// new [|C|](); +// const D = C; +// new D(); + +// === /b.ts === +// import { C } from "./a"; +// new [|C|](); + +// === /c.ts === +// import { C } from "./a"; +// class D extends C { +// constructor() { +// [|super|](); +// super.method(); +// } +// method() { super(); } +// // --- (line: 8) skipped --- + +// === /d.ts === +// import * as a from "./a"; +// new a.C(); +// class d extends a.C { constructor() { [|super|](); } // === findAllReferences === // === /a.ts === // export class C { -// constructor(n: number); -// constructor(); -// /*FIND ALL REFS*/constructor(n?: number){} +// [|constructor|](n: number); +// [|constructor|](); +// /*FIND ALL REFS*/[|constructor|](n?: number){} // static f() { // this.f(); -// new this(); -// // --- (line: 8) skipped --- \ No newline at end of file +// new [|this|](); +// } +// } +// new [|C|](); +// const D = C; +// new D(); + +// === /b.ts === +// import { C } from "./a"; +// new [|C|](); + +// === /c.ts === +// import { C } from "./a"; +// class D extends C { +// constructor() { +// [|super|](); +// super.method(); +// } +// method() { super(); } +// // --- (line: 8) skipped --- + +// === /d.ts === +// import * as a from "./a"; +// new a.C(); +// class d extends a.C { constructor() { [|super|](); } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor_badOverload.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor_badOverload.baseline.jsonc index 537d665657..9947e3cb5d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor_badOverload.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor_badOverload.baseline.jsonc @@ -1,8 +1,8 @@ // === findAllReferences === // === /findAllReferencesOfConstructor_badOverload.ts === // class C { -// /*FIND ALL REFS*/constructor(n: number); -// constructor(){} +// /*FIND ALL REFS*/[|constructor|](n: number); +// [|constructor|](){} // } @@ -10,6 +10,6 @@ // === findAllReferences === // === /findAllReferencesOfConstructor_badOverload.ts === // class C { -// constructor(n: number); -// /*FIND ALL REFS*/constructor(){} +// [|constructor|](n: number); +// /*FIND ALL REFS*/[|constructor|](){} // } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression0.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression0.baseline.jsonc index a080ea120c..29550fa58b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression0.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression0.baseline.jsonc @@ -1,9 +1,13 @@ // === findAllReferences === // === /a.ts === -// export = class /*FIND ALL REFS*/A { -// m() { A; } +// export = class /*FIND ALL REFS*/[|A|] { +// m() { [|A|]; } // }; +// === /b.ts === +// import [|A|] = require("./a"); +// [|A|]; + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression1.baseline.jsonc index 30b6befd3e..28ff6fba96 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassExpression1.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /a.js === -// module.exports = class /*FIND ALL REFS*/A {}; +// module.exports = class /*FIND ALL REFS*/[|A|] {}; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassWithStaticThisAccess.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassWithStaticThisAccess.baseline.jsonc index 6b2c6881a3..62eab0f718 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassWithStaticThisAccess.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsClassWithStaticThisAccess.baseline.jsonc @@ -1,10 +1,16 @@ // === findAllReferences === // === /findAllRefsClassWithStaticThisAccess.ts === -// class /*FIND ALL REFS*/C { +// class /*FIND ALL REFS*/[|C|] { // static s() { -// this; +// [|this|]; +// } +// static get f() { +// return [|this|]; +// +// function inner() { this; } +// class Inner { x = this; } // } -// // --- (line: 5) skipped --- +// } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc index a9656aba0e..a0e7b903e9 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsDeclareClass.baseline.jsonc @@ -8,6 +8,6 @@ // === findAllReferences === // === /findAllRefsDeclareClass.ts === -// declare class /*FIND ALL REFS*/C { +// declare class /*FIND ALL REFS*/[|C|] { // static m(): void; // } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc index 7753cfcbce..a7e3cdedf6 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport01.baseline.jsonc @@ -11,12 +11,12 @@ // === findAllReferences === // === /findAllRefsForDefaultExport01.ts === -// export default class /*FIND ALL REFS*/DefaultExportedClass { +// export default class /*FIND ALL REFS*/[|DefaultExportedClass|] { // } // -// var x: DefaultExportedClass; +// var x: [|DefaultExportedClass|]; // -// var y = new DefaultExportedClass; +// var y = new [|DefaultExportedClass|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsIsDefinition.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsIsDefinition.baseline.jsonc index 30e0fbdd46..b1d0fc3619 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsIsDefinition.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsIsDefinition.baseline.jsonc @@ -73,13 +73,15 @@ // === findAllReferences === // === /findAllRefsIsDefinition.ts === -// --- (line: 18) skipped --- +// --- (line: 16) skipped --- +// foo(): void; +// } // class Foo implements IFoo { -// constructor(n: number) -// constructor() -// /*FIND ALL REFS*/constructor(n: number?) { } +// [|constructor|](n: number) +// [|constructor|]() +// /*FIND ALL REFS*/[|constructor|](n: number?) { } // foo(): void { } -// static init() { return new this() } +// static init() { return new [|this|]() } // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor_withModifier.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor_withModifier.baseline.jsonc index 7986a7a190..1843c960f8 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor_withModifier.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOfConstructor_withModifier.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /findAllRefsOfConstructor_withModifier.ts === // class X { -// public /*FIND ALL REFS*/constructor() {} +// public /*FIND ALL REFS*/[|constructor|]() {} // } -// var x = new X(); \ No newline at end of file +// var x = new [|X|](); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases.baseline.jsonc index fc81fc9a66..0074e398ae 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases.baseline.jsonc @@ -1,8 +1,13 @@ // === findAllReferences === // === /a.ts === -// export class /*FIND ALL REFS*/Class { +// export class /*FIND ALL REFS*/[|Class|] { // } +// === /b.ts === +// import { [|Class|] } from "./a"; +// +// var c = new [|Class|](); + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases2.baseline.jsonc index 24264cbb57..78284dcace 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsOnImportAliases2.baseline.jsonc @@ -1,14 +1,14 @@ // === findAllReferences === +// === /a.ts === +// export class /*FIND ALL REFS*/[|Class|] {} + // === /b.ts === -// import { [|Class|] as C2 } from "./a"; -// var c = new C2(); +// import { [|Class|] as [|C2|] } from "./a"; +// var c = new [|C2|](); // === /c.ts === // export { [|Class|] as C3 } from "./a"; -// === /a.ts === -// export class /*FIND ALL REFS*/Class {} - // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc index 7353cd36d6..01bbfdfb3a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /findReferencesDefinitionDisplayParts.ts === -// class Gre/*FIND ALL REFS*/eter { +// class [|Gre/*FIND ALL REFS*/eter|] { // someFunction() { this; } // } // diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc index b4a92b4433..66aa26aa9b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfClass.baseline.jsonc @@ -10,11 +10,13 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfClass.ts === -// class /*FIND ALL REFS*/C { +// class /*FIND ALL REFS*/[|C|] { // n: number; // constructor() { // this.n = 12; -// // --- (line: 5) skipped --- +// } +// } +// let c = new [|C|](); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc index 149bb36401..0482d27845 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc @@ -73,15 +73,19 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfInterfaceClassMerge.ts === -// --- (line: 3) skipped --- -// interface Numbers { +// interface [|Numbers|] { +// p: number; +// } +// interface [|Numbers|] { // m: number; // } -// class /*FIND ALL REFS*/Numbers { +// class /*FIND ALL REFS*/[|Numbers|] { // f(n: number) { // return this.p + this.m + n; // } -// // --- (line: 11) skipped --- +// } +// let i: [|Numbers|] = new [|Numbers|](); +// let x = i.f(i.p + i.m); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/jsdocThrowsTag_findAllReferences.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/jsdocThrowsTag_findAllReferences.baseline.jsonc index e63335df14..d399b6dc09 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/jsdocThrowsTag_findAllReferences.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/jsdocThrowsTag_findAllReferences.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /jsdocThrowsTag_findAllReferences.ts === -// class /*FIND ALL REFS*/E extends Error {} +// class /*FIND ALL REFS*/[|E|] extends Error {} // /** // * @throws {E} // */ diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referenceToClass.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referenceToClass.baseline.jsonc index a2f1eee4ac..039a517c5f 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referenceToClass.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referenceToClass.baseline.jsonc @@ -1,10 +1,21 @@ // === findAllReferences === // === /referenceToClass_1.ts === -// class /*FIND ALL REFS*/foo { -// public n: foo; +// class /*FIND ALL REFS*/[|foo|] { +// public n: [|foo|]; // public foo: number; // } -// // --- (line: 5) skipped --- +// +// class bar { +// public n: [|foo|]; +// public k = new [|foo|](); +// } +// +// module mod { +// var k: [|foo|] = null; +// } + +// === /referenceToClass_2.ts === +// var k: [|foo|]; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc index 2d552fc3b6..31467511fe 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobals2.baseline.jsonc @@ -8,10 +8,13 @@ // === findAllReferences === // === /referencesForGlobals_1.ts === -// class /*FIND ALL REFS*/globalClass { +// class /*FIND ALL REFS*/[|globalClass|] { // public f() { } // } +// === /referencesForGlobals_2.ts === +// var c = [|globalClass|](); + // === findAllReferences === diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc index 763559f012..73e1bc6410 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForGlobalsInExternalModule.baseline.jsonc @@ -48,11 +48,12 @@ // var topLevelVar = 2; // var topLevelVar2 = topLevelVar; // -// class /*FIND ALL REFS*/topLevelClass { } -// var c = new topLevelClass(); +// class /*FIND ALL REFS*/[|topLevelClass|] { } +// var c = new [|topLevelClass|](); // // interface topLevelInterface { } -// // --- (line: 8) skipped --- +// var i: topLevelInterface; +// // --- (line: 9) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations3.baseline.jsonc index 9f6f4b5434..1fc1969780 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations3.baseline.jsonc @@ -22,8 +22,19 @@ // === findAllReferences === // === /referencesForMergedDeclarations3.ts === -// class /*FIND ALL REFS*/testClass { +// class /*FIND ALL REFS*/[|testClass|] { // static staticMethod() { } // method() { } // } -// // --- (line: 5) skipped --- \ No newline at end of file +// // --- (line: 5) skipped --- + +// --- (line: 8) skipped --- +// } +// } +// +// var c1: [|testClass|]; +// var c2: testClass.Bar; +// [|testClass|].staticMethod(); +// [|testClass|].prototype.method(); +// [|testClass|].bind(this); +// new [|testClass|](); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc index 70648e2d99..fc54de7f4b 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForMergedDeclarations4.baseline.jsonc @@ -10,11 +10,25 @@ // === findAllReferences === // === /referencesForMergedDeclarations4.ts === -// class /*FIND ALL REFS*/testClass { +// class /*FIND ALL REFS*/[|testClass|] { // static staticMethod() { } // method() { } // } -// // --- (line: 5) skipped --- +// +// module [|testClass|] { +// export interface Bar { +// +// } +// export var s = 0; +// } +// +// var c1: [|testClass|]; +// var c2: [|testClass|].Bar; +// [|testClass|].staticMethod(); +// [|testClass|].prototype.method(); +// [|testClass|].bind(this); +// [|testClass|].s; +// new [|testClass|](); diff --git a/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc index d67947baf9..2515a755e4 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/remoteGetReferences.baseline.jsonc @@ -773,14 +773,71 @@ // === findAllReferences === +// === /remoteGetReferences_1.ts === +// --- (line: 82) skipped --- +// +// //Remotes +// //Type test +// var remoteclsTest: [|remotefooCls|]; +// +// //Arguments +// remoteclsTest = new [|remotefooCls|](remoteglobalVar); +// remotefoo(remoteglobalVar); +// +// //Increments +// [|remotefooCls|].remoteclsSVar++; +// remotemodTest.remotemodVar++; +// remoteglobalVar = remoteglobalVar + remoteglobalVar; +// +// // --- (line: 97) skipped --- + // === /remoteGetReferences_2.ts === // var remoteglobalVar: number = 2; // -// class /*FIND ALL REFS*/remotefooCls { +// class /*FIND ALL REFS*/[|remotefooCls|] { // //Declare // remoteclsVar = 1; // static remoteclsSVar = 1; -// // --- (line: 7) skipped --- +// +// constructor(public remoteclsParam: number) { +// //Increments +// remoteglobalVar++; +// this.remoteclsVar++; +// [|remotefooCls|].remoteclsSVar++; +// this.remoteclsParam++; +// remotemodTest.remotemodVar++; +// } +// // --- (line: 16) skipped --- + +// --- (line: 19) skipped --- +// var remotefnVar = 1; +// +// //Increments +// [|remotefooCls|].remoteclsSVar++; +// remoteglobalVar++; +// remotemodTest.remotemodVar++; +// remotefnVar++; +// // --- (line: 27) skipped --- + +// --- (line: 34) skipped --- +// +// //Increments +// remoteglobalVar++; +// [|remotefooCls|].remoteclsSVar++; +// remotemodVar++; +// +// class remotetestCls { +// // --- (line: 42) skipped --- + +// --- (line: 46) skipped --- +// +// //Increments +// remoteglobalVar++; +// [|remotefooCls|].remoteclsSVar++; +// remotemodVar++; +// } +// +// // --- (line: 54) skipped --- diff --git a/testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc index 411bc485a0..4ae1126485 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc @@ -1,6 +1,11 @@ // === findAllReferences === +// === /A.ts === +// import [|B|] from "./B"; +// let b = new [|B|](); +// b.test(); + // === /B.ts === -// export default class /*FIND ALL REFS*/C { +// export default class /*FIND ALL REFS*/[|C|] { // test() { // } // } diff --git a/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports02.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports02.baseline.jsonc index 3a68efe58a..eab27fdda9 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports02.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports02.baseline.jsonc @@ -1,6 +1,6 @@ // === findAllReferences === // === /a.js === -// module.exports = class /*FIND ALL REFS*/A {} +// module.exports = class /*FIND ALL REFS*/[|A|] {} diff --git a/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports03.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports03.baseline.jsonc index aeb69b3d9b..e6aca1fc85 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports03.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/renameJsExports03.baseline.jsonc @@ -1,16 +1,16 @@ // === findAllReferences === // === /a.js === -// class /*FIND ALL REFS*/A { +// class /*FIND ALL REFS*/[|A|] { // constructor() { } // } -// module.exports = A; +// module.exports = [|A|]; // === findAllReferences === // === /a.js === // class A { -// /*FIND ALL REFS*/constructor() { } +// /*FIND ALL REFS*/[|constructor|]() { } // } // module.exports = A; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc index 4fea343433..a65332382e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/tsxFindAllReferences4.baseline.jsonc @@ -18,11 +18,14 @@ // } // interface ElementAttributesProperty { props } // } -// class /*FIND ALL REFS*/MyClass { +// class /*FIND ALL REFS*/[|MyClass|] { // props: { // name?: string; // size?: number; -// // --- (line: 11) skipped --- +// } +// +// +// var x = <[|MyClass|] name='hello'>; diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc index 72614e24d4..f96fbc5b1d 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc @@ -1,6 +1,6 @@ // === findRenameLocations === // === /findAllRefsClassWithStaticThisAccess.ts === -// class /*RENAME*/C { +// class /*RENAME*/[|CRENAME|] { // static s() { // this; // } diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc.diff index 444eee2131..29eec4cdc0 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsClassWithStaticThisAccess.baseline.jsonc.diff @@ -1,10 +1,6 @@ --- old.findAllRefsClassWithStaticThisAccess.baseline.jsonc +++ new.findAllRefsClassWithStaticThisAccess.baseline.jsonc -@@= skipped -0, +0 lines =@@ - // === findRenameLocations === - // === /findAllRefsClassWithStaticThisAccess.ts === --// class /*RENAME*/[|CRENAME|] { -+// class /*RENAME*/C { +@@= skipped -3, +3 lines =@@ // static s() { // this; // } diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc index 473b644781..ef489e4c5e 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc @@ -1,4 +1,7 @@ // === findRenameLocations === +// === /a.ts === +// export class /*RENAME*/[|ClassRENAME|] {} + // === /b.ts === // import { [|ClassRENAME|] as C2 } from "./a"; // var c = new C2(); @@ -6,9 +9,6 @@ // === /c.ts === // export { [|ClassRENAME|] as C3 } from "./a"; -// === /a.ts === -// export class /*RENAME*/Class {} - // === findRenameLocations === diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc.diff index b18e813f92..293d6126e0 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/findAllRefsOnImportAliases2.baseline.jsonc.diff @@ -1,22 +1,5 @@ --- old.findAllRefsOnImportAliases2.baseline.jsonc +++ new.findAllRefsOnImportAliases2.baseline.jsonc -@@= skipped -0, +0 lines =@@ - // === findRenameLocations === --// === /a.ts === --// export class /*RENAME*/[|ClassRENAME|] {} -- - // === /b.ts === - // import { [|ClassRENAME|] as C2 } from "./a"; - // var c = new C2(); - - // === /c.ts === - // export { [|ClassRENAME|] as C3 } from "./a"; -+ -+// === /a.ts === -+// export class /*RENAME*/Class {} - - - @@= skipped -52, +52 lines =@@ // === findRenameLocations === diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc index bb21cfb060..c7fe097fcc 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc @@ -1,6 +1,6 @@ // === findRenameLocations === // === /jsdocThrowsTag_rename.ts === -// class /*RENAME*/E extends Error {} +// class /*RENAME*/[|ERENAME|] extends Error {} // /** // * @throws {E} // */ diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc.diff index 97a325b8da..a579e74bae 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/jsdocThrowsTag_rename.baseline.jsonc.diff @@ -1,10 +1,8 @@ --- old.jsdocThrowsTag_rename.baseline.jsonc +++ new.jsdocThrowsTag_rename.baseline.jsonc -@@= skipped -0, +0 lines =@@ - // === findRenameLocations === +@@= skipped -1, +1 lines =@@ // === /jsdocThrowsTag_rename.ts === --// class /*RENAME*/[|ERENAME|] extends Error {} -+// class /*RENAME*/E extends Error {} + // class /*RENAME*/[|ERENAME|] extends Error {} // /** -// * @throws {[|ERENAME|]} +// * @throws {E} diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc index 48be1703e2..af74bffd51 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc @@ -1,6 +1,6 @@ // === findRenameLocations === // === /renameAlias3.ts === -// module SomeModule { export class /*RENAME*/SomeClass { } } +// module SomeModule { export class /*RENAME*/[|SomeClassRENAME|] { } } // import M = SomeModule; // import C = M.SomeClass; diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc.diff index c92d4b87ee..24d0d63d58 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAlias3.baseline.jsonc.diff @@ -1,10 +1,8 @@ --- old.renameAlias3.baseline.jsonc +++ new.renameAlias3.baseline.jsonc -@@= skipped -0, +0 lines =@@ - // === findRenameLocations === +@@= skipped -1, +1 lines =@@ // === /renameAlias3.ts === --// module SomeModule { export class /*RENAME*/[|SomeClassRENAME|] { } } -+// module SomeModule { export class /*RENAME*/SomeClass { } } + // module SomeModule { export class /*RENAME*/[|SomeClassRENAME|] { } } // import M = SomeModule; -// import C = M.[|SomeClassRENAME|]; +// import C = M.SomeClass; diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc index 316dd2000d..c9f18c5c49 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc @@ -1,6 +1,6 @@ // === findRenameLocations === // === /a.ts === -// module SomeModule { export class /*RENAME*/SomeClass { } } +// module SomeModule { export class /*RENAME*/[|SomeClassRENAME|] { } } // export = SomeModule; diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc.diff index a4dc9653a3..b3dc143222 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameAliasExternalModule3.baseline.jsonc.diff @@ -1,16 +1,13 @@ --- old.renameAliasExternalModule3.baseline.jsonc +++ new.renameAliasExternalModule3.baseline.jsonc -@@= skipped -0, +0 lines =@@ - // === findRenameLocations === - // === /a.ts === --// module SomeModule { export class /*RENAME*/[|SomeClassRENAME|] { } } -+// module SomeModule { export class /*RENAME*/SomeClass { } } +@@= skipped -2, +2 lines =@@ + // module SomeModule { export class /*RENAME*/[|SomeClassRENAME|] { } } // export = SomeModule; -- + -// === /b.ts === -// import M = require("./a"); -// import C = M.[|SomeClassRENAME|]; - +- // === findRenameLocations === diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc index fd986a30f5..3cde049d52 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc @@ -1,6 +1,6 @@ // === findRenameLocations === // === /B.ts === -// export default class /*RENAME*/C { +// export default class /*RENAME*/[|CRENAME|] { // test() { // } // } diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff index 0af855ef3f..f45fc22589 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff @@ -1,13 +1,5 @@ --- old.renameDefaultImportDifferentName.baseline.jsonc +++ new.renameDefaultImportDifferentName.baseline.jsonc -@@= skipped -0, +0 lines =@@ - // === findRenameLocations === - // === /B.ts === --// export default class /*RENAME*/[|CRENAME|] { -+// export default class /*RENAME*/C { - // test() { - // } - // } @@= skipped -19, +19 lines =@@ // import [|BRENAME|] from "./B"; // let b = new /*RENAME*/[|BRENAME|](); diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc index 0c2a544d01..906a20df00 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc @@ -1,10 +1,14 @@ // === findRenameLocations === // === /renameForDefaultExport01.ts === -// export default class /*RENAME*/DefaultExportedClass { +// export default class /*RENAME*/[|DefaultExportedClassRENAME|] { // } // /* // * Commenting DefaultExportedClass -// // --- (line: 5) skipped --- +// */ +// +// var x: [|DefaultExportedClassRENAME|]; +// +// var y = new [|DefaultExportedClassRENAME|]; diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc.diff index a70e604497..57beca9cff 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameForDefaultExport01.baseline.jsonc.diff @@ -4,19 +4,15 @@ // === findRenameLocations === - // === /renameForDefaultExport01.ts === --// export default class /*RENAME*/[|DefaultExportedClassRENAME|] { -+// export default class /*RENAME*/DefaultExportedClass { + // export default class /*RENAME*/[|DefaultExportedClassRENAME|] { // } // /* -// * Commenting [|DefaultExportedClassRENAME|] --// */ --// --// var x: [|DefaultExportedClassRENAME|]; --// --// var y = new [|DefaultExportedClassRENAME|]; +// * Commenting DefaultExportedClass -+// // --- (line: 5) skipped --- - + // */ + // + // var x: [|DefaultExportedClassRENAME|]; +@@= skipped -13, +12 lines =@@ // === findRenameLocations === @@ -30,7 +26,7 @@ // */ // // var x: /*RENAME*/[|DefaultExportedClassRENAME|]; -@@= skipped -28, +22 lines =@@ +@@= skipped -15, +14 lines =@@ // === findRenameLocations === diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc index 4146f1221e..176f9c4566 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc @@ -3,11 +3,17 @@ // class Foo { // } // -// var x = class /*RENAME*/Foo { +// var x = class /*RENAME*/[|FooRENAME|] { // doIt() { -// return Foo; +// return [|FooRENAME|]; +// } +// +// static doItStatically() { +// return [|FooRENAME|].y; // } -// // --- (line: 8) skipped --- +// } +// +// // --- (line: 14) skipped --- diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc.diff index 55e25fe61c..c2ad5857b3 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameLocationsForClassExpression01.baseline.jsonc.diff @@ -1,30 +1,17 @@ --- old.renameLocationsForClassExpression01.baseline.jsonc +++ new.renameLocationsForClassExpression01.baseline.jsonc -@@= skipped -2, +2 lines =@@ - // class Foo { +@@= skipped -12, +12 lines =@@ + // } // } // --// var x = class /*RENAME*/[|FooRENAME|] { -+// var x = class /*RENAME*/Foo { - // doIt() { --// return [|FooRENAME|]; --// } --// --// static doItStatically() { --// return [|FooRENAME|].y; --// } --// } --// -// var y = class { -// getSomeName() { -// --- (line: 16) skipped --- -+// return Foo; -+// } -+// // --- (line: 8) skipped --- ++// // --- (line: 14) skipped --- -@@= skipped -31, +23 lines =@@ +@@= skipped -21, +19 lines =@@ // } // } // diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc index 7ef8b355cb..93eaefdfbb 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc @@ -2,8 +2,8 @@ // @useAliasesForRename: true // === /renameModuleExportsProperties1.ts === -// class /*RENAME*/A {} -// module.exports = { A } +// class /*RENAME*/[|ARENAME|] {} +// module.exports = { /*START PREFIX*/A: [|ARENAME|] } diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc.diff deleted file mode 100644 index 90c5272879..0000000000 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties1.baseline.jsonc.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.renameModuleExportsProperties1.baseline.jsonc -+++ new.renameModuleExportsProperties1.baseline.jsonc -@@= skipped -1, +1 lines =@@ - // @useAliasesForRename: true - - // === /renameModuleExportsProperties1.ts === --// class /*RENAME*/[|ARENAME|] {} --// module.exports = { /*START PREFIX*/A: [|ARENAME|] } -+// class /*RENAME*/A {} -+// module.exports = { A } - - diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc index 5fb48b23de..848173961a 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc @@ -1,7 +1,7 @@ // === findRenameLocations === // === /renameModuleExportsProperties2.ts === -// class /*RENAME*/A {} -// module.exports = { B: A } +// class /*RENAME*/[|ARENAME|] {} +// module.exports = { B: [|ARENAME|] } diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc.diff deleted file mode 100644 index f83b1bfc70..0000000000 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties2.baseline.jsonc.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.renameModuleExportsProperties2.baseline.jsonc -+++ new.renameModuleExportsProperties2.baseline.jsonc -@@= skipped -0, +0 lines =@@ - // === findRenameLocations === - // === /renameModuleExportsProperties2.ts === --// class /*RENAME*/[|ARENAME|] {} --// module.exports = { B: [|ARENAME|] } -+// class /*RENAME*/A {} -+// module.exports = { B: A } - - diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc index a9d33a983c..d195c0d246 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc @@ -2,8 +2,8 @@ // @useAliasesForRename: true // === /a.js === -// class /*RENAME*/A {} -// module.exports = { A } +// class /*RENAME*/[|ARENAME|] {} +// module.exports = { /*START PREFIX*/A: [|ARENAME|] } diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc.diff deleted file mode 100644 index 747957ca57..0000000000 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameModuleExportsProperties3.baseline.jsonc.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.renameModuleExportsProperties3.baseline.jsonc -+++ new.renameModuleExportsProperties3.baseline.jsonc -@@= skipped -1, +1 lines =@@ - // @useAliasesForRename: true - - // === /a.js === --// class /*RENAME*/[|ARENAME|] {} --// module.exports = { /*START PREFIX*/A: [|ARENAME|] } -+// class /*RENAME*/A {} -+// module.exports = { A } - - From 2bf56b76b87537d6102d6a77c63ecc50895b7442 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 2 Oct 2025 19:46:46 -0700 Subject: [PATCH 13/15] more --- internal/ls/findallreferences.go | 56 ++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index 7446ab3384..5c94c36922 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -1199,21 +1199,21 @@ type refSearch struct { includes func(symbol *ast.Symbol) bool } -// type inheritKey struct { -// symbol *ast.Symbol -// parent *ast.Symbol -// } +type inheritKey struct { + symbol *ast.Symbol + parent *ast.Symbol +} type refState struct { sourceFiles []*ast.SourceFile sourceFilesSet *collections.Set[string] - specialSearchKind string // !!! none, constructor, class + specialSearchKind string // "none", "constructor", or "class" checker *checker.Checker // cancellationToken CancellationToken - searchMeaning ast.SemanticMeaning - options refOptions - result []*SymbolAndEntries - // inheritsFromCache map[inheritKey]bool + searchMeaning ast.SemanticMeaning + options refOptions + result []*SymbolAndEntries + inheritsFromCache map[inheritKey]bool seenContainingTypeReferences collections.Set[*ast.Node] // node seen tracker // seenReExportRHS *collections.Set[*ast.Node] // node seen tracker importTracker ImportTracker @@ -1229,7 +1229,7 @@ func newState(sourceFiles []*ast.SourceFile, sourceFilesSet *collections.Set[str checker: checker, searchMeaning: searchMeaning, options: options, - // inheritsFromCache: map[inheritKey]bool{}, + inheritsFromCache: map[inheritKey]bool{}, // seenReExportRHS: &collections.Set[*ast.Node]{}, symbolToReferences: map[*ast.Symbol]*SymbolAndEntries{}, sourceFileToSeenSymbols: map[*ast.SourceFile]*collections.Set[*ast.Symbol]{}, @@ -1281,7 +1281,6 @@ func (state *refState) createSearch(location *ast.Node, symbol *ast.Symbol, comi } func (state *refState) referenceAdder(searchSymbol *ast.Symbol) func(*ast.Node, entryKind) { - // !!! after find all references is fully implemented, rename this to something like 'getReferenceAdder' symbolAndEntries := state.symbolToReferences[searchSymbol] if symbolAndEntries == nil { symbolAndEntries = NewSymbolAndEntries(definitionKindSymbol, nil, searchSymbol, nil) @@ -1822,9 +1821,7 @@ func (state *refState) getRelatedSymbol(search *refSearch, referenceSymbol *ast. }, func(rootSymbol *ast.Symbol) bool { return !(len(search.parents) != 0 && !core.Some(search.parents, func(parent *ast.Symbol) bool { - return false - // !!! not implemented - // return state.explicitlyInheritsFrom(rootSymbol.Parent, parent) + return state.explicitlyInheritsFrom(rootSymbol.Parent, parent) })) }, ) @@ -1976,3 +1973,34 @@ func (state *refState) searchForName(sourceFile *ast.SourceFile, search *refSear state.getReferencesInSourceFile(sourceFile, search, true /*addReferencesHere*/) } } + +func (state *refState) explicitlyInheritsFrom(symbol *ast.Symbol, parent *ast.Symbol) bool { + if symbol == parent { + return true + } + + // Check cache first + key := inheritKey{symbol: symbol, parent: parent} + if cached, ok := state.inheritsFromCache[key]; ok { + return cached + } + + // Set to false initially to prevent infinite recursion + state.inheritsFromCache[key] = false + + if symbol.Declarations == nil { + return false + } + + inherits := core.Some(symbol.Declarations, func(declaration *ast.Node) bool { + superTypeNodes := getAllSuperTypeNodes(declaration) + return core.Some(superTypeNodes, func(typeReference *ast.TypeNode) bool { + typ := state.checker.GetTypeAtLocation(typeReference.AsNode()) + return typ != nil && typ.Symbol() != nil && state.explicitlyInheritsFrom(typ.Symbol(), parent) + }) + }) + + // Update cache with the actual result + state.inheritsFromCache[key] = inherits + return inherits +} From 17f2964f04990133cc57dfa035678f00a801ed38 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 2 Oct 2025 19:49:42 -0700 Subject: [PATCH 14/15] remove unused I guess --- .../findAllRefsForModule.baseline.jsonc | 9 - .../getOccurrencesIfElseBroken.baseline.jsonc | 57 -- ...ndAllRefsForDefaultExport03.baseline.jsonc | 25 - .../findAllRefsForModule.baseline.jsonc | 33 -- ...findAllRefsModuleDotExports.baseline.jsonc | 3 - ...erencesForStatementKeywords.baseline.jsonc | 505 ------------------ 6 files changed, 632 deletions(-) delete mode 100644 testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc diff --git a/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc deleted file mode 100644 index 35e8e3f07c..0000000000 --- a/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc +++ /dev/null @@ -1,9 +0,0 @@ -// === documentHighlights === -// === /b.ts === -// import { x } from "/*HIGHLIGHTS*/[|./a|]"; - - - -// === documentHighlights === -// === /c/sub.js === -// const a = require("/*HIGHLIGHTS*/[|../a|]"); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc deleted file mode 100644 index c1c381e16a..0000000000 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc +++ /dev/null @@ -1,57 +0,0 @@ -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// /*HIGHLIGHTS*/[|if|] (true) { -// var x = 1; -// } -// [|else if|] () -// [|else if|] -// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) -// else - - - -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// [|if|] (true) { -// var x = 1; -// } -// /*HIGHLIGHTS*/[|else if|] () -// [|else if|] -// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) -// else - - - -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// [|if|] (true) { -// var x = 1; -// } -// [|else if|] () -// /*HIGHLIGHTS*/[|else if|] -// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) -// else - - - -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// [|if|] (true) { -// var x = 1; -// } -// [|else if|] () -// [|else if|] -// /*HIGHLIGHTS*/[|else|] /* whar garbl */ [|if|] (if (true) { } else { }) -// else - - - -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// [|if|] (true) { -// var x = 1; -// } -// [|else if|] () -// [|else if|] -// [|else|] /* whar garbl */ /*HIGHLIGHTS*/[|if|] (if (true) { } else { }) -// else \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc deleted file mode 100644 index 04c0f47d08..0000000000 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc +++ /dev/null @@ -1,25 +0,0 @@ -// === findAllReferences === -// === /findAllRefsForDefaultExport03.ts === -// /*FIND ALL REFS*/function f() { -// return 100; -// } -// -// // --- (line: 5) skipped --- - - - -// === findAllReferences === -// === /findAllRefsForDefaultExport03.ts === -// function /*FIND ALL REFS*/[|f|]() { -// return 100; -// } -// -// export default [|f|]; -// -// var x: typeof [|f|]; -// -// var y = [|f|](); -// -// namespace [|f|] { -// var local = 100; -// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc deleted file mode 100644 index 9ffdfecb1a..0000000000 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc +++ /dev/null @@ -1,33 +0,0 @@ -// === findAllReferences === -// === /b.ts === -// import { x } from "/*FIND ALL REFS*/[|./a|]"; - -// === /c/sub.js === -// const a = require("[|../a|]"); - -// === /d.ts === -// /// [||] - - - -// === findAllReferences === -// === /b.ts === -// import { x } from "[|./a|]"; - -// === /c/sub.js === -// const a = require("/*FIND ALL REFS*/[|../a|]"); - -// === /d.ts === -// /// [||] - - - -// === findAllReferences === -// === /b.ts === -// import { x } from "[|./a|]"; - -// === /c/sub.js === -// const a = require("[|../a|]"); - -// === /d.ts === -// /// [||] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc deleted file mode 100644 index ff5bbc30c4..0000000000 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc +++ /dev/null @@ -1,3 +0,0 @@ -// === findAllReferences === -// === /a.js === -// /*FIND ALL REFS*/const b = require("./b"); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc deleted file mode 100644 index f922007bc3..0000000000 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc +++ /dev/null @@ -1,505 +0,0 @@ -// === findAllReferences === -// === /main.ts === -// // import ... = ... -// /*FIND ALL REFS*/import A = require("./a"); -// namespace N { } -// import N2 = N; -// -// // --- (line: 6) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// // import ... = ... -// import A = /*FIND ALL REFS*/require("./a"); -// namespace N { } -// import N2 = N; -// -// // --- (line: 6) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// // import ... = ... -// import A = require("./a"); -// namespace N { } -// /*FIND ALL REFS*/import N2 = N; -// -// // import ... from ... -// import type B from "./b"; -// // --- (line: 8) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 3) skipped --- -// import N2 = N; -// -// // import ... from ... -// /*FIND ALL REFS*/import type B from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// // --- (line: 11) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 3) skipped --- -// import N2 = N; -// -// // import ... from ... -// import /*FIND ALL REFS*/type B from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// // --- (line: 11) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 3) skipped --- -// import N2 = N; -// -// // import ... from ... -// import type B /*FIND ALL REFS*/from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// // --- (line: 11) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 4) skipped --- -// -// // import ... from ... -// import type B from "./b"; -// /*FIND ALL REFS*/import type * as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // --- (line: 12) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 4) skipped --- -// -// // import ... from ... -// import type B from "./b"; -// import /*FIND ALL REFS*/type * as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // --- (line: 12) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 4) skipped --- -// -// // import ... from ... -// import type B from "./b"; -// import type * /*FIND ALL REFS*/as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // --- (line: 12) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 4) skipped --- -// -// // import ... from ... -// import type B from "./b"; -// import type * as C /*FIND ALL REFS*/from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // --- (line: 12) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 5) skipped --- -// // import ... from ... -// import type B from "./b"; -// import type * as C from "./c"; -// /*FIND ALL REFS*/import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // import "module" -// // --- (line: 13) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 5) skipped --- -// // import ... from ... -// import type B from "./b"; -// import type * as C from "./c"; -// import /*FIND ALL REFS*/type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // import "module" -// // --- (line: 13) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 5) skipped --- -// // import ... from ... -// import type B from "./b"; -// import type * as C from "./c"; -// import type { D } /*FIND ALL REFS*/from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // import "module" -// // --- (line: 13) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 6) skipped --- -// import type B from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// /*FIND ALL REFS*/import type { e1, e2 as e3 } from "./e"; -// -// // import "module" -// import "./f"; -// // --- (line: 14) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 6) skipped --- -// import type B from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// import /*FIND ALL REFS*/type { e1, e2 as e3 } from "./e"; -// -// // import "module" -// import "./f"; -// // --- (line: 14) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 6) skipped --- -// import type B from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } /*FIND ALL REFS*/from "./e"; -// -// // import "module" -// import "./f"; -// // --- (line: 14) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 6) skipped --- -// import type B from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 /*FIND ALL REFS*/as e3 } from "./e"; -// -// // import "module" -// import "./f"; -// // --- (line: 14) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 9) skipped --- -// import type { e1, e2 as e3 } from "./e"; -// -// // import "module" -// /*FIND ALL REFS*/import "./f"; -// -// // export ... from ... -// export type * from "./g"; -// // --- (line: 17) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 12) skipped --- -// import "./f"; -// -// // export ... from ... -// /*FIND ALL REFS*/export type * from "./g"; -// export type * as H from "./h"; -// export type { I } from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// // --- (line: 20) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 12) skipped --- -// import "./f"; -// -// // export ... from ... -// export /*FIND ALL REFS*/type * from "./g"; -// export type * as H from "./h"; -// export type { I } from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// // --- (line: 20) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 12) skipped --- -// import "./f"; -// -// // export ... from ... -// export type * /*FIND ALL REFS*/from "./g"; -// export type * as H from "./h"; -// export type { I } from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// // --- (line: 20) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 13) skipped --- -// -// // export ... from ... -// export type * from "./g"; -// /*FIND ALL REFS*/export type * as H from "./h"; -// export type { I } from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// type Z1 = 1; -// // --- (line: 21) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 13) skipped --- -// -// // export ... from ... -// export type * from "./g"; -// export /*FIND ALL REFS*/type * as H from "./h"; -// export type { I } from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// type Z1 = 1; -// // --- (line: 21) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 13) skipped --- -// -// // export ... from ... -// export type * from "./g"; -// export type * /*FIND ALL REFS*/as H from "./h"; -// export type { I } from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// type Z1 = 1; -// // --- (line: 21) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 13) skipped --- -// -// // export ... from ... -// export type * from "./g"; -// export type * as H /*FIND ALL REFS*/from "./h"; -// export type { I } from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// type Z1 = 1; -// // --- (line: 21) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 14) skipped --- -// // export ... from ... -// export type * from "./g"; -// export type * as H from "./h"; -// /*FIND ALL REFS*/export type { I } from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// type Z1 = 1; -// export type { Z1 }; -// // --- (line: 22) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 14) skipped --- -// // export ... from ... -// export type * from "./g"; -// export type * as H from "./h"; -// export /*FIND ALL REFS*/type { I } from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// type Z1 = 1; -// export type { Z1 }; -// // --- (line: 22) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 14) skipped --- -// // export ... from ... -// export type * from "./g"; -// export type * as H from "./h"; -// export type { I } /*FIND ALL REFS*/from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// type Z1 = 1; -// export type { Z1 }; -// // --- (line: 22) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 15) skipped --- -// export type * from "./g"; -// export type * as H from "./h"; -// export type { I } from "./i"; -// /*FIND ALL REFS*/export type { j1, j2 as j3 } from "./j"; -// type Z1 = 1; -// export type { Z1 }; -// type Z2 = 2; -// type Z3 = 3; -// export type { z2, z3 as z4 }; - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 15) skipped --- -// export type * from "./g"; -// export type * as H from "./h"; -// export type { I } from "./i"; -// export /*FIND ALL REFS*/type { j1, j2 as j3 } from "./j"; -// type Z1 = 1; -// export type { Z1 }; -// type Z2 = 2; -// type Z3 = 3; -// export type { z2, z3 as z4 }; - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 15) skipped --- -// export type * from "./g"; -// export type * as H from "./h"; -// export type { I } from "./i"; -// export type { j1, j2 as j3 } /*FIND ALL REFS*/from "./j"; -// type Z1 = 1; -// export type { Z1 }; -// type Z2 = 2; -// type Z3 = 3; -// export type { z2, z3 as z4 }; - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 15) skipped --- -// export type * from "./g"; -// export type * as H from "./h"; -// export type { I } from "./i"; -// export type { j1, j2 /*FIND ALL REFS*/as j3 } from "./j"; -// type Z1 = 1; -// export type { Z1 }; -// type Z2 = 2; -// type Z3 = 3; -// export type { z2, z3 as z4 }; - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 17) skipped --- -// export type { I } from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// type Z1 = 1; -// /*FIND ALL REFS*/export type { Z1 }; -// type Z2 = 2; -// type Z3 = 3; -// export type { z2, z3 as z4 }; - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 17) skipped --- -// export type { I } from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// type Z1 = 1; -// export /*FIND ALL REFS*/type { Z1 }; -// type Z2 = 2; -// type Z3 = 3; -// export type { z2, z3 as z4 }; - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 20) skipped --- -// export type { Z1 }; -// type Z2 = 2; -// type Z3 = 3; -// /*FIND ALL REFS*/export type { z2, z3 as z4 }; - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 20) skipped --- -// export type { Z1 }; -// type Z2 = 2; -// type Z3 = 3; -// export /*FIND ALL REFS*/type { z2, z3 as z4 }; - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 20) skipped --- -// export type { Z1 }; -// type Z2 = 2; -// type Z3 = 3; -// export type { z2, z3 /*FIND ALL REFS*/as z4 }; - - - -// === findAllReferences === -// === /main2.ts === -// const x = {}; -// /*FIND ALL REFS*/[|export = x;|] \ No newline at end of file From ebb33b670ae299b886fb3d60637e3004d8a9f3a9 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 3 Oct 2025 11:44:24 -0700 Subject: [PATCH 15/15] Just a bit more --- internal/ls/documenthighlights.go | 3 +- internal/ls/findallreferences.go | 52 ++++++++++++++++--- .../findAllRefsExportEquals.baseline.jsonc | 4 +- ...ailableThroughGlobalNoCrash.baseline.jsonc | 2 +- 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/internal/ls/documenthighlights.go b/internal/ls/documenthighlights.go index d536e2e744..8469c0935d 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -47,8 +47,7 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen documentHighlights = l.getSyntacticDocumentHighlights(node, sourceFile) } // if nil is passed here we never generate an error, just pass an empty higlight - resp := lsproto.DocumentHighlightsOrNull{DocumentHighlights: &documentHighlights} - return resp, nil + return lsproto.DocumentHighlightsOrNull{DocumentHighlights: &documentHighlights}, nil } func (l *LanguageService) getSemanticDocumentHighlights(ctx context.Context, position int, node *ast.Node, program *compiler.Program, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index 5c94c36922..259e091bbd 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -973,6 +973,33 @@ func getPossibleSymbolReferencePositions(sourceFile *ast.SourceFile, symbolName return positions } +// findFirstJsxNode recursively searches for the first JSX element, self-closing element, or fragment +func findFirstJsxNode(root *ast.Node) *ast.Node { + var visit func(*ast.Node) *ast.Node + visit = func(node *ast.Node) *ast.Node { + // Check if this is a JSX node we're looking for + switch node.Kind { + case ast.KindJsxElement, ast.KindJsxSelfClosingElement, ast.KindJsxFragment: + return node + } + + // Skip subtree if it doesn't contain JSX + if node.SubtreeFacts()&ast.SubtreeContainsJsx == 0 { + return nil + } + + // Traverse children to find JSX node + var result *ast.Node + node.ForEachChild(func(child *ast.Node) bool { + result = visit(child) + return result != nil // Stop if found + }) + return result + } + + return visit(root) +} + func getReferencesForNonModule(referencedFile *ast.SourceFile, program *compiler.Program) []*referenceEntry { // !!! not implemented return []*referenceEntry{} @@ -1013,13 +1040,21 @@ func getReferencedSymbolsForModule(ctx context.Context, program *compiler.Progra // import("foo") with no qualifier will reference the `export =` of the module, which may be referenced anyway. return newNodeEntry(reference.literal) case ModuleReferenceKindImplicit: - // For implicit references (e.g., JSX runtime imports), return the first statement or the whole file. - // We skip the complex JSX detection for now and just use the first statement or the file itself. + // For implicit references (e.g., JSX runtime imports), return the first JSX node, + // the first statement, or the whole file var rangeNode *ast.Node - if reference.referencingFile.Statements != nil && len(reference.referencingFile.Statements.Nodes) > 0 { - rangeNode = reference.referencingFile.Statements.Nodes[0] - } else { - rangeNode = reference.referencingFile.AsNode() + + // Skip the JSX search for tslib imports + if reference.literal.Text() != "tslib" { + rangeNode = findFirstJsxNode(reference.referencingFile.AsNode()) + } + + if rangeNode == nil { + if reference.referencingFile.Statements != nil && len(reference.referencingFile.Statements.Nodes) > 0 { + rangeNode = reference.referencingFile.Statements.Nodes[0] + } else { + rangeNode = reference.referencingFile.AsNode() + } } return newNodeEntry(rangeNode) case ModuleReferenceKindReference: @@ -1060,8 +1095,9 @@ func getReferencedSymbolsForModule(ctx context.Context, program *compiler.Progra if ast.IsBinaryExpression(decl) && ast.IsPropertyAccessExpression(decl.AsBinaryExpression().Left) { node = decl.AsBinaryExpression().Left.AsPropertyAccessExpression().Expression } else if ast.IsExportAssignment(decl) { - // Find the export keyword - for now, just use the declaration itself - node = decl + // Find the export keyword + node = findChildOfKind(decl, ast.KindExportKeyword, sourceFile) + debug.Assert(node != nil, "Expected to find export keyword") } else { node = ast.GetNameOfDeclaration(decl) if node == nil { diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc index 2dad021159..3734653d91 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsExportEquals.baseline.jsonc @@ -8,7 +8,7 @@ // === findAllReferences === // === /a.ts === // type T = number; -// /*FIND ALL REFS*/[|export = T;|] +// /*FIND ALL REFS*/[|export|] = T; // === /b.ts === // import T = require("[|./a|]"); @@ -38,7 +38,7 @@ // === findAllReferences === // === /a.ts === // type [|T|] = number; -// [|export = [|T|];|] +// [|export|] = [|T|]; // === /b.ts === // import [|T|] = require("/*FIND ALL REFS*/[|./a|]"); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc index 0cc4913a20..9ae5412973 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts === // declare var [|debug|]: [|debug|].Debug & { debug: [|debug|].Debug; default: [|debug|].Debug }; -// [|export = [|debug|];|] +// [|export|] = [|debug|]; // export as namespace debug; // declare namespace [|debug|] { // interface Debug {