Search in sources :

Example 6 with PsiRecursiveElementWalkingVisitor

use of com.intellij.psi.PsiRecursiveElementWalkingVisitor in project intellij-community by JetBrains.

the class PlatformTestUtil method collectWebReferences.

@NotNull
public static List<WebReference> collectWebReferences(@NotNull PsiElement element) {
    List<WebReference> refs = new ArrayList<>();
    element.accept(new PsiRecursiveElementWalkingVisitor() {

        @Override
        public void visitElement(PsiElement element) {
            for (PsiReference ref : element.getReferences()) {
                if (ref instanceof WebReference) {
                    refs.add((WebReference) ref);
                }
            }
            super.visitElement(element);
        }
    });
    return refs;
}
Also used : WebReference(com.intellij.openapi.paths.WebReference) PsiRecursiveElementWalkingVisitor(com.intellij.psi.PsiRecursiveElementWalkingVisitor) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) PsiReference(com.intellij.psi.PsiReference) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)6 PsiRecursiveElementWalkingVisitor (com.intellij.psi.PsiRecursiveElementWalkingVisitor)6 NotNull (org.jetbrains.annotations.NotNull)3 TextRange (com.intellij.openapi.util.TextRange)2 ASTNode (com.intellij.lang.ASTNode)1 WebReference (com.intellij.openapi.paths.WebReference)1 PsiReference (com.intellij.psi.PsiReference)1 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)1 THashMap (gnu.trove.THashMap)1 HashMap (java.util.HashMap)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 ConvertKeywordPairToTypeOperation (org.elixir_lang.local_quick_fix.ConvertKeywordPairToTypeOperation)1 ConvertMatchToTypeOperation (org.elixir_lang.local_quick_fix.ConvertMatchToTypeOperation)1 NoParentheses (org.elixir_lang.psi.call.arguments.star.NoParentheses)1 Infix (org.elixir_lang.psi.operation.Infix)1 Match (org.elixir_lang.psi.operation.Match)1 NamedArgumentDescriptor (org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor)1 GrArgumentLabel (org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel)1