use of com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode in project android by JetBrains.
the class AndroidViewProjectNode method getChildren.
@NotNull
@Override
public Collection<? extends AbstractTreeNode> getChildren() {
Project project = getProject();
assert project != null;
ViewSettings settings = getSettings();
// add a node for every module
// TODO: make this conditional on getSettings().isShowModules(), otherwise collapse them all at the root
List<Module> modules = Arrays.asList(ModuleManager.getInstance(project).getModules());
List<AbstractTreeNode> children = Lists.newArrayListWithExpectedSize(modules.size());
for (Module module : modules) {
if (isRootModuleWithNoSources(module)) {
// If we detect such a module, then we don't show it..
continue;
}
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
NdkFacet ndkFacet = NdkFacet.getInstance(module);
if (androidFacet != null && androidFacet.getAndroidModel() != null) {
children.add(new AndroidModuleNode(project, module, settings, myProjectViewPane));
} else if (ndkFacet != null && ndkFacet.getNdkModuleModel() != null) {
children.add(new NdkModuleNode(project, module, settings));
} else {
children.add(new NonAndroidModuleNode(project, module, settings));
}
}
// are still visible. See https://code.google.com/p/android/issues/detail?id=76564
if (children.isEmpty() && isBuildWithGradle(project) && GradleSyncState.getInstance(project).lastSyncFailed()) {
PsiDirectory dir = PsiManager.getInstance(project).findDirectory(project.getBaseDir());
if (dir != null) {
children.add(new PsiDirectoryNode(project, dir, settings));
}
}
if (isBuildWithGradle(project)) {
children.add(new AndroidBuildScriptsGroupNode(project, settings));
}
ExternalBuildFilesGroupNode externalBuildFilesNode = new ExternalBuildFilesGroupNode(project, settings);
if (!externalBuildFilesNode.getChildren().isEmpty()) {
children.add(externalBuildFilesNode);
}
return children;
}
use of com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode in project intellij-plugins by JetBrains.
the class DartTreeStructureProvider method modify.
@NotNull
public Collection<AbstractTreeNode> modify(@NotNull final AbstractTreeNode parentNode, @NotNull final Collection<AbstractTreeNode> children, final ViewSettings settings) {
if (parentNode instanceof ExternalLibrariesNode) {
return ContainerUtil.map(children, node -> {
if (node instanceof NamedLibraryElementNode && (DartPackagesLibraryType.DART_PACKAGES_LIBRARY_NAME.equals(node.getName()) || DartSdk.DART_SDK_LIB_NAME.equals(node.getName()))) {
final boolean isSdkRoot = DartSdk.DART_SDK_LIB_NAME.equals(node.getName());
return new NamedLibraryElementNode(node.getProject(), ((NamedLibraryElementNode) node).getValue(), settings) {
@Override
public boolean canNavigate() {
return isSdkRoot;
}
@Override
public void navigate(boolean requestFocus) {
final Project project = getProject();
if (project != null) {
DartConfigurable.openDartSettings(project);
}
}
};
}
return node;
});
}
if (parentNode instanceof NamedLibraryElementNode && (DartPackagesLibraryType.DART_PACKAGES_LIBRARY_NAME.equals(parentNode.getName()) || DartSdk.DART_SDK_LIB_NAME.equals(parentNode.getName()))) {
final boolean isSdkRoot = DartSdk.DART_SDK_LIB_NAME.equals(parentNode.getName());
return ContainerUtil.map(children, node -> {
final VirtualFile dir = node instanceof PsiDirectoryNode ? ((PsiDirectoryNode) node).getVirtualFile() : null;
if (dir != null && dir.isInLocalFileSystem() && dir.isDirectory() && (isSdkRoot || "lib".equals(dir.getName()))) {
return new DartSdkOrLibraryRootNode(node.getProject(), ((PsiDirectoryNode) node).getValue(), settings);
}
return node;
});
}
// root/packages/ThisProject and root/packages/PathPackage folders are excluded in dart projects (see DartProjectComponent.excludeBuildAndPackagesFolders),
// this provider adds location string tho these nodes in Project View like "ThisProject (ThisProject/lib)"
final Project project = parentNode.getProject();
final VirtualFile packagesDir = parentNode instanceof PsiDirectoryNode && project != null ? ((PsiDirectoryNode) parentNode).getVirtualFile() : null;
final VirtualFile parentFolder = packagesDir != null && packagesDir.isDirectory() && PACKAGES_FOLDER_NAME.equals(packagesDir.getName()) ? packagesDir.getParent() : null;
final VirtualFile pubspecYamlFile = parentFolder != null ? parentFolder.findChild(PUBSPEC_YAML) : null;
if (pubspecYamlFile != null && !pubspecYamlFile.isDirectory()) {
final ArrayList<AbstractTreeNode> modifiedChildren = new ArrayList<>(children);
final DartUrlResolver resolver = DartUrlResolver.getInstance(project, pubspecYamlFile);
resolver.processLivePackages((packageName, packageDir) -> {
final VirtualFile folder = packagesDir.findChild(packageName);
if (folder != null) {
final AbstractTreeNode node = getFolderNode(children, folder);
if (node == null) {
modifiedChildren.add(new SymlinkToLivePackageNode(project, packageName, packageDir));
} else {
node.getPresentation().setLocationString(getPackageLocationString(packageDir));
}
}
});
return modifiedChildren;
}
return children;
}
Aggregations