@@ -74,15 +74,51 @@ func (l *LanguageService) GetSignatureHelpItems(
74
74
return nil
75
75
}
76
76
77
+ type signatureHelpTriggerReasonKind int32
78
+
79
+ const (
80
+ signatureHelpTriggerReasonKindNone signatureHelpTriggerReasonKind = 0 // was undefined
81
+ signatureHelpTriggerReasonKindInvoked signatureHelpTriggerReasonKind = iota // was "invoked"
82
+ signatureHelpTriggerReasonKindCharacterTyped // was "characterTyped"
83
+ signatureHelpTriggerReasonKindRetriggered // was "retrigger"
84
+ )
85
+
86
+ // Emulate VS Code's toTsTriggerReason.
87
+ triggerReasonKind := signatureHelpTriggerReasonKindNone
88
+ if context != nil {
89
+ switch context .TriggerKind {
90
+ case lsproto .SignatureHelpTriggerKindTriggerCharacter :
91
+ if context .TriggerCharacter != nil {
92
+ if context .IsRetrigger {
93
+ triggerReasonKind = signatureHelpTriggerReasonKindRetriggered
94
+ } else {
95
+ triggerReasonKind = signatureHelpTriggerReasonKindCharacterTyped
96
+ }
97
+ } else {
98
+ triggerReasonKind = signatureHelpTriggerReasonKindInvoked
99
+ }
100
+ case lsproto .SignatureHelpTriggerKindContentChange :
101
+ if context .IsRetrigger {
102
+ triggerReasonKind = signatureHelpTriggerReasonKindRetriggered
103
+ } else {
104
+ triggerReasonKind = signatureHelpTriggerReasonKindCharacterTyped
105
+ }
106
+ case lsproto .SignatureHelpTriggerKindInvoked :
107
+ triggerReasonKind = signatureHelpTriggerReasonKindInvoked
108
+ default :
109
+ triggerReasonKind = signatureHelpTriggerReasonKindInvoked
110
+ }
111
+ }
112
+
77
113
// Only need to be careful if the user typed a character and signature help wasn't showing.
78
- onlyUseSyntacticOwners := context != nil && context . TriggerKind == lsproto . SignatureHelpTriggerKindTriggerCharacter
114
+ onlyUseSyntacticOwners := triggerReasonKind == signatureHelpTriggerReasonKindCharacterTyped
79
115
80
116
// Bail out quickly in the middle of a string or comment, don't provide signature help unless the user explicitly requested it.
81
117
if onlyUseSyntacticOwners && IsInString (sourceFile , position , startingToken ) { // isInComment(sourceFile, position) needs formatting implemented
82
118
return nil
83
119
}
84
120
85
- isManuallyInvoked := context != nil && context . TriggerKind == lsproto . SignatureHelpTriggerKindInvoked
121
+ isManuallyInvoked := triggerReasonKind == signatureHelpTriggerReasonKindInvoked
86
122
argumentInfo := getContainingArgumentInfo (startingToken , sourceFile , typeChecker , isManuallyInvoked , position )
87
123
if argumentInfo == nil {
88
124
return nil
@@ -94,11 +130,13 @@ func (l *LanguageService) GetSignatureHelpItems(
94
130
candidateInfo := getCandidateOrTypeInfo (argumentInfo , typeChecker , sourceFile , startingToken , onlyUseSyntacticOwners )
95
131
// cancellationToken.throwIfCancellationRequested();
96
132
97
- // if (!candidateInfo) { !!!
98
- // // We didn't have any sig help items produced by the TS compiler. If this is a JS
99
- // // file, then see if we can figure out anything better.
100
- // return isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellationToken) : undefined;
101
- // }
133
+ if candidateInfo == nil {
134
+ // !!!
135
+ // // We didn't have any sig help items produced by the TS compiler. If this is a JS
136
+ // // file, then see if we can figure out anything better.
137
+ // return isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellationToken) : undefined;
138
+ return nil
139
+ }
102
140
103
141
// return typeChecker.runWithCancellationToken(cancellationToken, typeChecker =>
104
142
if candidateInfo .candidateInfo != nil {
0 commit comments