@@ -36,6 +36,7 @@ namespace ts.NavigationBar {
3636 */
3737 interface NavigationBarNode {
3838 node : Node ;
39+ name : DeclarationName | undefined ;
3940 additionalNodes : Node [ ] | undefined ;
4041 parent : NavigationBarNode | undefined ; // Present for all but root node
4142 children : NavigationBarNode [ ] | undefined ;
@@ -91,7 +92,7 @@ namespace ts.NavigationBar {
9192
9293 function rootNavigationBarNode ( sourceFile : SourceFile ) : NavigationBarNode {
9394 Debug . assert ( ! parentsStack . length ) ;
94- const root : NavigationBarNode = { node : sourceFile , additionalNodes : undefined , parent : undefined , children : undefined , indent : 0 } ;
95+ const root : NavigationBarNode = { node : sourceFile , name : undefined , additionalNodes : undefined , parent : undefined , children : undefined , indent : 0 } ;
9596 parent = root ;
9697 for ( const statement of sourceFile . statements ) {
9798 addChildrenRecursively ( statement ) ;
@@ -108,6 +109,7 @@ namespace ts.NavigationBar {
108109 function emptyNavigationBarNode ( node : Node ) : NavigationBarNode {
109110 return {
110111 node,
112+ name : isDeclaration ( node ) || isExpression ( node ) ? getNameOfDeclaration ( node ) : undefined ,
111113 additionalNodes : undefined ,
112114 parent,
113115 children : undefined ,
@@ -420,12 +422,11 @@ namespace ts.NavigationBar {
420422 }
421423 }
422424
423- function getItemName ( node : Node ) : string {
425+ function getItemName ( node : Node , name : Node | undefined ) : string {
424426 if ( node . kind === SyntaxKind . ModuleDeclaration ) {
425427 return getModuleName ( < ModuleDeclaration > node ) ;
426428 }
427429
428- const name = getNameOfDeclaration ( < Declaration > node ) ;
429430 if ( name ) {
430431 const text = nodeText ( name ) ;
431432 if ( text . length > 0 ) {
@@ -534,17 +535,18 @@ namespace ts.NavigationBar {
534535
535536 function convertToTree ( n : NavigationBarNode ) : NavigationTree {
536537 return {
537- text : getItemName ( n . node ) ,
538+ text : getItemName ( n . node , n . name ) ,
538539 kind : getNodeKind ( n . node ) ,
539540 kindModifiers : getModifiers ( n . node ) ,
540541 spans : getSpans ( n ) ,
542+ nameSpan : n . name && getNodeSpan ( n . name ) ,
541543 childItems : map ( n . children , convertToTree )
542544 } ;
543545 }
544546
545547 function convertToTopLevelItem ( n : NavigationBarNode ) : NavigationBarItem {
546548 return {
547- text : getItemName ( n . node ) ,
549+ text : getItemName ( n . node , n . name ) ,
548550 kind : getNodeKind ( n . node ) ,
549551 kindModifiers : getModifiers ( n . node ) ,
550552 spans : getSpans ( n ) ,
@@ -556,7 +558,7 @@ namespace ts.NavigationBar {
556558
557559 function convertToChildItem ( n : NavigationBarNode ) : NavigationBarItem {
558560 return {
559- text : getItemName ( n . node ) ,
561+ text : getItemName ( n . node , n . name ) ,
560562 kind : getNodeKind ( n . node ) ,
561563 kindModifiers : getNodeModifiers ( n . node ) ,
562564 spans : getSpans ( n ) ,
0 commit comments