Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c5aa3ad

Browse filesBrowse files
Merge pull request microsoft#3846 from DickvdBrink/abstract-occurrences
Highlight Abstract occurrences
2 parents bb53c38 + 2718539 commit c5aa3ad
Copy full SHA for c5aa3ad

3 files changed

+70-1Lines changed: 70 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/services/services.ts‎

Copy file name to clipboardExpand all lines: src/services/services.ts
+17-1Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4696,6 +4696,11 @@ namespace ts {
46964696
return undefined;
46974697
}
46984698
}
4699+
else if (modifier === SyntaxKind.AbstractKeyword) {
4700+
if (!(container.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.ClassDeclaration)) {
4701+
return undefined;
4702+
}
4703+
}
46994704
else {
47004705
// unsupported modifier
47014706
return undefined;
@@ -4708,7 +4713,13 @@ namespace ts {
47084713
switch (container.kind) {
47094714
case SyntaxKind.ModuleBlock:
47104715
case SyntaxKind.SourceFile:
4711-
nodes = (<Block>container).statements;
4716+
// Container is either a class declaration or the declaration is a classDeclaration
4717+
if (modifierFlag & NodeFlags.Abstract) {
4718+
nodes = (<Node[]>(<ClassDeclaration>declaration).members).concat(declaration);
4719+
}
4720+
else {
4721+
nodes = (<Block>container).statements;
4722+
}
47124723
break;
47134724
case SyntaxKind.Constructor:
47144725
nodes = (<Node[]>(<ConstructorDeclaration>container).parameters).concat(
@@ -4728,6 +4739,9 @@ namespace ts {
47284739
nodes = nodes.concat(constructor.parameters);
47294740
}
47304741
}
4742+
else if (modifierFlag & NodeFlags.Abstract) {
4743+
nodes = nodes.concat(container);
4744+
}
47314745
break;
47324746
default:
47334747
Debug.fail("Invalid container kind.")
@@ -4755,6 +4769,8 @@ namespace ts {
47554769
return NodeFlags.Export;
47564770
case SyntaxKind.DeclareKeyword:
47574771
return NodeFlags.Ambient;
4772+
case SyntaxKind.AbstractKeyword:
4773+
return NodeFlags.Abstract;
47584774
default:
47594775
Debug.fail();
47604776
}
Collapse file
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////[|abstract|] class Animal {
4+
//// [|abstract|] prop1; // Does not compile
5+
//// [|abstract|] abstract();
6+
//// [|abstract|] walk(): void;
7+
//// [|abstract|] makeSound(): void;
8+
////}
9+
////// Abstract class below should not get highlighted
10+
////abstract class Foo {
11+
//// abstract foo(): void;
12+
//// abstract bar(): void;
13+
////}
14+
15+
const ranges = test.ranges();
16+
17+
for (let r of ranges) {
18+
goTo.position(r.start);
19+
verify.occurrencesAtPositionCount(ranges.length);
20+
21+
for (let range of ranges) {
22+
verify.occurrencesAtPositionContains(range, false);
23+
}
24+
}
Collapse file
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////// Not valid TS (abstract methods can only appear in abstract classes)
4+
////class Animal {
5+
//// [|abstract|] walk(): void;
6+
//// [|abstract|] makeSound(): void;
7+
////}
8+
////// abstract cannot appear here, won't get highlighted
9+
////let c = /*1*/abstract class Foo {
10+
//// /*2*/abstract foo(): void;
11+
//// abstract bar(): void;
12+
////}
13+
14+
const ranges = test.ranges();
15+
16+
for (let r of ranges) {
17+
goTo.position(r.start);
18+
verify.occurrencesAtPositionCount(ranges.length);
19+
20+
for (let range of ranges) {
21+
verify.occurrencesAtPositionContains(range, false);
22+
}
23+
}
24+
25+
goTo.marker("1");
26+
verify.occurrencesAtPositionCount(0);
27+
28+
goTo.marker("2");
29+
verify.occurrencesAtPositionCount(2);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.