Skip to content

Commit 1fc1813

Browse files
author
Andy Hanson
committed
Fix bug where class expression child item didn't get right name
1 parent a7bedb1 commit 1fc1813

5 files changed

+48
-17
lines changed

src/services/navigationBar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ namespace ts.NavigationBar {
383383

384384
case SyntaxKind.ClassDeclaration:
385385
case SyntaxKind.ClassExpression:
386-
return createItem(node, getTextOfNode((<ClassDeclaration>node).name), ts.ScriptElementKind.classElement);
386+
return createItem(node, getFunctionOrClassName(<ClassDeclaration>node), ts.ScriptElementKind.classElement);
387387

388388
case SyntaxKind.ArrowFunction:
389389
case SyntaxKind.FunctionExpression:

tests/cases/fourslash/navbar_exportDefault.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ goTo.file("a.ts");
1616
verify.navigationBar([
1717
{
1818
"text": "\"a\"",
19-
"kind": "module"
19+
"kind": "module",
20+
"childItems": [
21+
{
22+
"text": "default",
23+
"kind": "class",
24+
"kindModifiers": "export"
25+
}
26+
]
2027
},
2128
{
2229
"text": "default",

tests/cases/fourslash/navigationBarAnonymousDeclarationExpressions.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ verify.navigationBar([
4242
{
4343
"text": "classes",
4444
"kind": "function"
45+
},
46+
{
47+
"text": "global.cls",
48+
"kind": "class"
4549
}
4650
]
4751
},
@@ -105,6 +109,14 @@ verify.navigationBar([
105109
"text": "classes",
106110
"kind": "function",
107111
"childItems": [
112+
{
113+
"text": "<class>",
114+
"kind": "class"
115+
},
116+
{
117+
"text": "cls2",
118+
"kind": "class"
119+
},
108120
{
109121
"text": "cls3",
110122
"kind": "class"
@@ -132,4 +144,5 @@ verify.navigationBar([
132144
"kind": "class",
133145
"indent": 1
134146
}
135-
]);
147+
]
148+
);

tests/cases/fourslash/navigationBarItemsItems2.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ verify.navigationBar([
1212
"text": "\"navigationBarItemsItems2\"",
1313
"kind": "module",
1414
"childItems": [
15+
{
16+
"text": "<class>",
17+
"kind": "class",
18+
"kindModifiers": "export"
19+
},
1520
{
1621
"text": "A",
1722
"kind": "module"

tests/cases/fourslash/navigationBarItemsMissingName2.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,25 @@
77

88
// Anonymous classes are still included.
99
verify.navigationBar([
10-
{
11-
"text": "<global>",
12-
"kind": "module"
13-
},
14-
{
10+
{
11+
"text": "<global>",
12+
"kind": "module",
13+
"childItems": [
14+
{
1515
"text": "<class>",
16-
"kind": "class",
17-
"childItems": [
18-
{
19-
"text": "foo",
20-
"kind": "method"
21-
}
22-
],
23-
"indent": 1
24-
}
16+
"kind": "class"
17+
}
18+
]
19+
},
20+
{
21+
"text": "<class>",
22+
"kind": "class",
23+
"childItems": [
24+
{
25+
"text": "foo",
26+
"kind": "method"
27+
}
28+
],
29+
"indent": 1
30+
}
2531
]);

0 commit comments

Comments
 (0)