Skip to content

Commit 6653172

Browse files
committed
[ASTScope] Remove includeInactiveIfConfigClauses flag
This flag has never been enabled. Now that, Parser treats IfConfig block containing CC token as "active", so code completion doesn't lookup from inactive blocks.
1 parent 22c157f commit 6653172

File tree

2 files changed

+1
-41
lines changed

2 files changed

+1
-41
lines changed

include/swift/AST/NameLookup.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,6 @@ class ASTScope {
741741
return Mem;
742742
}
743743

744-
static bool areInactiveIfConfigClausesSupported();
745-
746744
private:
747745
static ast_scope::ASTSourceFileScope *createScopeTree(SourceFile *);
748746

lib/AST/ASTScopeCreation.cpp

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -479,23 +479,6 @@ class ScopeCreator final {
479479
}
480480

481481
public:
482-
/// When ASTScopes are enabled for code completion,
483-
/// IfConfigs will pose a challenge because we may need to field lookups into
484-
/// the inactive clauses, but the AST contains redundancy: the active clause's
485-
/// elements are present in the members or elements of an IterableTypeDecl or
486-
/// BraceStmt alongside of the IfConfigDecl. In addition there are two more
487-
/// complications:
488-
///
489-
/// 1. The active clause's elements may be nested inside an init self
490-
/// rebinding decl (as in StringObject.self).
491-
///
492-
/// 2. The active clause may be before or after the inactive ones
493-
///
494-
/// So, when encountering an IfConfigDecl, we will expand the inactive
495-
/// elements. Also, always sort members or elements so that the child scopes
496-
/// are in source order (Just one of several reasons we need to sort.)
497-
///
498-
static const bool includeInactiveIfConfigClauses = false;
499482

500483
private:
501484
static std::vector<ASTNode> expandIfConfigClauses(ArrayRef<ASTNode> input) {
@@ -526,9 +509,6 @@ class ScopeCreator final {
526509
if (isa<IfConfigDecl>(d))
527510
expandIfConfigClausesInto(expansion, {d}, true);
528511
}
529-
} else if (includeInactiveIfConfigClauses) {
530-
expandIfConfigClausesInto(expansion, clause.Elements,
531-
/*isInAnActiveNode=*/false);
532512
}
533513
}
534514
}
@@ -762,10 +742,6 @@ void ASTScope::
762742
impl->buildEnoughOfTreeForTopLevelExpressionsButDontRequestGenericsOrExtendedNominals();
763743
}
764744

765-
bool ASTScope::areInactiveIfConfigClausesSupported() {
766-
return ScopeCreator::includeInactiveIfConfigClauses;
767-
}
768-
769745
void ASTScope::expandFunctionBody(AbstractFunctionDecl *AFD) {
770746
auto *const SF = AFD->getParentSourceFile();
771747
SF->getScope().expandFunctionBodyImpl(AFD);
@@ -2083,10 +2059,8 @@ class LocalizableDeclContextCollector : public ASTWalker {
20832059
// catchForDebugging(D, "DictionaryBridging.swift", 694);
20842060
if (const auto *dc = dyn_cast<DeclContext>(D))
20852061
record(dc);
2086-
if (auto *icd = dyn_cast<IfConfigDecl>(D)) {
2087-
walkToClauses(icd);
2062+
if (isa<IfConfigDecl>(D))
20882063
return false;
2089-
}
20902064
if (auto *pd = dyn_cast<ParamDecl>(D))
20912065
record(pd->getDefaultArgumentInitContext());
20922066
else if (auto *pbd = dyn_cast<PatternBindingDecl>(D))
@@ -2104,18 +2078,6 @@ class LocalizableDeclContextCollector : public ASTWalker {
21042078
}
21052079

21062080
private:
2107-
void walkToClauses(IfConfigDecl *icd) {
2108-
for (auto &clause : icd->getClauses()) {
2109-
// Generate scopes for any closures in the condition
2110-
if (ScopeCreator::includeInactiveIfConfigClauses && clause.isActive) {
2111-
if (clause.Cond)
2112-
clause.Cond->walk(*this);
2113-
for (auto n : clause.Elements)
2114-
n.walk(*this);
2115-
}
2116-
}
2117-
}
2118-
21192081
void recordInitializers(PatternBindingDecl *pbd) {
21202082
for (auto idx : range(pbd->getNumPatternEntries()))
21212083
record(pbd->getInitContext(idx));

0 commit comments

Comments
 (0)