mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[IDE] Fix SyntaxModel to corretly walk sequence expression correctly
* Handle sequence expression at call argument position * Set the sequence expression as the parent when walking into its sub expressions. * Correctly call walkToExprPost() to the sequence expression. rdar://problem/47603866 / https://bugs.swift.org/browse/SR-9776
This commit is contained in:
@@ -425,18 +425,6 @@ std::pair<bool, Expr *> ModelASTWalker::walkToExprPre(Expr *E) {
|
||||
if (isVisitedBeforeInIfConfig(E))
|
||||
return {false, E};
|
||||
|
||||
// In SequenceExpr, explicit cast expressions (e.g. 'as', 'is') appear twice.
|
||||
// Skip pointers we've already seen.
|
||||
if (auto SE = dyn_cast<SequenceExpr>(E)) {
|
||||
SmallPtrSet<Expr *, 5> seenExpr;
|
||||
for (auto subExpr : SE->getElements()) {
|
||||
if (!seenExpr.insert(subExpr).second)
|
||||
continue;
|
||||
subExpr->walk(*this);
|
||||
}
|
||||
return { false, SE };
|
||||
}
|
||||
|
||||
auto addCallArgExpr = [&](Expr *Elem, TupleExpr *ParentTupleExpr) {
|
||||
if (isCurrentCallArgExpr(ParentTupleExpr)) {
|
||||
CharSourceRange NR = parameterNameRangeOfCallArg(ParentTupleExpr, Elem);
|
||||
@@ -558,6 +546,18 @@ std::pair<bool, Expr *> ModelASTWalker::walkToExprPre(Expr *E) {
|
||||
Closure->getExplicitResultTypeLoc().getSourceRange());
|
||||
|
||||
pushStructureNode(SN, Closure);
|
||||
} else if (auto SE = dyn_cast<SequenceExpr>(E)) {
|
||||
// In SequenceExpr, explicit cast expressions (e.g. 'as', 'is') appear
|
||||
// twice. Skip pointers we've already seen.
|
||||
SmallPtrSet<Expr *, 5> seenExpr;
|
||||
for (auto subExpr : SE->getElements()) {
|
||||
if (!seenExpr.insert(subExpr).second) {
|
||||
continue;
|
||||
}
|
||||
llvm::SaveAndRestore<ASTWalker::ParentTy> SetParent(Parent, E);
|
||||
subExpr->walk(*this);
|
||||
}
|
||||
return { false, walkToExprPost(SE) };
|
||||
}
|
||||
|
||||
return { true, E };
|
||||
|
||||
Reference in New Issue
Block a user