Merge pull request #21379 from amcasey/HighlightingAssert

Check syntax kind in isDeclarationNameOrImportPropertyName
This commit is contained in:
Andrew Casey 2018-02-01 10:11:10 -08:00 committed by GitHub
commit 02972899d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 1 deletions

View File

@ -26599,7 +26599,7 @@ namespace ts {
switch (name.parent.kind) {
case SyntaxKind.ImportSpecifier:
case SyntaxKind.ExportSpecifier:
return true;
return isIdentifier(name);
default:
return isDeclarationName(name);
}

View File

@ -2859,6 +2859,15 @@ Actual: ${stringify(fullActual)}`);
}
}
public verifyNoDocumentHighlights(startRange: Range) {
this.goToRangeStart(startRange);
const documentHighlights = this.getDocumentHighlightsAtCurrentPosition([this.activeFile.fileName]);
const numHighlights = ts.length(documentHighlights);
if (numHighlights > 0) {
this.raiseError(`verifyNoDocumentHighlights failed - unexpectedly got ${numHighlights} highlights`);
}
}
private verifyDocumentHighlights(expectedRanges: Range[], fileNames: string[] = [this.activeFile.fileName]) {
const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNames) || [];
@ -4267,6 +4276,10 @@ namespace FourSlashInterface {
this.state.verifyDocumentHighlightsOf(startRange, ranges);
}
public noDocumentHighlights(startRange: FourSlash.Range) {
this.state.verifyNoDocumentHighlights(startRange);
}
public completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string, tags?: ts.JSDocTagInfo[]) {
this.state.verifyCompletionEntryDetails(entryName, text, documentation, kind, tags);
}

View File

@ -0,0 +1,10 @@
/// <reference path='fourslash.ts'/>
//// class [|C|] {}
//// [|export|] { [|C|] [|as|] [|D|] };
const [classRange, exportKeywordRange, propertyNameRange, asKeywordRange, nameRange] = test.ranges();
verify.noDocumentHighlights(exportKeywordRange);
verify.documentHighlightsOf(propertyNameRange, [classRange, propertyNameRange, nameRange]);
verify.noDocumentHighlights(asKeywordRange);
verify.documentHighlightsOf(nameRange, [nameRange]);

View File

@ -0,0 +1,10 @@
/// <reference path='fourslash.ts'/>
//// class C {}
//// /*1*/export { C /*2*/as D };
goTo.marker("1");
verify.noReferences();
goTo.marker("2");
verify.noReferences();