mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use ConcurrentFactoryMap to simplify implementation of CoreJarFileSystem; add API to clear list of handlers
This commit is contained in:
@@ -19,17 +19,24 @@ import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.vfs.DeprecatedVirtualFileSystem;
|
||||
import com.intellij.openapi.vfs.StandardFileSystems;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ConcurrentFactoryMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
|
||||
private final Map<String, CoreJarHandler> myHandlers = new HashMap<String, CoreJarHandler>();
|
||||
private final Map<String, CoreJarHandler> myHandlers = new ConcurrentFactoryMap<String, CoreJarHandler>() {
|
||||
@Nullable
|
||||
@Override
|
||||
protected CoreJarHandler create(String key) {
|
||||
return new CoreJarHandler(CoreJarFileSystem.this, key);
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -40,7 +47,7 @@ public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
|
||||
@Override
|
||||
public VirtualFile findFileByPath(@NotNull @NonNls String path) {
|
||||
Couple<String> pair = splitPath(path);
|
||||
return getHandler(pair.first).findFileByPath(pair.second);
|
||||
return myHandlers.get(pair.first).findFileByPath(pair.second);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -54,16 +61,6 @@ public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
|
||||
return Couple.of(localPath, pathInJar);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private CoreJarHandler getHandler(String localPath) {
|
||||
CoreJarHandler handler = myHandlers.get(localPath);
|
||||
if (handler == null) {
|
||||
handler = new CoreJarHandler(this, localPath);
|
||||
myHandlers.put(localPath, handler);
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh(boolean asynchronous) { }
|
||||
|
||||
@@ -71,4 +68,9 @@ public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
|
||||
public VirtualFile refreshAndFindFileByPath(@NotNull String path) {
|
||||
return findFileByPath(path);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") // used in Kotlin
|
||||
public void clearHandlersCache() {
|
||||
myHandlers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user