mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup
This commit is contained in:
@@ -96,9 +96,10 @@ public class RefreshSessionImpl extends RefreshSession {
|
||||
if (!workQueue.isEmpty()) {
|
||||
((LocalFileSystemImpl)LocalFileSystem.getInstance()).markSuspiciousFilesDirty(workQueue);
|
||||
|
||||
final FileWatcher watcher = FileWatcher.getInstance();
|
||||
for (VirtualFile file : workQueue) {
|
||||
final NewVirtualFile nvf = (NewVirtualFile)file;
|
||||
if (!myIsRecursive && (!myIsAsync || !FileWatcher.getInstance().isWatched(nvf))) { // We're unable to definitely refresh synchronously by means of file watcher.
|
||||
if (!myIsRecursive && (!myIsAsync || !watcher.isWatched(nvf))) { // We're unable to definitely refresh synchronously by means of file watcher.
|
||||
nvf.markDirty();
|
||||
}
|
||||
|
||||
|
||||
+12
-17
@@ -183,7 +183,7 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
final FakeVirtualFile child = new FakeVirtualFile(file, name);
|
||||
final FileAttributes attributes = fs.getAttributes(child);
|
||||
if (attributes != null) {
|
||||
final int childId = createAndCopyRecord(fs, child, id, attributes);
|
||||
final int childId = createAndFillRecord(fs, child, id, attributes);
|
||||
childrenIds[i] = childId;
|
||||
}
|
||||
else {
|
||||
@@ -285,11 +285,11 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
return FSRecords.getModCount();
|
||||
}
|
||||
|
||||
private static boolean copyRecordFromDelegateFS(final int id,
|
||||
final int parentId,
|
||||
@NotNull VirtualFile file,
|
||||
@NotNull NewVirtualFileSystem fs,
|
||||
@NotNull FileAttributes attributes) {
|
||||
private static boolean writeAttributesToRecord(final int id,
|
||||
final int parentId,
|
||||
@NotNull VirtualFile file,
|
||||
@NotNull NewVirtualFileSystem fs,
|
||||
@NotNull FileAttributes attributes) {
|
||||
String name = file.getName();
|
||||
if (!name.isEmpty()) {
|
||||
if (namesEqual(fs, name, FSRecords.getName(id))) return false; // TODO: Handle root attributes change.
|
||||
@@ -396,7 +396,7 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
final VirtualFile fake = new FakeVirtualFile(parent, childName);
|
||||
final FileAttributes attributes = fs.getAttributes(fake);
|
||||
if (attributes != null) {
|
||||
final int child = createAndCopyRecord(fs, fake, parentId, attributes);
|
||||
final int child = createAndFillRecord(fs, fake, parentId, attributes);
|
||||
FSRecords.updateList(parentId, ArrayUtil.append(children, child));
|
||||
return child;
|
||||
}
|
||||
@@ -778,7 +778,7 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
return null;
|
||||
}
|
||||
|
||||
final boolean newRoot = copyRecordFromDelegateFS(rootId, 0, root, fs, attributes);
|
||||
final boolean newRoot = writeAttributesToRecord(rootId, 0, root, fs, attributes);
|
||||
if (!newRoot) {
|
||||
if (attributes.lastModified != FSRecords.getTimestamp(rootId)) {
|
||||
root.markDirtyRecursively();
|
||||
@@ -937,7 +937,7 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
}
|
||||
else if (event instanceof VFileCopyEvent) {
|
||||
final VFileCopyEvent copyEvent = (VFileCopyEvent)event;
|
||||
executeCopy(copyEvent.getFile(), copyEvent.getNewParent(), copyEvent.getNewChildName());
|
||||
executeCreateChild(copyEvent.getNewParent(), copyEvent.getNewChildName());
|
||||
}
|
||||
else if (event instanceof VFileMoveEvent) {
|
||||
final VFileMoveEvent moveEvent = (VFileMoveEvent)event;
|
||||
@@ -971,7 +971,7 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
final FileAttributes attributes = delegate.getAttributes(fake);
|
||||
if (attributes != null) {
|
||||
final int parentId = getFileId(parent);
|
||||
final int childId = createAndCopyRecord(delegate, fake, parentId, attributes);
|
||||
final int childId = createAndFillRecord(delegate, fake, parentId, attributes);
|
||||
appendIdToParentList(parentId, childId);
|
||||
assert parent instanceof VirtualDirectoryImpl : parent;
|
||||
final VirtualDirectoryImpl dir = (VirtualDirectoryImpl)parent;
|
||||
@@ -979,12 +979,12 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
}
|
||||
}
|
||||
|
||||
private static int createAndCopyRecord(@NotNull NewVirtualFileSystem delegateSystem,
|
||||
private static int createAndFillRecord(@NotNull NewVirtualFileSystem delegateSystem,
|
||||
@NotNull VirtualFile delegateFile,
|
||||
int parentId,
|
||||
@NotNull FileAttributes attributes) {
|
||||
final int childId = FSRecords.createRecord();
|
||||
copyRecordFromDelegateFS(childId, parentId, delegateFile, delegateSystem, attributes);
|
||||
writeAttributesToRecord(childId, parentId, delegateFile, delegateSystem, attributes);
|
||||
return childId;
|
||||
}
|
||||
|
||||
@@ -1097,11 +1097,6 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
((VirtualFileSystemEntry)file).setModificationStamp(newModificationStamp);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
private static void executeCopy(VirtualFile from, @NotNull VirtualFile newParent, @NotNull String copyName) {
|
||||
executeCreateChild(newParent, copyName);
|
||||
}
|
||||
|
||||
private void executeMove(@NotNull VirtualFile file, @NotNull VirtualFile newParent) {
|
||||
clearIdCache();
|
||||
|
||||
|
||||
+23
-39
@@ -130,7 +130,7 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
final LocalFileSystem.WatchRequest request = watch(file);
|
||||
try {
|
||||
myAccept = true;
|
||||
writeToFile(file, "new content");
|
||||
FileUtil.writeToFile(file, "new content");
|
||||
assertEvent(VFileContentChangeEvent.class, file.getAbsolutePath());
|
||||
|
||||
myAccept = true;
|
||||
@@ -138,7 +138,7 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
assertEvent(VFileDeleteEvent.class, file.getAbsolutePath());
|
||||
|
||||
myAccept = true;
|
||||
writeToFile(file, "re-creation");
|
||||
FileUtil.writeToFile(file, "re-creation");
|
||||
assertEvent(VFileCreateEvent.class, file.getAbsolutePath());
|
||||
}
|
||||
finally {
|
||||
@@ -147,22 +147,6 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeToFile(File file, String text) throws IOException {
|
||||
//try {
|
||||
// Thread.sleep(1000);
|
||||
//}
|
||||
//catch (InterruptedException e) {
|
||||
// LOG.error(e);
|
||||
//}
|
||||
FileUtil.writeToFile(file, text);
|
||||
//try {
|
||||
// Thread.sleep(1000);
|
||||
//}
|
||||
//catch (InterruptedException e) {
|
||||
// LOG.error(e);
|
||||
//}
|
||||
}
|
||||
|
||||
public void testNonCanonicallyNamedFileRoot() throws Exception {
|
||||
if (SystemInfo.isFileSystemCaseSensitive) {
|
||||
System.err.println("Ignored: case-insensitive FS required");
|
||||
@@ -176,7 +160,7 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
final LocalFileSystem.WatchRequest request = watch(new File(watchRoot));
|
||||
try {
|
||||
myAccept = true;
|
||||
writeToFile(file, "new content");
|
||||
FileUtil.writeToFile(file, "new content");
|
||||
assertEvent(VFileContentChangeEvent.class, file.getAbsolutePath());
|
||||
|
||||
myAccept = true;
|
||||
@@ -184,7 +168,7 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
assertEvent(VFileDeleteEvent.class, file.getAbsolutePath());
|
||||
|
||||
myAccept = true;
|
||||
writeToFile(file, "re-creation");
|
||||
FileUtil.writeToFile(file, "re-creation");
|
||||
assertEvent(VFileCreateEvent.class, file.getAbsolutePath());
|
||||
}
|
||||
finally {
|
||||
@@ -209,7 +193,7 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
assertEvent(VFileCreateEvent.class, file.getAbsolutePath());
|
||||
|
||||
myAccept = true;
|
||||
writeToFile(file, "new content");
|
||||
FileUtil.writeToFile(file, "new content");
|
||||
assertEvent(VFileContentChangeEvent.class, file.getAbsolutePath());
|
||||
|
||||
myAccept = true;
|
||||
@@ -217,7 +201,7 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
assertEvent(VFileDeleteEvent.class, file.getAbsolutePath());
|
||||
|
||||
myAccept = true;
|
||||
writeToFile(file, "re-creation");
|
||||
FileUtil.writeToFile(file, "re-creation");
|
||||
assertEvent(VFileCreateEvent.class, file.getAbsolutePath());
|
||||
}
|
||||
finally {
|
||||
@@ -236,13 +220,13 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
final LocalFileSystem.WatchRequest request = watch(topDir, false);
|
||||
try {
|
||||
myAccept = true;
|
||||
writeToFile(watchedFile, "new content");
|
||||
FileUtil.writeToFile(watchedFile, "new content");
|
||||
assertEvent(VFileContentChangeEvent.class, watchedFile.getAbsolutePath());
|
||||
|
||||
myAccept = true;
|
||||
try {
|
||||
myTimeout = 10 * INTER_RESPONSE_DELAY;
|
||||
writeToFile(unwatchedFile, "new content");
|
||||
FileUtil.writeToFile(unwatchedFile, "new content");
|
||||
assertEvent(VFileEvent.class);
|
||||
}
|
||||
finally {
|
||||
@@ -269,9 +253,9 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
final LocalFileSystem.WatchRequest subRequest = watch(sub2Dir);
|
||||
try {
|
||||
myAccept = true;
|
||||
writeToFile(watchedFile1, "new content");
|
||||
writeToFile(watchedFile2, "new content");
|
||||
writeToFile(unwatchedFile, "new content");
|
||||
FileUtil.writeToFile(watchedFile1, "new content");
|
||||
FileUtil.writeToFile(watchedFile2, "new content");
|
||||
FileUtil.writeToFile(unwatchedFile, "new content");
|
||||
assertEvent(VFileContentChangeEvent.class, watchedFile1.getAbsolutePath(), watchedFile2.getAbsolutePath());
|
||||
}
|
||||
finally {
|
||||
@@ -294,7 +278,7 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
refresh(subDir);
|
||||
|
||||
myAccept = true;
|
||||
writeToFile(file, "new content");
|
||||
FileUtil.writeToFile(file, "new content");
|
||||
assertEvent(VFileCreateEvent.class, file.getAbsolutePath());
|
||||
}
|
||||
finally {
|
||||
@@ -317,17 +301,17 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
final LocalFileSystem.WatchRequest requestForSideDir = watch(sideDir);
|
||||
try {
|
||||
myAccept = true;
|
||||
writeToFile(fileInTopDir, "new content");
|
||||
writeToFile(fileInSubDir, "new content");
|
||||
writeToFile(fileInSideDir, "new content");
|
||||
FileUtil.writeToFile(fileInTopDir, "new content");
|
||||
FileUtil.writeToFile(fileInSubDir, "new content");
|
||||
FileUtil.writeToFile(fileInSideDir, "new content");
|
||||
assertEvent(VFileContentChangeEvent.class, fileInSubDir.getAbsolutePath(), fileInSideDir.getAbsolutePath());
|
||||
|
||||
final LocalFileSystem.WatchRequest requestForTopDir = watch(topDir);
|
||||
try {
|
||||
myAccept = true;
|
||||
writeToFile(fileInTopDir, "newer content");
|
||||
writeToFile(fileInSubDir, "newer content");
|
||||
writeToFile(fileInSideDir, "newer content");
|
||||
FileUtil.writeToFile(fileInTopDir, "newer content");
|
||||
FileUtil.writeToFile(fileInSubDir, "newer content");
|
||||
FileUtil.writeToFile(fileInSideDir, "newer content");
|
||||
assertEvent(VFileContentChangeEvent.class, fileInTopDir.getAbsolutePath(), fileInSubDir.getAbsolutePath(), fileInSideDir.getAbsolutePath());
|
||||
}
|
||||
finally {
|
||||
@@ -335,9 +319,9 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
}
|
||||
|
||||
myAccept = true;
|
||||
writeToFile(fileInTopDir, "newest content");
|
||||
writeToFile(fileInSubDir, "newest content");
|
||||
writeToFile(fileInSideDir, "newest content");
|
||||
FileUtil.writeToFile(fileInTopDir, "newest content");
|
||||
FileUtil.writeToFile(fileInSubDir, "newest content");
|
||||
FileUtil.writeToFile(fileInSideDir, "newest content");
|
||||
assertEvent(VFileContentChangeEvent.class, fileInSubDir.getAbsolutePath(), fileInSideDir.getAbsolutePath());
|
||||
|
||||
myAccept = true;
|
||||
@@ -438,7 +422,7 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
final LocalFileSystem.WatchRequest request = watch(substDir);
|
||||
try {
|
||||
myAccept = true;
|
||||
writeToFile(file, "new content");
|
||||
FileUtil.writeToFile(file, "new content");
|
||||
assertEvent(VFileContentChangeEvent.class, substFile.getAbsolutePath());
|
||||
|
||||
final LocalFileSystem.WatchRequest request2 = watch(targetDir);
|
||||
@@ -452,7 +436,7 @@ public class FileWatcherTest extends PlatformLangTestCase {
|
||||
}
|
||||
|
||||
myAccept = true;
|
||||
writeToFile(file, "re-creation");
|
||||
FileUtil.writeToFile(file, "re-creation");
|
||||
assertEvent(VFileCreateEvent.class, substFile.getAbsolutePath());
|
||||
}
|
||||
finally {
|
||||
|
||||
Reference in New Issue
Block a user