-
Notifications
You must be signed in to change notification settings - Fork 749
Implementations, CodeLens, IncomingCalls across projects #2235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sheetalkamat
wants to merge
17
commits into
main
Choose a base branch
from
multiProjectImpl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7636405
Test
sheetalkamat c3b1ef0
Implementations across projects
sheetalkamat 46cb8a9
Test for codelens
sheetalkamat d2979e0
Refactor
sheetalkamat 982d122
Code lens to use the commands for references and implementations
sheetalkamat 26c20af
Rename
sheetalkamat ab6b577
rename function
sheetalkamat 7f752c7
Refactor to set
sheetalkamat 1bddd75
Fix per feedback
sheetalkamat 51d1de9
Fix incorrect fn use
sheetalkamat 9aca74f
refactor to use ls methods
sheetalkamat d9c40d3
Move the orchestrating to ls package
sheetalkamat d3ffd88
Remove duplicate
sheetalkamat 51eadd5
Test
sheetalkamat ad49351
Multi project incoming calls
sheetalkamat 61388d6
Fix recover
sheetalkamat 416e888
Merge branch 'main' into multiProjectImpl
sheetalkamat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| package fourslash_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/microsoft/typescript-go/internal/fourslash" | ||
| "github.com/microsoft/typescript-go/internal/testutil" | ||
| ) | ||
|
|
||
| func TestCallHierarchyAcrossProject(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| defer testutil.RecoverAndFail(t, "Panic on fourslash test") | ||
| const content = ` | ||
| // @stateBaseline: true | ||
| // @Filename: /projects/temp/temp.ts | ||
| /*temp*/let x = 10 | ||
| // @Filename: /projects/temp/tsconfig.json | ||
| {} | ||
| // @Filename: /projects/container/lib/tsconfig.json | ||
| { | ||
| "compilerOptions": { | ||
| "composite": true, | ||
| }, | ||
| references: [], | ||
| files: [ | ||
| "index.ts", | ||
| "bar.ts", | ||
| "baz.ts" | ||
| ], | ||
| } | ||
| // @Filename: /projects/container/lib/index.ts | ||
| export function /*call*/createModelReference() {} | ||
| // @Filename: /projects/container/lib/bar.ts | ||
| import { createModelReference } from "./index"; | ||
| function openElementsAtEditor() { | ||
| createModelReference(); | ||
| } | ||
| // @Filename: /projects/container/lib/baz.ts | ||
| import { createModelReference } from "./index"; | ||
| function registerDefaultLanguageCommand() { | ||
| createModelReference(); | ||
| } | ||
| // @Filename: /projects/container/exec/tsconfig.json | ||
| { | ||
| "files": ["./index.ts"], | ||
| "references": [ | ||
| { "path": "../lib" }, | ||
| ], | ||
| } | ||
| // @Filename: /projects/container/exec/index.ts | ||
| import { createModelReference } from "../lib"; | ||
| function openElementsAtEditor1() { | ||
| createModelReference(); | ||
| } | ||
| // @Filename: /projects/container/compositeExec/tsconfig.json | ||
| { | ||
| "compilerOptions": { | ||
| "composite": true, | ||
| }, | ||
| "files": ["./index.ts"], | ||
| "references": [ | ||
| { "path": "../lib" }, | ||
| ], | ||
| } | ||
| // @Filename: /projects/container/compositeExec/index.ts | ||
| import { createModelReference } from "../lib"; | ||
| function openElementsAtEditor2() { | ||
| createModelReference(); | ||
| } | ||
| // @Filename: /projects/container/tsconfig.json | ||
| { | ||
| "files": [], | ||
| "include": [], | ||
| "references": [ | ||
| { "path": "./exec" }, | ||
| { "path": "./compositeExec" }, | ||
| ], | ||
| } | ||
| // @Filename: /projects/container/tsconfig.json | ||
| { | ||
| "files": [], | ||
| "include": [], | ||
| "references": [ | ||
| { "path": "./exec" }, | ||
| { "path": "./compositeExec" }, | ||
| ], | ||
| } | ||
| // @Filename: /projects/container/tsconfig.json | ||
| { | ||
| "files": [], | ||
| "include": [], | ||
| "references": [ | ||
| { "path": "./exec" }, | ||
| { "path": "./compositeExec" }, | ||
| ], | ||
| }` | ||
| f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) | ||
| defer done() | ||
| f.GoToMarker(t, "call") | ||
| // Open temp file and verify all projects alive | ||
| f.GoToMarker(t, "temp") | ||
|
|
||
| // Ref projects are loaded after as part of this command | ||
| f.GoToMarker(t, "call") | ||
| f.VerifyBaselineCallHierarchy(t) | ||
|
|
||
| // Open temp file and verify all projects alive | ||
| f.CloseFileOfMarker(t, "temp") | ||
| f.GoToMarker(t, "temp") | ||
|
|
||
| // Close all files and open temp file, only inferred project should be alive | ||
| f.CloseFileOfMarker(t, "call") | ||
| f.CloseFileOfMarker(t, "temp") | ||
| f.GoToMarker(t, "temp") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| package fourslash_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/microsoft/typescript-go/internal/fourslash" | ||
| "github.com/microsoft/typescript-go/internal/ls/lsutil" | ||
| "github.com/microsoft/typescript-go/internal/testutil" | ||
| ) | ||
|
|
||
| func TestCodeLensAcrossProjects(t *testing.T) { | ||
| t.Parallel() | ||
| defer testutil.RecoverAndFail(t, "Panic on fourslash test") | ||
| content := ` | ||
| // @stateBaseline: true | ||
| // @Filename: /projects/temp/temp.ts | ||
| /*temp*/let x = 10 | ||
| // @Filename: /projects/temp/tsconfig.json | ||
| {} | ||
| // @Filename: /projects/container/lib/tsconfig.json | ||
| { | ||
| "compilerOptions": { | ||
| "composite": true, | ||
| }, | ||
| references: [], | ||
| files: [ | ||
| "index.ts", | ||
| "bar.ts" | ||
| ], | ||
| } | ||
| // @Filename: /projects/container/lib/index.ts | ||
| /*impl*/ | ||
| export interface Pointable { | ||
| getX(): number; | ||
| getY(): number; | ||
| } | ||
| export const val = 42; | ||
| // @Filename: /projects/container/lib/bar.ts | ||
| import { Pointable } from "./index"; | ||
| class Point implements Pointable { | ||
| getX(): number { | ||
| return 0; | ||
| } | ||
| getY(): number { | ||
| return 0; | ||
| } | ||
| } | ||
| // @Filename: /projects/container/exec/tsconfig.json | ||
| { | ||
| "files": ["./index.ts"], | ||
| "references": [ | ||
| { "path": "../lib" }, | ||
| ], | ||
| } | ||
| // @Filename: /projects/container/exec/index.ts | ||
| import { Pointable } from "../lib"; | ||
| class Point1 implements Pointable { | ||
| getX(): number { | ||
| return 0; | ||
| } | ||
| getY(): number { | ||
| return 0; | ||
| } | ||
| } | ||
| // @Filename: /projects/container/compositeExec/tsconfig.json | ||
| { | ||
| "compilerOptions": { | ||
| "composite": true, | ||
| }, | ||
| "files": ["./index.ts"], | ||
| "references": [ | ||
| { "path": "../lib" }, | ||
| ], | ||
| } | ||
| // @Filename: /projects/container/compositeExec/index.ts | ||
| import { Pointable } from "../lib"; | ||
| class Point2 implements Pointable { | ||
| getX(): number { | ||
| return 0; | ||
| } | ||
| getY(): number { | ||
| return 0; | ||
| } | ||
| } | ||
| // @Filename: /projects/container/tsconfig.json | ||
| { | ||
| "files": [], | ||
| "include": [], | ||
| "references": [ | ||
| { "path": "./exec" }, | ||
| { "path": "./compositeExec" }, | ||
| ], | ||
| } | ||
| // @Filename: /projects/container/tsconfig.json | ||
| { | ||
| "files": [], | ||
| "include": [], | ||
| "references": [ | ||
| { "path": "./exec" }, | ||
| { "path": "./compositeExec" }, | ||
| ], | ||
| } | ||
| // @Filename: /projects/container/tsconfig.json | ||
| { | ||
| "files": [], | ||
| "include": [], | ||
| "references": [ | ||
| { "path": "./exec" }, | ||
| { "path": "./compositeExec" }, | ||
| ], | ||
| } | ||
| ` | ||
| f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) | ||
| defer done() | ||
| f.GoToMarker(t, "impl") | ||
| // Open temp file and verify all projects alive | ||
| f.GoToMarker(t, "temp") | ||
|
|
||
| // Ref projects are loaded after as part of this command | ||
| f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{ | ||
| CodeLens: lsutil.CodeLensUserPreferences{ | ||
| ReferencesCodeLensEnabled: true, | ||
| ReferencesCodeLensShowOnAllFunctions: true, | ||
|
|
||
| ImplementationsCodeLensEnabled: true, | ||
| ImplementationsCodeLensShowOnInterfaceMethods: true, | ||
| ImplementationsCodeLensShowOnAllClassMethods: true, | ||
| }, | ||
| }) | ||
|
|
||
| // Open temp file and verify all projects alive | ||
| f.CloseFileOfMarker(t, "temp") | ||
| f.GoToMarker(t, "temp") | ||
|
|
||
| // Close all files and open temp file, only inferred project should be alive | ||
| f.CloseFileOfMarker(t, "impl") | ||
| f.CloseFileOfMarker(t, "temp") | ||
| f.GoToMarker(t, "temp") | ||
| } | ||
|
|
||
| func TestCodeLensOnFunctionAcrossProjects1(t *testing.T) { | ||
| t.Parallel() | ||
| defer testutil.RecoverAndFail(t, "Panic on fourslash test") | ||
| const content = ` | ||
| // @filename: ./a/tsconfig.json | ||
| { | ||
| "compilerOptions": { | ||
| "composite": true, | ||
| "declaration": true, | ||
| "declarationMaps": true, | ||
| "outDir": "./dist", | ||
| "rootDir": "src" | ||
| }, | ||
| "include": ["./src"] | ||
| } | ||
|
|
||
| // @filename: ./a/src/foo.ts | ||
| export function aaa() {} | ||
| aaa(); | ||
|
|
||
| // @filename: ./b/tsconfig.json | ||
| { | ||
| "compilerOptions": { | ||
| "composite": true, | ||
| "declaration": true, | ||
| "declarationMaps": true, | ||
| "outDir": "./dist", | ||
| "rootDir": "src" | ||
| }, | ||
| "references": [{ "path": "../a" }], | ||
| "include": ["./src"] | ||
| } | ||
|
|
||
| // @filename: ./b/src/bar.ts | ||
| import * as foo from '../../a/dist/foo.js'; | ||
| foo.aaa(); | ||
| ` | ||
| f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) | ||
| defer done() | ||
|
|
||
| f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{ | ||
| CodeLens: lsutil.CodeLensUserPreferences{ | ||
| ReferencesCodeLensEnabled: true, | ||
| }, | ||
| }) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.