mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-18 12:21:37 -06:00
Enable infrastructure to test the symbol display parts returned by quickInfo
This commit is contained in:
parent
e22500d77d
commit
307e28a8a1
@ -765,7 +765,7 @@ module FourSlash {
|
||||
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
|
||||
}
|
||||
|
||||
public verifyQuickInfo(negative: boolean, expectedText?: string, expectedDocumentation?: string) {
|
||||
public quickInfoIs(negative: boolean, expectedText?: string, expectedDocumentation?: string) {
|
||||
[expectedText, expectedDocumentation].forEach(str => {
|
||||
if (str) {
|
||||
this.scenarioActions.push('<ShowQuickInfo />');
|
||||
@ -794,6 +794,21 @@ module FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public verifyQuickInfo(kind: string, kindModifiers: string, textSpan: { start: number; length: number; },
|
||||
displayParts: { text: string; kind: string; }[],
|
||||
documentation: { text: string; kind: string; }[]) {
|
||||
this.scenarioActions.push('<ShowQuickInfo />');
|
||||
this.scenarioActions.push('<Verify return values of quickInfo="' + JSON.stringify(displayParts) + '"/>');
|
||||
|
||||
var actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
assert.equal(actualQuickInfo.kind, kind, this.messageAtLastKnownMarker("QuickInfo kind"));
|
||||
assert.equal(actualQuickInfo.kindModifiers, kindModifiers, this.messageAtLastKnownMarker("QuickInfo kindModifiers"));
|
||||
assert.equal(JSON.stringify(actualQuickInfo.textSpan), JSON.stringify(textSpan), this.messageAtLastKnownMarker("QuickInfo textSpan"));
|
||||
assert.equal(JSON.stringify(actualQuickInfo.displayParts), JSON.stringify(displayParts), this.messageAtLastKnownMarker("QuickInfo displayParts"));
|
||||
assert.equal(JSON.stringify(actualQuickInfo.documentation), JSON.stringify(documentation), this.messageAtLastKnownMarker("QuickInfo documentation"));
|
||||
}
|
||||
|
||||
public verifyRenameLocations(findInStrings: boolean, findInComments: boolean) {
|
||||
var renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (renameInfo.canRename) {
|
||||
|
||||
@ -1317,7 +1317,10 @@ module ts {
|
||||
|
||||
function writeIndent() {
|
||||
if (lineStart) {
|
||||
displayParts.push(displayPart(getIndentString(indent), SymbolDisplayPartKind.space));
|
||||
var indentString = getIndentString(indent);
|
||||
if (indentString) {
|
||||
displayParts.push(displayPart(indentString, SymbolDisplayPartKind.space));
|
||||
}
|
||||
lineStart = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,6 +83,10 @@ module FourSlashInterface {
|
||||
public ranges(): Range[] {
|
||||
return FourSlash.currentTestState.getRanges();
|
||||
}
|
||||
|
||||
public markerByName(s: string): Marker {
|
||||
return FourSlash.currentTestState.getMarkerByName(s);
|
||||
}
|
||||
}
|
||||
|
||||
export class diagnostics {
|
||||
@ -223,7 +227,7 @@ module FourSlashInterface {
|
||||
}
|
||||
|
||||
public quickInfoIs(expectedText?: string, expectedDocumentation?: string) {
|
||||
FourSlash.currentTestState.verifyQuickInfo(this.negative, expectedText, expectedDocumentation);
|
||||
FourSlash.currentTestState.quickInfoIs(this.negative, expectedText, expectedDocumentation);
|
||||
}
|
||||
|
||||
public quickInfoExists() {
|
||||
@ -420,6 +424,12 @@ module FourSlashInterface {
|
||||
public renameLocations(findInStrings: boolean, findInComments: boolean) {
|
||||
FourSlash.currentTestState.verifyRenameLocations(findInStrings, findInComments);
|
||||
}
|
||||
|
||||
public verifyQuickInfo(kind: string, kindModifiers: string, textSpan: { start: number; length: number; },
|
||||
displayParts: { text: string; kind: string; }[],
|
||||
documentation: { text: string; kind: string; }[]) {
|
||||
FourSlash.currentTestState.verifyQuickInfo(kind, kindModifiers, textSpan, displayParts, documentation);
|
||||
}
|
||||
}
|
||||
|
||||
export class edit {
|
||||
|
||||
39
tests/cases/fourslash/quicklInfoDisplayPartsClass.ts
Normal file
39
tests/cases/fourslash/quicklInfoDisplayPartsClass.ts
Normal file
@ -0,0 +1,39 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////class /*1*/c {
|
||||
////}
|
||||
////var /*2*/cInstance = new /*3*/c();
|
||||
////var /*4*/cVal = /*5*/c;
|
||||
|
||||
goTo.marker('1');
|
||||
verify.verifyQuickInfo("class", "", { start: test.markerByName("1").position, length: "c".length },
|
||||
[{ text: "class", kind: "keyword" }, { text: " ", kind: "space" }, { text: "c", kind: "className" }],
|
||||
[]);
|
||||
|
||||
goTo.marker('2');
|
||||
verify.verifyQuickInfo("var", "", { start: test.markerByName("2").position, length: "cInstance".length },
|
||||
[{ text: "(", kind: "punctuation" }, { text: "var", kind: "text" }, { text: ")", kind: "punctuation" },
|
||||
{ text: " ", kind: "space" }, { text: "cInstance", kind: "localName" }, { text: ":", kind: "punctuation" },
|
||||
{ text: " ", kind: "space" }, { text: "c", kind: "className" }],
|
||||
[]);
|
||||
|
||||
goTo.marker('3');
|
||||
verify.verifyQuickInfo("constructor", "", { start: test.markerByName("3").position, length: "c".length },
|
||||
[{ text: "(", kind: "punctuation" }, { text: "constructor", kind: "text" }, { text: ")", kind: "punctuation" },
|
||||
{ text: " ", kind: "space" }, { text: "c", kind: "className" },
|
||||
{ text: "(", kind: "punctuation" }, { text: ")", kind: "punctuation" }, { text: ":", kind: "punctuation" },
|
||||
{ text: " ", kind: "space" }, { text: "c", kind: "className" }],
|
||||
[]);
|
||||
|
||||
goTo.marker('4');
|
||||
verify.verifyQuickInfo("var", "", { start: test.markerByName("4").position, length: "cVal".length },
|
||||
[{ text: "(", kind: "punctuation" }, { text: "var", kind: "text" }, { text: ")", kind: "punctuation" },
|
||||
{ text: " ", kind: "space" }, { text: "cVal", kind: "localName" }, { text: ":", kind: "punctuation" },
|
||||
{ text: " ", kind: "space" },
|
||||
{ text: "typeof", kind: "keyword" }, { text: " ", kind: "space" }, { text: "c", kind: "className" }],
|
||||
[]);
|
||||
|
||||
goTo.marker('5');
|
||||
verify.verifyQuickInfo("class", "", { start: test.markerByName("5").position, length: "c".length },
|
||||
[{ text: "class", kind: "keyword" }, { text: " ", kind: "space" }, { text: "c", kind: "className" }],
|
||||
[]);
|
||||
Loading…
x
Reference in New Issue
Block a user