mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 05:41:22 -06:00
In getModifierOccurrences, support additional container kinds (#18947)
This commit is contained in:
parent
fe9129b1ab
commit
6617819bf3
@ -302,12 +302,15 @@ namespace ts.DocumentHighlights {
|
||||
switch (container.kind) {
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.DefaultClause:
|
||||
// Container is either a class declaration or the declaration is a classDeclaration
|
||||
if (modifierFlag & ModifierFlags.Abstract) {
|
||||
nodes = [...(<ClassDeclaration>declaration).members, declaration];
|
||||
}
|
||||
else {
|
||||
nodes = (<Block>container).statements;
|
||||
nodes = (<ModuleBlock | SourceFile | Block | CaseClause | DefaultClause>container).statements;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.Constructor:
|
||||
|
||||
21
tests/cases/fourslash/getOccurrencesAbstract03.ts
Normal file
21
tests/cases/fourslash/getOccurrencesAbstract03.ts
Normal file
@ -0,0 +1,21 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// Tests that we don't crash when encountering an abstract class in these scopes:
|
||||
|
||||
////function f() {
|
||||
//// [|abstract|] class A {
|
||||
//// [|abstract|] m(): void;
|
||||
//// }
|
||||
//// abstract class B {}
|
||||
////}
|
||||
////switch (0) {
|
||||
//// case 0:
|
||||
//// [|abstract|] class A { [|abstract|] m(): void; }
|
||||
//// default:
|
||||
//// [|abstract|] class B { [|abstract|] m(): void; }
|
||||
////}
|
||||
|
||||
const [r0, r1, r2, r3, r4, r5] = test.ranges();
|
||||
verify.rangesAreDocumentHighlights([r0, r1]);
|
||||
verify.rangesAreDocumentHighlights([r2, r3]);
|
||||
verify.rangesAreDocumentHighlights([r4, r5]);
|
||||
Loading…
x
Reference in New Issue
Block a user