當前位置: 首頁>>代碼示例>>Java>>正文


Java VfsUtil.findRelativeFile方法代碼示例

本文整理匯總了Java中com.intellij.openapi.vfs.VfsUtil.findRelativeFile方法的典型用法代碼示例。如果您正苦於以下問題:Java VfsUtil.findRelativeFile方法的具體用法?Java VfsUtil.findRelativeFile怎麽用?Java VfsUtil.findRelativeFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.vfs.VfsUtil的用法示例。


在下文中一共展示了VfsUtil.findRelativeFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTestsFile

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Nullable
@Override
protected VirtualFile getTestsFile() {
  VirtualFile taskDir = myTask.getTaskDir(myProject);
  if (taskDir == null) {
    return null;
  }
  for (String testFileName : myTask.getTestsText().keySet()) {
    VirtualFile testFile = VfsUtil.findRelativeFile(taskDir, testFileName);
    if (testFile != null) {
      return testFile;
    }
  }
  VirtualFile testsFile = taskDir.findChild(EduKotlinPluginConfigurator.LEGACY_TESTS_KT);
  if (testsFile != null) {
    return testsFile;
  }
  return taskDir.findChild(EduKotlinPluginConfigurator.TESTS_KT);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:20,代碼來源:EduKotlinPyCharmTaskChecker.java

示例2: configure

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Override
public void configure(@NotNull MavenProject mavenProject, @NotNull Project project, @Nullable Module module) {
  if (module == null) return;

  CompilerConfiguration configuration = CompilerConfiguration.getInstance(project);
  if (!Boolean.TRUE.equals(module.getUserData(IGNORE_MAVEN_COMPILER_TARGET_KEY))) {
    String targetLevel = mavenProject.getTargetLevel();
    // default source and target settings of maven-compiler-plugin is 1.5, see details at http://maven.apache.org/plugins/maven-compiler-plugin
    configuration.setBytecodeTargetLevel(module, ObjectUtils.notNull(targetLevel, "1.5"));
  }
  module.putUserData(IGNORE_MAVEN_COMPILER_TARGET_KEY, Boolean.FALSE);

  // Exclude src/main/archetype-resources
  VirtualFile dir = VfsUtil.findRelativeFile(mavenProject.getDirectoryFile(), "src", "main", "resources", "archetype-resources");
  if (dir != null && !configuration.isExcludedFromCompilation(dir)) {
    ExcludesConfiguration cfg = configuration.getExcludedEntriesConfiguration();
    cfg.addExcludeEntryDescription(new ExcludeEntryDescription(dir, true, false, project));
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:MavenCompilerConfigurer.java

示例3: findModuleWithoutLibrary

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Nullable
private static Pair<Module, MvcFramework> findModuleWithoutLibrary(Project project) {
  MvcFramework[] frameworks = MvcFramework.EP_NAME.getExtensions();

  for (Module module : ModuleManager.getInstance(project).getModules()) {
    for (MvcFramework framework : frameworks) {
      if (framework.hasFrameworkStructure(module) && !framework.hasFrameworkJar(module)) {
        if (VfsUtil.findRelativeFile(framework.findAppRoot(module), "application.properties") != null) {
          return Pair.create(module, framework);
        }
      }
    }
  }

  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:MvcProjectWithoutLibraryNotificator.java

示例4: triggerCleanAll

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private void triggerCleanAll(final Project project) {
    final HybrisProjectSettings yProjectSettings = HybrisProjectSettingsComponent.getInstance(project).getState();
    final File platformDir = new File(project.getBasePath() + "/" +
                                      yProjectSettings.getHybrisDirectory() + PLATFORM_MODULE_PREFIX);
    final VirtualFile vfPlatformDir = VfsUtil.findFileByIoFile(platformDir, true);
    final VirtualFile vfBuildFile = VfsUtil.findRelativeFile(vfPlatformDir, HybrisConstants.ANT_BUILD_XML);

    if (vfBuildFile == null) {
        return;
    }
    final PsiFile psiBuildFile = PsiManager.getInstance(project).findFile(vfBuildFile);

    if (psiBuildFile == null) {
        return;
    }
    final AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(project);
    final AntBuildFileBase antBuildFile = antConfiguration.getAntBuildFile(psiBuildFile);

    if (antBuildFile != null) {
        ExecutionHandler.runBuild(
            antBuildFile,
            antCleanAll,
            null,
            getDataContext(project),
            Collections.emptyList(),
            AntBuildListener.NULL
        );
    }
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:30,代碼來源:HybrisAntBuildListener.java

示例5: run

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Override
public void run() {
    if (sketchDataDirectory == null) {
        return;
    }

    VirtualFile projectResourceDirectory = VfsUtil.findRelativeFile(project.getBaseDir(), "src", "main", "resources");

    if (projectResourceDirectory == null) {
        throw new IllegalStateException("Cannot find directory 'src/main/resources' into which sketch resources are to be copied. Sketch resources cannot be imported.");
    }

    ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {

            for (VirtualFile resourceEntry : sketchDataDirectory.getChildren()) {
                try {
                    logger.debug("Copying '" + resourceEntry.getPath() + "' into sketch project.");
                    resourceEntry.copy(this, projectResourceDirectory, resourceEntry.getName());
                    logger.debug("Copy of '" + resourceEntry.getPath() + "' succeeded.");
                } catch (IOException io) {
                    // @TODO This failure is silent. Spawn a notification to inform the user.
                    logger.error("Whilst importing sketch resources into project, encountered an exception.", io);
                }
            }
        }
    });
}
 
開發者ID:mistodev,項目名稱:processing-idea,代碼行數:30,代碼來源:ImportSketchResources.java

示例6: initComponent

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Override
public void initComponent() {
    settings = GravProjectSettings.getInstance(project);
    if (settings != null) {
        if (project != null && VfsUtil.findRelativeFile(project.getBaseDir(), "src") == null) {
            settings.withSrcDirectory = false;
        } else {
            settings.withSrcDirectory = true;
        }
    }
}
 
開發者ID:PioBeat,項目名稱:GravSupport,代碼行數:12,代碼來源:GravProjectComponent.java

示例7: checkProject

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
public static boolean checkProject(Project project) {
    if (VfsUtil.findRelativeFile(project.getBaseDir(), "src", "user") != null
            && VfsUtil.findRelativeFile(project.getBaseDir(), "src", "bin") != null
            && VfsUtil.findRelativeFile(project.getBaseDir(), "src", "vendor") != null
            ) {
        return true;
    }
    return false;
}
 
開發者ID:PioBeat,項目名稱:GravSupport,代碼行數:10,代碼來源:ProjectChecker.java

示例8: getDefaultTheme

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
/**
 * Return the current theme which is set in the system/config/system.yaml file
 *
 * @param project the project
 * @return theme name or null
 */
public static String getDefaultTheme(Project project) {
    VirtualFile vfile = VfsUtil.findRelativeFile(project.getBaseDir(), "system", "config", "system.yaml");
    if (vfile == null) return null;
    PsiFile psiFile = PsiManager.getInstance(project).findFile(vfile);
    if (psiFile == null) return null;

    YAMLKeyValue yamlKeyValue = GravYAMLUtils.getKeyValue((YAMLFile) psiFile, Arrays.asList(new String[]{"pages", "theme"}));
    if (yamlKeyValue == null) return null;

    return yamlKeyValue.getValueText();
}
 
開發者ID:PioBeat,項目名稱:GravSupport,代碼行數:18,代碼來源:GravFileTemplateUtil.java

示例9: findCandidates

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private void findCandidates(@NotNull List<? extends FilePatch> list,
                            @NotNull final PatchBaseDirectoryDetector directoryDetector,
                            @NotNull List<PatchAndVariants> candidates, @NotNull List<FilePatch> newOrWithoutMatches) {
  for (final FilePatch patch : list) {
    final String fileName = patch.getBeforeFileName();
    if (patch.isNewFile() || (patch.getBeforeName() == null)) {
      newOrWithoutMatches.add(patch);
      continue;
    }
    final Collection<VirtualFile> files = findFilesFromIndex(directoryDetector, fileName);
    // for directories outside the project scope but under version control
    if (patch.getBeforeName() != null && patch.getBeforeName().startsWith("..")) {
      final VirtualFile relativeFile = VfsUtil.findRelativeFile(myBaseDir, patch.getBeforeName().replace('\\', '/').split("/"));
      if (relativeFile != null) {
        files.add(relativeFile);
      }
    }
    if (files.isEmpty()) {
      newOrWithoutMatches.add(patch);
    }
    else {
      //files order is not defined, so get the best variant depends on it, too
      final List<AbstractFilePatchInProgress> variants =
        ObjectsConvertor.convert(files, new Convertor<VirtualFile, AbstractFilePatchInProgress>() {
          @Override
          public AbstractFilePatchInProgress convert(VirtualFile o) {
            return processMatch(patch, o);
          }
        }, ObjectsConvertor.NOT_NULL);
      if (variants.isEmpty()) {
        newOrWithoutMatches.add(patch); // just to be sure
      }
      else {
        candidates.add(new PatchAndVariants(variants));
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:39,代碼來源:MatchPatchPaths.java

示例10: createOpenFileHyperlink

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
protected HyperlinkInfo createOpenFileHyperlink(String fileName, final int line, int column) {
  if ((fileName == null || fileName.length() == 0)) {
      if (myBase != null) {
          fileName = myBase.getPresentableUrl();
      } else {
          return null;
      }
  }
  fileName = fileName.replace(File.separatorChar, '/');

  VirtualFile file;
  // try to interpret the filename as URL
  if (URLUtil.containsScheme(fileName)) {
    try {
      file = VfsUtil.findFileByURL(new URL(fileName));
    } catch (MalformedURLException e) {
      file = VirtualFileManager.getInstance().findFileByUrl(VfsUtil.pathToUrl(fileName));
    }
  } else {
    file = VfsUtil.findRelativeFile(fileName, myBase);
  }
  if (file == null) {
    //noinspection ConstantConditions
    return null;
  }

  final FileType fileType = file.getFileType();
  if (fileType != null && column > 0) {
    final Document document = FileDocumentManager.getInstance().getDocument(file);

    final int start = document.getLineStartOffset(line);
    final int max = document.getLineEndOffset(line);
    final int tabSize = CodeStyleSettingsManager.getInstance(myProject).getCurrentSettings().getTabSize(fileType);
    column = EditorUtil.calcColumnNumber(null, document.getCharsSequence(), start, Math.min(start + column, max), tabSize);
  }
  return new OpenFileHyperlinkInfo(myProject, file, line, column);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:38,代碼來源:CustomRegexpFilter.java

示例11: resolveFile

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Nullable
public static PsiFile resolveFile(String name, PsiFile baseFile) {
    if (baseFile == null) return null;

    final VirtualFile virtualFile = VfsUtil.findRelativeFile(name, baseFile.getVirtualFile());
    if (virtualFile != null) {
        final PsiFile file = baseFile.getManager().findFile(virtualFile);
        if (file != baseFile && file instanceof XmlFile) {
            return file;
        }
    }
    return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:ResolveUtil.java

示例12: isValidGravSDK

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的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

示例13: isNeosProject

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
public static boolean isNeosProject(Project project) {
    return (VfsUtil.findRelativeFile(project.getBaseDir(), "Packages") != null
            && VfsUtil.findRelativeFile(project.getBaseDir(), "Configuration") != null
            && (VfsUtil.findRelativeFile(project.getBaseDir(), "Packages", "Application", "TYPO3.Neos") != null
            || VfsUtil.findRelativeFile(project.getBaseDir(), "Packages", "Application", "Neos.Neos") != null));
}
 
開發者ID:cvette,項目名稱:intellij-neos,代碼行數:7,代碼來源:NeosProjectComponent.java

示例14: addAttachArtifactDependency

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private void addAttachArtifactDependency(@NotNull Element buildHelperCfg,
                                         @NotNull DependencyScope scope,
                                         @NotNull MavenProject mavenProject,
                                         @NotNull MavenArtifact artifact) {
  Library.ModifiableModel libraryModel = null;

  for (Element artifactsElement : buildHelperCfg.getChildren("artifacts")) {
    for (Element artifactElement : artifactsElement.getChildren("artifact")) {
      String typeString = artifactElement.getChildTextTrim("type");
      if (typeString != null && !typeString.equals("jar")) continue;

      OrderRootType rootType = OrderRootType.CLASSES;

      String classifier = artifactElement.getChildTextTrim("classifier");
      if ("sources".equals(classifier)) {
        rootType = OrderRootType.SOURCES;
      }
      else if ("javadoc".equals(classifier)) {
        rootType = JavadocOrderRootType.getInstance();
      }

      String filePath = artifactElement.getChildTextTrim("file");
      if (StringUtil.isEmpty(filePath)) continue;

      VirtualFile file = VfsUtil.findRelativeFile(filePath, mavenProject.getDirectoryFile());
      if (file == null) continue;

      file = JarFileSystem.getInstance().getJarRootForLocalFile(file);
      if (file == null) continue;

      if (libraryModel == null) {
        String libraryName = getAttachedJarsLibName(artifact);

        Library library = myModifiableModelsProvider.getLibraryByName(libraryName);
        if (library == null) {
          library = myModifiableModelsProvider.createLibrary(libraryName);
        }
        libraryModel = myModifiableModelsProvider.getModifiableLibraryModel(library);

        LibraryOrderEntry entry = myRootModelAdapter.getRootModel().addLibraryEntry(library);
        entry.setScope(scope);
      }

      libraryModel.addRoot(file, rootType);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:48,代碼來源:MavenModuleImporter.java

示例15: hasFrameworkStructure

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Override
public boolean hasFrameworkStructure(@NotNull Module module) {
  return framework.hasFrameworkStructure(module) &&
         VfsUtil.findRelativeFile(framework.findAppRoot(module), "application.properties") != null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:6,代碼來源:MvcConfigureNotification.java


注:本文中的com.intellij.openapi.vfs.VfsUtil.findRelativeFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。