mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SourceKit] Fix placeholder expansion not working inside #if
Update the PlaceholderFinder ASTWalker to walk into the clauses of IfConfigDecls. It wasn't previously, resulting in any placeholders there not being expanded. Also update CallExprFinder (used to determine if expansions should use trailing closure syntax) to walk into inactive if-config clauses. Previously it only walked into active regions, so expansions never used trailing closure syntax in inactive regions. Resolves rdar://problem/51995648
This commit is contained in:
@@ -1409,6 +1409,22 @@ private:
|
||||
}
|
||||
return { true, E };
|
||||
}
|
||||
|
||||
bool walkToDeclPre(Decl *D) override {
|
||||
if (auto *ICD = dyn_cast<IfConfigDecl>(D)) {
|
||||
// The base walker assumes the content of active IfConfigDecl clauses
|
||||
// has been injected into the parent context and will be walked there.
|
||||
// This doesn't hold for pre-typechecked ASTs and we need to find
|
||||
// placeholders in inactive clauses anyway, so walk them here.
|
||||
for (auto Clause: ICD->getClauses()) {
|
||||
for (auto Elem: Clause.Elements) {
|
||||
Elem.walk(*this);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class ClosureTypeWalker: public ASTWalker {
|
||||
@@ -1571,6 +1587,8 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool shouldWalkInactiveConfigRegion() override { return true; }
|
||||
|
||||
Expr *findEnclosingCallArg(SourceFile &SF, SourceLoc SL) {
|
||||
EnclosingCallAndArg = {nullptr, nullptr};
|
||||
OuterExpr = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user