Skip to content

Commit

Permalink
Don’t consider Swift structs class-like
Browse files Browse the repository at this point in the history
  • Loading branch information
ahoppen committed Jul 30, 2024
1 parent ec95739 commit 777bf01
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 18 deletions.
2 changes: 0 additions & 2 deletions include/IndexStoreDB/Core/Symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ class Symbol {
SymbolLanguage getLanguage() const { return SymInfo.Lang; }

bool isCallable() const { return SymInfo.isCallable(); }
bool isClassLike() const { return SymInfo.isClassLike(); }
bool isClassLikeOrExtension() const { return SymInfo.isClassLikeOrExtension(); }

void print(raw_ostream &OS) const;
};
Expand Down
14 changes: 0 additions & 14 deletions lib/Core/Symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@ bool SymbolInfo::isCallable() const {
}
}

bool SymbolInfo::isClassLike() const {
switch (Kind) {
case SymbolKind::Class:
case SymbolKind::Struct:
return Lang != SymbolLanguage::C;
default:
return false;
}
}

bool SymbolInfo::isClassLikeOrExtension() const {
return isClassLike() || Kind == SymbolKind::Extension;
}

bool SymbolInfo::preferDeclarationAsCanonical() const {
if (Lang == SymbolLanguage::ObjC) {
return Kind == SymbolKind::Class ||
Expand Down
2 changes: 1 addition & 1 deletion lib/Database/ImportTransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ IDCode ImportTransaction::Implementation::addSymbolInfo(IDCode provider, StringR
if (symInfo.Properties.contains(SymbolProperty::UnitTest) &&
roles.contains(SymbolRole::Definition)) {
Optional<GlobalSymbolKind> unitTestGlobalKind;
if (symInfo.isClassLikeOrExtension())
if (symInfo.Kind == SymbolKind::Class || symInfo.Kind == SymbolKind::Extension)
unitTestGlobalKind = GlobalSymbolKind::TestClassOrExtension;
else if (symInfo.Kind == SymbolKind::InstanceMethod)
unitTestGlobalKind = GlobalSymbolKind::TestMethod;
Expand Down
2 changes: 1 addition & 1 deletion lib/Index/SymbolIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void SymbolIndexImpl::importSymbols(ImportTransaction &import, SymbolDataProvide
std::uninitialized_copy(Name.begin(), Name.end(), copiedStr);
StringRef copiedName = StringRef(copiedStr, Name.size());
// FIXME: Make this part of the compiler indexing output. E.g. a C++-like 'struct' should be a 'class' kind.
if (Info.isClassLike())
if (Info.Kind == SymbolKind::Struct && Info.Lang == SymbolLanguage::CXX)
Info.Kind = SymbolKind::Class;
auto pair = CoreSymbols.insert(std::make_pair(USR, CoreSymbolData{copiedName, Info, Roles, RelatedRoles}));
bool wasInserted = pair.second;
Expand Down

0 comments on commit 777bf01

Please sign in to comment.