Skip to content

Commit 888529c

Browse files
author
Nathan Hawes
committed
[IDE] Fix ModelASTWalker passing syntax nodes before the corresponding AST nodes had been visited
This was causing the tokens comprising image literals to be output separately, rather than as a single object literal. Resolves rdar://problem/55045797
1 parent 079a1a4 commit 888529c

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

lib/IDE/SyntaxModel.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -525,13 +525,7 @@ std::pair<bool, Expr *> ModelASTWalker::walkToExprPre(Expr *E) {
525525
pushStructureNode(SN, E);
526526
} else if (auto *Tup = dyn_cast<TupleExpr>(E)) {
527527
auto *ParentE = Parent.getAsExpr();
528-
if (isCurrentCallArgExpr(Tup)) {
529-
for (unsigned I = 0; I < Tup->getNumElements(); ++ I) {
530-
SourceLoc NameLoc = Tup->getElementNameLoc(I);
531-
if (NameLoc.isValid())
532-
passTokenNodesUntil(NameLoc, PassNodesBehavior::ExcludeNodeAtLocation);
533-
}
534-
} else if (!ParentE || !isa<InterpolatedStringLiteralExpr>(ParentE)) {
528+
if (!isCurrentCallArgExpr(Tup) && (!ParentE || !isa<InterpolatedStringLiteralExpr>(ParentE))) {
535529
SyntaxStructureNode SN;
536530
SN.Kind = SyntaxStructureKind::TupleExpression;
537531
SN.Range = charSourceRangeFromSourceRange(SM, Tup->getSourceRange());

test/IDE/coloring.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ func bar(x: Int) -> (Int, Float) {
273273

274274
// CHECK: <object-literal>#colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)</object-literal>
275275
#colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
276+
// CHECK: test(<object-literal>#imageLiteral(resourceName: "test")</object-literal>, test: <int>0</int>)
277+
test(#imageLiteral(resourceName: "test"), test: 0)
276278

277279
class GenC<T1,T2> {}
278280

0 commit comments

Comments
 (0)