mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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).
This commit is contained in:
@@ -371,11 +371,13 @@ struct CacheKeyHashInfo<ASTKey> {
|
||||
struct SwiftASTManager::Implementation {
|
||||
explicit Implementation(
|
||||
std::shared_ptr<SwiftEditorDocumentFileMap> EditorDocs,
|
||||
std::shared_ptr<GlobalConfig> Config,
|
||||
std::shared_ptr<SwiftStatistics> Stats, StringRef RuntimeResourcePath)
|
||||
: EditorDocs(EditorDocs), Stats(Stats),
|
||||
: EditorDocs(EditorDocs), Config(Config), Stats(Stats),
|
||||
RuntimeResourcePath(RuntimeResourcePath) {}
|
||||
|
||||
std::shared_ptr<SwiftEditorDocumentFileMap> EditorDocs;
|
||||
std::shared_ptr<GlobalConfig> Config;
|
||||
std::shared_ptr<SwiftStatistics> Stats;
|
||||
std::string RuntimeResourcePath;
|
||||
SourceManager SourceMgr;
|
||||
@@ -401,8 +403,10 @@ struct SwiftASTManager::Implementation {
|
||||
|
||||
SwiftASTManager::SwiftASTManager(
|
||||
std::shared_ptr<SwiftEditorDocumentFileMap> EditorDocs,
|
||||
std::shared_ptr<GlobalConfig> Config,
|
||||
std::shared_ptr<SwiftStatistics> Stats, StringRef RuntimeResourcePath)
|
||||
: Impl(*new Implementation(EditorDocs, Stats, RuntimeResourcePath)) {}
|
||||
: Impl(*new Implementation(EditorDocs, Config, Stats,
|
||||
RuntimeResourcePath)) {}
|
||||
|
||||
SwiftASTManager::~SwiftASTManager() {
|
||||
delete &Impl;
|
||||
@@ -535,6 +539,15 @@ bool SwiftASTManager::initCompilerInvocation(
|
||||
// We don't care about LLVMArgs
|
||||
FrontendOpts.LLVMArgs.clear();
|
||||
|
||||
// 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 (diagnostics, which are filtered to just
|
||||
// those with a location in the primary file, and everything else).
|
||||
if (Impl.Config->shouldOptimizeForIDE())
|
||||
FrontendOpts.IgnoreSwiftSourceInfo = true;
|
||||
|
||||
// Disable expensive SIL options to reduce time spent in SILGen.
|
||||
disableExpensiveSILOptions(Invocation.getSILOptions());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user