@@ -1209,72 +1209,6 @@ bool LimitedResultView::walk(CodeCompletionView::Walker &walker) const {
1209
1209
// CompletionBuilder
1210
1210
// ===----------------------------------------------------------------------===//
1211
1211
1212
- void CompletionBuilder::getFilterName (CodeCompletionString *str,
1213
- raw_ostream &OS) {
1214
- using ChunkKind = CodeCompletionString::Chunk::ChunkKind;
1215
-
1216
- // FIXME: we need a more uniform way to handle operator completions.
1217
- if (str->getChunks ().size () == 1 && str->getChunks ()[0 ].is (ChunkKind::Dot)) {
1218
- OS << " ." ;
1219
- return ;
1220
- } else if (str->getChunks ().size () == 2 &&
1221
- str->getChunks ()[0 ].is (ChunkKind::QuestionMark) &&
1222
- str->getChunks ()[1 ].is (ChunkKind::Dot)) {
1223
- OS << " ?." ;
1224
- return ;
1225
- }
1226
-
1227
- auto FirstTextChunk = str->getFirstTextChunkIndex ();
1228
- if (FirstTextChunk.hasValue ()) {
1229
- auto chunks = str->getChunks ().slice (*FirstTextChunk);
1230
- for (auto i = chunks.begin (), e = chunks.end (); i != e; ++i) {
1231
- auto &C = *i;
1232
-
1233
- if (C.is (ChunkKind::BraceStmtWithCursor))
1234
- break ; // Don't include brace-stmt in filter name.
1235
-
1236
- if (C.is (ChunkKind::Equal)) {
1237
- OS << C.getText ();
1238
- break ;
1239
- }
1240
-
1241
- bool shouldPrint = !C.isAnnotation ();
1242
- switch (C.getKind ()) {
1243
- case ChunkKind::TypeAnnotation:
1244
- case ChunkKind::CallParameterInternalName:
1245
- case ChunkKind::CallParameterClosureType:
1246
- case ChunkKind::CallParameterClosureExpr:
1247
- case ChunkKind::CallParameterType:
1248
- case ChunkKind::DeclAttrParamColon:
1249
- case ChunkKind::Comma:
1250
- case ChunkKind::Whitespace:
1251
- case ChunkKind::Ellipsis:
1252
- case ChunkKind::Ampersand:
1253
- case ChunkKind::OptionalMethodCallTail:
1254
- continue ;
1255
- case ChunkKind::CallParameterTypeBegin:
1256
- case ChunkKind::TypeAnnotationBegin: {
1257
- // Skip call parameter type or type annotation structure.
1258
- auto nestingLevel = C.getNestingLevel ();
1259
- do { ++i; } while (i != e && !i->endsPreviousNestedGroup (nestingLevel));
1260
- --i;
1261
- continue ;
1262
- }
1263
- case ChunkKind::CallParameterColon:
1264
- // Since we don't add the type, also don't add the space after ':'.
1265
- if (shouldPrint)
1266
- OS << " :" ;
1267
- continue ;
1268
- default :
1269
- break ;
1270
- }
1271
-
1272
- if (C.hasText () && shouldPrint)
1273
- OS << C.getText ();
1274
- }
1275
- }
1276
- }
1277
-
1278
1212
CompletionBuilder::CompletionBuilder (CompletionSink &sink, SwiftResult &base)
1279
1213
: sink(sink), current(base) {
1280
1214
typeRelation = current.getExpectedTypeRelation ();
@@ -1286,7 +1220,7 @@ CompletionBuilder::CompletionBuilder(CompletionSink &sink, SwiftResult &base)
1286
1220
// strings for our inner "." result.
1287
1221
if (current.getCompletionString ()->getFirstTextChunkIndex ().hasValue ()) {
1288
1222
llvm::raw_svector_ostream OSS (originalName);
1289
- getFilterName (current. getCompletionString () , OSS);
1223
+ ide::printCodeCompletionResultFilterName (current, OSS);
1290
1224
}
1291
1225
}
1292
1226
@@ -1336,7 +1270,7 @@ Completion *CompletionBuilder::finish() {
1336
1270
}
1337
1271
1338
1272
llvm::raw_svector_ostream OSS (nameStorage);
1339
- getFilterName (base. getCompletionString () , OSS);
1273
+ ide::printCodeCompletionResultFilterName (base, OSS);
1340
1274
name = OSS.str ();
1341
1275
}
1342
1276
0 commit comments