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


Java VirtualFile.findFileByRelativePath方法代码示例

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


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

示例1: drawAllPlaceholders

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static void drawAllPlaceholders(@NotNull final Project project, @NotNull final Task task) {
  VirtualFile taskDir = task.getTaskDir(project);
  if (taskDir == null) {
    return;
  }
  for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
    String name = entry.getKey();
    TaskFile taskFile = entry.getValue();
    VirtualFile virtualFile = taskDir.findFileByRelativePath(name);
    if (virtualFile == null) {
      continue;
    }
    FileEditor fileEditor = FileEditorManager.getInstance(project).getSelectedEditor(virtualFile);
    if (fileEditor instanceof StudyEditor) {
      StudyEditor studyEditor = (StudyEditor)fileEditor;
      StudyUtils.drawAllAnswerPlaceholders(studyEditor.getEditor(), taskFile);
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:20,代码来源:StudyCheckUtils.java

示例2: getBinaryPath

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static String getBinaryPath(Project project, String binary) {
    if (binary == null) {
        return null;
    }

    if (new File(binary).isAbsolute()) {
        return binary;
    }

    VirtualFile baseDir = Platform.findBaseRoot(project);
    VirtualFile absoluteBinary = baseDir.findFileByRelativePath(binary);

    return absoluteBinary == null ? null : absoluteBinary.getCanonicalPath();
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:16,代码来源:Platform.java

示例3: runSmartTestProcess

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
static void runSmartTestProcess(@NotNull final VirtualFile taskDir,
                                       @NotNull final PyStudyTestRunner testRunner,
                                       @NotNull final String taskFileName,
                                       @NotNull final TaskFile taskFile,
                                       @NotNull final Project project) {
  final VirtualFile virtualFile = taskDir.findFileByRelativePath(taskFileName);
  if (virtualFile == null) {
    return;
  }
  Pair<VirtualFile, TaskFile> pair = getCopyWithAnswers(taskDir, virtualFile, taskFile);
  if (pair == null) {
    return;
  }
  VirtualFile answerFile = pair.getFirst();
  TaskFile answerTaskFile = pair.getSecond();
  try {
    for (final AnswerPlaceholder answerPlaceholder : answerTaskFile.getActivePlaceholders()) {
      final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
      if (document == null) {
        continue;
      }
      smartCheck(answerPlaceholder, project, answerFile, answerTaskFile, taskFile, testRunner,
                 virtualFile, document);
    }
  }
  finally {
    StudyUtils.deleteFile(answerFile);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:30,代码来源:PyStudySmartChecker.java

示例4: postSolution

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static void postSolution(@NotNull final Task task, boolean passed, @NotNull final Project project) {
  if (task.getStepId() <= 0) {
    return;
  }

  try {
    final String response = postAttempt(task.getStepId());
    if (response.isEmpty()) return;
    final StepicWrappers.AttemptWrapper.Attempt attempt =
      new Gson().fromJson(response, StepicWrappers.AttemptContainer.class).attempts.get(0);
    final Map<String, TaskFile> taskFiles = task.getTaskFiles();
    final ArrayList<StepicWrappers.SolutionFile> files = new ArrayList<>();
    final VirtualFile taskDir = task.getTaskDir(project);
    if (taskDir == null) {
      LOG.error("Failed to find task directory " + task.getName());
      return;
    }
    for (TaskFile fileEntry : taskFiles.values()) {
      final String fileName = fileEntry.name;
      final VirtualFile virtualFile = taskDir.findFileByRelativePath(fileName);
      if (virtualFile != null) {
        ApplicationManager.getApplication().runReadAction(() -> {
          final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
          if (document != null) {
            files.add(new StepicWrappers.SolutionFile(fileName, document.getCharsSequence().toString()));
          }
        });
      }
    }

    postSubmission(passed, attempt, files);
  }
  catch (IOException e) {
    LOG.error(e.getMessage());
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:37,代码来源:EduStepicConnector.java

示例5: 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

示例6: rememberAnswers

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private void rememberAnswers(int nextSubtaskIndex, @NotNull TaskWithSubtasks task) {
  VirtualFile taskDir = task.getTaskDir(myProject);
  if (taskDir == null) {
    return;
  }
  VirtualFile srcDir = taskDir.findChild(EduNames.SRC);
  if (srcDir != null) {
    taskDir = srcDir;
  }
  for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
    TaskFile taskFile = entry.getValue();
    VirtualFile virtualFile = taskDir.findFileByRelativePath(entry.getKey());
    if (virtualFile == null) {
      continue;
    }
    Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
    if (document == null) {
      continue;
    }
    for (AnswerPlaceholder placeholder : taskFile.getActivePlaceholders()) {
      if (placeholder.getSubtaskInfos().containsKey(nextSubtaskIndex - 1)) {
        int offset = placeholder.getOffset();
        String answer = document.getText(TextRange.create(offset, offset + placeholder.getRealLength()));
        placeholder.getSubtaskInfos().get(nextSubtaskIndex - 1).setAnswer(answer);
      }
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:29,代码来源:TaskWithSubtasksChecker.java

示例7: navigateToFailedPlaceholder

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static void navigateToFailedPlaceholder(@NotNull final StudyState studyState,
                                               @NotNull final Task task,
                                               @NotNull final VirtualFile taskDir,
                                               @NotNull final Project project) {
  TaskFile selectedTaskFile = studyState.getTaskFile();
  Editor editor = studyState.getEditor();
  TaskFile taskFileToNavigate = selectedTaskFile;
  VirtualFile fileToNavigate = studyState.getVirtualFile();
  final StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
  if (!taskManager.hasFailedAnswerPlaceholders(selectedTaskFile)) {
    for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
      String name = entry.getKey();
      TaskFile taskFile = entry.getValue();
      if (taskManager.hasFailedAnswerPlaceholders(taskFile)) {
        taskFileToNavigate = taskFile;
        VirtualFile virtualFile = taskDir.findFileByRelativePath(name);
        if (virtualFile == null) {
          continue;
        }
        FileEditor fileEditor = FileEditorManager.getInstance(project).getSelectedEditor(virtualFile);
        if (fileEditor instanceof StudyEditor) {
          StudyEditor studyEditor = (StudyEditor)fileEditor;
          editor = studyEditor.getEditor();
        }
        fileToNavigate = virtualFile;
        break;
      }
    }
  }
  if (fileToNavigate != null) {
    FileEditorManager.getInstance(project).openFile(fileToNavigate, true);
  }
  final Editor editorToNavigate = editor;
  ApplicationManager.getApplication().invokeLater(
    () -> IdeFocusManager.getInstance(project).requestFocus(editorToNavigate.getContentComponent(), true));

  StudyNavigator.navigateToFirstFailedAnswerPlaceholder(editor, taskFileToNavigate);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:39,代码来源:StudyCheckUtils.java

示例8: flushWindows

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

示例9: isValidFilePath

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
protected String isValidFilePath(@NotNull String fullFilePath, @NotNull PsiDirectory baseDirectory) {
    String filePath = StringUtil.replace(
            fullFilePath,
            File.separator,
            "/"
    );

    if(filePath.length() == 0) {
        return PhpBundle.message(
            "validation.file.not.valid.name",
                fullFilePath);
    } else {
        List<String> split = StringUtil.split(filePath, "/");
        if(split.size() == 0) {
            return PhpBundle.message(
                "validation.file.not.valid.name",
                    fullFilePath);
        } else {
            for (String aSplit : split) {
                if (!PhpNameUtil.isValidFileName(aSplit)) {
                    return PhpBundle.message(
                        "validation.file.not.valid.name",
                            fullFilePath);
                }
            }

            VirtualFile baseDirectoryFile = baseDirectory.getVirtualFile();
            VirtualFile fileByRelativePath = baseDirectoryFile.findFileByRelativePath(
                    PhpNameUtil.trimStart(
                            filePath,
                            '/')
            );

            if (fileByRelativePath != null) {
                return PhpBundle.message(
                    "validation.file.already.exists",
                        fullFilePath);
            } else {
                return null;
            }
        }
    }
}
 
开发者ID:aurimasniekis,项目名称:idea-php-class-templates,代码行数:44,代码来源:PhpNewClassDialog.java

示例10: openFirstTask

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static void openFirstTask(@NotNull final Course course, @NotNull final Project project) {
  LocalFileSystem.getInstance().refresh(false);
  final Lesson firstLesson = getFirst(course.getLessons());
  if (firstLesson == null) return;
  final Task firstTask = getFirst(firstLesson.getTaskList());
  if (firstTask == null) return;
  final VirtualFile taskDir = firstTask.getTaskDir(project);
  if (taskDir == null) return;
  final Map<String, TaskFile> taskFiles = firstTask.getTaskFiles();
  VirtualFile activeVirtualFile = null;
  for (Map.Entry<String, TaskFile> entry : taskFiles.entrySet()) {
    final String relativePath = entry.getKey();
    final TaskFile taskFile = entry.getValue();
    taskDir.refresh(false, true);
    final VirtualFile virtualFile = taskDir.findFileByRelativePath(relativePath);
    if (virtualFile != null) {
      if (!taskFile.getActivePlaceholders().isEmpty()) {
        activeVirtualFile = virtualFile;
      }
    }
  }
  if (activeVirtualFile != null) {
    final PsiFile file = PsiManager.getInstance(project).findFile(activeVirtualFile);
    ProjectView.getInstance(project).select(file, activeVirtualFile, false);
    final FileEditor[] editors = FileEditorManager.getInstance(project).openFile(activeVirtualFile, true);
    if (editors.length == 0) {
      return;
    }
    final FileEditor studyEditor = editors[0];
    if (studyEditor instanceof StudyEditor) {
      selectFirstAnswerPlaceholder((StudyEditor)studyEditor, project);
    }
    FileEditorManager.getInstance(project).openFile(activeVirtualFile, true);
  }
  else {
    String first = getFirst(taskFiles.keySet());
    if (first != null) {
      NewVirtualFile firstFile = ((VirtualDirectoryImpl)taskDir).refreshAndFindChild(first);
      if (firstFile != null) {
        FileEditorManager.getInstance(project).openFile(firstFile, true);
      }
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:45,代码来源:StudyUtils.java

示例11: switchStep

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
/***
 * @param toSubtaskIndex from 0 to subtaskNum - 1
 */
public static void switchStep(@NotNull Project project, @NotNull TaskWithSubtasks task, int toSubtaskIndex, boolean navigateToTask) {
  if (toSubtaskIndex == task.getActiveSubtaskIndex()) {
    return;
  }
  VirtualFile taskDir = task.getTaskDir(project);
  if (taskDir == null) {
    return;
  }
  VirtualFile srcDir = taskDir.findChild(EduNames.SRC);
  if (srcDir != null) {
    taskDir = srcDir;
  }
  int fromSubtaskIndex = task.getActiveSubtaskIndex();
  for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
    String name = entry.getKey();
    VirtualFile virtualFile = taskDir.findFileByRelativePath(name);
    if (virtualFile == null) {
      continue;
    }
    TaskFile taskFile = entry.getValue();
    Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
    if (document == null) {
      continue;
    }
    EduDocumentListener listener = null;
    if (!FileEditorManager.getInstance(project).isFileOpen(virtualFile)) {
      listener = new EduDocumentListener(taskFile, true);
      document.addDocumentListener(listener);
    }
    updatePlaceholderTexts(document, taskFile, fromSubtaskIndex, toSubtaskIndex);
    if (listener != null) {
      document.removeDocumentListener(listener);
    }
    UndoManager.getInstance(project).nonundoableActionPerformed(DocumentReferenceManager.getInstance().create(document), false);
    EditorNotifications.getInstance(project).updateNotifications(virtualFile);
    if (StudyUtils.isStudentProject(project)) {
      WolfTheProblemSolver.getInstance(project).clearProblems(virtualFile);
      taskFile.setHighlightErrors(false);
    }
  }
  transformTestFile(project, toSubtaskIndex, taskDir);
  task.setActiveSubtaskIndex(toSubtaskIndex);
  updateUI(project, task, !CCUtils.isCourseCreator(project) && navigateToTask);
  if (CCUtils.isCourseCreator(project)) {
    updateOpenedTestFiles(project, taskDir, fromSubtaskIndex, toSubtaskIndex);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:51,代码来源:StudySubtaskUtils.java

示例12: navigateToTask

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static void navigateToTask(@NotNull Project project, @NotNull Task task) {
  for (VirtualFile file : FileEditorManager.getInstance(project).getOpenFiles()) {
    FileEditorManager.getInstance(project).closeFile(file);
  }
  Map<String, TaskFile> taskFiles = task.getTaskFiles();
  VirtualFile taskDir = task.getTaskDir(project);
  if (taskDir == null) {
    return;
  }
  VirtualFile srcDir = taskDir.findChild(EduNames.SRC);
  if (srcDir != null) {
    taskDir = srcDir;
  }
  if (taskFiles.isEmpty()) {
    ProjectView.getInstance(project).select(taskDir, taskDir, false);
    return;
  }
  VirtualFile fileToActivate = getFirstTaskFile(taskDir, project);
  for (Map.Entry<String, TaskFile> entry : taskFiles.entrySet()) {
    final TaskFile taskFile = entry.getValue();
    if (taskFile.getActivePlaceholders().isEmpty()) {
      continue;
    }
    VirtualFile virtualFile = taskDir.findFileByRelativePath(entry.getKey());
    if (virtualFile == null) {
      continue;
    }
    FileEditorManager.getInstance(project).openFile(virtualFile, true);
    fileToActivate = virtualFile;
  }
  EduUsagesCollector.taskNavigation();
  if (fileToActivate != null) {
    updateProjectView(project, fileToActivate);
  }

  StudyUtils.selectFirstAnswerPlaceholder(StudyUtils.getSelectedStudyEditor(project), project);
  ToolWindow runToolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.RUN);
  if (runToolWindow != null) {
    runToolWindow.hide(null);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:42,代码来源:StudyNavigator.java

示例13: isValidGravSDK

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static boolean isValidGravSDK(VirtualFile root) {
    return root.findChild("user") != null &&
            VfsUtil.findRelativeFile(root, "system") != null &&
            root.findFileByRelativePath("bin") != null;
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:6,代码来源:GravSdkType.java


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