Code completion: report "semantic context" for every code completion result

Semantic context describes the origin of the declaration and serves the same
purpose as opaque numeric "priority" in Clang -- to determine the most likely
completion.

This is the initial implementation.  There are a few opportunities to bump the
priority of a certain decl by giving it SemanticContextKind::ExprSpecific
context that are not implemented yet.


Swift SVN r9052
This commit is contained in:
Dmitri Hrybenko
2013-10-09 02:08:05 +00:00
parent f07d0c17f0
commit 6895c34741
8 changed files with 363 additions and 115 deletions

View File

@@ -215,13 +215,13 @@ void TUModuleCache::lookupVisibleDecls(AccessPathTy AccessPath,
if (I == TopLevelValues.end()) return;
for (auto vd : I->second)
Consumer.foundDecl(vd);
Consumer.foundDecl(vd, DeclVisibilityKind::VisibleAtTopLevel);
return;
}
for (auto &tlv : TopLevelValues) {
for (ValueDecl *vd : tlv.second)
Consumer.foundDecl(vd);
Consumer.foundDecl(vd, DeclVisibilityKind::VisibleAtTopLevel);
}
}
@@ -239,7 +239,7 @@ void TUModuleCache::lookupClassMembers(AccessPathTy accessPath,
Type ty = vd->getDeclContext()->getDeclaredTypeOfContext();
if (auto nominal = ty->getAnyNominal())
if (nominal->getName() == accessPath.front().first)
consumer.foundDecl(vd);
consumer.foundDecl(vd, DeclVisibilityKind::DynamicLookup);
}
}
return;
@@ -247,7 +247,7 @@ void TUModuleCache::lookupClassMembers(AccessPathTy accessPath,
for (auto &member : ClassMembers) {
for (ValueDecl *vd : member.second)
consumer.foundDecl(vd);
consumer.foundDecl(vd, DeclVisibilityKind::DynamicLookup);
}
}