use of com.intellij.psi.search.GlobalSearchScope in project intellij-elixir by KronicDeth.
the class FileReferenceFilter method resolveAbsolutePath.
@Nullable
private VirtualFile resolveAbsolutePath(@NotNull String path) {
VirtualFile asIsFile = pathToVirtualFile(path);
if (asIsFile != null) {
return asIsFile;
}
String projectBasedPath = path.startsWith(myProject.getBasePath()) ? path : new File(myProject.getBasePath(), path).getAbsolutePath();
VirtualFile projectBasedFile = pathToVirtualFile(projectBasedPath);
if (projectBasedFile != null) {
return projectBasedFile;
}
Matcher filenameMatcher = PATTERN_FILENAME.matcher(path);
if (filenameMatcher.find()) {
String filename = filenameMatcher.group(1);
GlobalSearchScope projectScope = ProjectScope.getProjectScope(myProject);
PsiFile[] projectFiles = FilenameIndex.getFilesByName(myProject, filename, projectScope);
if (projectFiles.length > 0) {
return projectFiles[0].getVirtualFile();
}
GlobalSearchScope libraryScope = ProjectScope.getLibrariesScope(myProject);
PsiFile[] libraryFiles = FilenameIndex.getFilesByName(myProject, filename, libraryScope);
if (libraryFiles.length > 0) {
return libraryFiles[0].getVirtualFile();
}
}
return null;
}
use of com.intellij.psi.search.GlobalSearchScope in project intellij-elixir by KronicDeth.
the class ElixirPsiImplUtil method moduleWithDependentsScope.
private static GlobalSearchScope moduleWithDependentsScope(PsiElement element) {
VirtualFile virtualFile = element.getContainingFile().getVirtualFile();
Project project = element.getProject();
com.intellij.openapi.module.Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
GlobalSearchScope globalSearchScope;
// module can be null for scratch files
if (module != null) {
globalSearchScope = GlobalSearchScope.moduleWithDependentsScope(module);
} else {
globalSearchScope = GlobalSearchScope.allScope(project);
}
return globalSearchScope;
}
use of com.intellij.psi.search.GlobalSearchScope in project intellij-community by JetBrains.
the class SourceScope method evaluateScopesAndUnite.
private static GlobalSearchScope evaluateScopesAndUnite(final Module[] modules, final ScopeForModuleEvaluator evaluator) {
GlobalSearchScope scope = evaluator.evaluate(modules[0]);
for (int i = 1; i < modules.length; i++) {
final Module module = modules[i];
final GlobalSearchScope otherscope = evaluator.evaluate(module);
scope = scope.uniteWith(otherscope);
}
return scope;
}
use of com.intellij.psi.search.GlobalSearchScope in project intellij-community by JetBrains.
the class TodoJavaTreeHelper method traverseSubPackages.
private static void traverseSubPackages(PsiPackage psiPackage, Module module, TodoTreeBuilder builder, Project project, Set<PsiPackage> packages) {
if (!isPackageEmpty(new PackageElement(module, psiPackage, false), builder, project)) {
packages.add(psiPackage);
}
GlobalSearchScope scope = module != null ? GlobalSearchScope.moduleScope(module) : GlobalSearchScope.projectScope(project);
final PsiPackage[] subPackages = psiPackage.getSubPackages(scope);
for (PsiPackage subPackage : subPackages) {
traverseSubPackages(subPackage, module, builder, project, packages);
}
}
use of com.intellij.psi.search.GlobalSearchScope in project intellij-community by JetBrains.
the class TodoPackageNode method getFiles.
/**
* @return read-only iterator of all valid PSI files that can have T.O.D.O items
* and which are located under specified {@code psiDirctory}.
*/
public Iterator<PsiFile> getFiles(PackageElement packageElement) {
ArrayList<PsiFile> psiFileList = new ArrayList<>();
GlobalSearchScope scope = packageElement.getModule() != null ? GlobalSearchScope.moduleScope(packageElement.getModule()) : GlobalSearchScope.projectScope(myProject);
final PsiDirectory[] directories = packageElement.getPackage().getDirectories(scope);
for (PsiDirectory directory : directories) {
Iterator<PsiFile> files = myBuilder.getFiles(directory, false);
for (; files.hasNext(); ) {
psiFileList.add(files.next());
}
}
return psiFileList.iterator();
}
Aggregations