mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 19:27:35 -06:00
Merge pull request #21379 from amcasey/HighlightingAssert
Check syntax kind in isDeclarationNameOrImportPropertyName
This commit is contained in:
commit
02972899d7
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
10
tests/cases/fourslash/documentHighlightInExport1.ts
Normal file
10
tests/cases/fourslash/documentHighlightInExport1.ts
Normal 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]);
|
||||
10
tests/cases/fourslash/findAllRefsInExport1.ts
Normal file
10
tests/cases/fourslash/findAllRefsInExport1.ts
Normal 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();
|
||||
Loading…
x
Reference in New Issue
Block a user