mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -561,13 +561,15 @@ void ModuleFile::lookupVisibleDecls(Module::AccessPathTy accessPath,
|
||||
return;
|
||||
|
||||
for (auto item : *iter)
|
||||
consumer.foundDecl(cast<ValueDecl>(getDecl(item.second)));
|
||||
consumer.foundDecl(cast<ValueDecl>(getDecl(item.second)),
|
||||
DeclVisibilityKind::VisibleAtTopLevel);
|
||||
}
|
||||
|
||||
for (auto entry : make_range(TopLevelDecls->data_begin(),
|
||||
TopLevelDecls->data_end())) {
|
||||
for (auto item : entry)
|
||||
consumer.foundDecl(cast<ValueDecl>(getDecl(item.second)));
|
||||
consumer.foundDecl(cast<ValueDecl>(getDecl(item.second)),
|
||||
DeclVisibilityKind::VisibleAtTopLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,7 +645,7 @@ void ModuleFile::lookupClassMembers(Module::AccessPathTy accessPath,
|
||||
dc = dc->getParent();
|
||||
if (auto nominal = dc->getDeclaredTypeInContext()->getAnyNominal())
|
||||
if (nominal->getName() == accessPath.front().first)
|
||||
consumer.foundDecl(vd);
|
||||
consumer.foundDecl(vd, DeclVisibilityKind::DynamicLookup);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -652,7 +654,8 @@ void ModuleFile::lookupClassMembers(Module::AccessPathTy accessPath,
|
||||
for (const auto &list : make_range(ClassMembersByName->data_begin(),
|
||||
ClassMembersByName->data_end())) {
|
||||
for (auto item : list)
|
||||
consumer.foundDecl(cast<ValueDecl>(getDecl(item.second)));
|
||||
consumer.foundDecl(cast<ValueDecl>(getDecl(item.second)),
|
||||
DeclVisibilityKind::DynamicLookup);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user