use of com.intellij.psi.PsiDirectory 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();
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class TodoPackageNode method getFileCount.
private int getFileCount(final PackageElement packageElement) {
int count = 0;
if (getSettings().isFlattenPackages()) {
final PsiPackage aPackage = packageElement.getPackage();
final Module module = packageElement.getModule();
final GlobalSearchScope scope = module != null ? GlobalSearchScope.moduleScope(module) : GlobalSearchScope.projectScope(aPackage.getProject());
final PsiDirectory[] directories = aPackage.getDirectories(scope);
for (PsiDirectory directory : directories) {
Iterator<PsiFile> iterator = myBuilder.getFilesUnderDirectory(directory);
while (iterator.hasNext()) {
PsiFile psiFile = iterator.next();
if (getStructure().accept(psiFile))
count++;
}
}
} else {
Iterator<PsiFile> iterator = getFiles(packageElement);
while (iterator.hasNext()) {
PsiFile psiFile = iterator.next();
if (getStructure().accept(psiFile)) {
count++;
}
}
}
return count;
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class JavaProjectViewDirectoryHelper method getNodeName.
@Nullable
@Override
public String getNodeName(final ViewSettings settings, final Object parentValue, final PsiDirectory directory) {
PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory);
PsiPackage parentPackage;
if (!ProjectRootsUtil.isSourceRoot(directory) && aPackage != null && !aPackage.getQualifiedName().isEmpty() && parentValue instanceof PsiDirectory) {
parentPackage = JavaDirectoryService.getInstance().getPackage(((PsiDirectory) parentValue));
} else if (ProjectRootsUtil.isSourceRoot(directory) && aPackage != null) {
//package prefix
aPackage = null;
parentPackage = null;
} else {
parentPackage = null;
}
return PackageUtil.getNodeName(settings, aPackage, parentPackage, directory.getName(), isShowFQName(settings, parentValue, directory));
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class PackageElement method getRoots.
@NotNull
@Override
public Collection<VirtualFile> getRoots() {
Set<VirtualFile> roots = new HashSet<>();
final PsiDirectory[] dirs = PackageUtil.getDirectories(getPackage(), myModule, isLibraryElement());
for (PsiDirectory each : dirs) {
roots.add(each.getVirtualFile());
}
return roots;
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class PackageElementNode method canRepresent.
@Override
public boolean canRepresent(final Object element) {
if (super.canRepresent(element))
return true;
final PackageElement value = getValue();
if (value == null)
return true;
if (element instanceof PackageElement) {
final PackageElement packageElement = (PackageElement) element;
final String otherPackage = packageElement.getPackage().getQualifiedName();
final String aPackage = value.getPackage().getQualifiedName();
if (otherPackage.equals(aPackage)) {
return true;
}
}
if (element instanceof PsiDirectory) {
final PsiDirectory directory = (PsiDirectory) element;
return Arrays.asList(value.getPackage().getDirectories()).contains(directory);
}
return false;
}
Aggregations