use of com.intellij.ide.projectView.impl.nodes.PackageElementNode in project intellij-community by JetBrains.
the class PackageViewPane method getSelectedDirectories.
@NotNull
@Override
public PsiDirectory[] getSelectedDirectories() {
List<PsiDirectory> directories = ContainerUtil.newArrayList();
for (PackageElementNode node : getSelectedNodes(PackageElementNode.class)) {
PackageElement packageElement = node.getValue();
PsiPackage aPackage = packageElement != null ? packageElement.getPackage() : null;
final Module module = packageElement != null ? packageElement.getModule() : null;
if (aPackage != null && module != null) {
GlobalSearchScope scope = GlobalSearchScope.moduleScope(module);
Collections.addAll(directories, aPackage.getDirectories(scope));
if (Registry.is("projectView.choose.directory.on.compacted.middle.packages")) {
Object parentValue = node.getParent().getValue();
PsiPackage parentNodePackage = parentValue instanceof PackageElement ? ((PackageElement) parentValue).getPackage() : null;
while (true) {
aPackage = aPackage.getParentPackage();
if (aPackage == null || aPackage.getQualifiedName().isEmpty() || aPackage.equals(parentNodePackage)) {
break;
}
Collections.addAll(directories, aPackage.getDirectories(scope));
}
}
}
}
if (!directories.isEmpty()) {
return directories.toArray(new PsiDirectory[directories.size()]);
}
return super.getSelectedDirectories();
}
Aggregations