Skip to content

Commit e2718f3

Browse files
authored
Merge pull request #80162 from hamishknight/inspector-gadget
Remove `IDEInspectionFileRequest`
2 parents 13f1bea + 2d7dbd3 commit e2718f3

File tree

4 files changed

+9
-37
lines changed

4 files changed

+9
-37
lines changed

include/swift/AST/TypeCheckRequests.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3994,25 +3994,6 @@ class PrimarySourceFilesRequest
39943994
bool isCached() const { return true; }
39953995
};
39963996

3997-
/// Retrieve the file being used for code completion in the main module.
3998-
// FIXME: This isn't really a type-checking request, if we ever split off a
3999-
// zone for more basic AST requests, this should be moved there.
4000-
class IDEInspectionFileRequest
4001-
: public SimpleRequest<IDEInspectionFileRequest,
4002-
SourceFile *(ModuleDecl *), RequestFlags::Cached> {
4003-
public:
4004-
using SimpleRequest::SimpleRequest;
4005-
4006-
private:
4007-
friend SimpleRequest;
4008-
4009-
SourceFile *evaluate(Evaluator &evaluator, ModuleDecl *mod) const;
4010-
4011-
public:
4012-
// Cached.
4013-
bool isCached() const { return true; }
4014-
};
4015-
40163997
/// Kinds of types for CustomAttr.
40173998
enum class CustomAttrTypeKind {
40183999
/// The type is required to not be expressed in terms of

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ SWIFT_REQUEST(TypeChecker, CheckRedeclarationRequest,
5151
Uncached, NoLocationInfo)
5252
SWIFT_REQUEST(TypeChecker, ClassAncestryFlagsRequest,
5353
AncestryFlags(ClassDecl *), Cached, NoLocationInfo)
54-
SWIFT_REQUEST(TypeChecker, IDEInspectionFileRequest,
55-
SourceFile *(ModuleDecl *), Cached, NoLocationInfo)
5654
SWIFT_REQUEST(TypeChecker, CompareDeclSpecializationRequest,
5755
bool (DeclContext *, ValueDecl *, ValueDecl *, bool, bool),
5856
Cached, NoLocationInfo)

lib/AST/Module.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -912,20 +912,6 @@ ArrayRef<SourceFile *> ModuleDecl::getPrimarySourceFiles() const {
912912
return evaluateOrDefault(eval, PrimarySourceFilesRequest{mutableThis}, {});
913913
}
914914

915-
SourceFile *IDEInspectionFileRequest::evaluate(Evaluator &evaluator,
916-
ModuleDecl *mod) const {
917-
const auto &SM = mod->getASTContext().SourceMgr;
918-
assert(mod->isMainModule() && "Can only do completion in the main module");
919-
assert(SM.hasIDEInspectionTargetBuffer() && "Not in IDE inspection mode?");
920-
921-
for (auto *file : mod->getFiles()) {
922-
auto *SF = dyn_cast<SourceFile>(file);
923-
if (SF && SF->getBufferID() == SM.getIDEInspectionTargetBufferID())
924-
return SF;
925-
}
926-
llvm_unreachable("Couldn't find the completion file?");
927-
}
928-
929915
#define FORWARD(name, args) \
930916
for (const FileUnit *file : getFiles()) { \
931917
file->name args; \

lib/Frontend/Frontend.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,9 +897,16 @@ std::optional<unsigned> CompilerInstance::setUpIDEInspectionTargetBuffer() {
897897
}
898898

899899
SourceFile *CompilerInstance::getIDEInspectionFile() const {
900+
ASSERT(SourceMgr.hasIDEInspectionTargetBuffer() &&
901+
"Not in IDE inspection mode?");
902+
900903
auto *mod = getMainModule();
901-
auto &eval = mod->getASTContext().evaluator;
902-
return evaluateOrDefault(eval, IDEInspectionFileRequest{mod}, nullptr);
904+
auto bufferID = SourceMgr.getIDEInspectionTargetBufferID();
905+
for (auto *SF : SourceMgr.getSourceFilesForBufferID(bufferID)) {
906+
if (SF->getParentModule() == mod)
907+
return SF;
908+
}
909+
llvm_unreachable("Couldn't find IDE inspection file?");
903910
}
904911

905912
std::string CompilerInstance::getBridgingHeaderPath() const {

0 commit comments

Comments
 (0)