Skip to content

Fix global ts server operations in configured projects #8266

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

Merged
merged 2 commits into from
Apr 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ namespace FourSlash {
}

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

public verifyReferencesCountIs(count: number, localFilesOnly = true) {
Expand Down Expand Up @@ -801,7 +801,7 @@ namespace FourSlash {

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

Expand Down Expand Up @@ -876,7 +876,7 @@ namespace FourSlash {
}

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

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

this.raiseError("Rename location results do not match.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references));
this.raiseError("Rename location results do not match.\n\nExpected: " + JSON.stringify(ranges, undefined, 2) + "\n\nActual:" + JSON.stringify(references, undefined, 2));
}
}
}
Expand Down Expand Up @@ -973,7 +973,7 @@ namespace FourSlash {
}
else {
if (actual) {
this.raiseError(`Expected no signature help, but got "${JSON.stringify(actual)}"`);
this.raiseError(`Expected no signature help, but got "${JSON.stringify(actual, undefined, 2)}"`);
}
}
}
Expand Down Expand Up @@ -1185,7 +1185,7 @@ namespace FourSlash {

public printCurrentParameterHelp() {
const help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition);
Harness.IO.log(JSON.stringify(help));
Harness.IO.log(JSON.stringify(help, undefined, 2));
}

public printCurrentQuickInfo() {
Expand Down Expand Up @@ -1227,7 +1227,7 @@ namespace FourSlash {

public printCurrentSignatureHelp() {
const sigHelp = this.getActiveSignatureHelpItem();
Harness.IO.log(JSON.stringify(sigHelp));
Harness.IO.log(JSON.stringify(sigHelp, undefined, 2));
}

public printMemberListMembers() {
Expand Down Expand Up @@ -1257,7 +1257,7 @@ namespace FourSlash {
public printReferences() {
const references = this.getReferencesAtCaret();
ts.forEach(references, entry => {
Harness.IO.log(JSON.stringify(entry));
Harness.IO.log(JSON.stringify(entry, undefined, 2));
});
}

Expand Down Expand Up @@ -1748,8 +1748,8 @@ namespace FourSlash {

function jsonMismatchString() {
return Harness.IO.newLine() +
"expected: '" + Harness.IO.newLine() + JSON.stringify(expected, (k, v) => v, 2) + "'" + Harness.IO.newLine() +
"actual: '" + Harness.IO.newLine() + JSON.stringify(actual, (k, v) => v, 2) + "'";
"expected: '" + Harness.IO.newLine() + JSON.stringify(expected, undefined, 2) + "'" + Harness.IO.newLine() +
"actual: '" + Harness.IO.newLine() + JSON.stringify(actual, undefined, 2) + "'";
}
}

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

Expand Down Expand Up @@ -2001,7 +2001,7 @@ namespace FourSlash {
}

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

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

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

public verifyOccurrencesAtPositionListCount(expectedCount: number) {
Expand Down Expand Up @@ -2105,7 +2105,7 @@ namespace FourSlash {
}

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

public verifyDocumentHighlightsAtPositionListCount(expectedCount: number, fileNamesToSearch: string[]) {
Expand Down Expand Up @@ -2171,9 +2171,9 @@ namespace FourSlash {
}
}

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

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

private findFile(indexOrName: any) {
Expand Down
1 change: 1 addition & 0 deletions src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ namespace ts.server {
configuredProject.updateGraph();
if (configuredProject.getSourceFile(info)) {
info.defaultProject = configuredProject;
referencingProjects.push(configuredProject);
}
}
return referencingProjects;
Expand Down
20 changes: 20 additions & 0 deletions tests/cases/fourslash/server/referencesInConfiguredProject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// <reference path="../fourslash.ts"/>

// Global class reference.

// @Filename: referencesForGlobals_1.ts
////class /*2*/globalClass {
//// public f() { }
////}

// @Filename: referencesForGlobals_2.ts
////var c = /*1*/globalClass();

// @Filename: tsconfig.json
////{ "files": ["referencesForGlobals_1.ts", "referencesForGlobals_2.ts"] }

goTo.marker("1");
verify.referencesCountIs(2);

goTo.marker("2");
verify.referencesCountIs(2);
13 changes: 13 additions & 0 deletions tests/cases/fourslash/server/renameInConfiguredProject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference path="../fourslash.ts"/>

// @Filename: referencesForGlobals_1.ts
////var [|globalName|] = 0;

// @Filename: referencesForGlobals_2.ts
////var y = /*1*/[|globalName|];

// @Filename: tsconfig.json
////{ "files": ["referencesForGlobals_1.ts", "referencesForGlobals_2.ts"] }

goTo.marker("1");
verify.renameLocations(/*findInStrings:*/ true, /*findInComments:*/ true);