Skip to content

[CodeCompletion] Cleanup typeCheckContextAt() #33270

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
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
20 changes: 4 additions & 16 deletions lib/IDE/ExprContextAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ using namespace ide;
// typeCheckContextAt(DeclContext, SourceLoc)
//===----------------------------------------------------------------------===//

namespace {
void typeCheckContextImpl(DeclContext *DC, SourceLoc Loc) {
// Nothing to type check in module context.
if (DC->isModuleScopeContext())
return;
void swift::ide::typeCheckContextAt(DeclContext *DC, SourceLoc Loc) {
while (isa<AbstractClosureExpr>(DC))
DC = DC->getParent();

// Make sure the extension has been bound, in case it is in an inactive #if
// or something weird like that.
Expand All @@ -67,6 +65,7 @@ void typeCheckContextImpl(DeclContext *DC, SourceLoc Loc) {
switch (DC->getContextKind()) {
case DeclContextKind::AbstractClosureExpr:
case DeclContextKind::Module:
case DeclContextKind::FileUnit:
case DeclContextKind::SerializedLocal:
case DeclContextKind::EnumElementDecl:
case DeclContextKind::GenericTypeDecl:
Expand Down Expand Up @@ -105,19 +104,8 @@ void typeCheckContextImpl(DeclContext *DC, SourceLoc Loc) {
}
break;
}

case DeclContextKind::FileUnit:
llvm_unreachable("module scope context handled above");
}
}
} // anonymous namespace

void swift::ide::typeCheckContextAt(DeclContext *DC, SourceLoc Loc) {
while (isa<AbstractClosureExpr>(DC))
DC = DC->getParent();

typeCheckContextImpl(DC, Loc);
}

//===----------------------------------------------------------------------===//
// findParsedExpr(DeclContext, Expr)
Expand Down