예제 #1
0
 @Override
 public void fileMoved(@NotNull VirtualFileMoveEvent event) {
   String dirName = event.getFileName();
   String ancestorPath = event.getOldParent().getPath() + "/" + dirName;
   String moduleFilePath = getModuleFilePath();
   if (VfsUtilCore.isAncestor(new File(ancestorPath), new File(moduleFilePath), true)) {
     setModuleFilePath(
         event.getNewParent().getPath()
             + "/"
             + dirName
             + "/"
             + FileUtil.getRelativePath(ancestorPath, moduleFilePath, '/'));
   }
 }
예제 #2
0
    @Override
    public void propertyChanged(@NotNull VirtualFilePropertyEvent event) {
      if (!isModuleAdded
          || event.getRequestor() instanceof StateStorage
          || !VirtualFile.PROP_NAME.equals(event.getPropertyName())) {
        return;
      }

      VirtualFile parent = event.getParent();
      if (parent != null) {
        String parentPath = parent.getPath();
        String ancestorPath = parentPath + "/" + event.getOldValue();
        String moduleFilePath = getModuleFilePath();
        if (VfsUtilCore.isAncestor(new File(ancestorPath), new File(moduleFilePath), true)) {
          setModuleFilePath(
              parentPath
                  + "/"
                  + event.getNewValue()
                  + "/"
                  + FileUtil.getRelativePath(ancestorPath, moduleFilePath, '/'));
        }
      }
    }