mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -21,15 +21,11 @@ import com.intellij.openapi.util.io.FileAttributes;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.impl.local.LocalFileSystemBase;
|
||||
import com.intellij.openapi.vfs.newvfs.ManagingFS;
|
||||
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
|
||||
import com.intellij.openapi.vfs.newvfs.VfsImplUtil;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.FSRecords;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.LocalTimeCounter;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -57,7 +53,7 @@ public class TempFileSystem extends LocalFileSystemBase {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private FSItem convert(VirtualFile file) {
|
||||
private FSItem convert(@NotNull VirtualFile file) {
|
||||
final VirtualFile parentFile = file.getParent();
|
||||
if (parentFile == null) return myRoot;
|
||||
|
||||
@@ -233,26 +229,6 @@ public class TempFileSystem extends LocalFileSystemBase {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh(final boolean asynchronous) {
|
||||
RefreshQueue.getInstance().refresh(asynchronous, true, null, ManagingFS.getInstance().getRoots(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile findFileByPath(@NotNull @NonNls String path) {
|
||||
return VfsImplUtil.findFileByPath(this, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile findFileByPathIfCached(@NotNull @NonNls String path) {
|
||||
return VfsImplUtil.findFileByPathIfCached(this, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile refreshAndFindFileByPath(@NotNull String path) {
|
||||
return VfsImplUtil.refreshAndFindFileByPath(this, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLength(@NotNull final VirtualFile file) {
|
||||
try {
|
||||
@@ -269,7 +245,7 @@ public class TempFileSystem extends LocalFileSystemBase {
|
||||
private long myTimestamp;
|
||||
private boolean myWritable;
|
||||
|
||||
protected FSItem(final FSDir parent, final String name) {
|
||||
FSItem(@Nullable FSDir parent, @NotNull String name) {
|
||||
myParent = parent;
|
||||
myName = name;
|
||||
myTimestamp = LocalTimeCounter.currentTime();
|
||||
@@ -283,7 +259,7 @@ public class TempFileSystem extends LocalFileSystemBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
void setName(@NotNull String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
@@ -291,6 +267,7 @@ public class TempFileSystem extends LocalFileSystemBase {
|
||||
return myParent;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String[] list() {
|
||||
return ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
@@ -304,7 +281,7 @@ public class TempFileSystem extends LocalFileSystemBase {
|
||||
private static class FSDir extends FSItem {
|
||||
private final List<FSItem> myChildren = new ArrayList<>();
|
||||
|
||||
public FSDir(final FSDir parent, final String name) {
|
||||
FSDir(@Nullable FSDir parent, @NotNull String name) {
|
||||
super(parent, name);
|
||||
}
|
||||
|
||||
@@ -325,17 +302,18 @@ public class TempFileSystem extends LocalFileSystemBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addChild(final FSItem item) {
|
||||
void addChild(@NotNull FSItem item) {
|
||||
myChildren.add(item);
|
||||
}
|
||||
|
||||
public void removeChild(final FSItem fsItem) {
|
||||
void removeChild(@NotNull FSItem fsItem) {
|
||||
if (fsItem.myName.equals("src") && getParent() == null) {
|
||||
throw new RuntimeException("removing src directory");
|
||||
}
|
||||
myChildren.remove(fsItem);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] list() {
|
||||
String[] names = ArrayUtil.newStringArray(myChildren.size());
|
||||
@@ -347,7 +325,7 @@ public class TempFileSystem extends LocalFileSystemBase {
|
||||
}
|
||||
|
||||
private static class FSFile extends FSItem {
|
||||
public FSFile(final FSDir parent, final String name) {
|
||||
FSFile(@NotNull FSDir parent, @NotNull String name) {
|
||||
super(parent, name);
|
||||
}
|
||||
|
||||
|
||||
+1
-5
@@ -447,8 +447,7 @@ public abstract class LocalFileSystemBase extends LocalFileSystem {
|
||||
@Override
|
||||
@NotNull
|
||||
public byte[] contentsToByteArray(@NotNull final VirtualFile file) throws IOException {
|
||||
final InputStream stream = new FileInputStream(convertToIOFileAndCheck(file));
|
||||
try {
|
||||
try (InputStream stream = new FileInputStream(convertToIOFileAndCheck(file))) {
|
||||
long l = file.getLength();
|
||||
if (l > Integer.MAX_VALUE) throw new IOException("File is too large: " + l + ", " + file);
|
||||
final int length = (int)l;
|
||||
@@ -457,9 +456,6 @@ public abstract class LocalFileSystemBase extends LocalFileSystem {
|
||||
// so let's do buffered requests with buffer size 8192 that will use stack allocated buffer
|
||||
return loadBytes(length <= 8192 ? stream : new BufferedInputStream(stream), length);
|
||||
}
|
||||
finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-3
@@ -59,7 +59,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
private final boolean myWatchRecursively;
|
||||
private boolean myDominated;
|
||||
|
||||
public WatchRequestImpl(String rootPath, boolean watchRecursively) {
|
||||
WatchRequestImpl(String rootPath, boolean watchRecursively) {
|
||||
myFSRootPath = rootPath;
|
||||
myWatchRecursively = watchRecursively;
|
||||
}
|
||||
@@ -125,7 +125,6 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
String rootPath = request.getRootPath();
|
||||
|
||||
TreeNode currentNode = rootNode;
|
||||
MainLoop:
|
||||
for (String subPath : splitPath(rootPath)) {
|
||||
TreeNode nextNode = currentNode.nodes.get(subPath);
|
||||
if (nextNode != null) {
|
||||
@@ -133,7 +132,7 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
if (currentNode.watchRequest != null && currentNode.watchRequest.isToWatchRecursively()) {
|
||||
// a parent path of this request is already being watched recursively - do not need to add this one
|
||||
request.myDominated = true;
|
||||
break MainLoop;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user