@@ -606,30 +606,17 @@ namespace ts.NavigationBar {
606606 case SyntaxKind . Constructor :
607607 case SyntaxKind . GetAccessor :
608608 case SyntaxKind . SetAccessor :
609- // "export default function().." looks just like a regular function/class declaration, except with the 'default' flag set
610- const name = node . flags && ( node . flags & NodeFlags . Default ) ? "default" :
609+ // "export default function().." looks just like a regular function/class declaration, except with the 'default' flag
610+ const name = node . flags && ( node . flags & NodeFlags . Default ) && ! ( node as ( Declaration ) ) . name ? "default" :
611611 node . kind === SyntaxKind . Constructor ? "constructor" :
612612 declarationNameToString ( ( node as ( Declaration ) ) . name ) ;
613-
614- const elementKind =
615- node . kind === SyntaxKind . VariableDeclaration ? ScriptElementKind . variableElement :
616- node . kind === SyntaxKind . FunctionDeclaration ? ScriptElementKind . functionElement :
617- node . kind === SyntaxKind . ClassDeclaration ? ScriptElementKind . classElement :
618- node . kind === SyntaxKind . Constructor ? ScriptElementKind . constructorImplementationElement :
619- node . kind === SyntaxKind . GetAccessor ? ScriptElementKind . memberGetAccessorElement :
620- node . kind === SyntaxKind . SetAccessor ? ScriptElementKind . memberSetAccessorElement :
621- "unknown" ;
622-
623- return getNavBarItem ( name , elementKind , [ getNodeSpan ( node ) ] ) ;
613+ return getNavBarItem ( name , getScriptKindForElementKind ( node . kind ) , [ getNodeSpan ( node ) ] ) ;
624614 case SyntaxKind . FunctionExpression :
625615 case SyntaxKind . ArrowFunction :
626616 case SyntaxKind . ClassExpression :
627617 return getDefineModuleItem ( node ) || getFunctionOrClassExpressionItem ( node ) ;
628618 case SyntaxKind . MethodDeclaration :
629619 const methodDecl = node as MethodDeclaration ;
630- if ( ! methodDecl . name ) {
631- return undefined ;
632- }
633620 return getNavBarItem ( declarationNameToString ( methodDecl . name ) ,
634621 ScriptElementKind . memberFunctionElement ,
635622 [ getNodeSpan ( node ) ] ) ;
@@ -710,10 +697,10 @@ namespace ts.NavigationBar {
710697 }
711698 // See if it is of the form "<expr> = function(){...}". If so, use the text from the left-hand side.
712699 else if ( fnExpr . parent . kind === SyntaxKind . BinaryExpression &&
713- ( fnExpr . parent as BinaryExpression ) . operatorToken . kind === SyntaxKind . FirstAssignment ) {
700+ ( fnExpr . parent as BinaryExpression ) . operatorToken . kind === SyntaxKind . EqualsToken ) {
714701 fnName = ( fnExpr . parent as BinaryExpression ) . left . getText ( ) ;
715702 if ( fnName . length > 20 ) {
716- fnName = fnName . substring ( 0 , 20 ) + "..." ;
703+ fnName = fnName . substring ( 0 , 17 ) + "..." ;
717704 }
718705 }
719706 // See if it is a property assignment, and if so use the property name
@@ -735,6 +722,25 @@ namespace ts.NavigationBar {
735722 : createTextSpanFromBounds ( node . getStart ( ) , node . getEnd ( ) ) ;
736723 }
737724
725+ function getScriptKindForElementKind ( kind : SyntaxKind ) {
726+ switch ( kind ) {
727+ case SyntaxKind . VariableDeclaration :
728+ return ScriptElementKind . variableElement ;
729+ case SyntaxKind . FunctionDeclaration :
730+ return ScriptElementKind . functionElement ;
731+ case SyntaxKind . ClassDeclaration :
732+ return ScriptElementKind . classElement ;
733+ case SyntaxKind . Constructor :
734+ return ScriptElementKind . constructorImplementationElement ;
735+ case SyntaxKind . GetAccessor :
736+ return ScriptElementKind . memberGetAccessorElement ;
737+ case SyntaxKind . SetAccessor :
738+ return ScriptElementKind . memberSetAccessorElement ;
739+ default :
740+ return "unknown" ;
741+ }
742+ }
743+
738744 return sourceFileItem . childItems ;
739745 }
740746}
0 commit comments