@@ -631,28 +631,52 @@ 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 {
658+ if ( isCallExpression ( parent ) ) {
659+ const name = getCalledExpressionName ( parent . expression ) ;
660+ if ( name !== undefined ) {
661+ const args = mapDefined ( parent . arguments , a => isStringLiteral ( a ) ? a . getText ( curSourceFile ) : undefined ) . join ( ", " ) ;
662+ return `${ name } (${ args } ) callback` ;
663+ }
664+ }
665+ return "<function>" ;
666+ }
667+ }
668+
669+ function getCalledExpressionName ( expr : Expression ) : string | undefined {
670+ if ( isIdentifier ( expr ) ) {
671+ return expr . text ;
672+ }
673+ else if ( isPropertyAccessExpression ( expr ) ) {
674+ const left = getCalledExpressionName ( expr . expression ) ;
675+ const right = expr . name . text ;
676+ return left === undefined ? right : `${ left } .${ right } ` ;
677+ }
654678 else {
655- return isClassLike ( node ) ? "<class>" : "<function>" ;
679+ return undefined ;
656680 }
657681 }
658682
0 commit comments