@@ -30,13 +30,11 @@ namespace ts.SignatureHelp {
30
30
}
31
31
32
32
// Only need to be careful if the user typed a character and signature help wasn't showing.
33
- const shouldCarefullyCheckContext = ! ! triggerReason && triggerReason . kind === "characterTyped" ;
33
+ const onlyUseSyntacticOwners = ! ! triggerReason && triggerReason . kind === "characterTyped" ;
34
34
35
35
// Bail out quickly in the middle of a string or comment, don't provide signature help unless the user explicitly requested it.
36
- if ( shouldCarefullyCheckContext ) {
37
- if ( isInString ( sourceFile , position , startingToken ) || isInComment ( sourceFile , position ) ) {
38
- return undefined ;
39
- }
36
+ if ( onlyUseSyntacticOwners && ( isInString ( sourceFile , position , startingToken ) || isInComment ( sourceFile , position ) ) ) {
37
+ return undefined ;
40
38
}
41
39
42
40
const argumentInfo = getContainingArgumentInfo ( startingToken , position , sourceFile ) ;
@@ -45,7 +43,7 @@ namespace ts.SignatureHelp {
45
43
cancellationToken . throwIfCancellationRequested ( ) ;
46
44
47
45
// Extra syntactic and semantic filtering of signature help
48
- const candidateInfo = getCandidateInfo ( argumentInfo , typeChecker , sourceFile , startingToken , shouldCarefullyCheckContext ) ;
46
+ const candidateInfo = getCandidateInfo ( argumentInfo , typeChecker , sourceFile , startingToken , onlyUseSyntacticOwners ) ;
49
47
cancellationToken . throwIfCancellationRequested ( ) ;
50
48
51
49
if ( ! candidateInfo ) {
@@ -66,35 +64,9 @@ namespace ts.SignatureHelp {
66
64
67
65
const { invocation } = argumentInfo ;
68
66
if ( invocation . kind === InvocationKind . Call ) {
69
- if ( onlyUseSyntacticOwners ) {
70
- if ( isCallOrNewExpression ( invocation . node ) ) {
71
- const invocationChildren = invocation . node . getChildren ( sourceFile ) ;
72
- switch ( startingToken . kind ) {
73
- case SyntaxKind . OpenParenToken :
74
- if ( ! contains ( invocationChildren , startingToken ) ) {
75
- return undefined ;
76
- }
77
- break ;
78
- case SyntaxKind . CommaToken :
79
- const containingList = findContainingList ( startingToken ) ;
80
- if ( ! containingList || ! contains ( invocationChildren , findContainingList ( startingToken ) ) ) {
81
- return undefined ;
82
- }
83
- break ;
84
- case SyntaxKind . LessThanToken :
85
- if ( ! lessThanFollowsCalledExpression ( startingToken , sourceFile , invocation . node . expression ) ) {
86
- return undefined ;
87
- }
88
- break ;
89
- default :
90
- return undefined ;
91
- }
92
- }
93
- else {
94
- return undefined ;
95
- }
67
+ if ( onlyUseSyntacticOwners && ! isSyntacticOwner ( startingToken , invocation . node , sourceFile ) ) {
68
+ return undefined ;
96
69
}
97
-
98
70
const candidates : Signature [ ] = [ ] ;
99
71
const resolvedSignature = checker . getResolvedSignature ( invocation . node , candidates , argumentInfo . argumentCount ) ! ; // TODO: GH#18217
100
72
return candidates . length === 0 ? undefined : { candidates, resolvedSignature } ;
@@ -111,6 +83,23 @@ namespace ts.SignatureHelp {
111
83
}
112
84
}
113
85
86
+ function isSyntacticOwner ( startingToken : Node , node : CallLikeExpression , sourceFile : SourceFile ) : boolean {
87
+ if ( ! isCallOrNewExpression ( node ) ) return false ;
88
+ const invocationChildren = node . getChildren ( sourceFile ) ;
89
+ switch ( startingToken . kind ) {
90
+ case SyntaxKind . OpenParenToken :
91
+ return contains ( invocationChildren , startingToken ) ;
92
+ case SyntaxKind . CommaToken : {
93
+ const containingList = findContainingList ( startingToken ) ;
94
+ return ! ! containingList && contains ( invocationChildren , containingList ) ;
95
+ }
96
+ case SyntaxKind . LessThanToken :
97
+ return lessThanFollowsCalledExpression ( startingToken , sourceFile , node . expression ) ;
98
+ default :
99
+ return false ;
100
+ }
101
+ }
102
+
114
103
function createJavaScriptSignatureHelpItems ( argumentInfo : ArgumentListInfo , program : Program , cancellationToken : CancellationToken ) : SignatureHelpItems | undefined {
115
104
// See if we can find some symbol with the call expression name that has call signatures.
116
105
const expression = getExpressionFromInvocation ( argumentInfo . invocation ) ;
0 commit comments