mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (warnings; formatting)
GitOrigin-RevId: e70e133284dd0f11a3a02bf171613f487c554ef8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
529816aef9
commit
01e5d4b270
@@ -1,42 +1,35 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. 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.impl.jar;
|
||||
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
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 java.util.Map;
|
||||
|
||||
import static com.intellij.openapi.util.Pair.pair;
|
||||
|
||||
public final class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
|
||||
private final Map<String, CoreJarHandler> myHandlers =
|
||||
ConcurrentFactoryMap.createMap(key -> new CoreJarHandler(CoreJarFileSystem.this, key));
|
||||
private final Map<String, CoreJarHandler> myHandlers = ConcurrentFactoryMap.createMap(key -> new CoreJarHandler(this, key));
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getProtocol() {
|
||||
public @NotNull String getProtocol() {
|
||||
return StandardFileSystems.JAR_PROTOCOL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile findFileByPath(@NotNull @NonNls String path) {
|
||||
Couple<String> pair = splitPath(path);
|
||||
public VirtualFile findFileByPath(@NotNull String path) {
|
||||
Pair<String, String> pair = splitPath(path);
|
||||
return myHandlers.get(pair.first).findFileByPath(pair.second);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static Couple<String> splitPath(@NotNull String path) {
|
||||
static @NotNull Pair<String, String> splitPath(@NotNull String path) {
|
||||
int separator = path.indexOf("!/");
|
||||
if (separator < 0) {
|
||||
throw new IllegalArgumentException("Path in JarFileSystem must contain a separator: " + path);
|
||||
}
|
||||
String localPath = path.substring(0, separator);
|
||||
String pathInJar = path.substring(separator + 2);
|
||||
return Couple.of(localPath, pathInJar);
|
||||
if (separator < 0) throw new IllegalArgumentException("Path in JarFileSystem must contain a separator: " + path);
|
||||
return pair(path.substring(0, separator), path.substring(separator + 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2021 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.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. 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.impl.jar;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -12,7 +12,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
final class CoreJarHandler extends ZipHandler {
|
||||
private final CoreJarFileSystem myFileSystem;
|
||||
private final VirtualFile myRoot;
|
||||
@@ -23,8 +22,8 @@ final class CoreJarHandler extends ZipHandler {
|
||||
|
||||
Map<EntryInfo, CoreJarVirtualFile> entries = new HashMap<>();
|
||||
|
||||
final Map<String, EntryInfo> entriesMap = getEntriesMap();
|
||||
final Map<CoreJarVirtualFile, List<VirtualFile>> childrenMap = FactoryMap.create(key -> new ArrayList<>());
|
||||
Map<String, EntryInfo> entriesMap = getEntriesMap();
|
||||
Map<CoreJarVirtualFile, List<VirtualFile>> childrenMap = FactoryMap.create(key -> new ArrayList<>());
|
||||
for (EntryInfo info : entriesMap.values()) {
|
||||
CoreJarVirtualFile file = getOrCreateFile(info, entries);
|
||||
VirtualFile parent = file.getParent();
|
||||
@@ -41,27 +40,22 @@ final class CoreJarHandler extends ZipHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private CoreJarVirtualFile getOrCreateFile(@NotNull EntryInfo info, @NotNull Map<EntryInfo, CoreJarVirtualFile> entries) {
|
||||
private CoreJarVirtualFile getOrCreateFile(EntryInfo info, Map<EntryInfo, CoreJarVirtualFile> entries) {
|
||||
CoreJarVirtualFile file = entries.get(info);
|
||||
if (file == null) {
|
||||
EntryInfo parent = info.parent;
|
||||
file = new CoreJarVirtualFile(this, info.shortName,
|
||||
info.isDirectory ? -1 : info.length,
|
||||
info.timestamp,
|
||||
parent != null ? getOrCreateFile(parent, entries) : null);
|
||||
long length = info.isDirectory ? -1 : info.length;
|
||||
CoreJarVirtualFile parent = info.parent != null ? getOrCreateFile(info.parent, entries) : null;
|
||||
file = new CoreJarVirtualFile(this, info.shortName, length, info.timestamp, parent);
|
||||
entries.put(info, file);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
VirtualFile findFileByPath(@NotNull String pathInJar) {
|
||||
@Nullable VirtualFile findFileByPath(@NotNull String pathInJar) {
|
||||
return myRoot != null ? myRoot.findFileByRelativePath(pathInJar) : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
CoreJarFileSystem getFileSystem() {
|
||||
@NotNull CoreJarFileSystem getFileSystem() {
|
||||
return myFileSystem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2000-2021 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.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. 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.impl.jar;
|
||||
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.BufferExposingByteArrayInputStream;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -13,7 +13,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
|
||||
final class CoreJarVirtualFile extends VirtualFile {
|
||||
private final CoreJarHandler myHandler;
|
||||
private final CharSequence myName;
|
||||
@@ -22,11 +21,7 @@ final class CoreJarVirtualFile extends VirtualFile {
|
||||
private final VirtualFile myParent;
|
||||
private VirtualFile[] myChildren = VirtualFile.EMPTY_ARRAY;
|
||||
|
||||
CoreJarVirtualFile(@NotNull CoreJarHandler handler,
|
||||
@NotNull CharSequence name,
|
||||
long length,
|
||||
long timestamp,
|
||||
@Nullable CoreJarVirtualFile parent) {
|
||||
CoreJarVirtualFile(@NotNull CoreJarHandler handler, @NotNull CharSequence name, long length, long timestamp, @Nullable CoreJarVirtualFile parent) {
|
||||
myHandler = handler;
|
||||
myName = name;
|
||||
myLength = length;
|
||||
@@ -38,27 +33,23 @@ final class CoreJarVirtualFile extends VirtualFile {
|
||||
myChildren = children;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NotNull String getName() {
|
||||
return myName.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CharSequence getNameSequence() {
|
||||
public @NotNull CharSequence getNameSequence() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public VirtualFileSystem getFileSystem() {
|
||||
public @NotNull VirtualFileSystem getFileSystem() {
|
||||
return myHandler.getFileSystem();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getPath() {
|
||||
public @NotNull String getPath() {
|
||||
if (myParent == null) {
|
||||
return FileUtil.toSystemIndependentName(myHandler.getFile().getPath()) + "!/";
|
||||
}
|
||||
@@ -99,15 +90,14 @@ final class CoreJarVirtualFile extends VirtualFile {
|
||||
return myChildren;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public OutputStream getOutputStream(Object requestor, long newModificationStamp, long newTimeStamp) throws IOException {
|
||||
public @NotNull OutputStream getOutputStream(Object requestor, long newModificationStamp, long newTimeStamp) throws IOException {
|
||||
throw new UnsupportedOperationException("JarFileSystem is read-only");
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte @NotNull [] contentsToByteArray() throws IOException {
|
||||
Couple<String> pair = CoreJarFileSystem.splitPath(getPath());
|
||||
Pair<String, String> pair = CoreJarFileSystem.splitPath(getPath());
|
||||
return myHandler.contentsToByteArray(pair.second);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ package com.intellij.openapi.vfs.local;
|
||||
import com.intellij.openapi.vfs.DeprecatedVirtualFileSystem;
|
||||
import com.intellij.openapi.vfs.StandardFileSystems;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -13,11 +12,9 @@ import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
|
||||
public class CoreLocalFileSystem extends DeprecatedVirtualFileSystem {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getProtocol() {
|
||||
public @NotNull String getProtocol() {
|
||||
return StandardFileSystems.FILE_PROTOCOL;
|
||||
}
|
||||
|
||||
@@ -30,13 +27,12 @@ public class CoreLocalFileSystem extends DeprecatedVirtualFileSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile findFileByPath(@NotNull @NonNls String path) {
|
||||
public VirtualFile findFileByPath(@NotNull String path) {
|
||||
return findFileByNioFile(FileSystems.getDefault().getPath(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh(boolean asynchronous) {
|
||||
}
|
||||
public void refresh(boolean asynchronous) { }
|
||||
|
||||
@Override
|
||||
public VirtualFile refreshAndFindFileByPath(@NotNull String path) {
|
||||
|
||||
@@ -131,9 +131,8 @@ public class CoreLocalVirtualFile extends VirtualFile {
|
||||
return myChildren;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public OutputStream getOutputStream(Object requestor, long newModificationStamp, long newTimeStamp) throws IOException {
|
||||
public @NotNull OutputStream getOutputStream(Object requestor, long newModificationStamp, long newTimeStamp) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -143,8 +142,7 @@ public class CoreLocalVirtualFile extends VirtualFile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh(boolean asynchronous, boolean recursive, Runnable postRunnable) {
|
||||
}
|
||||
public void refresh(boolean asynchronous, boolean recursive, Runnable postRunnable) { }
|
||||
|
||||
@Override
|
||||
public @NotNull InputStream getInputStream() throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user