do not use getComponentInstancesOfType() in PlatformVirtualFileManager because it slow-down start-up and leads to loading of unrelated classes (because PlatformVirtualFileManager is a preloaded service)

Warn was released as 2019.2, so, any plugin that not yet migrated to a correct API, must be also migrated.

GitOrigin-RevId: 5b3bfb9d4622dae848becea5e3a85cfe7392779f
This commit is contained in:
Vladimir Krivosheev
2019-09-11 06:02:36 +00:00
committed by intellij-monorepo-bot
parent b9c10af718
commit 45fd0cbaca
@@ -1,9 +1,7 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.vfs;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.impl.ComponentManagerImpl;
import com.intellij.openapi.vfs.impl.VirtualFileManagerImpl;
import com.intellij.openapi.vfs.newvfs.ManagingFS;
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
@@ -13,31 +11,16 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
public final class PlatformVirtualFileManager extends VirtualFileManagerImpl {
@NotNull private final ManagingFS myManagingFS;
public PlatformVirtualFileManager() {
super(getVirtualFileSystems());
super(Collections.emptyList());
myManagingFS = ManagingFS.getInstance();
}
@NotNull
private static List<VirtualFileSystem> getVirtualFileSystems() {
Application app = ApplicationManager.getApplication();
@SuppressWarnings("deprecation")
List<VirtualFileSystem> result = app instanceof ComponentManagerImpl
? app.getComponentInstancesOfType(VirtualFileSystem.class, true)
: Collections.emptyList();
if (!result.isEmpty()) {
LOG.warn("Do not register file system as application component, instead, register as extension, for example:\n" +
"<virtualFileSystem implementationClass=\"com.example.MyFileSystem\" key=\"myProtocol\" physical=\"true\"/>\n\n" + result);
}
return result;
}
@Override
protected long doRefresh(boolean asynchronous, @Nullable Runnable postAction) {
if (!asynchronous) {