@@ -631,28 +631,50 @@ namespace ts.NavigationBar {
631631 }
632632
633633 function getFunctionOrClassName ( node : FunctionExpression | FunctionDeclaration | ArrowFunction | ClassLikeDeclaration ) : string {
634+ const { parent } = node ;
634635 if ( node . name && getFullWidth ( node . name ) > 0 ) {
635636 return declarationNameToString ( node . name ) ;
636637 }
637638 // See if it is a var initializer. If so, use the var name.
638- else if ( node . parent . kind === SyntaxKind . VariableDeclaration ) {
639- return declarationNameToString ( ( node . parent as VariableDeclaration ) . name ) ;
639+ else if ( isVariableDeclaration ( parent ) ) {
640+ return declarationNameToString ( parent . name ) ;
640641 }
641642 // See if it is of the form "<expr> = function(){...}". If so, use the text from the left-hand side.
642- else if ( node . parent . kind === SyntaxKind . BinaryExpression &&
643- ( node . parent as BinaryExpression ) . operatorToken . kind === SyntaxKind . EqualsToken ) {
644- return nodeText ( ( node . parent as BinaryExpression ) . left ) . replace ( whiteSpaceRegex , "" ) ;
643+ else if ( isBinaryExpression ( parent ) && parent . operatorToken . kind === SyntaxKind . EqualsToken ) {
644+ return nodeText ( parent . left ) . replace ( whiteSpaceRegex , "" ) ;
645645 }
646646 // See if it is a property assignment, and if so use the property name
647- else if ( node . parent . kind === SyntaxKind . PropertyAssignment && ( node . parent as PropertyAssignment ) . name ) {
648- return nodeText ( ( node . parent as PropertyAssignment ) . name ) ;
647+ else if ( isPropertyAssignment ( parent ) ) {
648+ return nodeText ( parent . name ) ;
649649 }
650650 // Default exports are named "default"
651651 else if ( getModifierFlags ( node ) & ModifierFlags . Default ) {
652652 return "default" ;
653653 }
654+ else if ( isClassLike ( node ) ) {
655+ return "<class>" ;
656+ }
657+ else if ( isCallExpression ( parent ) ) {
658+ const name = getCalledExpressionName ( parent . expression ) ;
659+ if ( name !== undefined ) {
660+ const args = mapDefined ( parent . arguments , a => isStringLiteral ( a ) ? a . getText ( curSourceFile ) : undefined ) . join ( ", " ) ;
661+ return `${ name } (${ args } ) callback` ;
662+ }
663+ }
664+ return "<function>" ;
665+ }
666+
667+ function getCalledExpressionName ( expr : Expression ) : string | undefined {
668+ if ( isIdentifier ( expr ) ) {
669+ return expr . text ;
670+ }
671+ else if ( isPropertyAccessExpression ( expr ) ) {
672+ const left = getCalledExpressionName ( expr . expression ) ;
673+ const right = expr . name . text ;
674+ return left === undefined ? right : `${ left } .${ right } ` ;
675+ }
654676 else {
655- return isClassLike ( node ) ? "<class>" : "<function>" ;
677+ return undefined ;
656678 }
657679 }
658680
0 commit comments