Skip to content

Commit 54360ad

Browse files
committed
[SourceKit] Remove unused MainModule param from cursor info results
1 parent 6526860 commit 54360ad

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,8 @@ static void setLocationInfo(const ValueDecl *VD,
920920

921921
static llvm::Error
922922
fillSymbolInfo(CursorSymbolInfo &Symbol, const DeclInfo &DInfo,
923-
ModuleDecl *MainModule, SourceLoc CursorLoc, bool AddSymbolGraph,
924-
SwiftLangSupport &Lang, const CompilerInvocation &Invoc,
923+
SourceLoc CursorLoc, bool AddSymbolGraph, SwiftLangSupport &Lang,
924+
const CompilerInvocation &Invoc,
925925
ArrayRef<ImmutableTextSnapshotRef> PreviousSnaps,
926926
llvm::BumpPtrAllocator &Allocator) {
927927
SmallString<256> Buffer;
@@ -1142,11 +1142,10 @@ fillSymbolInfo(CursorSymbolInfo &Symbol, const DeclInfo &DInfo,
11421142

11431143
/// Returns true on success, false on error (and sets `Diagnostic` accordingly).
11441144
static bool passCursorInfoForDecl(
1145-
const ResolvedValueRefCursorInfo &Info, ModuleDecl *MainModule,
1146-
bool AddRefactorings, bool AddSymbolGraph,
1147-
ArrayRef<RefactoringInfo> KnownRefactoringInfo, SwiftLangSupport &Lang,
1148-
const CompilerInvocation &Invoc, std::string &Diagnostic,
1149-
ArrayRef<ImmutableTextSnapshotRef> PreviousSnaps,
1145+
const ResolvedValueRefCursorInfo &Info, bool AddRefactorings,
1146+
bool AddSymbolGraph, ArrayRef<RefactoringInfo> KnownRefactoringInfo,
1147+
SwiftLangSupport &Lang, const CompilerInvocation &Invoc,
1148+
std::string &Diagnostic, ArrayRef<ImmutableTextSnapshotRef> PreviousSnaps,
11501149
std::function<void(const RequestResult<CursorInfoData> &)> Receiver) {
11511150
DeclInfo OrigInfo(Info.getValueD(), Info.getContainerType(), Info.isRef(),
11521151
Info.isDynamic(), Info.getReceiverTypes(), Invoc);
@@ -1165,19 +1164,19 @@ static bool passCursorInfoForDecl(
11651164
// The primary result for constructor calls, eg. `MyType()` should be
11661165
// the type itself, rather than the constructor. The constructor will be
11671166
// added as a secondary result.
1168-
if (auto Err = fillSymbolInfo(MainSymbol, MainInfo, MainModule, Info.getLoc(),
1169-
AddSymbolGraph, Lang, Invoc, PreviousSnaps,
1170-
Allocator)) {
1167+
if (auto Err =
1168+
fillSymbolInfo(MainSymbol, MainInfo, Info.getLoc(), AddSymbolGraph,
1169+
Lang, Invoc, PreviousSnaps, Allocator)) {
11711170
llvm::handleAllErrors(std::move(Err), [&](const llvm::StringError &E) {
11721171
Diagnostic = E.message();
11731172
});
11741173
return false;
11751174
}
11761175
if (MainInfo.VD != OrigInfo.VD && !OrigInfo.Unavailable) {
11771176
CursorSymbolInfo &CtorSymbol = Symbols.emplace_back();
1178-
if (auto Err = fillSymbolInfo(CtorSymbol, OrigInfo, MainModule,
1179-
Info.getLoc(), AddSymbolGraph, Lang, Invoc,
1180-
PreviousSnaps, Allocator)) {
1177+
if (auto Err =
1178+
fillSymbolInfo(CtorSymbol, OrigInfo, Info.getLoc(), AddSymbolGraph,
1179+
Lang, Invoc, PreviousSnaps, Allocator)) {
11811180
// Ignore but make sure to remove the partially-filled symbol
11821181
llvm::handleAllErrors(std::move(Err), [](const llvm::StringError &E) {});
11831182
Symbols.pop_back();
@@ -1187,9 +1186,9 @@ static bool passCursorInfoForDecl(
11871186
CursorSymbolInfo &SymbolInfo = Symbols.emplace_back();
11881187
DeclInfo DInfo(D, Type(), /*IsRef=*/true, /*IsDynamic=*/false,
11891188
ArrayRef<NominalTypeDecl *>(), Invoc);
1190-
if (auto Err = fillSymbolInfo(SymbolInfo, DInfo, MainModule, Info.getLoc(),
1191-
AddSymbolGraph, Lang, Invoc, PreviousSnaps,
1192-
Allocator)) {
1189+
if (auto Err =
1190+
fillSymbolInfo(SymbolInfo, DInfo, Info.getLoc(), AddSymbolGraph,
1191+
Lang, Invoc, PreviousSnaps, Allocator)) {
11931192
// Ignore but make sure to remove the partially-filled symbol
11941193
llvm::handleAllErrors(std::move(Err), [](const llvm::StringError &E) {});
11951194
Symbols.pop_back();
@@ -1476,7 +1475,6 @@ static void resolveCursor(
14761475

14771476
void handlePrimaryAST(ASTUnitRef AstUnit) override {
14781477
auto &CompIns = AstUnit->getCompilerInstance();
1479-
ModuleDecl *MainModule = CompIns.getMainModule();
14801478
SourceManager &SM = CompIns.getSourceMgr();
14811479
unsigned BufferID = AstUnit->getPrimarySourceFile().getBufferID().value();
14821480
SourceLoc Loc =
@@ -1548,8 +1546,8 @@ static void resolveCursor(
15481546
case CursorInfoKind::ValueRef: {
15491547
std::string Diagnostic;
15501548
bool Success = passCursorInfoForDecl(
1551-
cast<ResolvedValueRefCursorInfo>(CursorInfo), MainModule,
1552-
Actionables, SymbolGraph, Actions, Lang, CompInvok, Diagnostic,
1549+
cast<ResolvedValueRefCursorInfo>(CursorInfo), Actionables,
1550+
SymbolGraph, Actions, Lang, CompInvok, Diagnostic,
15531551
getPreviousASTSnaps(), Receiver);
15541552
if (!Success) {
15551553
if (!getPreviousASTSnaps().empty()) {
@@ -1880,13 +1878,12 @@ void SwiftLangSupport::getCursorInfo(
18801878
passCursorInfoForModule(Entity.Mod, IFaceGenContexts, Invok,
18811879
Receiver);
18821880
} else {
1883-
std::string Diagnostic; // Unused.
1884-
ModuleDecl *MainModule = IFaceGenRef->getModuleDecl();
1881+
std::string Diagnostic; // Unused.
18851882
ResolvedValueRefCursorInfo Info;
18861883
Info.setValueD(const_cast<ValueDecl *>(Entity.Dcl));
18871884
Info.setIsRef(Entity.IsRef);
1888-
passCursorInfoForDecl(Info, MainModule, Actionables, SymbolGraph, {},
1889-
*this, Invok, Diagnostic, {}, Receiver);
1885+
passCursorInfoForDecl(Info, Actionables, SymbolGraph, {}, *this,
1886+
Invok, Diagnostic, {}, Receiver);
18901887
}
18911888
} else {
18921889
CursorInfoData Info;
@@ -2060,7 +2057,6 @@ static void resolveCursorFromUSR(
20602057

20612058
void handlePrimaryAST(ASTUnitRef AstUnit) override {
20622059
auto &CompIns = AstUnit->getCompilerInstance();
2063-
ModuleDecl *MainModule = CompIns.getMainModule();
20642060

20652061
if (USR.startswith("c:")) {
20662062
LOG_WARN_FUNC("lookup for C/C++/ObjC USRs not implemented");
@@ -2101,7 +2097,7 @@ static void resolveCursorFromUSR(
21012097

21022098
std::string Diagnostic;
21032099
bool Success =
2104-
passCursorInfoForDecl(Info, MainModule, /*AddRefactorings*/ false,
2100+
passCursorInfoForDecl(Info, /*AddRefactorings*/ false,
21052101
/*AddSymbolGraph*/ false, {}, Lang, CompInvok,
21062102
Diagnostic, PreviousASTSnaps, Receiver);
21072103
if (!Success) {

0 commit comments

Comments
 (0)