Skip to content

Commit dbd3054

Browse files
author
Andy Hanson
committed
Include classes as childItems in navigation bar
1 parent 7173fa8 commit dbd3054

14 files changed

+27
-23
lines changed

src/services/navigationBar.ts

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

333+
case SyntaxKind.ClassDeclaration:
334+
return createItem(node, getTextOfNode((<ClassDeclaration>node).name), ts.ScriptElementKind.classElement);
335+
333336
case SyntaxKind.FunctionDeclaration:
334337
return createItem(node, getTextOfNode((<FunctionLikeDeclaration>node).name), ts.ScriptElementKind.functionElement);
335338

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(19);
42+
verify.navigationBarCount(21);

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(24);
52+
verify.navigationBarCount(25);
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

tests/cases/fourslash/navigationBarItemsMissingName1.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/////**
33
//// * This is a class.
44
//// */
5-
////{| "itemName": "C", "kind": "class" |} class C {
5+
////{| "itemName": "C", "kind": "class", "parentName": "\"navigationBarItemsMissingName1\"" |} class C {
66
//// {| "itemName": "foo", "kind": "method" |} foo() {
77
//// }
88
////}
@@ -12,5 +12,5 @@ test.markers().forEach((marker) => {
1212
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
1313
});
1414

15-
/// Only have two named elements.
16-
verify.navigationBarCount(2);
15+
/// Root + 1 child, class + 1 child
16+
verify.navigationBarCount(4);

tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//// b"(): Foo;
2121
////}
2222
////
23-
////{| "itemName": "Bar", "kind": "class" |}
23+
////{| "itemName": "Bar", "kind": "class", "parentName": "<global>" |}
2424
////class Bar implements Foo {
2525
//// {| "itemName": "'a1\\\\\\r\\nb'", "kind": "property", "parentName": "Bar" |}
2626
//// 'a1\\\r\nb': Foo;
@@ -38,4 +38,4 @@ test.markers().forEach((marker) => {
3838
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
3939
});
4040

41-
verify.navigationBarCount(9); // interface w/ 2 properties, class w/ 2 properties, 3 modules
41+
verify.navigationBarCount(11); // global + 1 child, interface w/ 2 properties, class w/ 2 properties, 3 modules

tests/cases/fourslash/navigationBarItemsPropertiesDefinedInConstructors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ verify.navigationBarContains("a", "property");
1212
verify.navigationBarContains("b", "property");
1313

1414
// no other items
15-
verify.navigationBarCount(4);
15+
verify.navigationBarCount(6);

tests/cases/fourslash/navigationBarItemsSymbols1.ts

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

3-
////{| "itemName": "C", "kind": "class", "parentName": "" |}
3+
////{| "itemName": "C", "kind": "class", "parentName": "<global>" |}
44
////class C {
55
//// {| "itemName": "[Symbol.isRegExp]", "kind": "property", "parentName": "C" |}
66
//// [Symbol.isRegExp] = 0;
@@ -14,4 +14,5 @@ test.markers().forEach(marker => {
1414
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
1515
});
1616

17-
verify.navigationBarCount(test.markers().length);
17+
// 2 lack markers: <global> and its child
18+
verify.navigationBarCount(2 + test.markers().length);

tests/cases/fourslash/server/navbar01.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(24);
52+
verify.navigationBarCount(25);

0 commit comments

Comments
 (0)