Skip to content

Commit 5617e4a

Browse files
committed
AST: TapExpr should return sub-expression's source locations if set.
Without source location, TapExpr could stop IDE from collecting parameters while perform refactoring. rdar://47835267
1 parent 9bc5bd2 commit 5617e4a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

include/swift/AST/Expr.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,11 @@ class TapExpr : public Expr {
988988
BraceStmt * getBody() const { return Body; }
989989
void setBody(BraceStmt * b) { Body = b; }
990990

991-
SourceLoc getLoc() const { return SourceLoc(); }
992-
SourceRange getSourceRange() const { return SourceRange(); }
991+
SourceLoc getLoc() const { return SubExpr ? SubExpr->getLoc() : SourceLoc(); }
992+
993+
SourceRange getSourceRange() const {
994+
return SubExpr ? SubExpr->getSourceRange() : SourceRange();
995+
}
993996

994997
static bool classof(const Expr *E) {
995998
return E->getKind() == ExprKind::Tap;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
func test(x: Int, y: Int) {
2+
let z = "x = \(x), y = \(y)"
3+
print(z)
4+
}
5+
6+
// RUN: %target-swift-ide-test -range -pos=2:1 -end-pos 4:1 -source-filename %s | %FileCheck %s -check-prefix=CHECK-PARAMS
7+
8+
// CHECK-PARAMS: <Referenced>x</Referenced><Type>Int</Type>
9+
// CHECK-PARAMS: <Referenced>y</Referenced><Type>Int</Type>

0 commit comments

Comments
 (0)