Java 类com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry 实例源码

项目:intellij-ce-playground    文件:EncodingProjectManagerImpl.java   
private static Processor<VirtualFile> createChangeCharsetProcessor() {
  return new Processor<VirtualFile>() {
    @Override
    public boolean process(final VirtualFile file) {
      if (!(file instanceof VirtualFileSystemEntry)) return false;
      Document cachedDocument = FileDocumentManager.getInstance().getCachedDocument(file);
      if (cachedDocument == null) return true;
      ProgressManager.progress("Reloading files...", file.getPresentableUrl());
      UIUtil.invokeLaterIfNeeded(new Runnable() {
        @Override
        public void run() {
          clearAndReload(file);
        }
      });
      return true;
    }
  };
}
项目:intellij-ce-playground    文件:LocalFileSystemTest.java   
public void testSingleFileRootRefresh() throws Exception {
  File file = FileUtil.createTempFile("test.", ".txt");
  VirtualFile virtualFile = myFS.refreshAndFindFileByIoFile(file);
  assertNotNull(virtualFile);
  assertTrue(virtualFile.exists());
  assertTrue(virtualFile.isValid());

  virtualFile.refresh(false, false);
  assertFalse(((VirtualFileSystemEntry)virtualFile).isDirty());

  FileUtil.delete(file);
  assertFalse(file.exists());
  virtualFile.refresh(false, false);
  assertFalse(virtualFile.exists());
  assertFalse(virtualFile.isValid());
}
项目:intellij-ce-playground    文件:LocalFileSystemTest.java   
public void testBadFileName() throws Exception {
  if (!SystemInfo.isUnix) {
    System.err.println(getName() + " skipped: " + SystemInfo.OS_NAME);
    return;
  }

  final File dir = FileUtil.createTempDirectory("test.", ".dir");
  final File file = FileUtil.createTempFile(dir, "test\\", "\\txt", true);

  final VirtualFile vDir = myFS.refreshAndFindFileByIoFile(dir);
  assertNotNull(vDir);
  assertEquals(0, vDir.getChildren().length);

  ((VirtualFileSystemEntry)vDir).markDirtyRecursively();
  vDir.refresh(false, true);

  final VirtualFile vFile = myFS.refreshAndFindFileByIoFile(file);
  assertNull(vFile);
}
项目:intellij-ce-playground    文件:ComputeVirtualFileNameStatAction.java   
private void compute(VirtualFile root) {
  String name = root.getName();
  if (!nameCount.increment(name)) nameCount.put(name, 1);
  for (int i=1; i<=name.length(); i++) {
    //String prefix = name.substring(0, i);
    //if (!prefixes.increment(prefix)) prefixes.put(prefix, 1);

    String suffix = name.substring(name.length()-i);
    if (!suffixes.increment(suffix)) suffixes.put(suffix, 1);
  }
  Collection<VirtualFile> cachedChildren = ((VirtualFileSystemEntry)root).getCachedChildren();
  //VirtualFile[] cachedChildren = ((VirtualFileSystemEntry)root).getChildren();
  for (VirtualFile cachedChild : cachedChildren) {
    compute(cachedChild);
  }
}
项目:tools-idea    文件:PersistentFSImpl.java   
private static VirtualFileSystemEntry executeCreateChild(@NotNull VirtualFile parent, @NotNull String name) {
  final NewVirtualFileSystem delegate = getDelegate(parent);
  final VirtualFile fake = new FakeVirtualFile(parent, name);
  final FileAttributes attributes = delegate.getAttributes(fake);
  if (attributes != null) {
    final int parentId = getFileId(parent);
    final int childId = createAndFillRecord(delegate, fake, parentId, attributes);
    appendIdToParentList(parentId, childId);
    assert parent instanceof VirtualDirectoryImpl : parent;
    final VirtualDirectoryImpl dir = (VirtualDirectoryImpl)parent;
    VirtualFileSystemEntry child = dir.createChild(name, childId, dir.getFileSystem());
    dir.addChild(child);
    return child;
  }
  return null;
}
项目:tools-idea    文件:EncodingProjectManagerImpl.java   
private static Processor<VirtualFile> createChangeCharsetProcessor() {
  return new Processor<VirtualFile>() {
    @Override
    public boolean process(final VirtualFile file) {
      if (!(file instanceof VirtualFileSystemEntry)) return false;
      Document cachedDocument = FileDocumentManager.getInstance().getCachedDocument(file);
      if (cachedDocument == null) return true;
      ProgressManager.progress("Reloading files...", file.getPresentableUrl());
      UIUtil.invokeLaterIfNeeded(new Runnable() {
        @Override
        public void run() {
          clearAndReload(file);
        }
      });
      return true;
    }
  };
}
项目:tools-idea    文件:LocalFileSystemTest.java   
public void testSingleFileRootRefresh() throws Exception {
  File file = FileUtil.createTempFile("test.", ".txt");
  VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
  assertNotNull(virtualFile);
  assertTrue(virtualFile.exists());
  assertTrue(virtualFile.isValid());

  virtualFile.refresh(false, false);
  assertFalse(((VirtualFileSystemEntry)virtualFile).isDirty());

  FileUtil.delete(file);
  assertFalse(file.exists());
  virtualFile.refresh(false, false);
  assertFalse(virtualFile.exists());
  assertFalse(virtualFile.isValid());
}
项目:tools-idea    文件:LocalFileSystemTest.java   
public void testBadFileName() throws Exception {
  if (!SystemInfo.isUnix) {
    System.err.println(getName() + " skipped: " + SystemInfo.OS_NAME);
    return;
  }

  final File dir = FileUtil.createTempDirectory("test.", ".dir");
  final File file = FileUtil.createTempFile(dir, "test\\", "\\txt", true);

  final VirtualFile vDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
  assertNotNull(vDir);
  assertEquals(0, vDir.getChildren().length);

  ((VirtualFileSystemEntry)vDir).markDirtyRecursively();
  vDir.refresh(false, true);

  final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
  assertNull(vFile);
}
项目:tools-idea    文件:ComputeVirtualFileNameStatAction.java   
private void compute(VirtualFile root) {
  String name = root.getName();
  if (!nameCount.increment(name)) nameCount.put(name, 1);
  for (int i=1; i<=name.length(); i++) {
    //String prefix = name.substring(0, i);
    //if (!prefixes.increment(prefix)) prefixes.put(prefix, 1);

    String suffix = name.substring(name.length()-i);
    if (!suffixes.increment(suffix)) suffixes.put(suffix, 1);
  }
  Collection<VirtualFile> cachedChildren = ((VirtualFileSystemEntry)root).getCachedChildren();
  //VirtualFile[] cachedChildren = ((VirtualFileSystemEntry)root).getChildren();
  for (VirtualFile cachedChild : cachedChildren) {
    compute(cachedChild);
  }
}
项目:consulo    文件:LocalFileSystemTest.java   
public void testSingleFileRootRefresh() throws Exception {
  File file = FileUtil.createTempFile("test.", ".txt");
  VirtualFile virtualFile = myFS.refreshAndFindFileByIoFile(file);
  assertNotNull(virtualFile);
  assertTrue(virtualFile.exists());
  assertTrue(virtualFile.isValid());

  virtualFile.refresh(false, false);
  assertFalse(((VirtualFileSystemEntry)virtualFile).isDirty());

  FileUtil.delete(file);
  assertFalse(file.exists());
  virtualFile.refresh(false, false);
  assertFalse(virtualFile.exists());
  assertFalse(virtualFile.isValid());
}
项目:consulo    文件:LocalFileSystemTest.java   
public void testBadFileName() throws Exception {
  if (!SystemInfo.isUnix) {
    System.err.println(getName() + " skipped: " + SystemInfo.OS_NAME);
    return;
  }

  final File dir = FileUtil.createTempDirectory("test.", ".dir");
  final File file = FileUtil.createTempFile(dir, "test\\", "\\txt", true);

  final VirtualFile vDir = myFS.refreshAndFindFileByIoFile(dir);
  assertNotNull(vDir);
  assertEquals(0, vDir.getChildren().length);

  ((VirtualFileSystemEntry)vDir).markDirtyRecursively();
  vDir.refresh(false, true);

  final VirtualFile vFile = myFS.refreshAndFindFileByIoFile(file);
  assertNull(vFile);
}
项目:consulo    文件:ComputeVirtualFileNameStatAction.java   
private void compute(VirtualFile root) {
  String name = root.getName();
  if (!nameCount.increment(name)) nameCount.put(name, 1);
  for (int i=1; i<=name.length(); i++) {
    //String prefix = name.substring(0, i);
    //if (!prefixes.increment(prefix)) prefixes.put(prefix, 1);

    String suffix = name.substring(name.length()-i);
    if (!suffixes.increment(suffix)) suffixes.put(suffix, 1);
  }
  Collection<VirtualFile> cachedChildren = ((VirtualFileSystemEntry)root).getCachedChildren();
  //VirtualFile[] cachedChildren = ((VirtualFileSystemEntry)root).getChildren();
  for (VirtualFile cachedChild : cachedChildren) {
    compute(cachedChild);
  }
}
项目:idea-php-typo3-plugin    文件:ExtensionDefinitionFactory.java   
public static TYPO3ExtensionDefinition fromDirectory(VirtualDirectoryImpl virtualDirectory) {
    TYPO3ExtensionDefinition extensionDefinition = null;

    // try finding composer manifest
    VirtualFileSystemEntry composerManifest = virtualDirectory.findChild("composer.json");
    if (composerManifest != null) {
        try {
            extensionDefinition = fromComposerManifest(composerManifest);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    return extensionDefinition != null ? extensionDefinition : null;
}
项目:intellij-ce-playground    文件:InlineLibraryMethodTest.java   
public void testInlineAllInProjectFromLibrary() throws Exception {
  configureByText(JavaFileType.INSTANCE, "package mycompany;\n" +
                                         "public class File {\n" +
                                         " public static File createTempFile(String pr, String postfix){return createTempFile(pr, postfix, null);}\n" +
                                         " public static File createTempFile(String pr, String postfix, String base){return new File();}\n" +
                                         "}");
  @NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java";
  configureByFile(fileName);

  PsiClass fileClass = getJavaFacade().findClass("mycompany.File");
  assertNotNull(fileClass);
  final PsiFile file = fileClass.getContainingFile();
  WriteCommandAction.runWriteCommandAction(null, () -> {
    try {
      ((VirtualFileSystemEntry)file.getVirtualFile()).setWritable(false);
    }
    catch (IOException e) {
      throw new RuntimeException(e);
    }
  });

  PsiElement element = null;
  PsiMethod[] createTempFiles = fileClass.findMethodsByName("createTempFile", false);
  for (PsiMethod createTempFile : createTempFiles) {
    if (createTempFile.getParameterList().getParametersCount() == 2) {
      element = createTempFile;
      break;
    }
  }
  assertNotNull(element);
  PsiMethod method = (PsiMethod)element;
  final boolean condition = InlineMethodProcessor.checkBadReturns(method) && !InlineUtil.allUsagesAreTailCalls(method);
  assertFalse("Bad returns found", condition);
  final InlineMethodProcessor processor = new InlineMethodProcessor(getProject(), method, null, myEditor, false);
  processor.run();
  checkResultByFile(fileName + ".after");
}
项目:intellij-ce-playground    文件:EncodingProjectManagerImpl.java   
private void reloadAllFilesUnder(@Nullable final VirtualFile root) {
  tryStartReloadWithProgress(new Runnable() {
    @Override
    public void run() {
      processSubFiles(root, new Processor<VirtualFile>() {
        @Override
        public boolean process(final VirtualFile file) {
          if (!(file instanceof VirtualFileSystemEntry)) return true;
          Document cachedDocument = FileDocumentManager.getInstance().getCachedDocument(file);
          if (cachedDocument != null) {
            ProgressManager.progress("Reloading file...", file.getPresentableUrl());
            UIUtil.invokeLaterIfNeeded(new Runnable() {
              @Override
              public void run() {
                reload(file);
              }
            });
          }
          // for not loaded files deep under project, reset encoding to give them chance re-detect the right one later
          else if (file.isCharsetSet() && !file.equals(root)) {
            file.setCharset(null);
          }
          return true;
        }
      });
    }
  });
}
项目:intellij-ce-playground    文件:FileBasedIndexImpl.java   
private static void cleanProcessedFlag(@NotNull final VirtualFile file) {
  if (!(file instanceof VirtualFileSystemEntry)) return;

  final VirtualFileSystemEntry nvf = (VirtualFileSystemEntry)file;
  if (file.isDirectory()) {
    nvf.setFileIndexed(false);
    for (VirtualFile child : nvf.getCachedChildren()) {
      cleanProcessedFlag(child);
    }
  }
  else {
    nvf.setFileIndexed(false);
  }
}
项目:tools-idea    文件:InlineLibraryMethodTest.java   
public void testInlineAllInProjectFromLibrary() throws Exception {
  configureByText(JavaFileType.INSTANCE, "package mycompany;\n" +
                                         "public class File {\n" +
                                         " public static File createTempFile(String pr, String postfix){return createTempFile(pr, postfix, null);}\n" +
                                         " public static File createTempFile(String pr, String postfix, String base){return new File();}\n" +
                                         "}");
  @NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java";
  configureByFile(fileName);

  PsiClass fileClass = getJavaFacade().findClass("mycompany.File");
  assertNotNull(fileClass);
  final PsiFile file = fileClass.getContainingFile();
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      try {
        ((VirtualFileSystemEntry)file.getVirtualFile()).setWritable(false);
      }
      catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  });

  PsiElement element = null;
  PsiMethod[] createTempFiles = fileClass.findMethodsByName("createTempFile", false);
  for (PsiMethod createTempFile : createTempFiles) {
    if (createTempFile.getParameterList().getParametersCount() == 2) {
      element = createTempFile;
      break;
    }
  }
  assertNotNull(element);
  PsiMethod method = (PsiMethod)element;
  final boolean condition = InlineMethodProcessor.checkBadReturns(method) && !InlineUtil.allUsagesAreTailCalls(method);
  assertFalse("Bad returns found", condition);
  final InlineMethodProcessor processor = new InlineMethodProcessor(getProject(), method, null, myEditor, false);
  processor.run();
  checkResultByFile(fileName + ".after");
}
项目:tools-idea    文件:PersistentFSImpl.java   
@Override
@NotNull
public VirtualFile[] getRoots() {
  myRootsLock.readLock().lock();
  try {
    Collection<VirtualFileSystemEntry> roots = myRoots.values();
    return VfsUtilCore.toVirtualFileArray(roots);
  }
  finally {
    myRootsLock.readLock().unlock();
  }
}
项目:tools-idea    文件:PersistentFSImpl.java   
private static void invalidateSubtree(@NotNull VirtualFile file) {
  final VirtualFileSystemEntry impl = (VirtualFileSystemEntry)file;
  impl.invalidate();
  for (VirtualFile child : impl.getCachedChildren()) {
    invalidateSubtree(child);
  }
}
项目:tools-idea    文件:PersistentFSImpl.java   
private static void executeTouch(@NotNull VirtualFile file, boolean reloadContentFromDelegate, long newModificationStamp) {
  if (reloadContentFromDelegate) {
    setFlag(file, MUST_RELOAD_CONTENT, true);
  }

  final NewVirtualFileSystem delegate = getDelegate(file);
  final FileAttributes attributes = delegate.getAttributes(file);
  FSRecords.setLength(getFileId(file), attributes != null ? attributes.length : DEFAULT_LENGTH);
  FSRecords.setTimestamp(getFileId(file), attributes != null ? attributes.lastModified : DEFAULT_TIMESTAMP);

  ((VirtualFileSystemEntry)file).setModificationStamp(newModificationStamp);
}
项目:tools-idea    文件:PersistentFSImpl.java   
private void executeMove(@NotNull VirtualFile file, @NotNull VirtualFile newParent) {
  clearIdCache();

  final int fileId = getFileId(file);
  final int newParentId = getFileId(newParent);
  final int oldParentId = getFileId(file.getParent());

  removeIdFromParentList(oldParentId, fileId, file.getParent(), file);
  appendIdToParentList(newParentId, fileId);

  ((VirtualFileSystemEntry)file).setParent(newParent);
  FSRecords.setParent(fileId, newParentId);
}
项目:tools-idea    文件:EncodingProjectManagerImpl.java   
private void reloadAllFilesUnder(final VirtualFile root) {
  tryStartReloadWithProgress(new Runnable() {
    @Override
    public void run() {
      processSubFiles(root, new Processor<VirtualFile>() {
        @Override
        public boolean process(final VirtualFile file) {
          if (!(file instanceof VirtualFileSystemEntry)) return true;
          Document cachedDocument = FileDocumentManager.getInstance().getCachedDocument(file);
          if (cachedDocument != null) {
            ProgressManager.progress("Reloading file...", file.getPresentableUrl());
            UIUtil.invokeLaterIfNeeded(new Runnable() {
              @Override
              public void run() {
                reload(file);
              }
            });
          }
          // for not loaded files deep under project, reset encoding to give them chance re-detect the right one later
          else if (file.isCharsetSet() && !file.equals(root)) {
            file.setCharset(null);
          }
          return true;
        }
      });
    }
  });
}
项目:tools-idea    文件:FileBasedIndexImpl.java   
public static boolean isProjectOrWorkspaceFile(final VirtualFile file,
                                               final @Nullable FileType fileType) {
  if (fileType instanceof InternalFileType) return true;
  VirtualFile parent = file.isDirectory() ? file: file.getParent();
  while(parent instanceof VirtualFileSystemEntry) {
    if (((VirtualFileSystemEntry)parent).compareNameTo(ProjectCoreUtil.DIRECTORY_BASED_PROJECT_DIR, !SystemInfoRt.isFileSystemCaseSensitive) == 0) return true;
    parent = parent.getParent();
  }
  return false;
}
项目:tools-idea    文件:FileBasedIndexImpl.java   
private static void cleanProcessedFlag(@NotNull final VirtualFile file) {
  if (!(file instanceof VirtualFileSystemEntry)) return;

  final VirtualFileSystemEntry nvf = (VirtualFileSystemEntry)file;
  if (file.isDirectory()) {
    nvf.setFileIndexed(false);
    for (VirtualFile child : nvf.getCachedChildren()) {
      cleanProcessedFlag(child);
    }
  }
  else {
    nvf.setFileIndexed(false);
  }
}
项目:consulo    文件:IdeaGateway.java   
@Nonnull
private Entry doCreateFileEntry(@Nonnull VirtualFile file, Pair<StoredContent, Long> contentAndStamps) {
  if (file instanceof VirtualFileSystemEntry) {
    return new FileEntry(((VirtualFileSystemEntry)file).getNameId(), contentAndStamps.first, contentAndStamps.second, !file.isWritable());
  }
  return new FileEntry(file.getName(), contentAndStamps.first, contentAndStamps.second, !file.isWritable());
}
项目:consulo    文件:EncodingProjectManagerImpl.java   
private static Processor<VirtualFile> createChangeCharsetProcessor() {
  return file -> {
    if (!(file instanceof VirtualFileSystemEntry)) return false;
    Document cachedDocument = FileDocumentManager.getInstance().getCachedDocument(file);
    if (cachedDocument == null) return true;
    ProgressManager.progress("Reloading files...", file.getPresentableUrl());
    TransactionGuard.submitTransaction(ApplicationManager.getApplication(), () -> clearAndReload(file));
    return true;
  };
}
项目:consulo    文件:EncodingProjectManagerImpl.java   
private void reloadAllFilesUnder(@Nullable final VirtualFile root) {
  tryStartReloadWithProgress(() -> processSubFiles(root, file -> {
    if (!(file instanceof VirtualFileSystemEntry)) return true;
    Document cachedDocument = FileDocumentManager.getInstance().getCachedDocument(file);
    if (cachedDocument != null) {
      ProgressManager.progress("Reloading file...", file.getPresentableUrl());
      TransactionGuard.submitTransaction(myProject, () -> reload(file));
    }
    // for not loaded files deep under project, reset encoding to give them chance re-detect the right one later
    else if (file.isCharsetSet() && !file.equals(root)) {
      file.setCharset(null);
    }
    return true;
  }));
}
项目:consulo    文件:FileBasedIndexImpl.java   
private static void cleanProcessedFlag(@Nonnull final VirtualFile file) {
  if (!(file instanceof VirtualFileSystemEntry)) return;

  final VirtualFileSystemEntry nvf = (VirtualFileSystemEntry)file;
  if (file.isDirectory()) {
    nvf.setFileIndexed(false);
    for (VirtualFile child : nvf.getCachedChildren()) {
      cleanProcessedFlag(child);
    }
  }
  else {
    nvf.setFileIndexed(false);
  }
}
项目:consulo-java    文件:InlineLibraryMethodTest.java   
public void testInlineAllInProjectFromLibrary() throws Exception {
  configureByText(JavaFileType.INSTANCE, "package mycompany;\n" +
                                         "public class File {\n" +
                                         " public static File createTempFile(String pr, String postfix){return createTempFile(pr, postfix, null);}\n" +
                                         " public static File createTempFile(String pr, String postfix, String base){return new File();}\n" +
                                         "}");
  @NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java";
  configureByFile(fileName);

  PsiClass fileClass = getJavaFacade().findClass("mycompany.File");
  assertNotNull(fileClass);
  final PsiFile file = fileClass.getContainingFile();
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      try {
        ((VirtualFileSystemEntry)file.getVirtualFile()).setWritable(false);
      }
      catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  });

  PsiElement element = null;
  PsiMethod[] createTempFiles = fileClass.findMethodsByName("createTempFile", false);
  for (PsiMethod createTempFile : createTempFiles) {
    if (createTempFile.getParameterList().getParametersCount() == 2) {
      element = createTempFile;
      break;
    }
  }
  assertNotNull(element);
  PsiMethod method = (PsiMethod)element;
  final boolean condition = InlineMethodProcessor.checkBadReturns(method) && !InlineUtil.allUsagesAreTailCalls(method);
  assertFalse("Bad returns found", condition);
  final InlineMethodProcessor processor = new InlineMethodProcessor(getProject(), method, null, myEditor, false);
  processor.run();
  checkResultByFile(fileName + ".after");
}
项目:tools-idea    文件:PersistentFSImpl.java   
@Nullable
private VirtualFileSystemEntry findFileById(int id, boolean cachedOnly, TIntArrayList visited, int mask) {
  VirtualFileSystemEntry cached = myIdToDirCache.get(id);
  if (cached != null) return cached;

  if (visited != null && (visited.size() >= DEPTH_LIMIT || (mask & id) == id && visited.contains(id))) {
    @NonNls String sb = "Dead loop detected in persistent FS (id=" + id + " cached-only=" + cachedOnly + "):";
    for (int i = 0; i < visited.size(); i++) {
      int _id = visited.get(i);
      sb += "\n  " + _id + " '" + getName(_id) + "' " +
        String.format("%02x", getFileAttributes(_id)) + ' ' + myIdToDirCache.containsKey(_id);
    }
    LOG.error(sb);
    return null;
  }
  if (visited == null) visited = new TIntArrayList(DEPTH_LIMIT);
  visited.add(id);

  int parentId = getParent(id);
  VirtualFileSystemEntry result;
  if (parentId == 0) {
    myRootsLock.readLock().lock();
    try {
      result = myRootsById.get(id);
    }
    finally {
      myRootsLock.readLock().unlock();
    }
  }
  else {
    VirtualFileSystemEntry parentFile = findFileById(parentId, cachedOnly, visited, mask |= id);
    if (parentFile instanceof VirtualDirectoryImpl) {
      result = ((VirtualDirectoryImpl)parentFile).findChildById(id, cachedOnly);
    }
    else {
      result = null;
    }
  }

  if (result != null && result.isDirectory()) {
    VirtualFileSystemEntry old = myIdToDirCache.put(id, result);
    if (old != null) result = old;
  }
  return result;
}
项目:tools-idea    文件:PersistentFSImpl.java   
private VirtualFileSystemEntry applyEvent(@NotNull VFileEvent event) {
  try {
    if (event instanceof VFileCreateEvent) {
      final VFileCreateEvent createEvent = (VFileCreateEvent)event;
      return executeCreateChild(createEvent.getParent(), createEvent.getChildName());
    }
    else if (event instanceof VFileDeleteEvent) {
      final VFileDeleteEvent deleteEvent = (VFileDeleteEvent)event;
      executeDelete(deleteEvent.getFile());
    }
    else if (event instanceof VFileContentChangeEvent) {
      final VFileContentChangeEvent contentUpdateEvent = (VFileContentChangeEvent)event;
      executeTouch(contentUpdateEvent.getFile(), contentUpdateEvent.isFromRefresh(), contentUpdateEvent.getModificationStamp());
    }
    else if (event instanceof VFileCopyEvent) {
      final VFileCopyEvent copyEvent = (VFileCopyEvent)event;
      return executeCreateChild(copyEvent.getNewParent(), copyEvent.getNewChildName());
    }
    else if (event instanceof VFileMoveEvent) {
      final VFileMoveEvent moveEvent = (VFileMoveEvent)event;
      executeMove(moveEvent.getFile(), moveEvent.getNewParent());
    }
    else if (event instanceof VFilePropertyChangeEvent) {
      final VFilePropertyChangeEvent propertyChangeEvent = (VFilePropertyChangeEvent)event;
      if (VirtualFile.PROP_NAME.equals(propertyChangeEvent.getPropertyName())) {
        executeRename(propertyChangeEvent.getFile(), (String)propertyChangeEvent.getNewValue());
      }
      else if (VirtualFile.PROP_WRITABLE.equals(propertyChangeEvent.getPropertyName())) {
        executeSetWritable(propertyChangeEvent.getFile(), ((Boolean)propertyChangeEvent.getNewValue()).booleanValue());
      }
      else if (VirtualFile.PROP_HIDDEN.equals(propertyChangeEvent.getPropertyName())) {
        executeSetHidden(propertyChangeEvent.getFile(), ((Boolean)propertyChangeEvent.getNewValue()).booleanValue());
      }
    }
  }
  catch (Exception e) {
    // Exception applying single event should not prevent other events from applying.
    LOG.error(e);
  }
  return null;
}
项目:tools-idea    文件:PersistentFSImpl.java   
private static void executeRename(@NotNull VirtualFile file, @NotNull final String newName) {
  ((VirtualFileSystemEntry)file).setNewName(newName);
  final int id = getFileId(file);
  FSRecords.setName(id, newName);
}
项目:tools-idea    文件:PersistentFSImpl.java   
private static void executeSetWritable(@NotNull VirtualFile file, boolean writableFlag) {
  setFlag(file, IS_READ_ONLY, !writableFlag);
  ((VirtualFileSystemEntry)file).updateProperty(VirtualFile.PROP_WRITABLE, writableFlag);
}
项目:tools-idea    文件:PersistentFSImpl.java   
private static void executeSetHidden(@NotNull VirtualFile file, boolean hiddenFlag) {
  setFlag(file, IS_HIDDEN, hiddenFlag);
  ((VirtualFileSystemEntry)file).updateProperty(VirtualFile.PROP_HIDDEN, hiddenFlag);
}