use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class SliceNullnessAnalyzer method calcNullableLeaves.
@NotNull
static NullAnalysisResult calcNullableLeaves(@NotNull final SliceNode root, @NotNull AbstractTreeStructure treeStructure, @NotNull final Map<SliceNode, NullAnalysisResult> map) {
final SliceLeafAnalyzer.SliceNodeGuide guide = new SliceLeafAnalyzer.SliceNodeGuide(treeStructure);
WalkingState<SliceNode> walkingState = new WalkingState<SliceNode>(guide) {
@Override
public void visit(@NotNull final SliceNode element) {
element.calculateDupNode();
node(element, map).clear();
SliceNode duplicate = element.getDuplicate();
if (duplicate != null) {
node(element, map).add(node(duplicate, map));
} else {
final PsiElement value = ApplicationManager.getApplication().runReadAction(new Computable<PsiElement>() {
@Override
public PsiElement compute() {
return element.getValue().getElement();
}
});
Nullness nullness = ApplicationManager.getApplication().runReadAction(new Computable<Nullness>() {
@Override
public Nullness compute() {
return checkNullness(value);
}
});
if (nullness == Nullness.NULLABLE) {
group(element, map, NullAnalysisResult.NULLS).add(value);
} else if (nullness == Nullness.NOT_NULL) {
group(element, map, NullAnalysisResult.NOT_NULLS).add(value);
} else {
Collection<? extends AbstractTreeNode> children = ApplicationManager.getApplication().runReadAction(new Computable<Collection<? extends AbstractTreeNode>>() {
@Override
public Collection<? extends AbstractTreeNode> compute() {
return element.getChildren();
}
});
if (children.isEmpty()) {
group(element, map, NullAnalysisResult.UNKNOWNS).add(value);
}
super.visit(element);
}
}
}
@Override
public void elementFinished(@NotNull SliceNode element) {
SliceNode parent = guide.getParent(element);
if (parent != null) {
node(parent, map).add(node(element, map));
}
}
};
walkingState.visit(root);
return node(root, map);
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-plugins by JetBrains.
the class FlexTreeStructureProvider method modify.
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
List<AbstractTreeNode> result = new ArrayList<>();
if (parent instanceof SwfQualifiedNamedElementNode || parent instanceof FlexFileNode) {
if (((ProjectViewNode) parent).getSettings().isShowMembers()) {
JSQualifiedNamedElement parentElement = getElement(parent);
if (parentElement != null) {
JSStructureViewElement structureViewElement = parentElement instanceof XmlBackedJSClassImpl ? new FlexStructureViewElement(((XmlBackedJSClassImpl) parentElement), (XmlFile) parentElement.getContainingFile(), false) : new JSStructureViewElement(parentElement, false, true);
StructureViewTreeElement[] structureViewChildren = structureViewElement.getChildren();
for (final StructureViewTreeElement structureViewChild : structureViewChildren) {
if (structureViewChild instanceof JSStructureViewElement) {
PsiElement childElement = ((JSStructureViewElement) structureViewChild).getValue();
result.add(new FlexClassMemberNode((JSElement) childElement, ((ProjectViewNode) parent).getSettings()));
} else {
result.add(new UnknownNode(parentElement.getProject(), structureViewChild, ((ProjectViewNode) parent).getSettings()));
}
}
}
}
} else {
for (final AbstractTreeNode child : children) {
Object o = child.getValue();
if (o instanceof JSFileImpl && !(o instanceof PsiCompiledFile) && DialectDetector.isActionScript((PsiFile) o) || o instanceof XmlFile && JavaScriptSupportLoader.isFlexMxmFile((PsiFile) o)) {
result.add(new FlexFileNode((PsiFile) o, ((ProjectViewNode) parent).getSettings()));
continue;
}
result.add(child);
}
}
return result;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project android by JetBrains.
the class ResourceTypeInspection method processValuesFlownTo.
@NotNull
private static InspectionResult processValuesFlownTo(@NotNull final PsiExpression argument, @NotNull PsiElement scope, @NotNull PsiManager manager, @NotNull final Function<PsiExpression, InspectionResult> processor) {
SliceAnalysisParams params = new SliceAnalysisParams();
params.dataFlowToThis = true;
params.scope = new AnalysisScope(new LocalSearchScope(scope), manager.getProject());
SliceLanguageSupportProvider languageSlicing = LanguageSlicing.getProvider(argument);
assert languageSlicing != null;
SliceRootNode rootNode = new SliceRootNode(manager.getProject(), new DuplicateMap(), languageSlicing.createRootUsage(argument, params));
@SuppressWarnings("unchecked") Collection<? extends AbstractTreeNode> children = rootNode.getChildren().iterator().next().getChildren();
for (AbstractTreeNode child : children) {
SliceUsage usage = (SliceUsage) child.getValue();
if (usage == null) {
continue;
}
PsiElement element = usage.getElement();
if (element instanceof PsiExpression) {
// If we report an error, use the current expression being evaluated. This will mark the error in the argument as opposed to using
// the original field or variable declaration.
InspectionResult result = processor.fun((PsiExpression) element).useErrorNode(argument);
if (result.isInvalid()) {
return result;
}
}
}
return !children.isEmpty() ? InspectionResult.valid() : InspectionResult.uncertain();
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project android by JetBrains.
the class AndroidModuleNode method getChildren.
@NotNull
public static Collection<AbstractTreeNode> getChildren(@NotNull AndroidFacet facet, @NotNull ViewSettings settings, @NotNull AndroidProjectViewPane pane, @NotNull List<IdeaSourceProvider> providers) {
Project project = facet.getModule().getProject();
List<AbstractTreeNode> result = Lists.newArrayList();
AndroidModuleModel androidModuleModel = AndroidModuleModel.get(facet);
HashMultimap<AndroidSourceType, VirtualFile> sourcesByType = getSourcesBySourceType(providers, androidModuleModel);
NdkModuleModel ndkModuleModel = NdkModuleModel.get(facet.getModule());
for (AndroidSourceType sourceType : sourcesByType.keySet()) {
if (sourceType == AndroidSourceType.CPP && ndkModuleModel != null) {
// Native sources will be added separately from NativeAndroidGradleModel.
continue;
}
if (sourceType == AndroidSourceType.MANIFEST) {
result.add(new AndroidManifestsGroupNode(project, facet, settings, sourcesByType.get(sourceType)));
continue;
}
if (sourceType == AndroidSourceType.RES) {
result.add(new AndroidResFolderNode(project, facet, settings, sourcesByType.get(sourceType), pane));
continue;
}
if (sourceType == AndroidSourceType.SHADERS) {
if (androidModuleModel == null || !androidModuleModel.getFeatures().isShadersSupported()) {
continue;
}
}
result.add(new AndroidSourceTypeNode(project, facet, settings, sourceType, sourcesByType.get(sourceType), pane));
}
if (ndkModuleModel != null) {
result.add(new AndroidJniFolderNode(project, ndkModuleModel, settings));
}
return result;
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project android by JetBrains.
the class AndroidResFolderNode method getChildren.
/**
* Returns the children of the res folder. Rather than showing the existing directory hierarchy, this merges together
* all the folders by their {@link com.android.resources.ResourceFolderType}.
*/
@NotNull
@Override
public Collection<? extends AbstractTreeNode> getChildren() {
// collect all res folders from all source providers
List<PsiDirectory> resFolders = Lists.newArrayList();
for (PsiDirectory directory : getSourceDirectories()) {
resFolders.addAll(Lists.newArrayList(directory.getSubdirectories()));
}
// group all the res folders by their folder type
HashMultimap<ResourceFolderType, PsiDirectory> foldersByResourceType = HashMultimap.create();
for (PsiDirectory resFolder : resFolders) {
ResourceFolderType type = ResourceFolderType.getFolderType(resFolder.getName());
if (type == null) {
// skip unknown folder types inside res
continue;
}
foldersByResourceType.put(type, resFolder);
}
// create a node for each res folder type that actually has some resources
AndroidProjectTreeBuilder treeBuilder = (AndroidProjectTreeBuilder) myProjectViewPane.getTreeBuilder();
List<AbstractTreeNode> children = Lists.newArrayListWithExpectedSize(foldersByResourceType.size());
for (ResourceFolderType type : foldersByResourceType.keySet()) {
Set<PsiDirectory> folders = foldersByResourceType.get(type);
final AndroidResFolderTypeNode androidResFolderTypeNode = new AndroidResFolderTypeNode(myProject, getValue(), Lists.newArrayList(folders), getSettings(), type, myProjectViewPane);
children.add(androidResFolderTypeNode);
// Inform the tree builder of the node that this particular virtual file maps to
for (PsiDirectory folder : folders) {
treeBuilder.createMapping(folder.getVirtualFile(), androidResFolderTypeNode);
}
}
return children;
}
Aggregations