@Nullable private File findApplicationFileRecursively(@NotNull final VirtualFile appDirectory, @NotNull final String applicationName) { final VirtualFileVisitor<VirtualFile> fileVisitor = new VirtualFileVisitor<VirtualFile>(VirtualFileVisitor .limit(APP_DEPTH_SEARCH), VirtualFileVisitor.SKIP_ROOT, VirtualFileVisitor.NO_FOLLOW_SYMLINKS) { @Override public boolean visitFile(@NotNull VirtualFile file) { if (ApplicationDictionary.SUPPORTED_APPLICATION_EXTENSIONS.contains(file.getExtension())) { if (applicationName.equals(file.getNameWithoutExtension())) { throw new MyStopVisitingException(file); } return false; //do not search inside application bundles } return true; } }; try { VfsUtilCore.visitChildrenRecursively(appDirectory, fileVisitor, MyStopVisitingException.class); } catch (MyStopVisitingException e) { LOG.debug("Application file found for application " + applicationName + " : " + e.getResult()); return new File(e.getResult().getPath()); } return null; }
public static Collection<VirtualFile> getAllSubFiles(VirtualFile virtualFile) { Collection<VirtualFile> list = new ArrayList<>(); VfsUtilCore.visitChildrenRecursively(virtualFile, new VirtualFileVisitor() { @Override public boolean visitFile(@NotNull VirtualFile file) { if (!file.isDirectory()) { list.add(file); } return super.visitFile(file); } }); return list; }
private void saveCustomDirectoryLocation(final Project project) { final HybrisProjectSettings hybrisProjectSettings = HybrisProjectSettingsComponent.getInstance(project) .getState(); final File customDirectory = hybrisProjectDescriptor.getExternalExtensionsDirectory(); final File hybrisDirectory = hybrisProjectDescriptor.getHybrisDistributionDirectory(); final File baseDirectory = VfsUtilCore.virtualToIoFile(project.getBaseDir()); final Path projectPath = Paths.get(baseDirectory.getAbsolutePath()); final Path hybrisPath = Paths.get(hybrisDirectory.getAbsolutePath()); final Path relativeHybrisPath = projectPath.relativize(hybrisPath); hybrisProjectSettings.setHybrisDirectory(relativeHybrisPath.toString()); if (customDirectory != null) { final Path customPath = Paths.get(customDirectory.getAbsolutePath()); final Path relativeCustomPath = hybrisPath.relativize(customPath); hybrisProjectSettings.setCustomDirectory(relativeCustomPath.toString()); } }
@Override public void configure( @NotNull final ModifiableRootModel modifiableRootModel, @NotNull final HybrisModuleDescriptor moduleDescriptor ) { Validate.notNull(modifiableRootModel); Validate.notNull(moduleDescriptor); final CompilerModuleExtension compilerModuleExtension = modifiableRootModel.getModuleExtension( CompilerModuleExtension.class ); final File outputDirectory = new File( moduleDescriptor.getRootDirectory(), HybrisConstants.JAVA_COMPILER_FAKE_OUTPUT_PATH ); compilerModuleExtension.setCompilerOutputPath(VfsUtilCore.pathToUrl(outputDirectory.getAbsolutePath())); compilerModuleExtension.setCompilerOutputPathForTests(VfsUtilCore.pathToUrl(outputDirectory.getAbsolutePath())); compilerModuleExtension.setExcludeOutput(true); compilerModuleExtension.inheritCompilerOutputPath(false); }
private static void getFilesWithBom(@NotNull VirtualFile root, @NotNull final List<VirtualFile> result, final boolean all) { VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() { @Override public boolean visitFile(@NotNull VirtualFile file) { if (file.isDirectory()) { if (!all && !result.isEmpty()) { return false; } } else if (file.getBOM() != null) { result.add(file); } return true; } }); }
public void mergeCommit(VirtualFile root) throws VcsException { GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.COMMIT); handler.setStdoutSuppressed(false); File gitDir = new File(VfsUtilCore.virtualToIoFile(root), GitUtil.DOT_GIT); File messageFile = new File(gitDir, GitRepositoryFiles.MERGE_MSG); if (!messageFile.exists()) { final GitBranch branch = GitBranchUtil.getCurrentBranch(myProject, root); final String branchName = branch != null ? branch.getName() : ""; handler.addParameters("-m", "Merge branch '" + branchName + "' of " + root.getPresentableUrl() + " with conflicts."); } else { handler.addParameters("-F", messageFile.getAbsolutePath()); } handler.endOptions(); handler.run(); }
@NonNull @Override public List<File> getJavaClassFolders() { if (SUPPORT_CLASS_FILES) { if (mJavaClassFolders == null) { VirtualFile folder = AndroidDexCompiler.getOutputDirectoryForDex(myModule); if (folder != null) { mJavaClassFolders = Collections.singletonList(VfsUtilCore.virtualToIoFile(folder)); } else { mJavaClassFolders = Collections.emptyList(); } } return mJavaClassFolders; } return Collections.emptyList(); }
@Override public <S> List<S> filterUniqueRoots(final List<S> in, final Convertor<S, VirtualFile> convertor) { Collections.sort(in, new ComparatorDelegate<S, VirtualFile>(convertor, FilePathComparator.getInstance())); for (int i = 1; i < in.size(); i++) { final S sChild = in.get(i); final VirtualFile child = convertor.convert(sChild); final VirtualFile childRoot = HgUtil.getHgRootOrNull(myProject, child); if (childRoot == null) { continue; } for (int j = i - 1; j >= 0; --j) { final S sParent = in.get(j); final VirtualFile parent = convertor.convert(sParent); // if the parent is an ancestor of the child and that they share common root, the child is removed if (VfsUtilCore.isAncestor(parent, child, false) && VfsUtilCore.isAncestor(childRoot, parent, false)) { in.remove(i); //noinspection AssignmentToForLoopParameter --i; break; } } } return in; }
protected VirtualFile[] getSelectedFiles() { final Change[] changes = getSelectedChanges(); Collection<VirtualFile> files = new HashSet<VirtualFile>(); for (Change change : changes) { final ContentRevision afterRevision = change.getAfterRevision(); if (afterRevision != null) { final VirtualFile file = afterRevision.getFile().getVirtualFile(); if (file != null && file.isValid()) { files.add(file); } } } files.addAll(getSelectedVirtualFiles(null)); return VfsUtilCore.toVirtualFileArray(files); }
@Override protected void updatePsi(PsiTreeChangeEvent event) { boolean runState = myRunState; super.updatePsi(event); if (!runState && myResourceDepends != null && !myUpdateRenderer) { PsiFile psiFile = event.getFile(); if (psiFile == null) { return; } VirtualFile file = psiFile.getVirtualFile(); if (file == null) { return; } for (VirtualFile resourceDir : myResourceDepends) { if (VfsUtilCore.isAncestor(resourceDir, file, false)) { myUpdateRenderer = true; break; } } } }
@NotNull private static CellAppearanceEx formatRelativePath(@NotNull final ContentFolder folder, @NotNull final Icon icon) { LightFilePointer folderFile = new LightFilePointer(folder.getUrl()); VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(folder.getContentEntry().getUrl()); if (file == null) return FileAppearanceService.getInstance().forInvalidUrl(folderFile.getPresentableUrl()); String contentPath = file.getPath(); String relativePath; SimpleTextAttributes textAttributes; VirtualFile folderFileFile = folderFile.getFile(); if (folderFileFile == null) { String absolutePath = folderFile.getPresentableUrl(); relativePath = absolutePath.startsWith(contentPath) ? absolutePath.substring(contentPath.length()) : absolutePath; textAttributes = SimpleTextAttributes.ERROR_ATTRIBUTES; } else { relativePath = VfsUtilCore.getRelativePath(folderFileFile, file, File.separatorChar); textAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES; } relativePath = StringUtil.isEmpty(relativePath) ? "." + File.separatorChar : relativePath; return new SimpleTextCellAppearance(relativePath, icon, textAttributes); }
@Override public void reset() { myTypeCombo.setSelectedItem(myProperties.getSigningMode()); final String keyStoreUrl = myProperties.getKeyStoreUrl(); myKeyStorePathField.setText(keyStoreUrl != null ? FileUtil.toSystemDependentName(VfsUtilCore.urlToPath(keyStoreUrl)) : ""); myKeyStorePasswordField.setText(myProperties.getPlainKeystorePassword()); final String keyAlias = myProperties.getKeyAlias(); myKeyAliasField.setText(keyAlias != null ? keyAlias : ""); myKeyPasswordField.setText(myProperties.getPlainKeyPassword()); myProGuardCheckBox.setSelected(myProperties.isRunProGuard()); myProGuardConfigFilesPanel.setUrls(myProperties.getProGuardCfgFiles()); UIUtil.setEnabled(myCertificatePanel, myProperties.getSigningMode() == AndroidArtifactSigningMode.RELEASE_SIGNED, true); UIUtil.setEnabled(myProGuardConfigPanel, myProperties.isRunProGuard(), true); }
@Nullable String getRelativePath(final VirtualFile virtualFile, final Project project) { String url = virtualFile.getPresentableUrl(); if (project == null) { return url; } VirtualFile root = ProjectFileIndex.SERVICE.getInstance(project).getContentRootForFile(virtualFile); if (root != null) { return root.getName() + File.separatorChar + VfsUtilCore.getRelativePath(virtualFile, root, File.separatorChar); } final VirtualFile baseDir = project.getBaseDir(); if (baseDir != null) { //noinspection ConstantConditions final String projectHomeUrl = baseDir.getPresentableUrl(); if (url.startsWith(projectHomeUrl)) { final String cont = url.substring(projectHomeUrl.length()); if (cont.isEmpty()) return null; url = "..." + cont; } } return url; }
private static void addOutputModuleRoots(@Nullable ExternalSourceSet externalSourceSet, @NotNull ExternalSystemSourceType sourceType, @NotNull Collection<String> result) { if (externalSourceSet == null) return; final ExternalSourceDirectorySet directorySet = externalSourceSet.getSources().get(sourceType); if (directorySet == null) return; if (directorySet.isCompilerOutputPathInherited()) return; final String path = directorySet.getOutputDir().getAbsolutePath(); VirtualFile virtualFile = VirtualFileManager.getInstance().findFileByUrl(path); if (virtualFile == null) { if(!directorySet.getOutputDir().exists()){ FileUtil.createDirectory(directorySet.getOutputDir()); } ApplicationEx app = (ApplicationEx)ApplicationManager.getApplication(); if (app.isDispatchThread() || !app.holdsReadLock()) { LocalFileSystem.getInstance().refreshAndFindFileByIoFile(directorySet.getOutputDir()); } } result.add(VfsUtilCore.pathToUrl(path)); }
/** * Checks whether we have a file filter (e.g. a set of specific files to check in the module rather than all files, * and if so, and if all the files have been found, returns true) */ private static boolean processFileFilter(@NonNull Module module, @Nullable List<VirtualFile> files, @NonNull LintModuleProject project) { if (files != null && !files.isEmpty()) { ListIterator<VirtualFile> iterator = files.listIterator(); while (iterator.hasNext()) { VirtualFile file = iterator.next(); if (module.getModuleContentScope().accept(file)) { project.addFile(VfsUtilCore.virtualToIoFile(file)); iterator.remove(); } } if (files.isEmpty()) { // We're only scanning a subset of files (typically the current file in the editor); // in that case, don't initialize all the libraries etc project.setDirectLibraries(Collections.<Project>emptyList()); return true; } } return false; }
@NotNull @Override public Set<VirtualFile> getAdditionalRootsToIndex() { Set<VirtualFile> roots = new THashSet<VirtualFile>(); for (String url : myStandardResources.getValue()) { VirtualFile file = VfsUtilCore.findRelativeFile(url, null); if (file != null) { roots.add(file); } } String path = FetchExtResourceAction.getExternalResourcesPath(); VirtualFile extResources = LocalFileSystem.getInstance().findFileByPath(path); ContainerUtil.addIfNotNull(extResources, roots); return roots; }
@Override @NotNull public VirtualFile[] getFiles(@NotNull OrderRootType rootType) { checkDisposed(); VirtualFilePointerContainer container = myRoots.get(rootType); if (container == null) { return VirtualFile.EMPTY_ARRAY; } List<VirtualFile> expanded = new SmartList<VirtualFile>(); for (VirtualFile file : container.getFiles()) { if (file.isDirectory()) { if (myJarDirectories.contains(rootType, file.getUrl())) { collectJarFiles(file, expanded, myJarDirectories.isRecursive(rootType, file.getUrl())); continue; } } expanded.add(file); } return VfsUtilCore.toVirtualFileArray(expanded); }
static boolean isUnsynced(Project project, VirtualFile virtualFile) { if (!virtualFile.isInLocalFileSystem()) { return false; } if (ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(virtualFile) == null) { return false; } OCWorkspace workspace = OCWorkspaceProvider.getWorkspace(project); if (!(workspace instanceof BlazeCWorkspace)) { // Skip if the project isn't a Blaze project or doesn't have C support enabled anyway. return false; } if (workspace.getConfigurations().isEmpty()) { // The workspace configurations may not have been loaded yet. return false; } SourceToTargetMap sourceToTargetMap = SourceToTargetMap.getInstance(project); return sourceToTargetMap .getRulesForSourceFile(VfsUtilCore.virtualToIoFile(virtualFile)) .isEmpty(); }
@NotNull public VirtualFile[] getSelectedFiles() { final Set<VirtualFile> files = new ArrayListSet<VirtualFile>(); for (final EditorWindow window : myWindows) { final VirtualFile file = window.getSelectedFile(); if (file != null) { files.add(file); } } final VirtualFile[] virtualFiles = VfsUtilCore.toVirtualFileArray(files); final VirtualFile currentFile = getCurrentFile(); if (currentFile != null) { for (int i = 0; i != virtualFiles.length; ++i) { if (Comparing.equal(virtualFiles[i], currentFile)) { virtualFiles[i] = virtualFiles[0]; virtualFiles[0] = currentFile; break; } } } return virtualFiles; }
/** * If no target directory is given, but we have a resource module, we can still figure out some * paths. */ @Test public void getResourceSourceSetsWithNoTargetDirectory() { AndroidFacet facet = mockResourceFacet(); File resourceFile = VfsUtilCore.virtualToIoFile(resource); List<AndroidSourceSet> sourceSets = AndroidSourceSet.getSourceSets(facet, null); assertThat(sourceSets).hasSize(1); AndroidSourceSet sourceSet = sourceSets.get(0); AndroidProjectPaths paths = sourceSet.getPaths(); assertThat(sourceSet.getName()).isEqualTo("com.google.resource"); assertThat(paths.getModuleRoot()).isEqualTo(resourceFile); assertThat(paths.getSrcDirectory(null)).isEqualTo(resourceFile); assertThat(paths.getTestDirectory(null)).isEqualTo(resourceFile); assertThat(paths.getResDirectory()).isEqualTo(new File(resourceFile, "res")); assertThat(paths.getAidlDirectory(null)).isEqualTo(resourceFile); assertThat(paths.getManifestDirectory()).isEqualTo(resourceFile); }
/** * given a list of action-target files, returns ALL the files that should be * subject to the action Does not keep directories, but recursively adds * directory contents * * @param project the project subject of the action * @param files the root selection * @return the complete set of files this action should apply to */ @NotNull protected VirtualFile[] collectAffectedFiles(@NotNull Project project, @NotNull VirtualFile[] files) { List<VirtualFile> affectedFiles = new ArrayList<VirtualFile>(files.length); ProjectLevelVcsManager projectLevelVcsManager = ProjectLevelVcsManager.getInstance(project); for (VirtualFile file : files) { if (!file.isDirectory() && projectLevelVcsManager.getVcsFor(file) instanceof GitVcs) { affectedFiles.add(file); } else if (file.isDirectory() && isRecursive()) { addChildren(project, affectedFiles, file); } } return VfsUtilCore.toVirtualFileArray(affectedFiles); }
@Override public String getPresentableRelativePathFor(final VirtualFile file) { if (file == null) return ""; return ApplicationManager.getApplication().runReadAction(new Computable<String>() { @Override public String compute() { ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); boolean hideExcludedFiles = Registry.is("ide.hide.excluded.files"); Module module = fileIndex.getModuleForFile(file, hideExcludedFiles); VirtualFile contentRoot = fileIndex.getContentRootForFile(file, hideExcludedFiles); if (module == null || contentRoot == null) return file.getPresentableUrl(); StringBuffer result = new StringBuffer(); result.append("["); result.append(module.getName()); result.append("] "); result.append(contentRoot.getName()); String relativePath = VfsUtilCore.getRelativePath(file, contentRoot, File.separatorChar); if (!relativePath.isEmpty()) { result.append(File.separatorChar); result.append(relativePath); } return result.toString(); } }); }
protected boolean accept(@NotNull final PsiDirectory dir, @NotNull final Processor<VirtualFile> processor) { final Project project = dir.getProject(); final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex(); //we should analyze generated source files only if the action is explicitly invoked for a directory located under generated roots final boolean processGeneratedFiles = isInGeneratedSources(dir.getVirtualFile(), project); return VfsUtilCore.iterateChildrenRecursively(dir.getVirtualFile(), VirtualFileFilter.ALL, new ContentIterator() { @Override @SuppressWarnings({"SimplifiableIfStatement"}) public boolean processFile(@NotNull final VirtualFile fileOrDir) { if (!myIncludeTestSource && index.isInTestSourceContent(fileOrDir)) return true; if (!processGeneratedFiles && isInGeneratedSources(fileOrDir, project)) return true; if (!fileOrDir.isDirectory()) { return processor.process(fileOrDir); } return true; } }); }
@NotNull public VirtualFile[] getOrmLibSources() { final File libsDir = new File(myHomePath, "src/orm"); final File[] files = libsDir.listFiles(); List<VirtualFile> roots = new ArrayList<VirtualFile>(); if (files != null) { for (File file : files) { final String url = VfsUtil.getUrlForLibraryRoot(file); final VirtualFile zipRoot = VirtualFileManager.getInstance().findFileByUrl(url); if (zipRoot != null && zipRoot.isDirectory()) { String fileName = file.getName(); final String srcDirName = StringUtil.trimEnd(fileName, "-src.zip"); final VirtualFile sourcesDir = zipRoot.findFileByRelativePath(srcDirName + "/src/java"); if (sourcesDir != null) { roots.add(sourcesDir); } else { roots.add(zipRoot); } } } } return VfsUtilCore.toVirtualFileArray(roots); }
public static JPanel constructFileURLBrowserField(final TextFieldWithHistory field, final String objectName) { return constructFieldWithBrowseButton(field, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor().withTitle("Select " + objectName); VirtualFile file = FileChooser.chooseFile(descriptor, field, null, null); if (file != null) { try { field.setText(VfsUtilCore.virtualToIoFile(file).toURI().toURL().toString()); } catch (MalformedURLException e1) { field.setText(""); } } } }); }
@Override public Collection<VirtualFile> getAffectedContentRootsWithCheck() { if (myVcs.allowsNestedRoots()) { final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myVcs.getProject()); final VirtualFile[] roots = vcsManager.getRootsUnderVcs(myVcs); final Set<VirtualFile> result = new HashSet<VirtualFile>(myAffectedContentRoots); for (VirtualFile root : roots) { for (VirtualFile dir : myDirtyDirectoriesRecursively.keySet()) { if (VfsUtilCore.isAncestor(dir, root, true)) { result.add(root); } } } return new SmartList<VirtualFile>(result); } return myAffectedContentRoots; }
@Override public boolean contains(@NotNull VirtualFile file) { final PsiDirectory value = getValue(); if (value == null) { return false; } VirtualFile directory = value.getVirtualFile(); if (directory.getFileSystem() instanceof LocalFileSystem) { file = PathUtil.getLocalFile(file); } if (!VfsUtilCore.isAncestor(directory, file, false)) { return false; } if (Registry.is("ide.hide.excluded.files")) { final Project project = value.getProject(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); return !fileIndex.isExcluded(file); } else { return !FileTypeRegistry.getInstance().isFileIgnored(file); } }
@Override public <S> List<S> filterUniqueRoots(final List<S> in, final Convertor<S, VirtualFile> convertor) { Collections.sort(in, new ComparatorDelegate<S, VirtualFile>(convertor, FilePathComparator.getInstance())); for (int i = 1; i < in.size(); i++) { final S sChild = in.get(i); final VirtualFile child = convertor.convert(sChild); final VirtualFile childRoot = GitUtil.gitRootOrNull(child); if (childRoot == null) { // non-git file actually, skip it continue; } for (int j = i - 1; j >= 0; --j) { final S sParent = in.get(j); final VirtualFile parent = convertor.convert(sParent); // the method check both that parent is an ancestor of the child and that they share common git root if (VfsUtilCore.isAncestor(parent, child, false) && VfsUtilCore.isAncestor(childRoot, parent, false)) { in.remove(i); //noinspection AssignmentToForLoopParameter --i; break; } } } return in; }
public Set<String> getRootDirs(final Project project) { if (!Registry.is("editor.config.stop.at.project.root")) { return Collections.emptySet(); } return CachedValuesManager.getManager(project).getCachedValue(project, new CachedValueProvider<Set<String>>() { @Nullable @Override public Result<Set<String>> compute() { final Set<String> dirs = new HashSet<String>(); final VirtualFile projectBase = project.getBaseDir(); if (projectBase != null) { dirs.add(project.getBasePath()); for (Module module : ModuleManager.getInstance(project).getModules()) { for (VirtualFile root : ModuleRootManager.getInstance(module).getContentRoots()) { if (!VfsUtilCore.isAncestor(projectBase, root, false)) { dirs.add(root.getPath()); } } } } dirs.add(PathManager.getConfigPath()); return new Result<Set<String>>(dirs, ProjectRootModificationTracker.getInstance(project)); } }); }
private static void syncPaths(@NotNull final Module module, @NotNull IdeModifiableModelsProvider modelsProvider, @NotNull final ModuleData data) { final ModifiableRootModel modifiableRootModel = modelsProvider.getModifiableRootModel(module); CompilerModuleExtension extension = modifiableRootModel.getModuleExtension(CompilerModuleExtension.class); if (extension == null) { modifiableRootModel.dispose(); final String errorMsg = String.format("Can't sync paths for module '%s'. Reason: no compiler extension is found for it", module.getName()); throw new RuntimeException(errorMsg); } String compileOutputPath = data.getCompileOutputPath(ExternalSystemSourceType.SOURCE); if (compileOutputPath != null) { extension.setCompilerOutputPath(VfsUtilCore.pathToUrl(compileOutputPath)); } String testCompileOutputPath = data.getCompileOutputPath(ExternalSystemSourceType.TEST); if (testCompileOutputPath != null) { extension.setCompilerOutputPathForTests(VfsUtilCore.pathToUrl(testCompileOutputPath)); } extension.inheritCompilerOutputPath(data.isInheritProjectCompileOutputPath()); }
public void testCopyFormsRuntimeToArtifact() throws IOException { VirtualFile file = createFile("src/A.java", "class A{}"); VirtualFile srcRoot = file.getParent(); Module module = addModule("a", srcRoot); Artifact a = addArtifact(root().module(module)); make(a); assertOutput(a, fs().file("A.class")); File dir = PathManagerEx.findFileUnderCommunityHome("plugins/ui-designer/testData/build/copyFormsRuntimeToArtifact"); FileUtil.copyDir(dir, VfsUtilCore.virtualToIoFile(srcRoot)); srcRoot.refresh(false, false); make(a); File outputDir = VfsUtilCore.virtualToIoFile(getOutputDir(a)); assertTrue(new File(outputDir, "A.class").exists()); assertTrue(new File(outputDir, "B.class").exists()); assertTrue(new File(outputDir, AbstractLayout.class.getName().replace('.', '/') + ".class").exists()); }
@Override protected void modifyRoots(@NotNull VirtualFile vFile, @NotNull ContentEntry entry) { VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor() { @Override public boolean visitFile(@NotNull VirtualFile file) { if (file.isDirectory() && file.is(VFileProperty.SYMLINK)) { entry.addExcludeFolder(file); return false; } else { return true; } } }); }
private void discoverApplicationsInDirectory(@NotNull VirtualFile appsDirVFile) { VfsUtilCore.visitChildrenRecursively(appsDirVFile, new VirtualFileVisitor(VirtualFileVisitor.limit(APP_DEPTH_SEARCH)) { @Override public boolean visitFile(@NotNull VirtualFile file) { if (ApplicationDictionaryImpl.extensionSupported(file.getExtension())) { if (!"xml".equals(file.getExtension())) { discoveredApplicationNames.add(file.getNameWithoutExtension()); } return false; } return file.isDirectory(); } }); }
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); }
protected static boolean estimateIsCustomExtension(@NotNull final VirtualFile file) { final File itemsfile = VfsUtilCore.virtualToIoFile(file); final String itemsfilePath = normalize(itemsfile.getAbsolutePath()); if (itemsfilePath.contains(normalize(HybrisConstants.HYBRIS_OOTB_MODULE_PREFIX))) { return false; } if (itemsfilePath.contains(normalize(HybrisConstants.PLATFORM_EXT_MODULE_PREFIX))) { return false; } return true; }
protected void setCompilerOutput(@NotNull Project project) { CompilerProjectExtension compilerProjectExtension = CompilerProjectExtension.getInstance(project); String basePath = project.getBasePath(); if (compilerProjectExtension != null && basePath != null) { compilerProjectExtension.setCompilerOutputUrl(VfsUtilCore.pathToUrl(FileUtilRt.toSystemDependentName(basePath))); } }
private static void addFileWrapper(@NotNull VirtualFile file, List<FileWrapper> wrappers) { try { wrappers.add(new FileWrapper(file.getName(), VfsUtilCore.loadText(file))); } catch (IOException e) { LOG.error(e); } }
@Nullable @Override public VcsRevisionNumber getCurrentRevision(@NotNull VirtualFile file) { final Info svnInfo = myVcs.getInfo(VfsUtilCore.virtualToIoFile(file)); return getRevision(svnInfo); }
@Nullable public PsiPackage getPackage(PsiDirectory dir) { final VirtualFile file = dir.getVirtualFile(); for (VirtualFile root : myClasspath) { if (VfsUtilCore.isAncestor(root, file, false)) { String relativePath = FileUtil.getRelativePath(root.getPath(), file.getPath(), '/'); if (relativePath == null) continue; return new PsiPackageImpl(myPsiManager, relativePath.replace('/', '.')); } } return null; }
private static VirtualFile[] getAdminDirectoriesFor(Collection<File> files) { final Collection<VirtualFile> result = new HashSet<VirtualFile>(); for (File file : files) { final File parentFile = file.getParentFile(); final VirtualFile cvsAdminDirectory = CvsVfsUtil.findFileByIoFile(new File(parentFile, CvsUtil.CVS)); if (cvsAdminDirectory != null) result.add(cvsAdminDirectory); } return VfsUtilCore.toVirtualFileArray(result); }