File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
test/SourceKit/CodeComplete Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -614,6 +614,7 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
614
614
bool hasCCToken = false ;
615
615
if (SourceMgr.hasCodeCompletionBuffer () &&
616
616
SourceMgr.getCodeCompletionBufferID () == L->getBufferID ()) {
617
+ llvm::SaveAndRestore<Optional<llvm::MD5>> H (CurrentTokenHash, None);
617
618
BacktrackingScope backtrack (*this );
618
619
auto startLoc = Tok.getLoc ();
619
620
skipSingle ();
@@ -676,6 +677,7 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
676
677
677
678
// Treat the region containing code completion token as "active".
678
679
if (hasCCToken && !foundActive) {
680
+ llvm::SaveAndRestore<Optional<llvm::MD5>> H (CurrentTokenHash, None);
679
681
BacktrackingScope backtrack (*this );
680
682
auto startLoc = Tok.getLoc ();
681
683
skipUntilConditionalBlockClose ();
Original file line number Diff line number Diff line change
1
+ struct MyStruct {
2
+ init ( ) { }
3
+ var value : Int = 1
4
+ }
5
+
6
+ func foo( arg: MyStruct ) {
7
+ #if true
8
+ _ = arg./* 8 : 11 * /
9
+ #else
10
+ _ = arg./* 10 : 11 * /
11
+ #endif
12
+ }
13
+
14
+ struct TestStruct {
15
+ #if true
16
+ func testActive( arg: MyStruct ) {
17
+ _ = arg./* 17 : 13 * /
18
+ }
19
+ #else
20
+ func testInactive( arg: MyStruct ) {
21
+ _ = arg./* 21 : 13 * /
22
+ }
23
+ #endif
24
+ }
25
+
26
+ // Test that (1) fast completion happens even in inactive #if blocks, and
27
+ // (2) #if in toplevel decls invalidate cached ASTContext
28
+
29
+ // RUN: %sourcekitd-test \
30
+ // RUN: -req=complete -pos=8:11 %s -- %s -parse-as-library == \
31
+ // RUN: -req=complete -pos=10:11 %s -- %s -parse-as-library == \
32
+ // RUN: -req=complete -pos=17:13 %s -- %s -parse-as-library == \
33
+ // RUN: -req=complete -pos=21:13 %s -- %s -parse-as-library \
34
+ // RUN: | %FileCheck %s --check-prefix=RESULT
35
+
36
+ // RESULT-LABEL: key.results: [
37
+ // RESULT-DAG: key.description: "value"
38
+ // RESULT: ]
39
+ // RESULT-NOT: key.reusingastcontext: 1
40
+
41
+ // RESULT-LABEL: key.results: [
42
+ // RESULT-DAG: key.description: "value"
43
+ // RESULT: ]
44
+ // RESULT: key.reusingastcontext: 1
45
+
46
+ // RESULT-LABEL: key.results: [
47
+ // RESULT-DAG: key.description: "value"
48
+ // RESULT: ]
49
+ // RESULT: key.reusingastcontext: 1
50
+
51
+ // RESULT-LABEL: key.results: [
52
+ // RESULT-DAG: key.description: "value"
53
+ // RESULT: ]
54
+ // RESULT-NOT: key.reusingastcontext: 1
You can’t perform that action at this time.
0 commit comments