private boolean isAContentRoot(@Nullable PsiDirectory directory) { if (directory == null) { return false; } VirtualFile[] contentRoots = ProjectRootManager.getInstance(directory.getProject()).getContentRoots(); for (VirtualFile contentRoot : contentRoots) { if (contentRoot.equals(directory.getVirtualFile())) { return true; } } return false; } }
@Override protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) { Module module = myModuleProducer.produce(); if (module != null) { Project project = module.getProject(); VirtualFile[] contentRoots = ProjectRootManager.getInstance(project).getContentRoots(); for (VirtualFile contentRoot : contentRoots) { addDirectories(result, contentRoot.getPath(), contentRoot); } } }
@Nullable VirtualFile findFile(@NotNull String filename, @NotNull Project project) { VirtualFile found = null; if (filename.length() > 2 && filename.charAt(0) == '~' && filename.charAt(1) == File.separatorChar) { String homefile = filename.substring(2); String dir = System.getProperty("user.home"); if (logger.isDebugEnabled()) { logger.debug("home dir file"); logger.debug("looking for " + homefile + " in " + dir); } found = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(dir, homefile)); } else { ProjectRootManager prm = ProjectRootManager.getInstance(project); VirtualFile[] roots = prm.getContentRoots(); for (int i = 0; i < roots.length; i++) { if (logger.isDebugEnabled()) { logger.debug("root[" + i + "] = " + roots[i].getPath()); } found = findFile(roots[i], filename); if (found != null) { break; } } if (found == null) { found = LocalFileSystem.getInstance().findFileByIoFile(new File(filename)); } } return found; }
@Nullable @Override protected Runnable createRenewRequest(@NotNull CoverageSuitesBundle bundle, @NotNull CoverageDataManager manager) { GoCoverageProjectData data = new GoCoverageProjectData(); for (CoverageSuite suite : bundle.getSuites()) { ProjectData toMerge = suite.getCoverageData(manager); if (toMerge != null) { data.merge(toMerge); } } return () -> { annotateAllFiles(data, manager.doInReadActionIfProjectOpen(() -> ProjectRootManager.getInstance(getProject()).getContentRoots())); manager.triggerPresentationUpdate(); }; }
synchronized (myLastHandledGoPathSourcesRoots) { Collection<VirtualFile> goPathSourcesRoots = GoSdkUtil.getGoPathSources(project, myModule); Set<VirtualFile> excludeRoots = ContainerUtil.newHashSet(ProjectRootManager.getInstance(project).getContentRoots()); ProgressIndicatorProvider.checkCanceled(); if (!myLastHandledGoPathSourcesRoots.equals(goPathSourcesRoots) || !myLastHandledExclusions.equals(excludeRoots)) {
VirtualFile[] contentRoots = ProjectRootManager.getInstance(directory.getProject()).getContentRoots(); for (VirtualFile contentRoot : contentRoots) { if (contentRoot.equals(directory.getVirtualFile())) {
myModule); Set<VirtualFile> excludeRoots = ContainerUtil.newHashSet(ProjectRootManager.getInstance(project).getContentRoots()); ProgressIndicatorProvider.checkCanceled();
boolean preferSourceRoot = hasPackage && !preferGenRoot; VirtualFile[] sourceRoots = rootManager.getContentSourceRoots(); VirtualFile[] contentRoots = rootManager.getContentRoots(); final VirtualFile virtualRoot = existingFileRoot != null ? existingFileRoot : preferSourceRoot && fileIndex.isInSource(sourceFile) ? fileIndex.getSourceRootForFile(sourceFile) :