Skip to content

Commit 5ec5a0b

Browse files
Add comprehensive LocationLink end-to-end test
- Created TestLocationLinkEndToEnd to validate full functionality - Test uses client capabilities with LinkSupport enabled - Verifies that cross-file go-to-definition works with LocationLink format - Demonstrates proper integration between server, client capabilities, and definition provider Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
1 parent 34b1eb8 commit 5ec5a0b

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package fourslash_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/microsoft/typescript-go/internal/fourslash"
7+
"github.com/microsoft/typescript-go/internal/lsp/lsproto"
8+
"github.com/microsoft/typescript-go/internal/testutil"
9+
)
10+
11+
func TestLocationLinkEndToEnd(t *testing.T) {
12+
t.Parallel()
13+
14+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
15+
const content = `// @Filename: types.ts
16+
export interface [|/*def*/Person|] {
17+
name: string;
18+
age: number;
19+
}
20+
21+
export function createPerson(name: string, age: number): Person {
22+
return { name, age };
23+
}
24+
25+
// @Filename: main.ts
26+
import { /*usage*/Person, createPerson } from "./types";
27+
28+
const john: Person = createPerson("John", 30);`
29+
30+
// Test with LinkSupport enabled
31+
linkSupport := true
32+
capabilities := &lsproto.ClientCapabilities{
33+
TextDocument: &lsproto.TextDocumentClientCapabilities{
34+
Definition: &lsproto.DefinitionClientCapabilities{
35+
LinkSupport: &linkSupport,
36+
},
37+
},
38+
}
39+
40+
f := fourslash.NewFourslash(t, capabilities, content)
41+
42+
// Verify that going to definition from "usage" marker works
43+
// and returns LocationLink format when client supports it
44+
f.VerifyBaselineGoToDefinition(t, "usage")
45+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// === goToDefinition ===
2+
// === /types.ts ===
3+
4+
// export interface [|Person|] {
5+
// name: string;
6+
// age: number;
7+
// }
8+
// // --- (line: 5) skipped ---
9+
10+
11+
// === /main.ts ===
12+
13+
// import { /*GO TO DEFINITION*/Person, createPerson } from "./types";
14+
//
15+
// const john: Person = createPerson("John", 30);

0 commit comments

Comments
 (0)