Enable infrastructure to test the symbol display parts returned by quickInfo

This commit is contained in:
Sheetal Nandi
2014-10-13 14:38:18 -07:00
parent e22500d77d
commit 307e28a8a1
4 changed files with 70 additions and 3 deletions

View File

@@ -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) {

View File

@@ -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;
}
}