mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CodeCompletion] Address Argyrios' and Ben's comments.
Swift SVN r30772
This commit is contained in:
@@ -697,28 +697,23 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
|
|||||||
SmallVector<StringRef, 3> ParsedKeywords;
|
SmallVector<StringRef, 3> ParsedKeywords;
|
||||||
|
|
||||||
void addSuperKeyword(CodeCompletionResultSink &Sink) {
|
void addSuperKeyword(CodeCompletionResultSink &Sink) {
|
||||||
auto *D = CurDeclContext;
|
auto *D = CurDeclContext->getInnermostTypeContext();
|
||||||
for (;D && !D->isNominalTypeOrNominalTypeExtensionContext();
|
|
||||||
D = D->getParent());
|
|
||||||
if (!D)
|
if (!D)
|
||||||
return;
|
return;
|
||||||
Type DT = D->isNominalTypeOrNominalTypeExtensionContext()->getDeclaredType();
|
Type DT = D->getDeclaredTypeInContext();
|
||||||
if (DT.isNull() || DT->is<ErrorType>())
|
if (DT.isNull() || DT->is<ErrorType>())
|
||||||
return;
|
return;
|
||||||
OwnedResolver TypeResolver(createLazyResolver(CurDeclContext->getASTContext()));
|
OwnedResolver TypeResolver(createLazyResolver(CurDeclContext->getASTContext()));
|
||||||
Type ST = DT->getSuperclass(TypeResolver.get());
|
Type ST = DT->getSuperclass(TypeResolver.get());
|
||||||
if (ST.isNull() || ST->is<ErrorType>())
|
if (ST.isNull() || ST->is<ErrorType>())
|
||||||
return;
|
return;
|
||||||
auto Nominal = ST->getNominalOrBoundGenericNominal();
|
if (ST->getNominalOrBoundGenericNominal()) {
|
||||||
if (Nominal) {
|
|
||||||
CodeCompletionResultBuilder Builder(Sink,
|
CodeCompletionResultBuilder Builder(Sink,
|
||||||
CodeCompletionResult::ResultKind::Keyword,
|
CodeCompletionResult::ResultKind::Keyword,
|
||||||
SemanticContextKind::None);
|
SemanticContextKind::None);
|
||||||
Builder.addTextChunk("super");
|
Builder.addTextChunk("super");
|
||||||
ST = ST->getReferenceStorageReferent();
|
ST = ST->getReferenceStorageReferent();
|
||||||
if (ST->isVoid())
|
assert(!ST->isVoid() && "Cannot get type name.");
|
||||||
Builder.addTypeAnnotation("Void");
|
|
||||||
else
|
|
||||||
Builder.addTypeAnnotation(ST.getString());
|
Builder.addTypeAnnotation(ST.getString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user