[CodeCompletion] Enable type completion at beginning of attribute

for 'VarDecl' or if we don't know the kind of the decl.
Property delegate allows arbitrary type name (with `@propertyDelegate`
attr).
This commit is contained in:
Rintaro Ishizaki
2019-04-17 11:07:37 -07:00
parent afd6d66130
commit 878c9c600b
4 changed files with 14 additions and 10 deletions

View File

@@ -1367,7 +1367,7 @@ public:
void completeCaseStmtKeyword() override;
void completeCaseStmtBeginning() override;
void completeCaseStmtDotPrefix() override;
void completeDeclAttrKeyword(Decl *D, bool Sil, bool Param) override;
void completeDeclAttrBeginning(Decl *D, bool Sil, bool Param) override;
void completeDeclAttrParam(DeclAttrKind DK, int Index) override;
void completeInPrecedenceGroup(SyntaxKind SK) override;
void completeNominalMemberBeginning(
@@ -4601,9 +4601,8 @@ void CodeCompletionCallbacksImpl::completeDeclAttrParam(DeclAttrKind DK,
CurDeclContext = P.CurDeclContext;
}
void CodeCompletionCallbacksImpl::completeDeclAttrKeyword(Decl *D,
bool Sil,
bool Param) {
void CodeCompletionCallbacksImpl::completeDeclAttrBeginning(Decl *D, bool Sil,
bool Param) {
Kind = CompletionKind::AttributeBegin;
IsInSil = Sil;
if (Param) {
@@ -5378,6 +5377,11 @@ void CodeCompletionCallbacksImpl::doneParsing() {
case CompletionKind::AttributeBegin: {
Lookup.getAttributeDeclCompletions(IsInSil, AttTargetDK);
// Provide any type name for property delegate.
if (!AttTargetDK || *AttTargetDK == DeclKind::Var)
Lookup.getTypeCompletionsInDeclContext(
P.Context.SourceMgr.getCodeCompletionLoc());
break;
}
case CompletionKind::AttributeDeclParen: {