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


Java VfsUtil.findFileByIoFile方法代碼示例

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


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

示例1: findBuildFile

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private AntBuildFileBase findBuildFile(final File dir) {
    final File buildxml = new File(dir, HybrisConstants.ANT_BUILD_XML);
    if (!buildxml.exists()) {
        return null;
    }

    final VirtualFile buildFile = VfsUtil.findFileByIoFile(buildxml, true);
    if (buildFile == null) {
        return null;
    }

    final AntBuildFile antBuildFile;
    try {
        antBuildFile = antConfiguration.addBuildFile(buildFile);
    } catch (AntNoFileException e) {
        return null;
    }

    if (antBuildFile instanceof AntBuildFileBase) {
        return (AntBuildFileBase) antBuildFile;
    }
    return null;
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:24,代碼來源:DefaultAntConfigurator.java

示例2: getSourceCodeRoot

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Nullable
private VirtualFile getSourceCodeRoot(final @NotNull HybrisModuleDescriptor moduleDescriptor) {
    final VirtualFile sourceCodeRoot;
    final File sourceCodeFile = moduleDescriptor.getRootProjectDescriptor().getSourceCodeFile();

    if (null != sourceCodeFile) {
        final VirtualFile sourceVFile = VfsUtil.findFileByIoFile(sourceCodeFile, true);
        if (null == sourceVFile) {
            sourceCodeRoot = null;
        } else if (sourceVFile.isDirectory()) {
            sourceCodeRoot = sourceVFile;
        } else {
            sourceCodeRoot = JarFileSystem.getInstance().getJarRootForLocalFile(sourceVFile);
        }
    } else {
        sourceCodeRoot = null;
    }

    return sourceCodeRoot;
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:21,代碼來源:DefaultLibRootsConfigurator.java

示例3: createModule

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module module = super.createModule(moduleModel);
  Course course = myTask.getLesson().getCourse();
  String directory = getModuleFileDirectory();
  if (directory == null) {
    return module;
  }
  VirtualFile moduleDir = VfsUtil.findFileByIoFile(new File(directory), true);
  if (moduleDir == null) {
    return module;
  }
  VirtualFile src = moduleDir.findChild(EduNames.SRC);
  if (src == null) {
    return module;
  }
  createTask(module.getProject(), course, src);
  ModuleRootModificationUtil.addDependency(module, myUtilModule);
  EduIntellijUtils.addJUnit(module);
  return module;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:23,代碼來源:EduTaskModuleBuilder.java

示例4: testFindInOpenedFilesIncludesNoneProjectButOpenedFile

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
public void testFindInOpenedFilesIncludesNoneProjectButOpenedFile() throws IOException {
  File dir = createTempDirectory();
  File file = new File(dir.getPath(), "A.test1234");
  file.createNewFile();
  FileUtil.writeToFile(file, "foo fo foo");
  VirtualFile nonProjectFile = VfsUtil.findFileByIoFile(file, true);
  assertNotNull(nonProjectFile);

  FindModel findModel = new FindModel();
  findModel.setStringToFind("fo");
  findModel.setWholeWordsOnly(true);
  findModel.setFromCursor(false);
  findModel.setGlobal(true);
  findModel.setMultipleFiles(true);
  findModel.setCustomScope(true);
  findModel.setCustomScope(new GlobalSearchScope.FilesScope(myProject, ContainerUtil.list(nonProjectFile)));

  assertSize(1, findUsages(findModel));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:FindManagerTest.java

示例5: createTemporalFile

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@NotNull
public static VirtualFile createTemporalFile(@Nullable Project project,
                                             @NotNull String prefix,
                                             @NotNull String suffix,
                                             @NotNull byte[] content) throws IOException {
  File tempFile = FileUtil.createTempFile(PathUtil.suggestFileName(prefix + "_", true, false),
                                          PathUtil.suggestFileName("_" + suffix, true, false), true);
  if (content.length != 0) {
    FileUtil.writeToFile(tempFile, content);
  }
  VirtualFile file = VfsUtil.findFileByIoFile(tempFile, true);
  if (file == null) {
    throw new IOException("Can't create temp file for revision content");
  }
  VfsUtil.markDirtyAndRefresh(true, true, true, file);
  return file;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:DiffContentFactoryImpl.java

示例6: updateGradleVersion

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
static boolean updateGradleVersion(@NotNull Project project, @NotNull File wrapperPropertiesFile, @NotNull String gradleVersion) {
  try {
    boolean updated = GradleUtil.updateGradleDistributionUrl(gradleVersion, wrapperPropertiesFile);
    if (updated) {
      VirtualFile virtualFile = VfsUtil.findFileByIoFile(wrapperPropertiesFile, true);
      if (virtualFile != null) {
        virtualFile.refresh(false, false);
      }
      return true;
    }
  }
  catch (IOException e) {
    String msg = String.format("Unable to update Gradle wrapper to use Gradle %1$s\n", gradleVersion);
    msg += e.getMessage();
    Messages.showErrorDialog(project, msg, ERROR_MSG_TITLE);
  }
  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:FixGradleVersionInWrapperHyperlink.java

示例7: addClassesToModuleLibs

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private void addClassesToModuleLibs(
    @NotNull final ModifiableRootModel modifiableRootModel,
    @NotNull final IdeModifiableModelsProvider modifiableModelsProvider,
    @Nullable final VirtualFile sourceCodeRoot,
    @NotNull final JavaLibraryDescriptor javaLibraryDescriptor
) {
    final Library library = modifiableRootModel.getModuleLibraryTable().createLibrary();
    final Library.ModifiableModel libraryModifiableModel = modifiableModelsProvider
        .getModifiableLibraryModel(library);
    libraryModifiableModel.addRoot(
        VfsUtil.getUrlForLibraryRoot(javaLibraryDescriptor.getLibraryFile()), OrderRootType.CLASSES
    );

    if (null != javaLibraryDescriptor.getSourcesFile()) {
        final VirtualFile srcDirVF = VfsUtil.findFileByIoFile(javaLibraryDescriptor.getSourcesFile(), true);
        if (null != srcDirVF) {
            libraryModifiableModel.addRoot(srcDirVF, OrderRootType.SOURCES);
        }
    }

    if (sourceCodeRoot != null && javaLibraryDescriptor.getLibraryFile().getName().endsWith("server.jar")) {
        libraryModifiableModel.addRoot(sourceCodeRoot, OrderRootType.SOURCES);
    }

    if (javaLibraryDescriptor.isExported()) {
        this.setLibraryEntryExported(modifiableRootModel, library);
    }
    setLibraryEntryScope(modifiableRootModel, library, javaLibraryDescriptor.getScope());
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:30,代碼來源:DefaultLibRootsConfigurator.java

示例8: addJarFolderToModuleLibs

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private void addJarFolderToModuleLibs(
    @NotNull final ModifiableRootModel modifiableRootModel,
    @NotNull final IdeModifiableModelsProvider modifiableModelsProvider,
    @Nullable final VirtualFile sourceCodeRoot,
    @NotNull final JavaLibraryDescriptor javaLibraryDescriptor
) {
    final LibraryTable projectLibraryTable = modifiableRootModel.getModuleLibraryTable();

    final Library library = projectLibraryTable.createLibrary();
    final Library.ModifiableModel libraryModifiableModel = modifiableModelsProvider
        .getModifiableLibraryModel(library);

    libraryModifiableModel.addJarDirectory(
        VfsUtil.getUrlForLibraryRoot(javaLibraryDescriptor.getLibraryFile()), true
    );

    if (null != javaLibraryDescriptor.getSourcesFile()) {
        final VirtualFile srcDirVF = VfsUtil.findFileByIoFile(javaLibraryDescriptor.getSourcesFile(), true);
        if (null != srcDirVF) {
            libraryModifiableModel.addRoot(srcDirVF, OrderRootType.SOURCES);
        }
    }

    if (null != sourceCodeRoot) {
        libraryModifiableModel.addRoot(sourceCodeRoot, OrderRootType.SOURCES);
    }

    if (javaLibraryDescriptor.isExported()) {
        this.setLibraryEntryExported(modifiableRootModel, library);
    }
    setLibraryEntryScope(modifiableRootModel, library, javaLibraryDescriptor.getScope());
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:33,代碼來源:DefaultLibRootsConfigurator.java

示例9: setupFacetDeploymentDescriptor

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private void setupFacetDeploymentDescriptor(
    @NotNull final WebFacet webFacet,
    @NotNull final HybrisModuleDescriptor moduleDescriptor
) {
    final VirtualFile fileByIoFile = VfsUtil.findFileByIoFile(
        new File(moduleDescriptor.getRootDirectory(), HybrisConstants.WEB_XML_DIRECTORY_RELATIVE_PATH), true
    );

    if (null != fileByIoFile) {
        webFacet.getDescriptorsContainer().getConfiguration().addConfigFile(
            DeploymentDescriptorsConstants.WEB_XML_META_DATA, fileByIoFile.getUrl()
        );
    }
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:15,代碼來源:WebFacetConfigurator.java

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

示例11: createModule

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module baseModule = super.createModule(moduleModel);
  String directory = getModuleFileDirectory();
  if (directory == null) {
    return baseModule;
  }
  VirtualFile moduleDir = VfsUtil.findFileByIoFile(new File(directory), true);
  if (moduleDir == null) {
    return baseModule;
  }
  VirtualFile src = moduleDir.findChild(EduNames.SRC);
  if (src == null) {
    return baseModule;
  }
  Project project = baseModule.getProject();
  StartupManager.getInstance(project).registerPostStartupActivity(() -> DumbService.getInstance(project).runWhenSmart(() -> ApplicationManager.getApplication().runWriteAction(() -> {
    EduIntellijUtils.addTemplate(project, src, "EduTestRunner.java");
  })));
  EduIntellijUtils.addJUnit(baseModule);

  if (myAdditionalMaterials != null) {
    final List<Task> taskList = myAdditionalMaterials.getTaskList();
    if (taskList.size() == 1) {
      final Task task = taskList.get(0);
      for (Map.Entry<String, String> entry : task.getTestsText().entrySet()) {
        StudyGenerator.createChildFile(project.getBaseDir(), entry.getKey(), entry.getValue());
      }
    }
  }
  return baseModule;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:34,代碼來源:EduUtilModuleBuilder.java

示例12: getLayoutXmlVirtualFile

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Nullable
private static VirtualFile getLayoutXmlVirtualFile(boolean menu, @Nullable String resourceName, Configuration configuration) {
  ResourceType resourceType = menu ? ResourceType.MENU : ResourceType.LAYOUT;
  ResourceResolver resourceResolver = configuration.getResourceResolver();
  if (resourceResolver == null) {
    return null;
  }
  ResourceValue projectResource = resourceResolver.getProjectResource(resourceType, resourceName);
  if (projectResource == null) { /// seems to happen when we create a new resource
    return null;
  }
  return VfsUtil.findFileByIoFile(new File(projectResource.getValue()), false);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:NavigationView.java

示例13: addDirectoryToProjectView

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private static void addDirectoryToProjectView(
    Project project, File projectViewFile, ArtifactLocation generatedResDir) {
  ProjectViewEdit edit =
      ProjectViewEdit.editLocalProjectView(
          project,
          builder -> {
            ListSection<GenfilesPath> existingSection =
                builder.getLast(GeneratedAndroidResourcesSection.KEY);
            ListSection.Builder<GenfilesPath> directoryBuilder =
                ListSection.update(GeneratedAndroidResourcesSection.KEY, existingSection);
            directoryBuilder.add(new GenfilesPath(generatedResDir.getRelativePath()));
            builder.replace(existingSection, directoryBuilder);
            return true;
          });
  if (edit == null) {
    Messages.showErrorDialog(
        "Could not modify project view. Check for errors in your project view and try again",
        "Error");
    return;
  }
  edit.apply();
  VirtualFile projectView = VfsUtil.findFileByIoFile(projectViewFile, false);
  if (projectView != null) {
    FileEditorManager.getInstance(project)
        .openEditor(new OpenFileDescriptor(project, projectView), true);
  }
}
 
開發者ID:bazelbuild,項目名稱:intellij,代碼行數:28,代碼來源:AddGeneratedResourceDirectoryNavigatable.java

示例14: findChange

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Nullable
private HgChange findChange(@NotNull HgRepository hgRepo, @NotNull HgNameWithHashInfo info) {
  File file = new File(hgRepo.getRoot().getPath(), info.getName());
  VirtualFile virtualSubrepoFile = VfsUtil.findFileByIoFile(file, false);
  HgRepository subrepo = HgUtil.getRepositoryForFile(myProject, virtualSubrepoFile);
  if (subrepo != null && !info.getHash().asString().equals(subrepo.getCurrentRevision())) {
    return new HgChange(new HgFile(hgRepo.getRoot(), VcsUtil.getFilePath(virtualSubrepoFile)), HgFileStatusEnum.MODIFIED);
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:HgChangeProvider.java

示例15: inEnglish

import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
/**
 * Returns true if the given element is in an XML file that is in an English resource.
 * Manifest files are considered to be in English, as are resources in base folders
 * (unless a locale is explicitly defined on the root element)
 */
private static boolean inEnglish(PsiElement element) {
  XmlFile file = PsiTreeUtil.getParentOfType(element, XmlFile.class);
  if (file != null) {
    String name = file.getName();
    if (name.equals(ANDROID_MANIFEST_XML)) {
      return true;
    } else if (name.equals("generated.xml")) {
      // Android Studio Workaround for issue https://code.google.com/p/android/issues/detail?id=76715
      // If this a generated file like this:
      //   ${project}/${module}/build/generated/res/generated/{test?}/${flavors}/${build-type}/values/generated.xml
      // ? If so, skip it.
      AndroidFacet facet = AndroidFacet.getInstance(file);
      VirtualFile virtualFile = file.getVirtualFile();
      if (facet != null && facet.isGradleProject() && virtualFile != null) {
        IdeaAndroidProject project = facet.getIdeaAndroidProject();
        if (project != null) {
          VirtualFile buildFolder = VfsUtil.findFileByIoFile(project.getDelegate().getBuildFolder(), false);
          if (buildFolder != null && VfsUtilCore.isAncestor(buildFolder, virtualFile, false)) {
            return false;
          }
        }
      }
    }
    PsiDirectory dir = file.getParent();
    if (dir != null) {
      String locale = LintUtils.getLocaleAndRegion(dir.getName());
      if (locale == null) {
        locale = getToolsLocale(file);
      }
      return locale == null || locale.startsWith("en") || locale.equals("b+en") || locale.startsWith("b+en+");
    }
  }

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


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