Skip to content

Commit bf6c9f9

Browse files
committed
[SourceKit] Retrieve swiftsourcedocinfo for code completion request
We need swiftsourcedocinfo for cursor info and to be able to reuse the ASTContext from code completion for cursor info, we need to also retrieve the sourcedocinfo for code completion requests.
1 parent 8766c3c commit bf6c9f9

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

include/swift/IDETool/IDEInspectionInstance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class IDEInspectionInstance {
173173
swift::CompilerInvocation &Invocation, llvm::ArrayRef<const char *> Args,
174174
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
175175
llvm::MemoryBuffer *ideInspectionTargetBuffer, unsigned int Offset,
176-
DiagnosticConsumer *DiagC, bool IgnoreSwiftSourceInfo,
176+
DiagnosticConsumer *DiagC,
177177
std::shared_ptr<std::atomic<bool>> CancellationFlag,
178178
llvm::function_ref<void(CancellableResult<IDEInspectionInstanceResult>)>
179179
Callback);

lib/IDETool/IDEInspectionInstance.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ void swift::ide::IDEInspectionInstance::performOperation(
557557
swift::CompilerInvocation &Invocation, llvm::ArrayRef<const char *> Args,
558558
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
559559
llvm::MemoryBuffer *ideInspectionTargetBuffer, unsigned int Offset,
560-
DiagnosticConsumer *DiagC, bool IgnoreSwiftSourceInfo,
560+
DiagnosticConsumer *DiagC,
561561
std::shared_ptr<std::atomic<bool>> CancellationFlag,
562562
llvm::function_ref<void(CancellableResult<IDEInspectionInstanceResult>)>
563563
Callback) {
@@ -579,8 +579,6 @@ void swift::ide::IDEInspectionInstance::performOperation(
579579
return;
580580
}
581581

582-
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = IgnoreSwiftSourceInfo;
583-
584582
// We don't need token list.
585583
Invocation.getLangOptions().CollectParsedToken = false;
586584

@@ -636,7 +634,7 @@ void swift::ide::IDEInspectionInstance::codeComplete(
636634
// they're somewhat heavy operations and aren't needed for completion.
637635
performOperation(
638636
Invocation, Args, FileSystem, ideInspectionTargetBuffer, Offset, DiagC,
639-
/*IgnoreSwiftSourceInfo=*/true, CancellationFlag,
637+
CancellationFlag,
640638
[&](CancellableResult<IDEInspectionInstanceResult> CIResult) {
641639
CIResult.mapAsync<CodeCompleteResult>(
642640
[&CompletionContext, &CancellationFlag](auto &Result,
@@ -713,7 +711,7 @@ void swift::ide::IDEInspectionInstance::typeContextInfo(
713711

714712
performOperation(
715713
Invocation, Args, FileSystem, ideInspectionTargetBuffer, Offset, DiagC,
716-
/*IgnoreSwiftSourceInfo=*/true, CancellationFlag,
714+
CancellationFlag,
717715
[&](CancellableResult<IDEInspectionInstanceResult> CIResult) {
718716
CIResult.mapAsync<TypeContextInfoResult>(
719717
[&CancellationFlag](auto &Result, auto DeliverTransformed) {
@@ -781,7 +779,7 @@ void swift::ide::IDEInspectionInstance::conformingMethodList(
781779

782780
performOperation(
783781
Invocation, Args, FileSystem, ideInspectionTargetBuffer, Offset, DiagC,
784-
/*IgnoreSwiftSourceInfo=*/true, CancellationFlag,
782+
CancellationFlag,
785783
[&](CancellableResult<IDEInspectionInstanceResult> CIResult) {
786784
CIResult.mapAsync<ConformingMethodListResults>(
787785
[&ExpectedTypeNames, &CancellationFlag](auto &Result,
@@ -851,7 +849,7 @@ void swift::ide::IDEInspectionInstance::cursorInfo(
851849

852850
performOperation(
853851
Invocation, Args, FileSystem, ideInspectionTargetBuffer, Offset, DiagC,
854-
/*IgnoreSwiftSourceInfo=*/false, CancellationFlag,
852+
CancellationFlag,
855853
[&](CancellableResult<IDEInspectionInstanceResult> CIResult) {
856854
CIResult.mapAsync<CursorInfoResults>(
857855
[&CancellationFlag](auto &Result, auto DeliverTransformed) {

test/SourceKit/CursorInfo/cursor_uses_swiftsourceinfo.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
// 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
55
// 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 -target %target-triple | %FileCheck %s
66

7+
// We should also get source doc info if we execute a code completion request (which doesn't need source doc info) first
8+
// RUN: %sourcekitd-test \
9+
// RUN: -req=complete %t/split/test.swift -pos=5:14 -- %t/split/test.swift -I %t/build -target %target-triple == \
10+
// RUN: -req=cursor -req-opts=retrieve_symbol_graph=1 -pos=5:14 %t/split/test.swift -- %t/split/test.swift -I %t/build -target %target-triple
11+
712
// BEGIN Action.swift
813
public protocol Action {}
914

0 commit comments

Comments
 (0)