@@ -920,8 +920,8 @@ static void setLocationInfo(const ValueDecl *VD,
920
920
921
921
static llvm::Error
922
922
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,
925
925
ArrayRef<ImmutableTextSnapshotRef> PreviousSnaps,
926
926
llvm::BumpPtrAllocator &Allocator) {
927
927
SmallString<256 > Buffer;
@@ -1142,11 +1142,10 @@ fillSymbolInfo(CursorSymbolInfo &Symbol, const DeclInfo &DInfo,
1142
1142
1143
1143
// / Returns true on success, false on error (and sets `Diagnostic` accordingly).
1144
1144
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,
1150
1149
std::function<void (const RequestResult<CursorInfoData> &)> Receiver) {
1151
1150
DeclInfo OrigInfo (Info.getValueD (), Info.getContainerType (), Info.isRef (),
1152
1151
Info.isDynamic (), Info.getReceiverTypes (), Invoc);
@@ -1165,19 +1164,19 @@ static bool passCursorInfoForDecl(
1165
1164
// The primary result for constructor calls, eg. `MyType()` should be
1166
1165
// the type itself, rather than the constructor. The constructor will be
1167
1166
// 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)) {
1171
1170
llvm::handleAllErrors (std::move (Err), [&](const llvm::StringError &E) {
1172
1171
Diagnostic = E.message ();
1173
1172
});
1174
1173
return false ;
1175
1174
}
1176
1175
if (MainInfo.VD != OrigInfo.VD && !OrigInfo.Unavailable ) {
1177
1176
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)) {
1181
1180
// Ignore but make sure to remove the partially-filled symbol
1182
1181
llvm::handleAllErrors (std::move (Err), [](const llvm::StringError &E) {});
1183
1182
Symbols.pop_back ();
@@ -1187,9 +1186,9 @@ static bool passCursorInfoForDecl(
1187
1186
CursorSymbolInfo &SymbolInfo = Symbols.emplace_back ();
1188
1187
DeclInfo DInfo (D, Type (), /* IsRef=*/ true , /* IsDynamic=*/ false ,
1189
1188
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)) {
1193
1192
// Ignore but make sure to remove the partially-filled symbol
1194
1193
llvm::handleAllErrors (std::move (Err), [](const llvm::StringError &E) {});
1195
1194
Symbols.pop_back ();
@@ -1476,7 +1475,6 @@ static void resolveCursor(
1476
1475
1477
1476
void handlePrimaryAST (ASTUnitRef AstUnit) override {
1478
1477
auto &CompIns = AstUnit->getCompilerInstance ();
1479
- ModuleDecl *MainModule = CompIns.getMainModule ();
1480
1478
SourceManager &SM = CompIns.getSourceMgr ();
1481
1479
unsigned BufferID = AstUnit->getPrimarySourceFile ().getBufferID ().value ();
1482
1480
SourceLoc Loc =
@@ -1548,8 +1546,8 @@ static void resolveCursor(
1548
1546
case CursorInfoKind::ValueRef: {
1549
1547
std::string Diagnostic;
1550
1548
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,
1553
1551
getPreviousASTSnaps (), Receiver);
1554
1552
if (!Success) {
1555
1553
if (!getPreviousASTSnaps ().empty ()) {
@@ -1880,13 +1878,12 @@ void SwiftLangSupport::getCursorInfo(
1880
1878
passCursorInfoForModule (Entity.Mod , IFaceGenContexts, Invok,
1881
1879
Receiver);
1882
1880
} else {
1883
- std::string Diagnostic; // Unused.
1884
- ModuleDecl *MainModule = IFaceGenRef->getModuleDecl ();
1881
+ std::string Diagnostic; // Unused.
1885
1882
ResolvedValueRefCursorInfo Info;
1886
1883
Info.setValueD (const_cast <ValueDecl *>(Entity.Dcl ));
1887
1884
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);
1890
1887
}
1891
1888
} else {
1892
1889
CursorInfoData Info;
@@ -2060,7 +2057,6 @@ static void resolveCursorFromUSR(
2060
2057
2061
2058
void handlePrimaryAST (ASTUnitRef AstUnit) override {
2062
2059
auto &CompIns = AstUnit->getCompilerInstance ();
2063
- ModuleDecl *MainModule = CompIns.getMainModule ();
2064
2060
2065
2061
if (USR.startswith (" c:" )) {
2066
2062
LOG_WARN_FUNC (" lookup for C/C++/ObjC USRs not implemented" );
@@ -2101,7 +2097,7 @@ static void resolveCursorFromUSR(
2101
2097
2102
2098
std::string Diagnostic;
2103
2099
bool Success =
2104
- passCursorInfoForDecl (Info, MainModule, /* AddRefactorings*/ false ,
2100
+ passCursorInfoForDecl (Info, /* AddRefactorings*/ false ,
2105
2101
/* AddSymbolGraph*/ false , {}, Lang, CompInvok,
2106
2102
Diagnostic, PreviousASTSnaps, Receiver);
2107
2103
if (!Success) {
0 commit comments