to avoid deadlock, don't refresh VFS during service initialization, instead refresh asynchronously during plugin initialization
This commit is contained in:
+14
-6
@@ -94,12 +94,7 @@ public class BuiltInsReferenceResolver(val project: Project, val startupManager:
|
||||
val vf = VirtualFileManager.getInstance().findFileByUrl(fromUrl)
|
||||
assert(vf != null) { "Virtual file not found by URL: $url" }
|
||||
|
||||
// Refreshing VFS: in case the plugin jar was updated, the caches may hold the old value
|
||||
vf!!.getChildren()
|
||||
vf.refresh(false, true)
|
||||
PathUtil.getLocalFile(vf).refresh(false, true)
|
||||
|
||||
val psiDirectory = PsiManager.getInstance(project).findDirectory(vf)
|
||||
val psiDirectory = PsiManager.getInstance(project).findDirectory(vf!!)
|
||||
assert(psiDirectory != null) { "No PsiDirectory for $vf" }
|
||||
return psiDirectory!!.getFiles().filterIsInstance<JetFile>().toHashSet()
|
||||
}
|
||||
@@ -188,5 +183,18 @@ public class BuiltInsReferenceResolver(val project: Project, val startupManager:
|
||||
}
|
||||
return setOf(defaultBuiltIns)
|
||||
}
|
||||
|
||||
public fun refreshBuiltIns() {
|
||||
getBuiltInsDirUrls().forEach { url ->
|
||||
val fromUrl = VfsUtilCore.convertFromUrl(url)
|
||||
val vf = VirtualFileManager.getInstance().findFileByUrl(fromUrl)
|
||||
assert(vf != null) { "Virtual file not found by URL: $url" }
|
||||
|
||||
// Refreshing VFS: in case the plugin jar was updated, the caches may hold the old value
|
||||
vf!!.getChildren()
|
||||
vf.refresh(true, true)
|
||||
PathUtil.getLocalFile(vf).refresh(true, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.idea.caches.JarUserDataManager;
|
||||
import org.jetbrains.kotlin.idea.debugger.filter.DebuggerFiltersUtilKt;
|
||||
import org.jetbrains.kotlin.idea.decompiler.HasCompiledKotlinInJar;
|
||||
import org.jetbrains.kotlin.idea.framework.KotlinJavaScriptLibraryDetectionUtil;
|
||||
import org.jetbrains.kotlin.idea.references.BuiltInsReferenceResolver;
|
||||
import org.jetbrains.kotlin.utils.PathUtil;
|
||||
|
||||
import java.io.File;
|
||||
@@ -49,6 +50,8 @@ public class PluginStartupComponent implements ApplicationComponent {
|
||||
JarUserDataManager.INSTANCE$.register(KotlinJavaScriptLibraryDetectionUtil.HasKotlinJSMetadataInJar.INSTANCE$);
|
||||
JarUserDataManager.INSTANCE$.register(HasCompiledKotlinInJar.INSTANCE$);
|
||||
|
||||
BuiltInsReferenceResolver.Companion.refreshBuiltIns();
|
||||
|
||||
DebuggerFiltersUtilKt.addKotlinStdlibDebugFilterIfNeeded();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user