Skip to content

Commit 6b57a98

Browse files
author
Nathan Hawes
authored
Merge pull request #27330 from nathawes/r55045797-image-literal-syntax-map-5.1
[5.1][IDE] Fix ModelASTWalker passing syntax nodes before the corresponding AST nodes have been visited
2 parents db50701 + 6d98481 commit 6b57a98

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
@@ -516,13 +516,7 @@ std::pair<bool, Expr *> ModelASTWalker::walkToExprPre(Expr *E) {
516516
pushStructureNode(SN, E);
517517
} else if (auto *Tup = dyn_cast<TupleExpr>(E)) {
518518
auto *ParentE = Parent.getAsExpr();
519-
if (isCurrentCallArgExpr(Tup)) {
520-
for (unsigned I = 0; I < Tup->getNumElements(); ++ I) {
521-
SourceLoc NameLoc = Tup->getElementNameLoc(I);
522-
if (NameLoc.isValid())
523-
passTokenNodesUntil(NameLoc, PassNodesBehavior::ExcludeNodeAtLocation);
524-
}
525-
} else if (!ParentE || !isa<InterpolatedStringLiteralExpr>(ParentE)) {
519+
if (!isCurrentCallArgExpr(Tup) && (!ParentE || !isa<InterpolatedStringLiteralExpr>(ParentE))) {
526520
SyntaxStructureNode SN;
527521
SN.Kind = SyntaxStructureKind::TupleExpression;
528522
SN.Range = charSourceRangeFromSourceRange(SM, Tup->getSourceRange());

test/IDE/coloring.swift

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

265265
// CHECK: <object-literal>#colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)</object-literal>
266266
#colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
267+
// CHECK: test(<object-literal>#imageLiteral(resourceName: "test")</object-literal>, test: <int>0</int>)
268+
test(#imageLiteral(resourceName: "test"), test: 0)
267269

268270
class GenC<T1,T2> {}
269271

0 commit comments

Comments
 (0)