use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class TodoTreeHelper method addDirsToChildren.
protected void addDirsToChildren(List<VirtualFile> roots, ArrayList<AbstractTreeNode> children, TodoTreeBuilder builder) {
final PsiManager psiManager = PsiManager.getInstance(myProject);
for (VirtualFile dir : roots) {
final PsiDirectory directory = psiManager.findDirectory(dir);
if (directory == null) {
continue;
}
final Iterator<PsiFile> files = builder.getFiles(directory);
if (!files.hasNext())
continue;
TodoDirNode dirNode = new TodoDirNode(myProject, directory, builder);
if (!children.contains(dirNode)) {
children.add(dirNode);
}
}
}
use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class PlatformPackageUtil method getPackageDirectories.
private static PsiDirectory[] getPackageDirectories(Project project, String rootPackage, final GlobalSearchScope scope) {
final PsiManager manager = PsiManager.getInstance(project);
Query<VirtualFile> query = DirectoryIndex.getInstance(scope.getProject()).getDirectoriesByPackageName(rootPackage, true);
query = new FilteredQuery<>(query, scope::contains);
List<PsiDirectory> directories = ContainerUtil.mapNotNull(query.findAll(), manager::findDirectory);
return directories.toArray(new PsiDirectory[directories.size()]);
}
use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class ProjectBaseDirNavigationContributor method getItemsByName.
@Override
@NotNull
public NavigationItem[] getItemsByName(String name, final String pattern, Project project, boolean includeNonProjectItems) {
final PsiManager psiManager = PsiManager.getInstance(project);
final VirtualFile baseDir = project.getBaseDir();
if (baseDir == null)
return NavigationItem.EMPTY_NAVIGATION_ITEM_ARRAY;
final VirtualFile[] files = baseDir.getChildren();
final ArrayList<PsiFile> list = new ArrayList<>();
for (VirtualFile file : files) {
if (isEditable(file, includeNonProjectItems) && Comparing.strEqual(name, file.getName())) {
final PsiFile psiFile = psiManager.findFile(file);
if (psiFile != null) {
list.add(psiFile);
}
}
}
return PsiUtilCore.toPsiFileArray(list);
}
use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class DependenciesPanel method selectElementInLeftTree.
private void selectElementInLeftTree(PsiElement elt) {
PsiManager manager = PsiManager.getInstance(myProject);
PackageDependenciesNode root = (PackageDependenciesNode) myLeftTree.getModel().getRoot();
Enumeration enumeration = root.breadthFirstEnumeration();
while (enumeration.hasMoreElements()) {
PackageDependenciesNode child = (PackageDependenciesNode) enumeration.nextElement();
if (manager.areElementsEquivalent(child.getPsiElement(), elt)) {
myLeftTree.setSelectionPath(new TreePath(((DefaultTreeModel) myLeftTree.getModel()).getPathToRoot(child)));
break;
}
}
}
use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class PsiElementBaseIntentionAction method isAvailable.
@Override
public final boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
if (file == null)
return false;
final PsiManager manager = file.getManager();
if (manager == null)
return false;
if (!manager.isInProject(file))
return false;
final PsiElement element = getElement(editor, file);
return element != null && isAvailable(project, editor, element);
}
Aggregations