Skip to content

Commit e777d37

Browse files
committed
[SourceKit] Don't ignore swiftsourceinfo for solver-based cursor info
Cursor infor needs source info for referenced decls.
1 parent 1395928 commit e777d37

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

include/swift/IDETool/CompletionInstance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class CompletionInstance {
161161
swift::CompilerInvocation &Invocation, llvm::ArrayRef<const char *> Args,
162162
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
163163
llvm::MemoryBuffer *completionBuffer, unsigned int Offset,
164-
DiagnosticConsumer *DiagC,
164+
DiagnosticConsumer *DiagC, bool IgnoreSwiftSourceInfo,
165165
std::shared_ptr<std::atomic<bool>> CancellationFlag,
166166
llvm::function_ref<void(CancellableResult<CompletionInstanceResult>)>
167167
Callback);

lib/IDETool/CompletionInstance.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ void swift::ide::CompletionInstance::performOperation(
541541
swift::CompilerInvocation &Invocation, llvm::ArrayRef<const char *> Args,
542542
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
543543
llvm::MemoryBuffer *completionBuffer, unsigned int Offset,
544-
DiagnosticConsumer *DiagC,
544+
DiagnosticConsumer *DiagC, bool IgnoreSwiftSourceInfo,
545545
std::shared_ptr<std::atomic<bool>> CancellationFlag,
546546
llvm::function_ref<void(CancellableResult<CompletionInstanceResult>)>
547547
Callback) {
@@ -563,9 +563,7 @@ void swift::ide::CompletionInstance::performOperation(
563563
return;
564564
}
565565

566-
// Always disable source location resolutions from .swiftsourceinfo file
567-
// because they're somewhat heavy operations and aren't needed for completion.
568-
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;
566+
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = IgnoreSwiftSourceInfo;
569567

570568
// We don't need token list.
571569
Invocation.getLangOptions().CollectParsedToken = false;
@@ -617,9 +615,11 @@ void swift::ide::CompletionInstance::codeComplete(
617615
}
618616
};
619617

618+
// Disable source location resolutions from .swiftsourceinfo file because
619+
// they're somewhat heavy operations and aren't needed for completion.
620620
performOperation(
621621
Invocation, Args, FileSystem, completionBuffer, Offset, DiagC,
622-
CancellationFlag,
622+
/*IgnoreSwiftSourceInfo=*/true, CancellationFlag,
623623
[&](CancellableResult<CompletionInstanceResult> CIResult) {
624624
CIResult.mapAsync<CodeCompleteResult>(
625625
[&CompletionContext, &CancellationFlag](auto &Result,
@@ -696,7 +696,7 @@ void swift::ide::CompletionInstance::typeContextInfo(
696696

697697
performOperation(
698698
Invocation, Args, FileSystem, completionBuffer, Offset, DiagC,
699-
CancellationFlag,
699+
/*IgnoreSwiftSourceInfo=*/true, CancellationFlag,
700700
[&](CancellableResult<CompletionInstanceResult> CIResult) {
701701
CIResult.mapAsync<TypeContextInfoResult>(
702702
[&CancellationFlag](auto &Result, auto DeliverTransformed) {
@@ -764,7 +764,7 @@ void swift::ide::CompletionInstance::conformingMethodList(
764764

765765
performOperation(
766766
Invocation, Args, FileSystem, completionBuffer, Offset, DiagC,
767-
CancellationFlag,
767+
/*IgnoreSwiftSourceInfo=*/true, CancellationFlag,
768768
[&](CancellableResult<CompletionInstanceResult> CIResult) {
769769
CIResult.mapAsync<ConformingMethodListResults>(
770770
[&ExpectedTypeNames, &CancellationFlag](auto &Result,
@@ -830,7 +830,7 @@ void swift::ide::CompletionInstance::cursorInfo(
830830

831831
performOperation(
832832
Invocation, Args, FileSystem, completionBuffer, Offset, DiagC,
833-
CancellationFlag,
833+
/*IgnoreSwiftSourceInfo=*/false, CancellationFlag,
834834
[&](CancellableResult<CompletionInstanceResult> CIResult) {
835835
CIResult.mapAsync<CursorInfoResults>(
836836
[&CancellationFlag, Offset](auto &Result, auto DeliverTransformed) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %empty-directory(%t/split)
2+
// RUN: %{python} %utils/split_file.py -o %t/split %s
3+
// RUN: %empty-directory(%t/build)
4+
// RUN: %target-swift-frontend -emit-module -module-name MyModule -emit-module-path %t/build/MyModule.swiftmodule -emit-module-source-info-path %t/build/MyModule.swiftsourceinfo %t/split/Action.swift
5+
// RUN: %sourcekitd-test -req=cursor -req-opts=retrieve_symbol_graph=1 -pos=5:14 %t/split/test.swift -- %t/split/test.swift -I %t/build | %FileCheck %s
6+
7+
// BEGIN Action.swift
8+
public protocol Action {}
9+
10+
// BEGIN test.swift
11+
import MyModule
12+
13+
func test(action: Action) {
14+
switch action {
15+
case let action
16+
17+
// CHECK: REFERENCED DECLS BEGIN
18+
// CHECK-NEXT: s:8MyModule6ActionP | public | {{.*}}/split/Action.swift | MyModule | User | NonSPI | source.lang.swift
19+
// CHECK-NEXT: Action swift.protocol s:8MyModule6ActionP
20+
// CHECK-NEXT: REFERENCED DECLS END

0 commit comments

Comments
 (0)