MCPcopy Create free account
hub / github.com/clice-io/clice / build_snippet

Function build_snippet

src/feature/code_completion.cpp:164–209  ·  view source on GitHub ↗

Build a snippet string from a CodeCompletionString. Produces e.g. "funcName(${1:int x}, ${2:float y})" for functions, or "ClassName<${1:T}>" for class templates.

Source from the content-addressed store, hash-verified

162 case CK::CK_LeftParen:
163 in_parens = true;
164 signature += '(';
165 break;
166 case CK::CK_RightParen:
167 signature += ')';
168 in_parens = false;
169 break;
170 case CK::CK_Placeholder:
171 case CK::CK_CurrentParameter:
172 if(in_parens && chunk.Text) {
173 signature += chunk.Text;
174 }
175 break;
176 case CK::CK_Text:
177 if(in_parens && chunk.Text) {
178 signature += chunk.Text;
179 }
180 break;
181 case CK::CK_Informative: {
182 // A function that cannot be called where completion happens
183 // (a destructor after `T::`) carries its whole parameter list
184 // as informative chunks, parentheses included.
185 llvm::StringRef text = chunk.Text ? chunk.Text : "";
186 if(text == "(") {
187 in_parens = true;
188 }
189 if(in_parens) {
190 signature += text;
191 }
192 if(text == ")") {
193 in_parens = false;
194 }
195 break;
196 }
197 case CK::CK_LeftAngle:
198 signature += '<';
199 in_parens = true;
200 break;
201 case CK::CK_RightAngle:
202 signature += '>';
203 in_parens = false;
204 break;
205 case CK::CK_Comma:
206 if(in_parens) {
207 signature += ", ";
208 }
209 break;
210 default: break;
211 }
212 }

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected