Skip to content

Commit 51eadd5

Browse files
committed
Test
1 parent d3ffd88 commit 51eadd5

File tree

2 files changed

+558
-0
lines changed

2 files changed

+558
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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/testutil"
8+
)
9+
10+
func TestCallHierarchyAcrossProject(t *testing.T) {
11+
t.Parallel()
12+
13+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
14+
const content = `
15+
// @stateBaseline: true
16+
// @Filename: /projects/temp/temp.ts
17+
/*temp*/let x = 10
18+
// @Filename: /projects/temp/tsconfig.json
19+
{}
20+
// @Filename: /projects/container/lib/tsconfig.json
21+
{
22+
"compilerOptions": {
23+
"composite": true,
24+
},
25+
references: [],
26+
files: [
27+
"index.ts",
28+
"bar.ts",
29+
"baz.ts"
30+
],
31+
}
32+
// @Filename: /projects/container/lib/index.ts
33+
export function /*call*/createModelReference() {}
34+
// @Filename: /projects/container/lib/bar.ts
35+
import { createModelReference } from "./index";
36+
function openElementsAtEditor() {
37+
createModelReference();
38+
}
39+
// @Filename: /projects/container/lib/baz.ts
40+
import { createModelReference } from "./index";
41+
function registerDefaultLanguageCommand() {
42+
createModelReference();
43+
}
44+
// @Filename: /projects/container/exec/tsconfig.json
45+
{
46+
"files": ["./index.ts"],
47+
"references": [
48+
{ "path": "../lib" },
49+
],
50+
}
51+
// @Filename: /projects/container/exec/index.ts
52+
import { createModelReference } from "../lib";
53+
function openElementsAtEditor1() {
54+
createModelReference();
55+
}
56+
// @Filename: /projects/container/compositeExec/tsconfig.json
57+
{
58+
"compilerOptions": {
59+
"composite": true,
60+
},
61+
"files": ["./index.ts"],
62+
"references": [
63+
{ "path": "../lib" },
64+
],
65+
}
66+
// @Filename: /projects/container/compositeExec/index.ts
67+
import { createModelReference } from "../lib";
68+
function openElementsAtEditor2() {
69+
createModelReference();
70+
}
71+
// @Filename: /projects/container/tsconfig.json
72+
{
73+
"files": [],
74+
"include": [],
75+
"references": [
76+
{ "path": "./exec" },
77+
{ "path": "./compositeExec" },
78+
],
79+
}
80+
// @Filename: /projects/container/tsconfig.json
81+
{
82+
"files": [],
83+
"include": [],
84+
"references": [
85+
{ "path": "./exec" },
86+
{ "path": "./compositeExec" },
87+
],
88+
}
89+
// @Filename: /projects/container/tsconfig.json
90+
{
91+
"files": [],
92+
"include": [],
93+
"references": [
94+
{ "path": "./exec" },
95+
{ "path": "./compositeExec" },
96+
],
97+
}`
98+
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
99+
defer done()
100+
f.GoToMarker(t, "call")
101+
// Open temp file and verify all projects alive
102+
f.GoToMarker(t, "temp")
103+
104+
// Ref projects are loaded after as part of this command
105+
f.GoToMarker(t, "call")
106+
f.VerifyBaselineCallHierarchy(t)
107+
108+
// Open temp file and verify all projects alive
109+
f.CloseFileOfMarker(t, "temp")
110+
f.GoToMarker(t, "temp")
111+
112+
// Close all files and open temp file, only inferred project should be alive
113+
f.CloseFileOfMarker(t, "call")
114+
f.CloseFileOfMarker(t, "temp")
115+
f.GoToMarker(t, "temp")
116+
}

0 commit comments

Comments
 (0)