Java Code Examples for com.intellij.psi.PsiElement#acceptChildren()
The following examples show how to use
com.intellij.psi.PsiElement#acceptChildren() .
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: HaxeRefactoringUtil.java From intellij-haxe with Apache License 2.0 | 6 votes |
@NotNull public static List<PsiElement> getOccurrences(@NotNull final PsiElement pattern, @Nullable final PsiElement context) { if (context == null) { return Collections.emptyList(); } final List<PsiElement> occurrences = new ArrayList<PsiElement>(); final HaxeVisitor visitor = new HaxeVisitor() { public void visitElement(@NotNull final PsiElement element) { if (element instanceof HaxeParameter) { return; } if (PsiEquivalenceUtil.areElementsEquivalent(element, pattern)) { occurrences.add(element); return; } element.acceptChildren(this); } }; context.acceptChildren(visitor); return occurrences; }
Example 2
Source File: CSharpRefactoringUtil.java From consulo-csharp with Apache License 2.0 | 6 votes |
@Nonnull public static List<PsiElement> getOccurrences(@Nonnull final PsiElement pattern, @Nullable final PsiElement context) { if(context == null) { return Collections.emptyList(); } final List<PsiElement> occurrences = new ArrayList<>(); context.acceptChildren(new CSharpRecursiveElementVisitor() { @Override public void visitReferenceExpression(CSharpReferenceExpression expression) { if(expression.resolve() == pattern) { occurrences.add(expression); } } }); return occurrences; }
Example 3
Source File: StructureViewElement.java From reasonml-idea-plugin with MIT License | 6 votes |
@NotNull private List<TreeElement> buildModuleStructure(@NotNull PsiInnerModule moduleElement) { List<TreeElement> treeElements = new ArrayList<>(); PsiSignature moduleSignature = moduleElement.getSignature(); PsiElement rootElement = moduleSignature; if (rootElement == null) { rootElement = moduleElement.getBody(); } if (rootElement != null) { rootElement.acceptChildren(new ElementVisitor(treeElements)); } // Process body if there is a signature if (moduleSignature != null) { rootElement = moduleElement.getBody(); if (rootElement != null) { treeElements.add(new StructureModuleImplView(rootElement)); } } return treeElements; }
Example 4
Source File: StatementCollector.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 6 votes |
@Override public void visitElement(PsiElement element) { if (hasErrors) { return; } if (element.getNode().getElementType() == CypherTypes.STATEMENT_ITEM) { queries.add(element.getText()); try { parameters.putAll(parameterService.getParameters(element)); } catch (Exception e) { fail(); sendParametersRetrievalErrorEvent(e); } } element.acceptChildren(this); }
Example 5
Source File: LaravelLightCodeInsightFixtureTestCase.java From idea-php-laravel-plugin with MIT License | 5 votes |
@NotNull private List<PsiElement> collectPsiElementsRecursive(@NotNull PsiElement psiElement) { final List<PsiElement> elements = new ArrayList<PsiElement>(); elements.add(psiElement.getContainingFile()); psiElement.acceptChildren(new PsiRecursiveElementVisitor() { @Override public void visitElement(PsiElement element) { elements.add(element); super.visitElement(element); } }); return elements; }
Example 6
Source File: ControlFlowBuilder.java From consulo with Apache License 2.0 | 5 votes |
public ControlFlow build(final PsiElementVisitor visitor, final PsiElement element) { // create start pseudo node startNode(null); element.acceptChildren(visitor); // create end pseudo node and close all pending edges checkPending(startNode(null)); final List<Instruction> result = instructions; return new ControlFlowImpl(result.toArray(new Instruction[result.size()])); }
Example 7
Source File: LatteUtil.java From intellij-latte with MIT License | 5 votes |
private static void findLattePhpVariables(List<PsiPositionedElement> properties, PsiElement psiElement) { psiElement.acceptChildren(new PsiRecursiveElementWalkingVisitor() { @Override public void visitElement(PsiElement element) { if (element instanceof LattePhpVariable) { properties.add(new PsiPositionedElement(getStartOffsetInFile(element), element)); } else { super.visitElement(element); } } }); }
Example 8
Source File: StructureViewElement.java From reasonml-idea-plugin with MIT License | 5 votes |
@NotNull private List<TreeElement> buildYaccTrailerStructure(@NotNull OclYaccTrailer root) { List<TreeElement> treeElements = new ArrayList<>(); PsiElement rootElement = ORUtil.findImmediateFirstChildOfType(root, OclYaccTypes.OCAML_LAZY_NODE); if (rootElement != null) { rootElement.acceptChildren(new ElementVisitor(treeElements)); } return treeElements; }
Example 9
Source File: StructureViewElement.java From reasonml-idea-plugin with MIT License | 5 votes |
@NotNull private List<TreeElement> buildYaccHeaderStructure(@NotNull OclYaccHeader root) { List<TreeElement> treeElements = new ArrayList<>(); PsiElement rootElement = ORUtil.findImmediateFirstChildOfType(root, OclYaccTypes.OCAML_LAZY_NODE); if (rootElement != null) { rootElement.acceptChildren(new ElementVisitor(treeElements)); } return treeElements; }
Example 10
Source File: StructureViewElement.java From reasonml-idea-plugin with MIT License | 5 votes |
@NotNull private List<TreeElement> buildStanzaStructure(@NotNull PsiStanza stanzaElement) { List<TreeElement> treeElements = new ArrayList<>(); PsiElement rootElement = ORUtil.findImmediateFirstChildOfClass(stanzaElement, PsiDuneFields.class); if (rootElement != null) { rootElement.acceptChildren(new ElementVisitor(treeElements)); } return treeElements; }
Example 11
Source File: StructureViewElement.java From reasonml-idea-plugin with MIT License | 5 votes |
@NotNull private List<TreeElement> buildClassStructure(@NotNull PsiClass classElement) { List<TreeElement> treeElements = new ArrayList<>(); PsiElement rootElement = classElement.getClassBody(); if (rootElement != null) { rootElement.acceptChildren(new ElementVisitor(treeElements)); } return treeElements; }
Example 12
Source File: StructureViewElement.java From reasonml-idea-plugin with MIT License | 5 votes |
@NotNull private List<TreeElement> buildFunctorStructure(@NotNull PsiFunctor functor) { List<TreeElement> treeElements = new ArrayList<>(); PsiElement binding = functor.getBinding(); if (binding != null) { binding.acceptChildren(new ElementVisitor(treeElements)); } return treeElements; }
Example 13
Source File: SoyRecursiveElementVisitor.java From bamboo-soy with Apache License 2.0 | 4 votes |
public void visitElement(final PsiElement element) { element.acceptChildren(this); }
Example 14
Source File: RTRecursiveVisitor.java From react-templates-plugin with MIT License | 4 votes |
@Override public void visitElement(PsiElement element) { element.acceptChildren(this); }
Example 15
Source File: RTRecursiveVisitor.java From react-templates-plugin with MIT License | 4 votes |
@Override public void visitElement(PsiElement element) { element.acceptChildren(this); }
Example 16
Source File: TwigBlockIndexExtension.java From idea-php-symfony2-plugin with MIT License | 4 votes |
@NotNull @Override public DataIndexer<String, Set<String>, FileContent> getIndexer() { return fileContent -> { Map<String, Set<String>> blocks = new HashMap<>(); PsiFile psiFile = fileContent.getPsiFile(); if(psiFile instanceof TwigFile) { for (TwigBlock twigBlock : TwigUtil.getBlocksInFile((TwigFile) psiFile)) { // we only index file scope // {% embed 'foo.html.twig' %}{% block foo %}{% endembed %} PsiElement embedStatement = PsiElementUtils.getParentOfType(twigBlock.getTarget(), TwigElementTypes.EMBED_STATEMENT); if(embedStatement == null) { blocks.putIfAbsent("block", new HashSet<>()); blocks.get("block").add(twigBlock.getName()); } } for(PsiElement psiElement : PsiTreeUtil.getChildrenOfAnyType(psiFile, TwigExtendsTag.class, TwigCompositeElement.class)) { if(psiElement instanceof TwigCompositeElement) { // {% use 'foo.html.twig' %} if(psiElement.getNode().getElementType() == TwigElementTypes.TAG) { psiElement.acceptChildren(new PsiRecursiveElementWalkingVisitor() { @Override public void visitElement(PsiElement element) { if(TwigPattern.getTwigTagUseNamePattern().accepts(element) && PsiElementUtils.getParentOfType(element, TwigElementTypes.EMBED_STATEMENT) == null) { String templateName = TwigUtil.normalizeTemplateName(PsiElementUtils.trimQuote(element.getText())); if(StringUtils.isNotBlank(templateName)) { blocks.putIfAbsent("use", new HashSet<>()); blocks.get("use").add(templateName); } } super.visitElement(element); } }); } } } } return blocks; }; }
Example 17
Source File: DocCommentProcessor.java From markdown-doclet with GNU General Public License v3.0 | 4 votes |
@Override public void visitElement(PsiElement element) { if ( element instanceof PsiDocTag ) { PsiDocTag tag = (PsiDocTag)element; String tagName = null; switch ( tag.getName() ) { case "link": case "linkplain": case "see": // todo: @ssee tagName = tag.getName(); } if ( tagName != null ) { int inlineOffset = (tag instanceof PsiInlineDocTag) ? 1 : 0; String linkText = tag.getText().substring(inlineOffset + 1 + tagName.length(), tag.getTextLength() - inlineOffset).trim(); if ( !linkText.startsWith("#") ) { return; } StringBuilder newLink = new StringBuilder(100); if ( inlineOffset > 0 ) { newLink.append('{'); } newLink.append('@').append(tagName).append(' '); int refEndIndex = JavaDocUtil.extractReference(linkText); String refText = linkText.substring(0, refEndIndex); PsiElement target = JavaDocUtil.findReferenceTarget(docContext.getManager(), refText, docContext, true); if ( target == null ) { return; } newLink.append(JavaDocUtil.getReferenceText(project, target)).append(' '); String labelText = linkText.substring(refEndIndex).trim(); if ( labelText.isEmpty() ) { labelText = JavaDocUtil.getLabelText(project, docContext.getManager(), refText, docContext); } newLink.append(labelText); if ( inlineOffset > 0 ) { newLink.append('}'); } int start = getStartOffsetInComment(element); if ( buffer == null ) { buffer = new StringBuilder(docText.length() + 100); } buffer.append(docText, docTextPosition, start); buffer.append(newLink); docTextPosition += start - docTextPosition + element.getTextLength(); } } element.acceptChildren(this); }
Example 18
Source File: CSharpMacroRecursiveElementVisitor.java From consulo-csharp with Apache License 2.0 | 4 votes |
@Override public void visitElement(PsiElement element) { element.acceptChildren(this); }
Example 19
Source File: HaxeRecursiveVisitor.java From intellij-haxe with Apache License 2.0 | 4 votes |
@Override public void visitElement(PsiElement element) { super.visitElement(element); element.acceptChildren(this); }
Example 20
Source File: HaxeAnnotatingVisitor.java From intellij-haxe with Apache License 2.0 | 4 votes |
@Override public void visitElement(PsiElement element) { ProgressIndicatorProvider.checkCanceled(); element.acceptChildren(this); }