Skip to content

Commit 0297289

Browse files
authored
Merge pull request microsoft#21379 from amcasey/HighlightingAssert
Check syntax kind in isDeclarationNameOrImportPropertyName
2 parents df15d5b + cd00001 commit 0297289

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26599,7 +26599,7 @@ namespace ts {
2659926599
switch (name.parent.kind) {
2660026600
case SyntaxKind.ImportSpecifier:
2660126601
case SyntaxKind.ExportSpecifier:
26602-
return true;
26602+
return isIdentifier(name);
2660326603
default:
2660426604
return isDeclarationName(name);
2660526605
}

src/harness/fourslash.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,6 +2859,15 @@ Actual: ${stringify(fullActual)}`);
28592859
}
28602860
}
28612861

2862+
public verifyNoDocumentHighlights(startRange: Range) {
2863+
this.goToRangeStart(startRange);
2864+
const documentHighlights = this.getDocumentHighlightsAtCurrentPosition([this.activeFile.fileName]);
2865+
const numHighlights = ts.length(documentHighlights);
2866+
if (numHighlights > 0) {
2867+
this.raiseError(`verifyNoDocumentHighlights failed - unexpectedly got ${numHighlights} highlights`);
2868+
}
2869+
}
2870+
28622871
private verifyDocumentHighlights(expectedRanges: Range[], fileNames: string[] = [this.activeFile.fileName]) {
28632872
const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNames) || [];
28642873

@@ -4267,6 +4276,10 @@ namespace FourSlashInterface {
42674276
this.state.verifyDocumentHighlightsOf(startRange, ranges);
42684277
}
42694278

4279+
public noDocumentHighlights(startRange: FourSlash.Range) {
4280+
this.state.verifyNoDocumentHighlights(startRange);
4281+
}
4282+
42704283
public completionEntryDetailIs(entryName: string, text: string, documentation?: string, kind?: string, tags?: ts.JSDocTagInfo[]) {
42714284
this.state.verifyCompletionEntryDetails(entryName, text, documentation, kind, tags);
42724285
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
//// class [|C|] {}
4+
//// [|export|] { [|C|] [|as|] [|D|] };
5+
6+
const [classRange, exportKeywordRange, propertyNameRange, asKeywordRange, nameRange] = test.ranges();
7+
verify.noDocumentHighlights(exportKeywordRange);
8+
verify.documentHighlightsOf(propertyNameRange, [classRange, propertyNameRange, nameRange]);
9+
verify.noDocumentHighlights(asKeywordRange);
10+
verify.documentHighlightsOf(nameRange, [nameRange]);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
//// class C {}
4+
//// /*1*/export { C /*2*/as D };
5+
6+
goTo.marker("1");
7+
verify.noReferences();
8+
9+
goTo.marker("2");
10+
verify.noReferences();

0 commit comments

Comments
 (0)