com.intellij.ide.structureView.StructureViewTreeElement Java Examples
The following examples show how to use
com.intellij.ide.structureView.StructureViewTreeElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomRegionTreeElement.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public TreeElement[] getChildren() { if (mySubRegions == null || mySubRegions.isEmpty()) { return myChildElements.toArray(StructureViewTreeElement.EMPTY_ARRAY); } StructureViewTreeElement[] allElements = new StructureViewTreeElement[myChildElements.size() + mySubRegions.size()]; int index = 0; for (StructureViewTreeElement child : myChildElements) { allElements[index++] = child; } for (StructureViewTreeElement subRegion : mySubRegions) { allElements[index++] = subRegion; } return allElements; }
Example #2
Source File: WeaveObjectView.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@NotNull @Override public Collection<StructureViewTreeElement> getChildrenBase() { List<StructureViewTreeElement> result = new ArrayList<>(); final WeaveObjectExpression weaveObjectExpression = getElement(); final WeaveMultipleKeyValuePairObj keyValuePairObj = weaveObjectExpression.getMultipleKeyValuePairObj(); if (keyValuePairObj != null) { final List<WeaveKeyValuePair> valuePairList = keyValuePairObj.getKeyValuePairList(); for (WeaveKeyValuePair weaveKeyValuePair : valuePairList) { addKeyValuePair(result, weaveKeyValuePair); } } final WeaveSingleKeyValuePairObj singleKeyValuePairObj = weaveObjectExpression.getSingleKeyValuePairObj(); if (singleKeyValuePairObj != null) { final WeaveKeyValuePair keyValuePair = singleKeyValuePairObj.getKeyValuePair(); addKeyValuePair(result, keyValuePair); } return result; }
Example #3
Source File: SqliteMagicStructureViewExtension.java From sqlitemagic with Apache License 2.0 | 6 votes |
@Override public StructureViewTreeElement[] getChildren(PsiElement parent) { Collection<StructureViewTreeElement> result = new ArrayList<StructureViewTreeElement>(); final PsiClass psiClass = (PsiClass) parent; for (PsiField psiField : psiClass.getFields()) { if (psiField instanceof SqliteMagicLightFieldBuilder) { result.add(new PsiFieldTreeElement(psiField, false)); } } for (PsiMethod psiMethod : psiClass.getMethods()) { if (psiMethod instanceof SqliteMagicLightMethodBuilder) { result.add(new PsiMethodTreeElement(psiMethod, false)); } } if (!result.isEmpty()) { return result.toArray(new StructureViewTreeElement[result.size()]); } else { return StructureViewTreeElement.EMPTY_ARRAY; } }
Example #4
Source File: StructureAwareNavBarModelExtension.java From consulo with Apache License 2.0 | 6 votes |
@Nullable @RequiredReadAction private PsiElement findParentInModel(StructureViewTreeElement root, PsiElement psiElement) { for (TreeElement child : childrenFromNodeAndProviders(root)) { if(child instanceof StructureViewTreeElement) { if(Comparing.equal(((StructureViewTreeElement)child).getValue(), psiElement)) { return ObjectUtil.tryCast(root.getValue(), PsiElement.class); } PsiElement target = findParentInModel((StructureViewTreeElement)child, psiElement); if(target != null) { return target; } } } return null; }
Example #5
Source File: GraphQLStructureViewModel.java From js-graphql-intellij-plugin with MIT License | 6 votes |
@Override public boolean isAlwaysLeaf(StructureViewTreeElement element) { if (element instanceof GraphQLStructureViewTreeElement) { GraphQLStructureViewTreeElement treeElement = (GraphQLStructureViewTreeElement) element; if (treeElement.childrenBase instanceof LeafPsiElement) { return true; } if (treeElement.childrenBase instanceof GraphQLField) { final PsiElement[] children = treeElement.childrenBase.getChildren(); if (children.length == 0) { // field with no sub selections, but we have to check if there's attributes final PsiElement nextVisible = PsiTreeUtil.nextVisibleLeaf(treeElement.childrenBase); if (nextVisible != null && nextVisible.getNode().getElementType() == GraphQLElementTypes.PAREN_L) { return false; } return true; } if (children.length == 1 && children[0] instanceof LeafPsiElement) { return true; } } } return false; }
Example #6
Source File: WeaveArrayView.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@NotNull @Override public Collection<StructureViewTreeElement> getChildrenBase() { List<StructureViewTreeElement> result = new ArrayList<>(); final List<WeaveArrayElement> arrayElementList = getElement().getArrayElementList(); for (WeaveArrayElement weaveArrayElement : arrayElementList) { final WeaveSimpleArrayElement simpleArrayElement = weaveArrayElement.getSimpleArrayElement(); if (simpleArrayElement != null) { final WeaveExpression expression = simpleArrayElement.getExpression(); final StructureViewTreeElement structureViewTreeElement = WeaveStructureElementFactory.create(expression); if (structureViewTreeElement != null) { result.add(structureViewTreeElement); } } } return result; }
Example #7
Source File: CppStructureViewBuilder.java From CppTools with Apache License 2.0 | 6 votes |
public StructureViewTreeElement[] getChildren() { if (myChildren == null) { if (myOutlineData != null) { StructureViewTreeElement[] children = new StructureViewTreeElement[myOutlineData.maxCount]; final CppFile cppFile = (CppFile) myElement.getContainingFile(); final List<OutlineData> list = myOutlineData.nestedOutlines; for(int i = 0; i < children.length; ++i) { children[i] = new CppStructureViewTreeElement(cppFile, list.get(i)); } myChildren = children; } else { myChildren = EMPTY_ARRAY; } } return myChildren; }
Example #8
Source File: WeaveStructureElementFactory.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@Nullable public static StructureViewTreeElement create(PsiElement element) { if (element instanceof WeaveObjectExpression) { return new WeaveObjectView((WeaveObjectExpression) element); } else if (element instanceof WeaveArrayExpression) { return new WeaveArrayView((WeaveArrayExpression) element); } else if (element instanceof WeaveBinaryExpression) { return create(((WeaveBinaryExpression) element).getRight()); } else if (element instanceof WeaveBinaryClojureExpression) { return create(((WeaveBinaryClojureExpression) element).getRight()); } else if (element instanceof WeaveUsingExpression) { return create(((WeaveUsingExpression) element).getExpression()); } else if (element instanceof WeaveUnaryExpression) { return create(((WeaveUnaryExpression) element).getExpression()); } else { return null; } }
Example #9
Source File: ElmFileTreeElement.java From elm-plugin with MIT License | 5 votes |
@NotNull @Override public Collection<StructureViewTreeElement> getChildrenBase() { return StreamUtil.concatAll( element.getValueDeclarations().map((ElmValueDeclarationBase psiElement) -> new ElmValueDeclarationTreeElement(psiElement)), element.getTypeAliasDeclarations().map(ElmTypeAliasTreeElement::new), element.getTypeDeclarations().map(ElmUnionTypeTreeElement::new) ) .filter(a -> a.getElement() != null) .sorted(Comparator.comparingInt(a -> a.getElement().getTextOffset())) .collect(Collectors.toList()); }
Example #10
Source File: BuildStructureViewElement.java From intellij with Apache License 2.0 | 5 votes |
@NotNull @Override public Collection<StructureViewTreeElement> getChildrenBase() { if (!(element instanceof BuildFile)) { // TODO: show inner build rules in Skylark .bzl extensions return ImmutableList.of(); } ImmutableList.Builder<StructureViewTreeElement> builder = ImmutableList.builder(); for (BuildElement child : ((BuildFile) element).findChildrenByClass(BuildElement.class)) { builder.add(new BuildStructureViewElement(child)); } return builder.build(); }
Example #11
Source File: ApiStructureViewElement.java From ApiDebugger with Apache License 2.0 | 5 votes |
@NotNull @Override public Collection<StructureViewTreeElement> getChildrenBase() { PsiElement element = getElement(); if (element instanceof ApiPsiFile) { ApiDebugger type = PsiTreeUtil.findChildOfType(element, ApiDebugger.class); if (type != null) { return ContainerUtil.newArrayList(); } } return ContainerUtil.emptyList(); }
Example #12
Source File: PsiTreeElementBase.java From consulo with Apache License 2.0 | 5 votes |
/** * @return element base children merged with children provided by extensions */ @Nonnull public static List<StructureViewTreeElement> mergeWithExtensions(@Nonnull PsiElement element, @Nonnull Collection<StructureViewTreeElement> baseChildren, boolean withCustomRegions) { List<StructureViewTreeElement> result = new ArrayList<>(withCustomRegions ? CustomRegionStructureUtil.groupByCustomRegions(element, baseChildren) : baseChildren); StructureViewFactoryEx structureViewFactory = StructureViewFactoryEx.getInstanceEx(element.getProject()); Class<? extends PsiElement> aClass = element.getClass(); for (StructureViewExtension extension : structureViewFactory.getAllExtensions(aClass)) { StructureViewTreeElement[] children = extension.getChildren(element); if (children != null) { ContainerUtil.addAll(result, children); } extension.filterChildren(result, children == null || children.length == 0 ? Collections.emptyList() : Arrays.asList(children)); } return result; }
Example #13
Source File: StructureViewCompositeModel.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean isAutoExpand(@Nonnull StructureViewTreeElement element) { if (element.getValue() instanceof StructureViewComposite.StructureViewDescriptor) return true; for (ExpandInfoProvider p : getModels().filter(ExpandInfoProvider.class)) { if (p.isAutoExpand(element)) return true; } return false; }
Example #14
Source File: WeaveDocumentStructureView.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@NotNull @Override public Collection<StructureViewTreeElement> getChildrenBase() { final WeaveDocument element = getElement().getDocument(); final List<StructureViewTreeElement> result = new ArrayList<>(); if (element != null) { final WeaveHeader header = element.getHeader(); if (header != null) { final List<WeaveDirective> weaveDirectives = header.getDirectiveList(); for (WeaveDirective weaveDirective : weaveDirectives) { if (weaveDirective instanceof WeaveVariableDirective) { result.add(new WeaveVariableDirectiveView((WeaveVariableDirective) weaveDirective)); } if (weaveDirective instanceof WeaveFunctionDirective) { result.add(new WeaveFunctionDirectiveView((WeaveFunctionDirective) weaveDirective)); } } } final WeaveBody body = element.getBody(); final StructureViewTreeElement treeElement = WeaveStructureElementFactory.create(body.getExpression()); if (treeElement != null) { result.add(treeElement); } } return result; }
Example #15
Source File: FileStructureDialog.java From consulo with Apache License 2.0 | 5 votes |
@Override public Object getData(@Nonnull Key dataId) { Object selectedElement = myCommanderPanel.getSelectedValue(); if (selectedElement instanceof TreeElement) selectedElement = ((StructureViewTreeElement)selectedElement).getValue(); if (PlatformDataKeys.NAVIGATABLE == dataId) { return selectedElement instanceof Navigatable ? selectedElement : myNavigatable; } if (OpenFileDescriptor.NAVIGATE_IN_EDITOR == dataId) return myEditor; return getDataImpl(dataId); }
Example #16
Source File: ProtoStructureViewModel.java From protobuf-jetbrains-plugin with Apache License 2.0 | 5 votes |
@Override public boolean isAlwaysLeaf(StructureViewTreeElement element) { Object value = element.getValue(); return value instanceof RpcMethodNode || value instanceof EnumConstantNode || value instanceof FieldNode; }
Example #17
Source File: WeavePropertyView.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@NotNull @Override public Collection<StructureViewTreeElement> getChildrenBase() { final List<StructureViewTreeElement> result = new ArrayList<>(); final WeaveExpression expression = getElement().getExpression(); final StructureViewTreeElement treeElement = WeaveStructureElementFactory.create(expression); if (treeElement != null) { result.add(treeElement); }else{ // } return result; }
Example #18
Source File: GraphQLStructureViewTreeElement.java From js-graphql-intellij-plugin with MIT License | 5 votes |
private void addFieldChildren(List<StructureViewTreeElement> children) { final GraphQLField field = (GraphQLField) this.childrenBase; final GraphQLArguments arguments = field.getArguments(); if (arguments != null) { for (GraphQLArgument argument : arguments.getArgumentList()) { children.add(new GraphQLStructureViewTreeElement(argument, argument.getNameIdentifier())); } } if (field.getSelectionSet() != null) { addSelectionSetChildren(children); } }
Example #19
Source File: CustomRegionTreeElement.java From consulo with Apache License 2.0 | 5 votes |
public boolean containsElement(StructureViewTreeElement element) { Object o = element.getValue(); if (o instanceof PsiElement) { TextRange elementRange = ((PsiElement)o).getTextRange(); if (elementRange.getStartOffset() >= myStartElement.getTextRange().getStartOffset() && elementRange.getEndOffset() <= myEndOffset) { return true; } } return false; }
Example #20
Source File: GraphQLStructureViewTreeElement.java From js-graphql-intellij-plugin with MIT License | 5 votes |
private void addSelectionSetChildren(List<StructureViewTreeElement> children) { GraphQLSelectionSet selectionSet; if (childrenBase instanceof GraphQLSelectionSet) { selectionSet = (GraphQLSelectionSet) childrenBase; } else if (childrenBase instanceof GraphQLSelectionSetOperationDefinition) { selectionSet = ((GraphQLSelectionSetOperationDefinition) childrenBase).getSelectionSet(); } else if (childrenBase instanceof GraphQLField) { selectionSet = ((GraphQLField) childrenBase).getSelectionSet(); } else { return; } for (GraphQLSelection selection : selectionSet.getSelectionList()) { final GraphQLField field = selection.getField(); if (field != null) { children.add(new GraphQLStructureViewTreeElement(field, field.getNameIdentifier())); } else { final GraphQLFragmentSelection fragmentSelection = selection.getFragmentSelection(); if (fragmentSelection != null) { GraphQLFragmentSpread fragmentSpread = fragmentSelection.getFragmentSpread(); if (fragmentSpread != null) { children.add(new GraphQLStructureViewTreeElement(fragmentSpread, fragmentSpread.getNameIdentifier())); } else { GraphQLInlineFragment inlineFragment = fragmentSelection.getInlineFragment(); if (inlineFragment != null && inlineFragment.getSelectionSet() != null) { if (inlineFragment.getTypeCondition() != null && inlineFragment.getTypeCondition().getTypeName() != null) { children.add(new GraphQLStructureViewTreeElement(inlineFragment.getSelectionSet(), inlineFragment)); } } } } } } }
Example #21
Source File: JSGraphQLEndpointStructureViewModel.java From js-graphql-intellij-plugin with MIT License | 5 votes |
@Override public boolean isAlwaysLeaf(StructureViewTreeElement element) { if (element instanceof JSGraphQLEndpointStructureViewTreeElement) { JSGraphQLEndpointStructureViewTreeElement treeElement = (JSGraphQLEndpointStructureViewTreeElement) element; if (treeElement.childrenBase instanceof LeafPsiElement) { return true; } if (treeElement.childrenBase instanceof JSGraphQLEndpointInputValueDefinition) { return true; } } return false; }
Example #22
Source File: StructureAwareNavBarModelExtension.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction private List<TreeElement> childrenFromNodeAndProviders(StructureViewTreeElement parent) { List<TreeElement> children; if (parent instanceof PsiTreeElementBase) { children = ((PsiTreeElementBase)parent).getChildrenWithoutCustomRegions(); } else { children = Arrays.asList(parent.getChildren()); } List<TreeElement> fromProviders = getApplicableNodeProviders().stream().flatMap(nodeProvider -> nodeProvider.provideNodes(parent).stream()).collect(Collectors.toList()); return ContainerUtil.concat(children, fromProviders); }
Example #23
Source File: CppStructureViewBuilder.java From CppTools with Apache License 2.0 | 5 votes |
@NotNull public StructureViewTreeElement getRoot() { CachedValue<StructureViewTreeElement> value = myFile.getUserData(ourCachedKey); if (value == null) { value = CachedValuesManager.getManager(myFile.getManager().getProject()).createCachedValue(new CachedValueProvider<StructureViewTreeElement>() { public Result<StructureViewTreeElement> compute() { final OutlineCommand outlineCommand = new OutlineCommand(myFile.getVirtualFile().getPath()); outlineCommand.post(myFile.getProject()); final Communicator communicator = Communicator.getInstance(myFile.getProject()); if (outlineCommand.hasReadyResult()) { final OutlineData first = outlineCommand.outlineDatumStack.getFirst(); return new Result<StructureViewTreeElement>( new CppStructureViewTreeElement((CppFile) myFile, first), communicator.getServerRestartTracker(), communicator.getModificationTracker() ); } return new Result<StructureViewTreeElement>(new CppStructureViewTreeElement((CppFile) myFile, null), communicator.getServerRestartTracker(), communicator.getModificationTracker() ); } }, false); myFile.putUserData(ourCachedKey, value); } return value.getValue(); }
Example #24
Source File: LatteStructureViewTreeElement.java From intellij-latte with MIT License | 5 votes |
@NotNull @Override public Collection<StructureViewTreeElement> getChildrenBase() { Collection<StructureViewTreeElement> elements = new ArrayList<StructureViewTreeElement>(); if (getElement() == null) { return elements; } for (PsiElement el : getElement().getChildren()) { if (el instanceof LatteMacroClassic || el instanceof LatteAutoClosedBlock || el instanceof LatteNetteAttr) { elements.add(new LatteStructureViewTreeElement(el)); } } return elements; }
Example #25
Source File: CSharpNamedTreeElement.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nonnull @Override public Collection<StructureViewTreeElement> getChildrenBase() { List<StructureViewTreeElement> list = new ArrayList<>(); for(PsiElement psiElement : getValue().getChildren()) { if(psiElement instanceof DotNetQualifiedElement) { list.add(new CSharpNamedTreeElement((DotNetQualifiedElement) psiElement)); } } return list; }
Example #26
Source File: StructureViewElementWrapper.java From consulo with Apache License 2.0 | 5 votes |
@Override public StructureViewTreeElement[] getChildren() { TreeElement[] baseChildren = myTreeElement.getChildren(); List<StructureViewTreeElement> result = new ArrayList<StructureViewTreeElement>(); for (TreeElement element : baseChildren) { StructureViewTreeElement wrapper = new StructureViewElementWrapper((StructureViewTreeElement)element, myMainFile); result.add(wrapper); } return result.toArray(new StructureViewTreeElement[result.size()]); }
Example #27
Source File: MethodUpDownUtil.java From consulo with Apache License 2.0 | 5 votes |
private static void addStructureViewElements(final TreeElement parent, final Collection<PsiElement> array, @Nonnull PsiFile file) { for(TreeElement treeElement: parent.getChildren()) { Object value = ((StructureViewTreeElement)treeElement).getValue(); if (value instanceof PsiElement) { PsiElement element = (PsiElement)value; if (array.contains(element) || !file.equals(element.getContainingFile())) continue; array.add(element); } addStructureViewElements(treeElement, array, file); } }
Example #28
Source File: CommanderPanel.java From consulo with Apache License 2.0 | 5 votes |
private static Object getValueAtIndex(AbstractTreeNode node) { if (node == null) return null; Object value = node.getValue(); if (value instanceof StructureViewTreeElement) { return ((StructureViewTreeElement)value).getValue(); } return value; }
Example #29
Source File: AbstractListBuilder.java From consulo with Apache License 2.0 | 5 votes |
public final void selectElement(final Object element, VirtualFile virtualFile) { if (element == null) { return; } try { AbstractTreeNode node = goDownToElement(element, virtualFile); if (node == null) return; AbstractTreeNode parentElement = node.getParent(); if (parentElement == null) return; buildList(parentElement); for (int i = 0; i < myModel.getSize(); i++) { if (myModel.getElementAt(i) instanceof AbstractTreeNode) { final AbstractTreeNode desc = (AbstractTreeNode)myModel.getElementAt(i); if (desc.getValue() instanceof StructureViewTreeElement) { StructureViewTreeElement treeelement = (StructureViewTreeElement)desc.getValue(); if (element.equals(treeelement.getValue())) { selectItem(i); break; } } else { if (element.equals(desc.getValue())) { selectItem(i); break; } } } } } finally { updateParentTitle(); } }
Example #30
Source File: CustomRegionTreeElement.java From consulo with Apache License 2.0 | 5 votes |
public void addChild(@Nonnull StructureViewTreeElement childElement) { if (mySubRegions != null) { for (CustomRegionTreeElement subRegion : mySubRegions) { if (subRegion.containsElement(childElement)) { subRegion.addChild(childElement); return; } } } myChildElements.add(childElement); }