Skip to content

Commit cd5a443

Browse files
author
Andy
committed
Merge pull request #8811 from Microsoft/navbar_class_child_item
Include classes as childItems in navigation bar
2 parents 7ec13b3 + 5c23b3b commit cd5a443

15 files changed

+28
-24
lines changed

src/services/navigationBar.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ namespace ts.NavigationBar {
333333
case SyntaxKind.PropertySignature:
334334
return createItem(node, getTextOfNode((<PropertyDeclaration>node).name), ts.ScriptElementKind.memberVariableElement);
335335

336+
case SyntaxKind.ClassDeclaration:
337+
return createItem(node, getTextOfNode((<ClassDeclaration>node).name), ts.ScriptElementKind.classElement);
338+
336339
case SyntaxKind.FunctionDeclaration:
337340
return createItem(node, getTextOfNode((<FunctionLikeDeclaration>node).name), ts.ScriptElementKind.functionElement);
338341

tests/cases/fourslash/getNavigationBarItems.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//// ["bar"]: string;
66
////}
77

8-
verify.navigationBarCount(3);
8+
verify.navigationBarCount(5);
99
verify.navigationBarContains("C", "class");
1010
verify.navigationBarChildItem("C", "[\"bar\"]", "property");
1111
verify.navigationBarChildItem("C", "foo", "property");

tests/cases/fourslash/navbar_contains-no-duplicates.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//// {| "itemName": "Windows", "kind": "module", "parentName": "" |}declare module Windows {
33
//// {| "itemName": "Foundation", "kind": "module", "parentName": "" |}export module Foundation {
44
//// export var {| "itemName": "A", "kind": "var" |}A;
5-
//// {| "itemName": "Test", "kind": "class" |}export class Test {
5+
//// {| "itemName": "Test", "kind": "class", "parentName": "Foundation" |}export class Test {
66
//// {| "itemName": "wow", "kind": "method" |}public wow();
77
//// }
88
//// }
@@ -38,4 +38,4 @@ test.markers().forEach(marker => {
3838
marker.position);
3939
}
4040
});
41-
verify.navigationBarCount(12);
41+
verify.navigationBarCount(15);

tests/cases/fourslash/navigationBarItemsBindingPatternsInConstructor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
//// }
1212
////}
1313

14-
verify.navigationBarCount(6); // 2x(class + field + constructor)
14+
verify.navigationBarCount(9); // global + 2 children + 2x(class + field + constructor)

tests/cases/fourslash/navigationBarItemsEmptyConstructors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ verify.navigationBarContains("Test", "class");
99
verify.navigationBarContains("constructor", "constructor");
1010

1111
// no other items
12-
verify.navigationBarCount(2);
12+
verify.navigationBarCount(4); // global + 1 child, Test + 1 child

tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ test.markers().forEach((marker) => {
3939
});
4040

4141
// no other items
42-
verify.navigationBarCount(21);
42+
verify.navigationBarCount(23);

tests/cases/fourslash/navigationBarItemsItems.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes {
1414
////
1515
//// // Class
16-
//// {| "itemName": "Point", "kind": "class", "parentName": "" |}export class Point implements IPoint {
16+
//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point implements IPoint {
1717
//// {| "itemName": "constructor", "kind": "constructor", "parentName": "Point" |}constructor (public x: number, public y: number) { }
1818
////
1919
//// // Instance member
@@ -49,4 +49,4 @@ test.markers().forEach((marker) => {
4949
}
5050
});
5151

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

3-
////{| "itemName": "Bar", "kind": "class" |}export class Bar {
3+
////{| "itemName": "Bar", "kind": "class", "parentName": "\"navigationBarItemsItemsExternalModules\"" |}export class Bar {
44
//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string;
55
////}
66

77
test.markers().forEach((marker) => {
88
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
99
});
1010

11-
verify.navigationBarCount(2); // external module node + class + property
11+
verify.navigationBarCount(4); // external module node + class + property

tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference path="fourslash.ts"/>
22

33
// @Filename: test/file.ts
4-
////{| "itemName": "Bar", "kind": "class" |}export class Bar {
4+
////{| "itemName": "Bar", "kind": "class", "parentName": "\"file\"" |}export class Bar {
55
//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string;
66
////}
77
////{| "itemName": "\"file\"", "kind": "module" |}
@@ -12,4 +12,4 @@ test.markers().forEach((marker) => {
1212
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
1313
});
1414

15-
verify.navigationBarCount(4); // external module node + variable in module + class + property
15+
verify.navigationBarCount(5); // external module node + variable in module + class + property

tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference path="fourslash.ts"/>
22

33
// @Filename: test/my fil"e.ts
4-
////{| "itemName": "Bar", "kind": "class" |}export class Bar {
4+
////{| "itemName": "Bar", "kind": "class", "parentName": "\"my fil\\\"e\"" |}export class Bar {
55
//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string;
66
////}
77
////{| "itemName": "\"my fil\\\"e\"", "kind": "module" |}
@@ -12,4 +12,4 @@ test.markers().forEach((marker) => {
1212
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
1313
});
1414

15-
verify.navigationBarCount(4); // external module node + variable in module + class + property
15+
verify.navigationBarCount(5); // external module node + 2 children + class + property

0 commit comments

Comments
 (0)