mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CodeCompletion] Annotated result type
Introduced 'TypeAnnotationBegin' chunk kind for grouping the result type name chunks. rdar://problem/62617558
This commit is contained in:
@@ -110,13 +110,26 @@ std::vector<Completion *> SourceKit::CodeCompletion::extendCompletions(
|
||||
// FIXME: because other-module results are cached, they will not be
|
||||
// given a type-relation of invalid. As a hack, we look at the text of
|
||||
// the result type and look for 'Void'.
|
||||
for (auto &chunk : result->getCompletionString()->getChunks()) {
|
||||
bool isVoid = false;
|
||||
auto chunks = result->getCompletionString()->getChunks();
|
||||
for (auto i = chunks.begin(), e = chunks.end(); i != e; ++i) {
|
||||
using ChunkKind = ide::CodeCompletionString::Chunk::ChunkKind;
|
||||
if (chunk.is(ChunkKind::TypeAnnotation) && chunk.hasText() &&
|
||||
chunk.getText() == "Void") {
|
||||
builder.setExpectedTypeRelation(Completion::Invalid);
|
||||
bool isVoid = false;
|
||||
if (i->is(ChunkKind::TypeAnnotation)) {
|
||||
isVoid = i->getText() == "Void";
|
||||
break;
|
||||
} else if (i->is(ChunkKind::TypeAnnotationBegin)) {
|
||||
auto n = i + 1, t = i + 2;
|
||||
isVoid =
|
||||
// i+1 has text 'Void'.
|
||||
n != e && n->hasText() && n->getText() == "Void" &&
|
||||
// i+2 terminates the group.
|
||||
(t == e || t->endsPreviousNestedGroup(i->getNestingLevel()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isVoid)
|
||||
builder.setExpectedTypeRelation(Completion::Invalid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1240,14 +1253,11 @@ void CompletionBuilder::getFilterName(CodeCompletionString *str,
|
||||
case ChunkKind::Ampersand:
|
||||
case ChunkKind::OptionalMethodCallTail:
|
||||
continue;
|
||||
case ChunkKind::CallParameterTypeBegin: {
|
||||
// Skip call parameter type type structure.
|
||||
case ChunkKind::CallParameterTypeBegin:
|
||||
case ChunkKind::TypeAnnotationBegin: {
|
||||
// Skip call parameter type or type annotation structure.
|
||||
auto nestingLevel = C.getNestingLevel();
|
||||
++i;
|
||||
for (; i != e; ++i) {
|
||||
if (i->endsPreviousNestedGroup(nestingLevel))
|
||||
break;
|
||||
}
|
||||
do { ++i; } while (i != e && !i->endsPreviousNestedGroup(nestingLevel));
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user