Skip to content

Commit b9d5672

Browse files
author
Nathan Hawes
committed
[SourceKit] Add a global-configuration request to control SourceKit's behavior around .swiftsourceinfo files
SwiftSourceInfo files provide source location information for decls coming from loaded modules. For most IDE use cases it either has an undesirable impact on performance with no benefit (code completion), results in stale locations being used instead of more up-to-date indexer locations (cursor info), or has no observable effect (live diagnostics, which are filtered to just those with a location in the primary file). For non-IDE clients of SourceKit though, cursor info providing declaration locations for symbols from other modules is useful, so add a global configuration option (and a new request to set it) to control whether .swiftsourceinfo files are loaded or not based on use case (they are loaded by default).
1 parent 12bda79 commit b9d5672

23 files changed

+225
-54
lines changed

lib/IDE/SwiftSourceDocInfo.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -764,18 +764,21 @@ void swift::ide::getLocationInfo(const ValueDecl *VD,
764764
auto ClangNode = VD->getClangNode();
765765

766766
if (VD->getLoc().isValid()) {
767+
auto getSignatureRange = [&](const ValueDecl *VD) -> Optional<unsigned> {
768+
if (auto FD = dyn_cast<AbstractFunctionDecl>(VD)) {
769+
SourceRange R = FD->getSignatureSourceRange();
770+
if (R.isValid())
771+
return getCharLength(SM, R);
772+
}
773+
return None;
774+
};
767775
unsigned NameLen;
768-
if (auto FD = dyn_cast<AbstractFunctionDecl>(VD)) {
769-
SourceRange R = FD->getSignatureSourceRange();
770-
if (R.isInvalid())
771-
return;
772-
NameLen = getCharLength(SM, R);
776+
if (auto SigLen = getSignatureRange(VD)) {
777+
NameLen = SigLen.getValue();
778+
} else if (VD->hasName()) {
779+
NameLen = VD->getBaseName().userFacingName().size();
773780
} else {
774-
if (VD->hasName()) {
775-
NameLen = VD->getBaseName().userFacingName().size();
776-
} else {
777-
NameLen = getCharLength(SM, VD->getLoc());
778-
}
781+
NameLen = getCharLength(SM, VD->getLoc());
779782
}
780783

781784
unsigned DeclBufID = SM.findBufferContainingLoc(VD->getLoc());

test/Serialization/comments-batch-mode.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend -enable-batch-mode -emit-module -emit-module-doc -emit-module-path %t/Foo.swiftmodule %S/Inputs/comments-batch/File1.swift %S/Inputs/comments-batch/File2.swift %S/Inputs/comments-batch/File3.swift %S/Inputs/comments-batch/File4.swift %S/Inputs/comments-batch/File5.swift -module-name Foo -emit-module-source-info-path %t/Foo.swiftsourceinfo -emit-module-doc-path %t/Foo.swiftdoc
3-
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=Foo -source-filename %s -I %t | %FileCheck %s
3+
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=Foo -enable-swiftsourceinfo -source-filename %s -I %t | %FileCheck %s
44

55
// RUN: %empty-directory(%t)
66
// RUN: %target-swift-frontend -wmo -emit-module -emit-module-doc -emit-module-path %t/Foo.swiftmodule %S/Inputs/comments-batch/File1.swift %S/Inputs/comments-batch/File2.swift %S/Inputs/comments-batch/File3.swift %S/Inputs/comments-batch/File4.swift %S/Inputs/comments-batch/File5.swift -module-name Foo -emit-module-source-info-path %t/Foo.swiftsourceinfo -emit-module-doc-path %t/Foo.swiftdoc
7-
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=Foo -source-filename %s -I %t | %FileCheck %s
7+
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=Foo -enable-swiftsourceinfo -source-filename %s -I %t | %FileCheck %s
88

99
// CHECK: Inputs/comments-batch/File1.swift:2:13: Func/FuncFromFile1 RawComment=[/// Comment in File1\n]
1010
// CHECK: Inputs/comments-batch/File2.swift:2:13: Func/FuncFromFile2 RawComment=[/// Comment in File2\n]

test/Serialization/comments-framework.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// RUN: %empty-directory(%t/comments.framework/Modules/comments.swiftmodule/Project)
44

55
// RUN: %target-swift-frontend -module-name comments -emit-module -emit-module-path %t/comments.framework/Modules/comments.swiftmodule/%target-swiftmodule-name -emit-module-doc-path %t/comments.framework/Modules/comments.swiftmodule/%target-swiftdoc-name -emit-module-source-info-path %t/comments.framework/Modules/comments.swiftmodule/Project/%target-swiftsourceinfo-name %s
6-
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=comments -source-filename %s -F %t | %FileCheck %s
6+
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=comments -enable-swiftsourceinfo -source-filename %s -F %t | %FileCheck %s
77

88
// RUN: cp -r %t/comments.framework/Modules/comments.swiftmodule %t/comments.swiftmodule
9-
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=comments -source-filename %s -I %t | %FileCheck %s
9+
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=comments -enable-swiftsourceinfo -source-filename %s -I %t | %FileCheck %s
1010

1111
/// first_decl_class_1 Aaa.
1212
public class first_decl_class_1 {

test/Serialization/comments-hidden.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//
1919
// RUN: %empty-directory(%t)
2020
// RUN: %target-swift-frontend -enable-testing -module-name comments -emit-module -emit-module-path %t/comments.swiftmodule -emit-module-doc -emit-module-doc-path %t/comments.swiftdoc -emit-module-source-info-path %t/comments.swiftsourceinfo %s
21-
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=comments -source-filename %s -I %t > %t.testing.txt
21+
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=comments -enable-swiftsourceinfo -source-filename %s -I %t > %t.testing.txt
2222
// RUN: %FileCheck %s -check-prefix=SOURCE-LOC < %t.testing.txt
2323

2424
/// PublicClass Documentation

test/Serialization/comments.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// RUN: llvm-bcanalyzer %t/comments.swiftmodule | %FileCheck %s -check-prefix=BCANALYZER
66
// RUN: llvm-bcanalyzer %t/comments.swiftdoc | %FileCheck %s -check-prefix=BCANALYZER
77
// RUN: llvm-bcanalyzer %t/comments.swiftsourceinfo | %FileCheck %s -check-prefix=BCANALYZER
8-
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=comments -source-filename %s -I %t | %FileCheck %s -check-prefix=FIRST
8+
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=comments -enable-swiftsourceinfo -source-filename %s -I %t | %FileCheck %s -check-prefix=FIRST
99

1010
// Test the case when we have a multiple files in a module.
1111
//
@@ -16,7 +16,7 @@
1616
// RUN: llvm-bcanalyzer %t/comments.swiftmodule | %FileCheck %s -check-prefix=BCANALYZER
1717
// RUN: llvm-bcanalyzer %t/comments.swiftdoc | %FileCheck %s -check-prefix=BCANALYZER
1818
// RUN: llvm-bcanalyzer %t/comments.swiftsourceinfo | %FileCheck %s -check-prefix=BCANALYZER
19-
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=comments -source-filename %s -I %t > %t.printed.txt
19+
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=comments -enable-swiftsourceinfo -source-filename %s -I %t > %t.printed.txt
2020
// RUN: %FileCheck %s -check-prefix=FIRST < %t.printed.txt
2121
// RUN: %FileCheck %s -check-prefix=SECOND < %t.printed.txt
2222

test/SourceKit/CompileNotifications/arg-parsing.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// ARG_PARSE_0: {
44
// ARG_PARSE_0: key.notification: source.notification.compile-will-start
55
// ARG_PARSE_0: key.compileid: [[CID1:".*"]]
6-
// ARG_PARSE_0: key.compilerargs-string: "{{.*}}.swift -no-such-arg -Xfrontend -ignore-module-source-info"
6+
// ARG_PARSE_0: key.compilerargs-string: "{{.*}}.swift -no-such-arg"
77
// ARG_PARSE_0: }
88
// ARG_PARSE_0: {
99
// ARG_PARSE_0: key.notification: source.notification.compile-did-finish
@@ -24,7 +24,7 @@
2424
// ARG_PARSE_1: {
2525
// ARG_PARSE_1: key.notification: source.notification.compile-will-start
2626
// ARG_PARSE_1: key.compileid: [[CID1:".*"]]
27-
// ARG_PARSE_1: key.compilerargs-string: "{{.*}}.swift -no-such-arg -Xfrontend -ignore-module-source-info"
27+
// ARG_PARSE_1: key.compilerargs-string: "{{.*}}.swift -no-such-arg"
2828
// ARG_PARSE_1: }
2929
// ARG_PARSE_1: {
3030
// ARG_PARSE_1: key.notification: source.notification.compile-did-finish
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Foo
2+
func bar() {
3+
foo()
4+
}
5+
6+
// RUN: %empty-directory(%t)
7+
// RUN: echo "/// Some doc" >> %t/Foo.swift
8+
// RUN: echo "public func foo() { }" >> %t/Foo.swift
9+
// RUN: %target-swift-frontend -enable-batch-mode -emit-module -emit-module-doc -emit-module-path %t/Foo.swiftmodule %t/Foo.swift -module-name Foo -emit-module-source-info-path %t/Foo.swiftsourceinfo -emit-module-doc-path %t/Foo.swiftdoc
10+
//
11+
// Test setting optimize for ide to false
12+
// RUN: %sourcekitd-test -req=global-config -for-ide=0 == -req=cursor -pos=3:3 %s -- -I %t -target %target-triple %s | %FileCheck --check-prefixes=BOTH,WITH %s
13+
//
14+
// Test setting optimize for ide to true
15+
// RUN: %sourcekitd-test -req=global-config -for-ide=1 == -req=cursor -pos=3:3 %s -- -I %t -target %target-triple %s | %FileCheck --check-prefixes=BOTH,WITHOUT %s
16+
//
17+
// Test sourcekitd-test's default global configuration request (optimize for ide is true)
18+
// RUN: %sourcekitd-test -req=cursor -pos=3:3 %s -- -I %t -target %target-triple %s | %FileCheck --check-prefixes=BOTH,WITHOUT %s
19+
//
20+
// Test without sending any global configuration request to check the sevice's default settings (optimize for ide is false)
21+
// RUN: %sourcekitd-test -suppress-config-request -req=cursor -pos=3:3 %s -- -I %t -target %target-triple %s | %FileCheck --check-prefixes=BOTH,WITH %s
22+
23+
// WITH: source.lang.swift.ref.function.free ({{.*}}/Foo.swift:2:13-2:16)
24+
// WITHOUT: source.lang.swift.ref.function.free ()
25+
// BOTH: foo()
26+
// BOTH: s:3Foo3fooyyF
27+
// BOTH: () -> ()
28+
// BOTH: $syycD
29+
// BOTH: Foo

test/SourceKit/Misc/stats.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ func foo() {}
22

33
// RUN: %sourcekitd-test -req=syntax-map %s == -req=stats | %FileCheck %s -check-prefix=SYNTAX_1
44

5-
// SYNTAX_1: 2 {{.*}} source.statistic.num-requests
5+
// SYNTAX_1: 3 {{.*}} source.statistic.num-requests
66
// SYNTAX_1: 0 {{.*}} source.statistic.num-semantic-requests
77
// SYNTAX_1: 0 {{.*}} source.statistic.num-ast-builds
88
// SYNTAX_1: 1 {{.*}} source.statistic.num-open-documents
99
// SYNTAX_1: 1 {{.*}} source.statistic.max-open-documents
1010

1111
// RUN: %sourcekitd-test -req=syntax-map %s == -req=close %s == -req=stats | %FileCheck %s -check-prefix=SYNTAX_2
1212

13-
// SYNTAX_2: 3 {{.*}} source.statistic.num-requests
13+
// SYNTAX_2: 4 {{.*}} source.statistic.num-requests
1414
// SYNTAX_2: 0 {{.*}} source.statistic.num-semantic-requests
1515
// SYNTAX_2: 0 {{.*}} source.statistic.num-ast-builds
1616
// SYNTAX_2: 0 {{.*}} source.statistic.num-open-documents
1717
// SYNTAX_2: 1 {{.*}} source.statistic.max-open-documents
1818

1919
// RUN: %sourcekitd-test -req=sema %s -- %s == -req=stats | %FileCheck %s -check-prefix=SEMA_1
2020

21-
// SEMA_1: 3 {{.*}} source.statistic.num-requests
21+
// SEMA_1: 4 {{.*}} source.statistic.num-requests
2222
// SEMA_1: 0 {{.*}} source.statistic.num-semantic-requests
2323
// SEMA_1: 1 {{.*}} source.statistic.num-ast-builds
2424
// SEMA_1: 1 {{.*}} source.statistic.num-asts-in-memory
@@ -28,7 +28,7 @@ func foo() {}
2828

2929
// RUN: %sourcekitd-test -req=sema %s -- %s == -req=edit -pos=1:1 -replace=" " %s == -req=stats | %FileCheck %s -check-prefix=SEMA_2
3030

31-
// SEMA_2: 5 {{.*}} source.statistic.num-requests
31+
// SEMA_2: 6 {{.*}} source.statistic.num-requests
3232
// SEMA_2: 0 {{.*}} source.statistic.num-semantic-requests
3333
// SEMA_2: 2 {{.*}} source.statistic.num-ast-builds
3434
// NOTE: we cannot match num-asts-in-memory, or num-ast-cache-hits reliably when
@@ -40,7 +40,7 @@ func foo() {}
4040

4141
// RUN: %sourcekitd-test -req=sema %s -- %s == -req=cursor -pos=1:6 %s -- %s == -req=stats | %FileCheck %s -check-prefix=SEMA_3
4242

43-
// SEMA_3: 4 {{.*}} source.statistic.num-requests
43+
// SEMA_3: 5 {{.*}} source.statistic.num-requests
4444
// SEMA_3: 1 {{.*}} source.statistic.num-semantic-requests
4545
// SEMA_3: 1 {{.*}} source.statistic.num-ast-builds
4646
// SEMA_3: 1 {{.*}} source.statistic.num-asts-in-memory
@@ -50,7 +50,7 @@ func foo() {}
5050

5151
// RUN: %sourcekitd-test -req=sema %s -- %s == -req=related-idents -pos=1:6 %s -- %s == -req=stats | %FileCheck %s -check-prefix=SEMA_4
5252

53-
// SEMA_4: 4 {{.*}} source.statistic.num-requests
53+
// SEMA_4: 5 {{.*}} source.statistic.num-requests
5454
// SEMA_4: 1 {{.*}} source.statistic.num-semantic-requests
5555
// SEMA_4: 1 {{.*}} source.statistic.num-ast-builds
5656
// SEMA_4: 1 {{.*}} source.statistic.num-asts-in-memory

tools/SourceKit/include/SourceKit/Core/Context.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "SourceKit/Core/LLVM.h"
1717
#include "llvm/ADT/StringRef.h"
1818
#include "llvm/ADT/STLExtras.h"
19+
#include "llvm/Support/Mutex.h"
1920
#include <memory>
2021
#include <string>
2122

@@ -27,10 +28,30 @@ namespace SourceKit {
2728
class LangSupport;
2829
class NotificationCenter;
2930

31+
class GlobalConfig {
32+
public:
33+
struct Settings {
34+
/// When true, the default compiler options and other configuration flags will be chosen to optimize for
35+
/// usage from an IDE.
36+
///
37+
/// At the time of writing this just means ignoring .swiftsourceinfo files.
38+
bool OptimizeForIDE = false;
39+
};
40+
41+
private:
42+
Settings State;
43+
mutable llvm::sys::Mutex Mtx;
44+
45+
public:
46+
Settings update(Optional<bool> OptimizeForIDE);
47+
bool shouldOptimizeForIDE() const;
48+
};
49+
3050
class Context {
3151
std::string RuntimeLibPath;
3252
std::unique_ptr<LangSupport> SwiftLang;
3353
std::shared_ptr<NotificationCenter> NotificationCtr;
54+
std::shared_ptr<GlobalConfig> Config;
3455

3556
public:
3657
Context(StringRef RuntimeLibPath,
@@ -44,6 +65,8 @@ class Context {
4465
LangSupport &getSwiftLangSupport() { return *SwiftLang; }
4566

4667
std::shared_ptr<NotificationCenter> getNotificationCenter() { return NotificationCtr; }
68+
69+
std::shared_ptr<GlobalConfig> getGlobalConfiguration() { return Config; }
4770
};
4871

4972
} // namespace SourceKit

tools/SourceKit/lib/Core/Context.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,25 @@
1616

1717
using namespace SourceKit;
1818

19+
GlobalConfig::Settings
20+
GlobalConfig::update(Optional<bool> OptimizeForIDE) {
21+
llvm::sys::ScopedLock L(Mtx);
22+
if (OptimizeForIDE.hasValue())
23+
State.OptimizeForIDE = *OptimizeForIDE;
24+
return State;
25+
};
26+
27+
bool GlobalConfig::shouldOptimizeForIDE() const {
28+
llvm::sys::ScopedLock L(Mtx);
29+
return State.OptimizeForIDE;
30+
}
31+
1932
SourceKit::Context::Context(StringRef RuntimeLibPath,
2033
llvm::function_ref<std::unique_ptr<LangSupport>(Context &)>
2134
LangSupportFactoryFn,
2235
bool shouldDispatchNotificationsOnMain) : RuntimeLibPath(RuntimeLibPath),
23-
NotificationCtr(new NotificationCenter(shouldDispatchNotificationsOnMain)) {
36+
NotificationCtr(new NotificationCenter(shouldDispatchNotificationsOnMain)),
37+
Config(new GlobalConfig()) {
2438
// Should be called last after everything is initialized.
2539
SwiftLang = LangSupportFactoryFn(*this);
2640
}

tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,13 @@ struct CacheKeyHashInfo<ASTKey> {
371371
struct SwiftASTManager::Implementation {
372372
explicit Implementation(
373373
std::shared_ptr<SwiftEditorDocumentFileMap> EditorDocs,
374+
std::shared_ptr<GlobalConfig> Config,
374375
std::shared_ptr<SwiftStatistics> Stats, StringRef RuntimeResourcePath)
375-
: EditorDocs(EditorDocs), Stats(Stats),
376+
: EditorDocs(EditorDocs), Config(Config), Stats(Stats),
376377
RuntimeResourcePath(RuntimeResourcePath) {}
377378

378379
std::shared_ptr<SwiftEditorDocumentFileMap> EditorDocs;
380+
std::shared_ptr<GlobalConfig> Config;
379381
std::shared_ptr<SwiftStatistics> Stats;
380382
std::string RuntimeResourcePath;
381383
SourceManager SourceMgr;
@@ -401,8 +403,10 @@ struct SwiftASTManager::Implementation {
401403

402404
SwiftASTManager::SwiftASTManager(
403405
std::shared_ptr<SwiftEditorDocumentFileMap> EditorDocs,
406+
std::shared_ptr<GlobalConfig> Config,
404407
std::shared_ptr<SwiftStatistics> Stats, StringRef RuntimeResourcePath)
405-
: Impl(*new Implementation(EditorDocs, Stats, RuntimeResourcePath)) {}
408+
: Impl(*new Implementation(EditorDocs, Config, Stats,
409+
RuntimeResourcePath)) {}
406410

407411
SwiftASTManager::~SwiftASTManager() {
408412
delete &Impl;
@@ -535,6 +539,15 @@ bool SwiftASTManager::initCompilerInvocation(
535539
// We don't care about LLVMArgs
536540
FrontendOpts.LLVMArgs.clear();
537541

542+
// SwiftSourceInfo files provide source location information for decls coming
543+
// from loaded modules. For most IDE use cases it either has an undesirable
544+
// impact on performance with no benefit (code completion), results in stale
545+
// locations being used instead of more up-to-date indexer locations (cursor
546+
// info), or has no observable effect (diagnostics, which are filtered to just
547+
// those with a location in the primary file, and everything else).
548+
if (Impl.Config->shouldOptimizeForIDE())
549+
FrontendOpts.IgnoreSwiftSourceInfo = true;
550+
538551
// Disable expensive SIL options to reduce time spent in SILGen.
539552
disableExpensiveSILOptions(Invocation.getSILOptions());
540553

tools/SourceKit/lib/SwiftLang/SwiftASTManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ namespace SourceKit {
4343
class SwiftLangSupport;
4444
class SwiftInvocation;
4545
struct SwiftStatistics;
46+
class GlobalConfig;
4647
typedef RefPtr<SwiftInvocation> SwiftInvocationRef;
4748
class EditorDiagConsumer;
4849

@@ -89,6 +90,7 @@ typedef std::shared_ptr<SwiftASTConsumer> SwiftASTConsumerRef;
8990
class SwiftASTManager : public std::enable_shared_from_this<SwiftASTManager> {
9091
public:
9192
explicit SwiftASTManager(std::shared_ptr<SwiftEditorDocumentFileMap>,
93+
std::shared_ptr<GlobalConfig> Config,
9294
std::shared_ptr<SwiftStatistics> Stats,
9395
StringRef RuntimeResourcePath);
9496
~SwiftASTManager();

tools/SourceKit/lib/SwiftLang/SwiftCompletion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ static bool swiftCodeCompleteImpl(
172172
return false;
173173
}
174174

175-
// Disable source location resolutions from .swiftsourceinfo file because
176-
// they are somewhat heavy operations and are not needed for completions.
175+
// Always disable source location resolutions from .swiftsourceinfo file
176+
// because they're somewhat heavy operations and aren't needed for completion.
177177
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;
178178

179179
const char *Position = InputFile->getBufferStart() + CodeCompletionOffset;

tools/SourceKit/lib/SwiftLang/SwiftConformingMethodList.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ static bool swiftConformingMethodListImpl(
6767
return false;
6868
}
6969

70-
// Disable source location resolutions from .swiftsourceinfo file because
71-
// they are somewhat heavy operations and are not needed for completions.
70+
// Always disable source location resolutions from .swiftsourceinfo file
71+
// because they're somewhat heavy operations and aren't needed for completion.
7272
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;
7373

7474
Invocation.setCodeCompletionPoint(newBuffer.get(), Offset);

tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,9 @@ SwiftLangSupport::SwiftLangSupport(SourceKit::Context &SKCtx)
263263

264264
Stats = std::make_shared<SwiftStatistics>();
265265
EditorDocuments = std::make_shared<SwiftEditorDocumentFileMap>();
266-
ASTMgr = std::make_shared<SwiftASTManager>(EditorDocuments, Stats,
267-
RuntimeResourcePath);
266+
ASTMgr = std::make_shared<SwiftASTManager>(EditorDocuments,
267+
SKCtx.getGlobalConfiguration(),
268+
Stats, RuntimeResourcePath);
268269
// By default, just use the in-memory cache.
269270
CCCache->inMemory = llvm::make_unique<ide::CodeCompletionCache>();
270271

tools/SourceKit/lib/SwiftLang/SwiftTypeContextInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ static bool swiftTypeContextInfoImpl(SwiftLangSupport &Lang,
6767
return false;
6868
}
6969

70-
// Disable source location resolutions from .swiftsourceinfo file because
71-
// they are somewhat heavy operations and are not needed for completions.
70+
// Always disable source location resolutions from .swiftsourceinfo file
71+
// because they're somewhat heavy operations and aren't needed for completion.
7272
Invocation.getFrontendOptions().IgnoreSwiftSourceInfo = true;
7373

7474
Invocation.setCodeCompletionPoint(newBuffer.get(), Offset);

tools/SourceKit/tools/sourcekitd-test/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ def vfs_files : CommaJoined<["-"], "vfs-files=">,
140140
def vfs_name : Separate<["-"], "vfs-name">,
141141
HelpText<"Specify a virtual filesystem name">;
142142

143+
def optimize_for_ide : Joined<["-"], "for-ide=">,
144+
HelpText<"Value for the OptimizeForIde global configuration setting">;
145+
146+
def suppress_config_request : Flag<["-"], "suppress-config-request">,
147+
HelpText<"Suppress the default global configuration request, that is otherwise sent before any other request (except for the global-config request itself)">;
148+
143149
def help : Flag<["-", "--"], "help">,
144150
HelpText<"Display available options">;
145151

0 commit comments

Comments
 (0)