mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CodeCompletion] Added check dependency test for complete.open
This commit is contained in:
@@ -1 +1,5 @@
|
||||
func localSwiftFunc() -> Int {}
|
||||
|
||||
struct MyStruct {
|
||||
func myStructMethod() {}
|
||||
}
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
func localSwiftFunc_mod() -> Int {}
|
||||
|
||||
struct MyStruct {
|
||||
func myStructMethod_mod() {}
|
||||
}
|
||||
|
||||
45
test/SourceKit/CodeComplete/complete_checkdeps_vfs.swift
Normal file
45
test/SourceKit/CodeComplete/complete_checkdeps_vfs.swift
Normal file
@@ -0,0 +1,45 @@
|
||||
func foo(value: MyStruct) {
|
||||
value./*HERE*/
|
||||
}
|
||||
|
||||
// RUN: DEPCHECK_INTERVAL=1
|
||||
// RUN: SLEEP_TIME=2
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// RUN: %sourcekitd-test \
|
||||
// RUN: -req=global-config -completion-check-dependency-interval ${DEPCHECK_INTERVAL} == \
|
||||
|
||||
// RUN: -shell -- echo "### Initial" == \
|
||||
// RUN: -req=complete -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/Library.swift == \
|
||||
|
||||
// RUN: -shell -- echo "### Modify" == \
|
||||
// RUN: -shell -- sleep ${SLEEP_TIME} == \
|
||||
// RUN: -req=complete -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject_mod/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/Library.swift == \
|
||||
|
||||
// RUN: -shell -- echo "### Keep" == \
|
||||
// RUN: -shell -- sleep ${SLEEP_TIME} == \
|
||||
// RUN: -req=complete -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject_mod/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/Library.swift \
|
||||
|
||||
// RUN: | %FileCheck %s
|
||||
|
||||
// CHECK-LABEL: ### Initial
|
||||
// CHECK: key.results: [
|
||||
// CHECK-DAG: key.description: "myStructMethod()"
|
||||
// CHECK-DAG: key.description: "self"
|
||||
// CHECK: ]
|
||||
// CHECK-NOT: key.reusingastcontext: 1
|
||||
|
||||
// CHECK-LABEL: ### Modify
|
||||
// CHECK: key.results: [
|
||||
// CHECK-DAG: key.description: "myStructMethod_mod()"
|
||||
// CHECK-DAG: key.description: "self"
|
||||
// CHECK: ]
|
||||
// CHECK-NOT: key.reusingastcontext: 1
|
||||
|
||||
// CHECK-LABEL: ### Keep
|
||||
// CHECK: key.results: [
|
||||
// CHECK-DAG: key.description: "myStructMethod_mod()"
|
||||
// CHECK-DAG: key.description: "self"
|
||||
// CHECK: ]
|
||||
// CHECK: key.reusingastcontext: 1
|
||||
@@ -0,0 +1,46 @@
|
||||
func foo(value: MyStruct) {
|
||||
value./*HERE*/
|
||||
}
|
||||
|
||||
// RUN: DEPCHECK_INTERVAL=1
|
||||
// RUN: SLEEP_TIME=2
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %sourcekitd-test \
|
||||
// RUN: -req=global-config -completion-check-dependency-interval ${DEPCHECK_INTERVAL} == \
|
||||
|
||||
// RUN: -shell -- echo "### Initial" == \
|
||||
// RUN: -req=complete.open -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/Library.swift == \
|
||||
// RUN: -req=complete.close -pos=2:9 -name %t/VFS/Main.swift %s == \
|
||||
|
||||
// RUN: -shell -- echo "### Modify" == \
|
||||
// RUN: -shell -- sleep ${SLEEP_TIME} == \
|
||||
// RUN: -req=complete.open -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject_mod/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/Library.swift == \
|
||||
// RUN: -req=complete.close -pos=2:9 -name %t/VFS/Main.swift %s == \
|
||||
|
||||
// RUN: -shell -- echo "### Keep" == \
|
||||
// RUN: -req=complete.open -pos=2:9 -pass-as-sourcetext -vfs-files=%t/VFS/Main.swift=@%s,%t/VFS/Library.swift=@%S/Inputs/checkdeps/MyProject_mod/Library.swift %t/VFS/Main.swift -- -target %target-triple %t/VFS/Main.swift %t/VFS/Library.swift == \
|
||||
// RUN: -req=complete.close -pos=2:9 -name %t/VFS/Main.swift %s \
|
||||
|
||||
// RUN: | %FileCheck %s
|
||||
|
||||
// CHECK-LABEL: ### Initial
|
||||
// CHECK: key.results: [
|
||||
// CHECK-DAG: key.description: "myStructMethod()"
|
||||
// CHECK-DAG: key.description: "self"
|
||||
// CHECK: ]
|
||||
// CHECK-NOT: key.reusingastcontext: 1
|
||||
|
||||
// CHECK-LABEL: ### Modify
|
||||
// CHECK: key.results: [
|
||||
// CHECK-DAG: key.description: "myStructMethod_mod()"
|
||||
// CHECK-DAG: key.description: "self"
|
||||
// CHECK: ]
|
||||
// CHECK-NOT: key.reusingastcontext: 1
|
||||
|
||||
// CHECK-LABEL: ### Keep
|
||||
// CHECK: key.results: [
|
||||
// CHECK-DAG: key.description: "myStructMethod_mod()"
|
||||
// CHECK-DAG: key.description: "self"
|
||||
// CHECK: ]
|
||||
// CHECK: key.reusingastcontext: 1
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
virtual void failed(StringRef ErrDescription) = 0;
|
||||
|
||||
virtual void setCompletionKind(UIdent kind) {};
|
||||
virtual void setReusingASTContext(bool) {};
|
||||
virtual void setReusingASTContext(bool) = 0;
|
||||
virtual bool handleResult(const CodeCompletionInfo &Info) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -1221,6 +1221,7 @@ void SwiftLangSupport::codeCompleteOpen(
|
||||
completionKind = completionCtx.CodeCompletionKind;
|
||||
typeContextKind = completionCtx.typeContextKind;
|
||||
mayUseImplicitMemberExpr = completionCtx.MayUseImplicitMemberExpr;
|
||||
consumer.setReusingASTContext(completionCtx.ReusingASTContext);
|
||||
completions =
|
||||
extendCompletions(results, sink, info, nameToPopularity, CCOpts);
|
||||
});
|
||||
|
||||
@@ -2034,6 +2034,7 @@ public:
|
||||
void startGroup(UIdent kind, StringRef name) override;
|
||||
void endGroup() override;
|
||||
void setNextRequestStart(unsigned offset) override;
|
||||
void setReusingASTContext(bool flag) override;
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
@@ -2231,6 +2232,10 @@ void SKGroupedCodeCompletionConsumer::setNextRequestStart(unsigned offset) {
|
||||
assert(!Response.isNull());
|
||||
Response.set(KeyNextRequestStart, offset);
|
||||
}
|
||||
void SKGroupedCodeCompletionConsumer::setReusingASTContext(bool flag) {
|
||||
if (flag)
|
||||
RespBuilder.getDictionary().setBool(KeyReusingASTContext, flag);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Type Context Info
|
||||
|
||||
Reference in New Issue
Block a user