@@ -101,31 +101,16 @@ namespace ts.SignatureHelp {
101101 function createJavaScriptSignatureHelpItems ( argumentInfo : ArgumentListInfo , program : Program , cancellationToken : CancellationToken ) : SignatureHelpItems | undefined {
102102 // See if we can find some symbol with the call expression name that has call signatures.
103103 const expression = getExpressionFromInvocation ( argumentInfo . invocation ) ;
104- const name = isIdentifier ( expression ) ? expression : isPropertyAccessExpression ( expression ) ? expression . name : undefined ;
105- if ( ! name || ! name . escapedText ) {
106- return undefined ;
107- }
108-
104+ const name = isIdentifier ( expression ) ? expression . text : isPropertyAccessExpression ( expression ) ? expression . name . text : undefined ;
109105 const typeChecker = program . getTypeChecker ( ) ;
110- for ( const sourceFile of program . getSourceFiles ( ) ) {
111- const nameToDeclarations = sourceFile . getNamedDeclarations ( ) ;
112- const declarations = nameToDeclarations . get ( name . text ) ;
113-
114- if ( declarations ) {
115- for ( const declaration of declarations ) {
116- const symbol = declaration . symbol ;
117- if ( symbol ) {
118- const type = typeChecker . getTypeOfSymbolAtLocation ( symbol , declaration ) ;
119- if ( type ) {
120- const callSignatures = type . getCallSignatures ( ) ;
121- if ( callSignatures && callSignatures . length ) {
122- return typeChecker . runWithCancellationToken ( cancellationToken , typeChecker => createSignatureHelpItems ( callSignatures , callSignatures [ 0 ] , argumentInfo , sourceFile , typeChecker ) ) ;
123- }
124- }
125- }
106+ return name === undefined ? undefined : firstDefined ( program . getSourceFiles ( ) , sourceFile =>
107+ firstDefined ( sourceFile . getNamedDeclarations ( ) . get ( name ) , declaration => {
108+ const type = declaration . symbol && typeChecker . getTypeOfSymbolAtLocation ( declaration . symbol , declaration ) ;
109+ const callSignatures = type && type . getCallSignatures ( ) ;
110+ if ( callSignatures && callSignatures . length ) {
111+ return typeChecker . runWithCancellationToken ( cancellationToken , typeChecker => createSignatureHelpItems ( callSignatures , callSignatures [ 0 ] , argumentInfo , sourceFile , typeChecker ) ) ;
126112 }
127- }
128- }
113+ } ) ) ;
129114 }
130115
131116 function lessThanFollowsCalledExpression ( startingToken : Node , sourceFile : SourceFile , calledExpression : Expression ) {
0 commit comments