Java Code Examples for com.intellij.openapi.vfs.VfsUtilCore#toVirtualFileArray()
The following examples show how to use
com.intellij.openapi.vfs.VfsUtilCore#toVirtualFileArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DesktopEditorsSplitters.java From consulo with Apache License 2.0 | 6 votes |
@Override @Nonnull public VirtualFile[] getSelectedFiles() { final Set<VirtualFile> files = new ArrayListSet<>(); for (final DesktopEditorWindow 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; }
Example 2
Source File: DesktopEditorsSplitters.java From consulo with Apache License 2.0 | 6 votes |
@Override @Nonnull public VirtualFile[] getOpenFiles() { final Set<VirtualFile> files = new ArrayListSet<>(); for (final DesktopEditorWindow myWindow : myWindows) { final EditorWithProviderComposite[] editors = myWindow.getEditors(); for (final EditorWithProviderComposite editor : editors) { VirtualFile file = editor.getFile(); // background thread may call this method when invalid file is being removed // do not return it here as it will quietly drop out soon if (file.isValid()) { files.add(file); } } } return VfsUtilCore.toVirtualFileArray(files); }
Example 3
Source File: FileSetCompileScope.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public VirtualFile[] getFiles(final FileType fileType, boolean inSourceOnly) { final List<VirtualFile> files = new ArrayList<VirtualFile>(); for (Iterator<VirtualFile> it = myRootFiles.iterator(); it.hasNext();) { VirtualFile file = it.next(); if (!file.isValid()) { it.remove(); continue; } if (file.isDirectory()) { addRecursively(files, file, fileType); } else { if (fileType == null || fileType.equals(file.getFileType())) { files.add(file); } } } return VfsUtilCore.toVirtualFileArray(files); }
Example 4
Source File: CodeInsightUtilBase.java From consulo with Apache License 2.0 | 6 votes |
@Override public boolean preparePsiElementsForWrite(@Nonnull Collection<? extends PsiElement> elements) { if (elements.isEmpty()) return true; Set<VirtualFile> files = new THashSet<VirtualFile>(); Project project = null; for (PsiElement element : elements) { if (element == null) continue; PsiFile file = element.getContainingFile(); if (file == null || !file.isPhysical()) continue; project = file.getProject(); VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) continue; files.add(virtualFile); } if (!files.isEmpty()) { VirtualFile[] virtualFiles = VfsUtilCore.toVirtualFileArray(files); ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(virtualFiles); return !status.hasReadonlyFiles(); } return true; }
Example 5
Source File: NewLibraryEditor.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public VirtualFile[] getFiles(@Nonnull OrderRootType rootType) { List<VirtualFile> result = new ArrayList<>(); for (LightFilePointer pointer : myRoots.get(rootType)) { final VirtualFile file = pointer.getFile(); if (file == null) { continue; } if (file.isDirectory()) { final String url = file.getUrl(); if (isJarDirectory(url, rootType)) { boolean recursive = myJarDirectoryRecursiveUrls.get(rootType).contains(url); collectJarFiles(file, result, recursive); continue; } } result.add(file); } return VfsUtilCore.toVirtualFileArray(result); }
Example 6
Source File: ProjectLevelVcsManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public VirtualFile[] getAllVersionedRoots() { List<VirtualFile> vFiles = new ArrayList<>(); final AbstractVcs[] vcses = myMappings.getActiveVcses(); for (AbstractVcs vcs : vcses) { Collections.addAll(vFiles, getRootsUnderVcs(vcs)); } return VfsUtilCore.toVirtualFileArray(vFiles); }
Example 7
Source File: WolfTheProblemSolverImpl.java From consulo with Apache License 2.0 | 5 votes |
private void clearInvalidFiles() { VirtualFile[] files; synchronized (myProblems) { files = VfsUtilCore.toVirtualFileArray(myProblems.keySet()); } for (VirtualFile problemFile : files) { if (!problemFile.isValid() || !isToBeHighlighted(problemFile)) { doRemove(problemFile); } } }
Example 8
Source File: LRUPopupBuilder.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static ListPopup forFileLanguages(@Nonnull Project project, @Nonnull String title, @Nonnull Iterable<? extends VirtualFile> files, @Nonnull PerFileMappings<Language> mappings) { VirtualFile[] filesCopy = VfsUtilCore.toVirtualFileArray(JBIterable.from(files).toList()); Arrays.sort(filesCopy, (o1, o2) -> StringUtil.compare(o1.getName(), o2.getName(), !o1.getFileSystem().isCaseSensitive())); return forFileLanguages(project, title, null, t -> { try { WriteCommandAction.writeCommandAction(project).withName(LangBundle.message("command.name.change.language")).run(() -> changeLanguageWithUndo(project, t, filesCopy, mappings)); } catch (UnexpectedUndoException e) { LOG.error(e); } }); }
Example 9
Source File: EditorHistoryManager.java From consulo with Apache License 2.0 | 5 votes |
/** * @return array of valid files that are in the history, oldest first. May contain duplicates. */ public synchronized VirtualFile[] getFiles() { final List<VirtualFile> result = new ArrayList<>(myEntriesList.size()); for (HistoryEntry entry : myEntriesList) { VirtualFile file = entry.getFile(); if (file != null) result.add(file); } return VfsUtilCore.toVirtualFileArray(result); }
Example 10
Source File: FileIndexCompileScope.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public VirtualFile[] getFiles(final FileType fileType, final boolean inSourceOnly) { final List<VirtualFile> files = new ArrayList<VirtualFile>(); final FileIndex[] fileIndices = getFileIndices(); for (final FileIndex fileIndex : fileIndices) { fileIndex.iterateContent(new CompilerContentIterator(fileType, fileIndex, inSourceOnly, files)); } return VfsUtilCore.toVirtualFileArray(files); }
Example 11
Source File: ProjectRootManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public VirtualFile[] getContentRootsFromAllModules() { List<VirtualFile> result = new ArrayList<VirtualFile>(); final Module[] modules = getModuleManager().getSortedModules(); for (Module module : modules) { final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots(); ContainerUtil.addAll(result, files); } result.add(myProject.getBaseDir()); return VfsUtilCore.toVirtualFileArray(result); }
Example 12
Source File: MuleLibraryPresentationProvider.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Override public MuleLibraryProperties detect(@NotNull List<VirtualFile> classesRoots) { final VirtualFile[] libraryFiles = VfsUtilCore.toVirtualFileArray(classesRoots); for (VirtualFile libraryFile : libraryFiles) { final String muleHome = MuleSdk.getMuleHome(libraryFile.getCanonicalFile()); if(muleHome != null){ return new MuleLibraryProperties(new MuleSdk(muleHome)); } } return null; }
Example 13
Source File: ProjectRootManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public VirtualFile[] getContentRoots() { final List<VirtualFile> result = new ArrayList<VirtualFile>(); for (Module module : getModuleManager().getModules()) { final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots(); ContainerUtil.addAll(result, contentRoots); } return VfsUtilCore.toVirtualFileArray(result); }
Example 14
Source File: OrderRootsEnumeratorImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public VirtualFile[] fun(ModuleRootModel t, Predicate<ContentFolderTypeProvider> v) { List<VirtualFile> files = new ArrayList<>(5); ModuleCompilerPathsManager compilerPathsManager = ModuleCompilerPathsManager.getInstance(t.getModule()); for (ContentFolderTypeProvider contentFolderTypeProvider : ContentFolderTypeProvider.EP_NAME.getExtensionList()) { if(v.apply(contentFolderTypeProvider)) { ContainerUtil.addIfNotNull(files, compilerPathsManager.getCompilerOutput(contentFolderTypeProvider)); } } return VfsUtilCore.toVirtualFileArray(files); }
Example 15
Source File: ContentEntryImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public VirtualFile[] getFolderFiles(@Nonnull Predicate<ContentFolderTypeProvider> predicate) { List<VirtualFile> list = new ArrayList<>(); for (ContentFolder contentFolder : getFolders0(predicate)) { ContainerUtil.addIfNotNull(contentFolder.getFile(), list); } return VfsUtilCore.toVirtualFileArray(list); }
Example 16
Source File: ModuleRootLayerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public VirtualFile[] getExcludeRoots() { final List<VirtualFile> result = new SmartList<>(); for (ContentEntry contentEntry : getContent()) { Collections.addAll(result, contentEntry.getFolderFiles(ContentFolderScopes.excluded())); } return VfsUtilCore.toVirtualFileArray(result); }
Example 17
Source File: ModuleRootLayerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public VirtualFile[] getContentFolderFiles(@Nonnull Predicate<ContentFolderTypeProvider> predicate) { List<VirtualFile> result = new SmartList<>(); for (ContentEntry contentEntry : getContent()) { Collections.addAll(result, contentEntry.getFolderFiles(predicate)); } return VfsUtilCore.toVirtualFileArray(result); }
Example 18
Source File: ModuleRootLayerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public VirtualFile[] getContentRoots() { final ArrayList<VirtualFile> result = new ArrayList<>(); for (ContentEntry contentEntry : getContent()) { final VirtualFile file = contentEntry.getFile(); if (file != null) { result.add(file); } } return VfsUtilCore.toVirtualFileArray(result); }
Example 19
Source File: MappingsToRoots.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public VirtualFile[] getRootsUnderVcs(@Nonnull AbstractVcs vcs) { List<VirtualFile> result = myMappings.getMappingsAsFilesUnderVcs(vcs); final AbstractVcs.RootsConvertor convertor = vcs.getCustomConvertor(); if (convertor != null) { result = convertor.convertRoots(result); } Collections.sort(result, FilePathComparator.getInstance()); if (! vcs.allowsNestedRoots()) { final FileIndexFacade facade = ServiceManager.getService(myProject, FileIndexFacade.class); final List<VirtualFile> finalResult = result; ApplicationManager.getApplication().runReadAction(() -> { int i=1; while(i < finalResult.size()) { final VirtualFile previous = finalResult.get(i - 1); final VirtualFile current = finalResult.get(i); if (facade.isValidAncestor(previous, current)) { finalResult.remove(i); } else { i++; } } }); } result.removeIf(file -> !file.isDirectory()); return VfsUtilCore.toVirtualFileArray(result); }
Example 20
Source File: TestEditorManagerImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public VirtualFile[] getOpenFiles() { return VfsUtilCore.toVirtualFileArray(myVirtualFile2Editor.keySet()); }