mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CodeCompletion] Give up fast-completion if dependent files are modified
Check if dependencies are modified since the last checking. Dependencies: - Other source files in the current module - Dependent files collected by the dependency tracker When: - If the last dependency check was over N (defaults to 5) seconds ago Invalidate if: - The dependency file is missing - The modification time of the dependecy is greater than the last check - If the modification time is zero, compare the content using the file system from the previous completion and the current completion rdar://problem/62336432
This commit is contained in:
@@ -257,6 +257,13 @@ class InMemoryFileSystemProvider: public SourceKit::FileSystemProvider {
|
||||
};
|
||||
}
|
||||
|
||||
static void
|
||||
configureCompletionInstance(std::shared_ptr<CompletionInstance> CompletionInst,
|
||||
std::shared_ptr<GlobalConfig> GlobalConfig) {
|
||||
CompletionInst->setDependencyCheckIntervalSecond(
|
||||
GlobalConfig->getCompletionCheckDependencyInterval());
|
||||
}
|
||||
|
||||
SwiftLangSupport::SwiftLangSupport(SourceKit::Context &SKCtx)
|
||||
: NotificationCtr(SKCtx.getNotificationCenter()),
|
||||
CCCache(new SwiftCompletionCache) {
|
||||
@@ -270,7 +277,8 @@ SwiftLangSupport::SwiftLangSupport(SourceKit::Context &SKCtx)
|
||||
SKCtx.getGlobalConfiguration(),
|
||||
Stats, RuntimeResourcePath);
|
||||
|
||||
CompletionInst = std::make_unique<CompletionInstance>();
|
||||
CompletionInst = std::make_shared<CompletionInstance>();
|
||||
configureCompletionInstance(CompletionInst, SKCtx.getGlobalConfiguration());
|
||||
|
||||
// By default, just use the in-memory cache.
|
||||
CCCache->inMemory = std::make_unique<ide::CodeCompletionCache>();
|
||||
@@ -282,6 +290,11 @@ SwiftLangSupport::SwiftLangSupport(SourceKit::Context &SKCtx)
|
||||
SwiftLangSupport::~SwiftLangSupport() {
|
||||
}
|
||||
|
||||
void SwiftLangSupport::globalConfigurationUpdated(
|
||||
std::shared_ptr<GlobalConfig> Config) {
|
||||
configureCompletionInstance(CompletionInst, Config);
|
||||
}
|
||||
|
||||
UIdent SwiftLangSupport::getUIDForDecl(const Decl *D, bool IsRef) {
|
||||
return UIdentVisitor(IsRef).visit(const_cast<Decl*>(D));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user