mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.openapi.roots.impl.storage;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -29,5 +28,5 @@ public interface FileSet {
|
||||
|
||||
void commit() throws IOException;
|
||||
|
||||
void listModifiedFiles(List<VirtualFile> list);
|
||||
void listModifiedFiles(@NotNull List<VirtualFile> list);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.JDOMException;
|
||||
@@ -31,27 +31,26 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class CachedXmlDocumentSet implements FileSet {
|
||||
protected final Map<String, String> nameToDir = new HashMap<String, String>();
|
||||
protected final Map<String, Document> savedContent = new HashMap<String, Document>();
|
||||
protected final Map<String, Document> modifiedContent = new HashMap<String, Document>();
|
||||
protected final Set<String> deletedContent = new HashSet<String>();
|
||||
protected final Map<String, String> nameToDir = new THashMap<String, String>();
|
||||
protected final Map<String, Document> savedContent = new THashMap<String, Document>();
|
||||
protected final Map<String, Document> modifiedContent = new THashMap<String, Document>();
|
||||
protected final Set<String> deletedContent = new THashSet<String>();
|
||||
private final Project project;
|
||||
|
||||
public CachedXmlDocumentSet(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public Document read(final String name) throws IOException, JDOMException {
|
||||
public Document read(@NotNull String name) throws IOException, JDOMException {
|
||||
return read(name, true);
|
||||
}
|
||||
|
||||
public Document read(final String name, final boolean refresh) throws IOException, JDOMException {
|
||||
public Document read(@NotNull String name, final boolean refresh) throws IOException, JDOMException {
|
||||
return load(name, refresh).clone();
|
||||
}
|
||||
|
||||
@@ -59,15 +58,15 @@ public class CachedXmlDocumentSet implements FileSet {
|
||||
update(document.clone(), name);
|
||||
}
|
||||
|
||||
public String getParent(final String name) {
|
||||
public String getParent(@NotNull String name) {
|
||||
return nameToDir.get(name);
|
||||
}
|
||||
|
||||
public void register(final String name, final String path) {
|
||||
public void register(@NotNull String name, final String path) {
|
||||
nameToDir.put(name, path);
|
||||
}
|
||||
|
||||
protected void assertKnownName(final String name) {
|
||||
protected void assertKnownName(@NotNull String name) {
|
||||
assert nameToDir.containsKey(name) : name;
|
||||
}
|
||||
|
||||
@@ -77,12 +76,12 @@ public class CachedXmlDocumentSet implements FileSet {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected VirtualFile getVFile(final String name) {
|
||||
protected VirtualFile getVFile(@NotNull String name) {
|
||||
return getVFile(name, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected VirtualFile getVFile(final String name, boolean refresh) {
|
||||
protected VirtualFile getVFile(@NotNull String name, boolean refresh) {
|
||||
final VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(getParent(name), name));
|
||||
if (file != null && refresh) {
|
||||
file.refresh(false, true);
|
||||
@@ -92,7 +91,7 @@ public class CachedXmlDocumentSet implements FileSet {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private VirtualFile getOrCreateVFile(final String name) throws IOException {
|
||||
private VirtualFile getOrCreateVFile(@NotNull final String name) throws IOException {
|
||||
final VirtualFile vFile = getVFile(name);
|
||||
if (vFile != null) {
|
||||
return vFile;
|
||||
@@ -120,7 +119,7 @@ public class CachedXmlDocumentSet implements FileSet {
|
||||
}
|
||||
}
|
||||
|
||||
protected Document load(final String name, boolean refresh) throws IOException, JDOMException {
|
||||
protected Document load(@NotNull String name, boolean refresh) throws IOException, JDOMException {
|
||||
assertKnownName(name);
|
||||
final Document logical = modifiedContent.get(name);
|
||||
if (logical != null) {
|
||||
@@ -197,7 +196,7 @@ public class CachedXmlDocumentSet implements FileSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listModifiedFiles(List<VirtualFile> list) {
|
||||
public void listModifiedFiles(@NotNull List<VirtualFile> list) {
|
||||
for (String key : modifiedContent.keySet()) {
|
||||
try {
|
||||
if (hasChanged(key)) {
|
||||
|
||||
Reference in New Issue
Block a user