Skip to content

Commit 3700edb

Browse files
committed
[SourceKit] Fix issue where CompletionCheckDependencyInterval is set to 0 when the global config request is sent
Fixes rdar://66309544
1 parent 74f6199 commit 3700edb

File tree

2 files changed

+78
-5
lines changed

2 files changed

+78
-5
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import ClangFW
2+
import SwiftFW
3+
4+
func foo() {
5+
/*HERE*/
6+
}
7+
8+
// Checks that, due to default check delay, a modification will be ignored and fast completion will still activate.
9+
// REQUIRES: shell
10+
11+
// RUN: %empty-directory(%t/Frameworks)
12+
// RUN: %empty-directory(%t/MyProject)
13+
14+
// RUN: COMPILER_ARGS=( \
15+
// RUN: -target %target-triple \
16+
// RUN: -module-name MyProject \
17+
// RUN: -F %t/Frameworks \
18+
// RUN: -I %t/MyProject \
19+
// RUN: -import-objc-header %t/MyProject/Bridging.h \
20+
// RUN: %t/MyProject/Library.swift \
21+
// RUN: %s \
22+
// RUN: )
23+
// RUN: INPUT_DIR=%S/Inputs/checkdeps
24+
// RUN: DEPCHECK_INTERVAL=1
25+
// RUN: SLEEP_TIME=2
26+
27+
// RUN: cp -R $INPUT_DIR/MyProject %t/
28+
// RUN: cp -R $INPUT_DIR/ClangFW.framework %t/Frameworks/
29+
// RUN: %empty-directory(%t/Frameworks/SwiftFW.framework/Modules/SwiftFW.swiftmodule)
30+
// RUN: %target-swift-frontend -emit-module -module-name SwiftFW -o %t/Frameworks/SwiftFW.framework/Modules/SwiftFW.swiftmodule/%target-swiftmodule-name $INPUT_DIR/SwiftFW_src/Funcs.swift
31+
32+
// RUN: %sourcekitd-test \
33+
// RUN: -req=global-config == \
34+
35+
// RUN: -shell -- echo "### Initial" == \
36+
// RUN: -req=complete -pos=5:3 %s -- ${COMPILER_ARGS[@]} == \
37+
38+
// RUN: -shell -- echo '### Modify framework (c)' == \
39+
// RUN: -shell -- sleep $SLEEP_TIME == \
40+
// RUN: -shell -- cp -R $INPUT_DIR/ClangFW.framework_mod/* %t/Frameworks/ClangFW.framework/ == \
41+
// RUN: -req=complete -pos=5:3 %s -- ${COMPILER_ARGS[@]} == \
42+
43+
// RUN: -req=global-config -completion-check-dependency-interval ${DEPCHECK_INTERVAL} == \
44+
// RUN: -shell -- echo '### Checking dependencies' == \
45+
// RUN: -req=complete -pos=5:3 %s -- ${COMPILER_ARGS[@]} \
46+
47+
// RUN: | %FileCheck %s
48+
49+
50+
// CHECK-LABEL: ### Initial
51+
// CHECK: key.results: [
52+
// CHECK-DAG: key.description: "clangFWFunc()"
53+
// CHECK-DAG: key.description: "swiftFWFunc()"
54+
// CHECK-DAG: key.description: "localClangFunc()"
55+
// CHECK-DAG: key.description: "localSwiftFunc()"
56+
// CHECK: ]
57+
// CHECK-NOT: key.reusingastcontext: 1
58+
59+
// CHECK-LABEL: ### Modify framework (c)
60+
// CHECK: key.results: [
61+
// CHECK-DAG: key.description: "clangFWFunc()"
62+
// CHECK-DAG: key.description: "swiftFWFunc()"
63+
// CHECK-DAG: key.description: "localClangFunc()"
64+
// CHECK-DAG: key.description: "localSwiftFunc()"
65+
// CHECK: ]
66+
// CHECK: key.reusingastcontext: 1
67+
68+
// CHECK-LABEL: ### Checking dependencies
69+
// CHECK: key.results: [
70+
// CHECK-DAG: key.description: "clangFWFunc_mod()"
71+
// CHECK-DAG: key.description: "swiftFWFunc()"
72+
// CHECK-DAG: key.description: "localClangFunc()"
73+
// CHECK-DAG: key.description: "localSwiftFunc()"
74+
// CHECK: ]
75+
// CHECK-NOT: key.reusingastcontext: 1

tools/SourceKit/tools/sourcekitd/lib/API/Requests.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,9 @@ void handleRequestImpl(sourcekitd_object_t ReqObj, ResponseReceiver Rec) {
440440
if (!Req.getInt64(KeyOptimizeForIDE, EditorMode, true)) {
441441
OptimizeForIDE = EditorMode;
442442
}
443-
Optional<unsigned> CompletionCheckDependencyInterval;
444-
int64_t IntervalValue = 0;
445-
if (!Req.getInt64(KeyCompletionCheckDependencyInterval,
446-
IntervalValue, /*isOptional=*/true))
447-
CompletionCheckDependencyInterval = IntervalValue;
443+
Optional<unsigned> CompletionCheckDependencyInterval =
444+
Req.getOptionalInt64(KeyCompletionCheckDependencyInterval)
445+
.map([](int64_t v)->unsigned{return v;});
448446

449447
GlobalConfig::Settings UpdatedConfig = Config->update(
450448
OptimizeForIDE, CompletionCheckDependencyInterval);

0 commit comments

Comments
 (0)