本文整理汇总了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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}