Skip to content

Commit 4039146

Browse files
committed
Merge pull request #8266 from Microsoft/FixGlobalTSServerOprations
Fix global ts server operations in configured projects
2 parents 5ed6f30 + c7f4cb8 commit 4039146

File tree

4 files changed

+50
-16
lines changed

4 files changed

+50
-16
lines changed

src/harness/fourslash.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ namespace FourSlash {
747747
}
748748

749749
const missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess };
750-
this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(references)})`);
750+
this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(references, undefined, 2)})`);
751751
}
752752

753753
public verifyReferencesCountIs(count: number, localFilesOnly = true) {
@@ -801,7 +801,7 @@ namespace FourSlash {
801801

802802
private testDiagnostics(expected: string, diagnostics: ts.Diagnostic[]) {
803803
const realized = ts.realizeDiagnostics(diagnostics, "\r\n");
804-
const actual = JSON.stringify(realized, null, " ");
804+
const actual = JSON.stringify(realized, undefined, 2);
805805
assert.equal(actual, expected);
806806
}
807807

@@ -876,7 +876,7 @@ namespace FourSlash {
876876
}
877877

878878
if (ranges.length !== references.length) {
879-
this.raiseError("Rename location count does not match result.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references));
879+
this.raiseError("Rename location count does not match result.\n\nExpected: " + JSON.stringify(ranges, undefined, 2) + "\n\nActual:" + JSON.stringify(references, undefined, 2));
880880
}
881881

882882
ranges = ranges.sort((r1, r2) => r1.start - r2.start);
@@ -889,7 +889,7 @@ namespace FourSlash {
889889
if (reference.textSpan.start !== range.start ||
890890
ts.textSpanEnd(reference.textSpan) !== range.end) {
891891

892-
this.raiseError("Rename location results do not match.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references));
892+
this.raiseError("Rename location results do not match.\n\nExpected: " + JSON.stringify(ranges, undefined, 2) + "\n\nActual:" + JSON.stringify(references, undefined, 2));
893893
}
894894
}
895895
}
@@ -973,7 +973,7 @@ namespace FourSlash {
973973
}
974974
else {
975975
if (actual) {
976-
this.raiseError(`Expected no signature help, but got "${JSON.stringify(actual)}"`);
976+
this.raiseError(`Expected no signature help, but got "${JSON.stringify(actual, undefined, 2)}"`);
977977
}
978978
}
979979
}
@@ -1185,7 +1185,7 @@ namespace FourSlash {
11851185

11861186
public printCurrentParameterHelp() {
11871187
const help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition);
1188-
Harness.IO.log(JSON.stringify(help));
1188+
Harness.IO.log(JSON.stringify(help, undefined, 2));
11891189
}
11901190

11911191
public printCurrentQuickInfo() {
@@ -1227,7 +1227,7 @@ namespace FourSlash {
12271227

12281228
public printCurrentSignatureHelp() {
12291229
const sigHelp = this.getActiveSignatureHelpItem();
1230-
Harness.IO.log(JSON.stringify(sigHelp));
1230+
Harness.IO.log(JSON.stringify(sigHelp, undefined, 2));
12311231
}
12321232

12331233
public printMemberListMembers() {
@@ -1257,7 +1257,7 @@ namespace FourSlash {
12571257
public printReferences() {
12581258
const references = this.getReferencesAtCaret();
12591259
ts.forEach(references, entry => {
1260-
Harness.IO.log(JSON.stringify(entry));
1260+
Harness.IO.log(JSON.stringify(entry, undefined, 2));
12611261
});
12621262
}
12631263

@@ -1748,8 +1748,8 @@ namespace FourSlash {
17481748

17491749
function jsonMismatchString() {
17501750
return Harness.IO.newLine() +
1751-
"expected: '" + Harness.IO.newLine() + JSON.stringify(expected, (k, v) => v, 2) + "'" + Harness.IO.newLine() +
1752-
"actual: '" + Harness.IO.newLine() + JSON.stringify(actual, (k, v) => v, 2) + "'";
1751+
"expected: '" + Harness.IO.newLine() + JSON.stringify(expected, undefined, 2) + "'" + Harness.IO.newLine() +
1752+
"actual: '" + Harness.IO.newLine() + JSON.stringify(actual, undefined, 2) + "'";
17531753
}
17541754
}
17551755

@@ -1964,7 +1964,7 @@ namespace FourSlash {
19641964
// if there was an explicit match kind specified, then it should be validated.
19651965
if (matchKind !== undefined) {
19661966
const missingItem = { name: name, kind: kind, searchValue: searchValue, matchKind: matchKind, fileName: fileName, parentName: parentName };
1967-
this.raiseError(`verifyNavigationItemsListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(items)})`);
1967+
this.raiseError(`verifyNavigationItemsListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(items, undefined, 2)})`);
19681968
}
19691969
}
19701970

@@ -2001,7 +2001,7 @@ namespace FourSlash {
20012001
}
20022002

20032003
const missingItem = { name: name, kind: kind };
2004-
this.raiseError(`verifyGetScriptLexicalStructureListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(items, null, " ")})`);
2004+
this.raiseError(`verifyGetScriptLexicalStructureListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(items, undefined, 2)})`);
20052005
}
20062006

20072007
private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string) {
@@ -2066,7 +2066,7 @@ namespace FourSlash {
20662066
}
20672067

20682068
const missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess };
2069-
this.raiseError(`verifyOccurrencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(occurrences)})`);
2069+
this.raiseError(`verifyOccurrencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(occurrences, undefined, 2)})`);
20702070
}
20712071

20722072
public verifyOccurrencesAtPositionListCount(expectedCount: number) {
@@ -2105,7 +2105,7 @@ namespace FourSlash {
21052105
}
21062106

21072107
const missingItem = { fileName: fileName, start: start, end: end, kind: kind };
2108-
this.raiseError(`verifyDocumentHighlightsAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(documentHighlights)})`);
2108+
this.raiseError(`verifyDocumentHighlightsAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(documentHighlights, undefined, 2)})`);
21092109
}
21102110

21112111
public verifyDocumentHighlightsAtPositionListCount(expectedCount: number, fileNamesToSearch: string[]) {
@@ -2171,9 +2171,9 @@ namespace FourSlash {
21712171
}
21722172
}
21732173

2174-
const itemsString = items.map((item) => JSON.stringify({ name: item.name, kind: item.kind })).join(",\n");
2174+
const itemsString = items.map((item) => JSON.stringify({ name: item.name, kind: item.kind }, undefined, 2)).join(",\n");
21752175

2176-
this.raiseError(`Expected "${JSON.stringify({ name, text, documentation, kind })}" to be in list [${itemsString}]`);
2176+
this.raiseError(`Expected "${JSON.stringify({ name, text, documentation, kind }, undefined, 2)}" to be in list [${itemsString}]`);
21772177
}
21782178

21792179
private findFile(indexOrName: any) {

src/server/editorServices.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,7 @@ namespace ts.server {
919919
configuredProject.updateGraph();
920920
if (configuredProject.getSourceFile(info)) {
921921
info.defaultProject = configuredProject;
922+
referencingProjects.push(configuredProject);
922923
}
923924
}
924925
return referencingProjects;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference path="../fourslash.ts"/>
2+
3+
// Global class reference.
4+
5+
// @Filename: referencesForGlobals_1.ts
6+
////class /*2*/globalClass {
7+
//// public f() { }
8+
////}
9+
10+
// @Filename: referencesForGlobals_2.ts
11+
////var c = /*1*/globalClass();
12+
13+
// @Filename: tsconfig.json
14+
////{ "files": ["referencesForGlobals_1.ts", "referencesForGlobals_2.ts"] }
15+
16+
goTo.marker("1");
17+
verify.referencesCountIs(2);
18+
19+
goTo.marker("2");
20+
verify.referencesCountIs(2);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference path="../fourslash.ts"/>
2+
3+
// @Filename: referencesForGlobals_1.ts
4+
////var [|globalName|] = 0;
5+
6+
// @Filename: referencesForGlobals_2.ts
7+
////var y = /*1*/[|globalName|];
8+
9+
// @Filename: tsconfig.json
10+
////{ "files": ["referencesForGlobals_1.ts", "referencesForGlobals_2.ts"] }
11+
12+
goTo.marker("1");
13+
verify.renameLocations(/*findInStrings:*/ true, /*findInComments:*/ true);

0 commit comments

Comments
 (0)