Skip to content

Commit e67df33

Browse files
author
Andy
committed
Merge pull request microsoft#8780 from Microsoft/navbar_enum
Include enums in childItems in navigation bar
2 parents 27292e4 + 11d5186 commit e67df33

5 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/services/navigationBar.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ namespace ts.NavigationBar {
314314
case SyntaxKind.IndexSignature:
315315
return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement);
316316

317+
case SyntaxKind.EnumDeclaration:
318+
return createItem(node, getTextOfNode((<EnumDeclaration>node).name), ts.ScriptElementKind.enumElement);
319+
317320
case SyntaxKind.EnumMember:
318321
return createItem(node, getTextOfNode((<EnumMember>node).name), ts.ScriptElementKind.memberVariableElement);
319322

tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//// {| "itemName": "LocalInterfaceInConstrcutor", "kind": "interface", "parentName": ""|}interface LocalInterfaceInConstrcutor {
1010
//// }
1111
////
12-
//// enum LocalEnumInConstructor {
12+
//// {| "itemName": "LocalEnumInConstructor", "kind": "enum", "parentName": "constructor"|}enum LocalEnumInConstructor {
1313
//// {| "itemName": "LocalEnumMemberInConstructor", "kind": "property", "parentName": "LocalEnumInConstructor"|}LocalEnumMemberInConstructor,
1414
//// }
1515
//// }
@@ -24,7 +24,7 @@
2424
//// {| "itemName": "LocalInterfaceInMethod", "kind": "interface", "parentName": ""|}interface LocalInterfaceInMethod {
2525
//// }
2626
////
27-
//// {| "itemName": "LocalEnumInMethod", "kind": "enum", "parentName": ""|}enum LocalEnumInMethod {
27+
//// {| "itemName": "LocalEnumInMethod", "kind": "enum", "parentName": "method"|}enum LocalEnumInMethod {
2828
//// {| "itemName": "LocalEnumMemberInMethod", "kind": "property", "parentName": "LocalEnumInMethod"|}LocalEnumMemberInMethod,
2929
//// }
3030
//// }
@@ -39,4 +39,4 @@ test.markers().forEach((marker) => {
3939
});
4040

4141
// no other items
42-
verify.navigationBarCount(17);
42+
verify.navigationBarCount(19);

tests/cases/fourslash/navigationBarItemsItems.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
//// {| "itemName": "getOrigin", "kind": "method", "parentName": "Point" |}private static getOrigin() { return Point.origin;}
3333
//// }
3434
////
35-
//// {| "itemName": "Values", "kind": "enum", "parentName": "" |}enum Values {
35+
//// {| "itemName": "Values", "kind": "enum", "parentName": "Shapes" |}enum Values {
3636
//// value1,
3737
//// {| "itemName": "value2", "kind": "property", "parentName": "Values" |}value2,
3838
//// value3,
@@ -49,4 +49,4 @@ test.markers().forEach((marker) => {
4949
}
5050
});
5151

52-
verify.navigationBarCount(23);
52+
verify.navigationBarCount(24);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference path="fourslash.ts"/>
22

3-
////{| "itemName": "E", "kind": "enum", "parentName": "" |}
3+
////{| "itemName": "E", "kind": "enum", "parentName": "<global>" |}
44
////enum E {
55
//// // No nav bar entry for this
66
//// [Symbol.isRegExp] = 0
@@ -10,4 +10,4 @@ test.markers().forEach(marker => {
1010
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
1111
});
1212

13-
verify.navigationBarCount(test.markers().length);
13+
verify.navigationBarCount(3); // <global> and E appearing both toplevel and under <global>

tests/cases/fourslash/server/navbar01.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
//// {| "itemName": "getOrigin", "kind": "method", "parentName": "Point" |}private static getOrigin() { return Point.origin;}
3333
//// }
3434
////
35-
//// {| "itemName": "Values", "kind": "enum", "parentName": "" |}enum Values {
35+
//// {| "itemName": "Values", "kind": "enum", "parentName": "Shapes" |}enum Values {
3636
//// value1,
3737
//// {| "itemName": "value2", "kind": "property", "parentName": "Values" |}value2,
3838
//// value3,
@@ -49,4 +49,4 @@ test.markers().forEach((marker) => {
4949
}
5050
});
5151

52-
verify.navigationBarCount(23);
52+
verify.navigationBarCount(24);

0 commit comments

Comments
 (0)