Skip to content

Don’t consider Swift structs class-like #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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