Skip to content

Commit a706461

Browse files
committed
[CodeCompletion] Always look into decls to find the parsed expression
In fast completion scenario, 'AbstractFunctionDecl' may have the body from the different file than the decl itself. Thay may confuses source range checking. As a workaround, always look into decls regardless of the range. This should not regress the speed of the searching much because statements/expressions (including nested function bodies) in the decl is still skipped if it's outside the range. rdar://problem/58098222
1 parent 10936f6 commit a706461

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ class ExprFinder : public ASTWalker {
161161
return {isInterstingRange(S), S};
162162
}
163163

164-
bool walkToDeclPre(Decl *D) override { return isInterstingRange(D); }
165-
166164
bool walkToTypeLocPre(TypeLoc &TL) override { return false; }
167165
bool walkToTypeReprPre(TypeRepr *T) override { return false; }
168166
};
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
class TestChain {
2+
class Child {
3+
var value: Struct1?
4+
}
5+
class Struct1 {
6+
var value: Struct2
7+
}
8+
class Struct2 {
9+
var prop1: Int
10+
var prop2: Int
11+
}
12+
13+
var child: Child!
14+
15+
func foo() {
16+
let _ = child.value?.value.
17+
}
18+
}
19+
20+
// rdar://problem/58098222
21+
22+
// RUN: %sourcekitd-test \
23+
// RUN: -req=complete -req-opts=reuseastcontext=1 -pos=16:32 %s -async -- %s == \
24+
// RUN: -req=complete -req-opts=reuseastcontext=1 -pos=16:32 %s -async -- %s == \
25+
// RUN: -req=complete -req-opts=reuseastcontext=1 -pos=16:32 %s -async -- %s == \
26+
// RUN: -req=complete -req-opts=reuseastcontext=1 -pos=16:32 %s -async -- %s == \
27+
// RUN: -req=complete -req-opts=reuseastcontext=1 -pos=16:32 %s -async -- %s == \
28+
// RUN: -req=complete -req-opts=reuseastcontext=1 -pos=16:32 %s -async -- %s == \
29+
// RUN: -req=complete -req-opts=reuseastcontext=1 -pos=16:32 %s -async -- %s == \
30+
// RUN: -req=complete -req-opts=reuseastcontext=1 -pos=16:32 %s -async -- %s == \
31+
// RUN: -req=complete -req-opts=reuseastcontext=1 -pos=16:32 %s -async -- %s == \
32+
// RUN: -req=complete -req-opts=reuseastcontext=1 -pos=16:32 %s -async -- %s | %FileCheck %s
33+
34+
// CHECK-NOT: key.name: "prop1"
35+
// CHECK-NOT: key.name: "prop2"
36+
// CHECK: key.name: "prop1",
37+
// CHECK: key.name: "prop2",
38+
// CHECK: key.name: "prop1",
39+
// CHECK: key.name: "prop2",
40+
// CHECK: key.name: "prop1",
41+
// CHECK: key.name: "prop2",
42+
// CHECK: key.name: "prop1",
43+
// CHECK: key.name: "prop2",
44+
// CHECK: key.name: "prop1",
45+
// CHECK: key.name: "prop2",
46+
// CHECK: key.name: "prop1",
47+
// CHECK: key.name: "prop2",
48+
// CHECK: key.name: "prop1",
49+
// CHECK: key.name: "prop2",
50+
// CHECK: key.name: "prop1",
51+
// CHECK: key.name: "prop2",
52+
// CHECK: key.name: "prop1",
53+
// CHECK: key.name: "prop2",
54+
// CHECK: key.name: "prop1",
55+
// CHECK: key.name: "prop2",
56+
// CHECK-NOT: key.name: "prop1"
57+
// CHECK-NOT: key.name: "prop2"

0 commit comments

Comments
 (0)