当前位置: 首页>>代码示例>>Java>>正文


Java VirtualFile.getParent方法代码示例

本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFile.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualFile.getParent方法的具体用法?Java VirtualFile.getParent怎么用?Java VirtualFile.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.vfs.VirtualFile的用法示例。


在下文中一共展示了VirtualFile.getParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getIndexer

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
    return virtualFile -> {
        final Map<String, String> items = new THashMap<>();

        VirtualFile file = virtualFile.getFile();
        VirtualFile parentDirectory = file.getParent();
        if (parentDirectory != null) {
            VirtualFile ancestorDirectory = parentDirectory.getParent();
            if (ancestorDirectory != null && ancestorDirectory.isDirectory()) {
                String ancestorDirectoryName = ancestorDirectory.getName();
                if (ancestorDirectoryName.equals("sysext") || ancestorDirectoryName.equals("ext")) {
                    String path = file.getPath();
                    items.put(parentDirectory.getName(), path);
                }

                // handle the case where the extension name can *not* be inferred from the directory name
            }
        }

        return items;
    };
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:25,代码来源:ExtensionNameStubIndex.java

示例2: findExtensionRootFolder

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static VirtualFile findExtensionRootFolder(@NotNull VirtualFile file) {
    if (file.isDirectory()) {
        VirtualFile child = file.findChild("ext_emconf.php");

        if (child != null) {
            return file;
        }
    }

    // dragons ahead.
    if (file.getParent() != null) {
        return findExtensionRootFolder(file.getParent());
    }

    return null;
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:18,代码来源:FilesystemUtil.java

示例3: parsePom

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
private static ProjectInfo parsePom(@NotNull VirtualFile file)
{
    try
    {
        String content = VirtualFileHelper.read(file);
        PomModel model = PomModel.parse(content);
        PomModel parent = null;
        if (file.getParent() != null && file.getParent().getParent() != null)
        {
            VirtualFile parentDirFile = file.getParent().getParent();
            VirtualFile parentFile = parentDirFile.findChild("pom.xml");
            if (parentFile != null)
            {
                String parentContent = VirtualFileHelper.read(parentFile);
                parent = PomModel.parse(parentContent);
            }
        }
        return ProjectInfo.parse(model, parent);
    }
    catch (IOException | JAXBException | XMLStreamException ex)
    {
        LOG.log(Level.SEVERE, ex.getMessage());
        return null;
    }
}
 
开发者ID:miche-atucha,项目名称:deps-checker,代码行数:27,代码来源:MavenHelper.java

示例4: getTask

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static Task getTask(@NotNull Project project, @NotNull VirtualFile taskVF) {
  Course course = StudyTaskManager.getInstance(project).getCourse();
  if (course == null) {
    return null;
  }
  VirtualFile lessonVF = taskVF.getParent();
  if (lessonVF == null) {
    return null;
  }
  Lesson lesson = course.getLesson(lessonVF.getName());
  if (lesson == null) {
    return null;
  }
  return lesson.getTask(taskVF.getName());
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:StudyUtils.java

示例5: getTaskDir

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static VirtualFile getTaskDir(@NotNull VirtualFile taskFile) {
  VirtualFile parent = taskFile.getParent();

  while (parent != null) {
    String name = parent.getName();

    if (name.contains(EduNames.TASK) && parent.isDirectory()) {
      return parent;
    }
    if (EduNames.SRC.equals(name)) {
      return parent.getParent();
    }

    parent = parent.getParent();
  }
  return null;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:19,代码来源:StudyUtils.java

示例6: deleteTask

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private static void deleteTask(@NotNull final Course course, @NotNull final VirtualFile removedTask) {
  VirtualFile lessonDir = removedTask.getParent();
  if (lessonDir == null || !lessonDir.getName().contains(EduNames.LESSON)) {
    return;
  }
  final Lesson lesson = course.getLesson(lessonDir.getName());
  if (lesson == null) {
    return;
  }
  Task task = lesson.getTask(removedTask.getName());
  if (task == null) {
    return;
  }
  CCUtils.updateHigherElements(lessonDir.getChildren(), file -> lesson.getTask(file.getName()), task.getIndex(), EduNames.TASK, -1);
  lesson.getTaskList().remove(task);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:CCVirtualFileListener.java

示例7: getAreaName

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@NotNull
protected String getAreaName() {
    VirtualFile containingDirectory = xmlTag.getContainingFile().getVirtualFile().getParent();
    String configDirectory = containingDirectory.getName();

    if (configDirectory.equals("etc")) {
        VirtualFile moduleDirectory = containingDirectory.getParent();
        if (moduleDirectory.getName().equals("app")) {
            return "primary";
        }
        return "global";
    }
    return configDirectory;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:15,代码来源:LineMarkerXmlTagDecorator.java

示例8: findVfUp

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static VirtualFile findVfUp(VirtualFile item, String searchItemName)
{
    if (item.getParent() != null) {
        VirtualFile vf = VfsUtilCore.findRelativeFile(searchItemName, item.getParent());
        if (vf != null && !vf.isDirectory()) {
            return vf;
        }
    }
    return findVfUp(item.getParent(), searchItemName);
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:11,代码来源:VfsUtil.java

示例9: getTaskFile

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static TaskFile getTaskFile(@NotNull final Project project, @NotNull final VirtualFile file) {
  final Course course = StudyTaskManager.getInstance(project).getCourse();
  if (course == null) {
    return null;
  }
  VirtualFile taskDir = getTaskDir(file);
  if (taskDir == null) {
    return null;
  }
  //need this because of multi-module generation
  if (EduNames.SRC.equals(taskDir.getName())) {
    taskDir = taskDir.getParent();
    if (taskDir == null) {
      return null;
    }
  }
  final String taskDirName = taskDir.getName();
  if (taskDirName.contains(EduNames.TASK)) {
    final VirtualFile lessonDir = taskDir.getParent();
    if (lessonDir != null) {
      int lessonIndex = EduUtils.getIndex(lessonDir.getName(), EduNames.LESSON);
      List<Lesson> lessons = course.getLessons();
      if (!indexIsValid(lessonIndex, lessons)) {
        return null;
      }
      final Lesson lesson = lessons.get(lessonIndex);
      int taskIndex = EduUtils.getIndex(taskDirName, EduNames.TASK);
      final List<Task> tasks = lesson.getTaskList();
      if (!indexIsValid(taskIndex, tasks)) {
        return null;
      }
      final Task task = tasks.get(taskIndex);
      return task.getFile(pathRelativeToTask(file));
    }
  }
  return null;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:39,代码来源:StudyUtils.java

示例10: fileCreated

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
public void fileCreated(@NotNull VirtualFileEvent event) {
  if (myProject.isDisposed()) return;
  final VirtualFile createdFile = event.getFile();
  final VirtualFile taskDir = StudyUtils.getTaskDir(createdFile);
  final Course course = StudyTaskManager.getInstance(myProject).getCourse();
  if (course == null || !EduNames.STUDY.equals(course.getCourseMode())) {
    return;
  }
  if (taskDir != null && taskDir.getName().contains(EduNames.TASK)) {
    int taskIndex = EduUtils.getIndex(taskDir.getName(), EduNames.TASK);
    final VirtualFile lessonDir = taskDir.getParent();
    if (lessonDir != null && lessonDir.getName().contains(EduNames.LESSON)) {
      int lessonIndex = EduUtils.getIndex(lessonDir.getName(), EduNames.LESSON);
      List<Lesson> lessons = course.getLessons();
      if (StudyUtils.indexIsValid(lessonIndex, lessons)) {
        final Lesson lesson = lessons.get(lessonIndex);
        final List<Task> tasks = lesson.getTaskList();
        if (StudyUtils.indexIsValid(taskIndex, tasks)) {
          final Task task = tasks.get(taskIndex);
          final TaskFile taskFile = new TaskFile();
          taskFile.initTaskFile(task, false);
          taskFile.setUserCreated(true);
          final String name = FileUtil.getRelativePath(taskDir.getPath(), createdFile.getPath(), '/');
          taskFile.name = name;
          //TODO: put to other steps as well
          task.getTaskFiles().put(name, taskFile);
        }
      }
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:33,代码来源:StudyProjectComponent.java

示例11: deleteWindowDescriptions

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static void deleteWindowDescriptions(@NotNull final Task task, @NotNull final VirtualFile taskDir) {
  for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
    String name = entry.getKey();
    VirtualFile virtualFile = taskDir.findFileByRelativePath(name);
    if (virtualFile == null) {
      continue;
    }
    String windowsFileName = virtualFile.getNameWithoutExtension() + EduNames.WINDOWS_POSTFIX;
    VirtualFile parentDir = virtualFile.getParent();
    deleteWindowsFile(parentDir, windowsFileName);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:13,代码来源:EduUtils.java

示例12: isSourceFile

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private static boolean isSourceFile(@Nullable VirtualFile file) {
    String sources = Utils.getPropertyValue("sources", true);
    List<String> sourcesList = Utils.getSourcesList(sources);
    if (file == null) {
        return false;
    }
    for (String src : sourcesList) {
        if (src.equals(file.getName()) && file.getParent() != null && "values".equals(file.getParent().getName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:crowdin,项目名称:android-studio-plugin,代码行数:14,代码来源:UploadFromContextAction.java

示例13: isAvailable

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
protected boolean isAvailable(VirtualFile dir) {
  if (dir.getName().contains(EduNames.TASK)) {
    return true;
  }
  VirtualFile parent = dir.getParent();
  if (parent != null && parent.getName().contains(EduNames.TASK)) {
    return true;
  }
  return false;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:12,代码来源:CCTaskRenameHandler.java

示例14: actionPerformed

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent event) {
    VirtualFile file = DataKeys.VIRTUAL_FILE.getData(event.getDataContext());
    Project project = event.getProject();
    if (file == null || project == null) return;
    VirtualFile folder = file.isDirectory() ? file : file.getParent();

    WriteCommandAction.runWriteCommandAction(project, () -> {
        createData(folder);
        createDomain(folder);
        createPresentation(folder);
    });
}
 
开发者ID:edgarmiro,项目名称:clean-plugin,代码行数:14,代码来源:CreateCleanStructure.java

示例15: getLanguageFileType

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static LangFileEditorType getLanguageFileType(@NotNull final VirtualFile file) {
    VirtualFile parent = file.getParent();
    if (GravYamlFiles.withYamlExtension(file) && parent != null && parent.exists() && parent.getName().equalsIgnoreCase("languages")) {
        return LANGUAGE_FOLDER;
    } else if (GravYamlFiles.withYamlExtension(file) && file.getNameWithoutExtension().equalsIgnoreCase("languages")) {
        return LANGUAGE_FILE;
    }
    return NONE;
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:10,代码来源:GravYamlFiles.java


注:本文中的com.intellij.openapi.vfs.VirtualFile.getParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。