mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Index] Record the access level of declarations in the index
rdar://163256878
This commit is contained in:
@@ -135,54 +135,15 @@ private:
|
||||
if (!isRef && symbol.decl) {
|
||||
uidAttrs = getDeclAttributeUIDs(symbol.decl);
|
||||
info.Attrs = uidAttrs;
|
||||
if (auto *VD = dyn_cast<ValueDecl>(symbol.decl)) {
|
||||
if (shouldOutputEffectiveAccessOfValueSymbol(symbol.symInfo)) {
|
||||
AccessScope accessScope = VD->getFormalAccessScope();
|
||||
UIdent AttrUID = SwiftLangSupport::getUIDForFormalAccessScope(accessScope);
|
||||
info.EffectiveAccess = AttrUID;
|
||||
}
|
||||
if (auto accessLevel = clang::index::getSwiftAccessLevelFromSymbolPropertySet(
|
||||
symbol.symInfo.Properties)) {
|
||||
info.EffectiveAccess =
|
||||
SwiftLangSupport::getUIDForAccessLevel(*accessLevel);
|
||||
}
|
||||
}
|
||||
return func(info);
|
||||
}
|
||||
|
||||
bool shouldOutputEffectiveAccessOfValueSymbol(SymbolInfo Info) {
|
||||
SymbolKind Kind = Info.Kind;
|
||||
SymbolSubKind SubKind = Info.SubKind;
|
||||
switch (SubKind) {
|
||||
case SymbolSubKind::AccessorGetter:
|
||||
case SymbolSubKind::AccessorSetter:
|
||||
case SymbolSubKind::SwiftAccessorWillSet:
|
||||
case SymbolSubKind::SwiftAccessorDidSet:
|
||||
case SymbolSubKind::SwiftAccessorAddressor:
|
||||
case SymbolSubKind::SwiftAccessorMutableAddressor:
|
||||
case SymbolSubKind::SwiftGenericTypeParam:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (Kind) {
|
||||
case SymbolKind::Enum:
|
||||
case SymbolKind::Struct:
|
||||
case SymbolKind::Class:
|
||||
case SymbolKind::Protocol:
|
||||
case SymbolKind::Constructor:
|
||||
case SymbolKind::EnumConstant:
|
||||
case SymbolKind::Function:
|
||||
case SymbolKind::StaticMethod:
|
||||
case SymbolKind::Variable:
|
||||
case SymbolKind::InstanceMethod:
|
||||
case SymbolKind::ClassMethod:
|
||||
case SymbolKind::InstanceProperty:
|
||||
case SymbolKind::ClassProperty:
|
||||
case SymbolKind::StaticProperty:
|
||||
case SymbolKind::TypeAlias:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
bool withEntityInfo(const IndexRelation &relation, F func) {
|
||||
EntityInfo info;
|
||||
|
||||
Reference in New Issue
Block a user