Search in sources :

Example 36 with PsiElementProcessor

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

the class XmlHighlightingTest method testXsiSchemaLocation3.

public void testXsiSchemaLocation3() throws Exception {
    configureByFile(getFullRelativeTestName(".xsd"), null);
    doDoTest(true, false);
    final List<XmlTag> tags = new ArrayList<>();
    XmlUtil.processXmlElements(((XmlFile) myFile).getDocument(), new PsiElementProcessor() {

        @Override
        public boolean execute(@NotNull final PsiElement element) {
            if (element instanceof XmlTag && ((XmlTag) element).getName().equals("xs:include")) {
                tags.add((XmlTag) element);
            }
            return true;
        }
    }, true);
    assertEquals("Should be three tags", 3, tags.size());
    String location = "xslt-1_0.xsd";
    checkOneTagForSchemaAttribute(tags.get(2), "schemaLocation", location);
}
Also used : PsiElementProcessor(com.intellij.psi.search.PsiElementProcessor)

Example 37 with PsiElementProcessor

use of com.intellij.psi.search.PsiElementProcessor in project intellij-plugins by JetBrains.

the class AngularJSMessageFormatExpression method getExtensionTypeElement.

public PsiElement getExtensionTypeElement() {
    final Ref<PsiElement> ref = new Ref<>();
    PsiTreeUtil.processElements(this, new PsiElementProcessor() {

        @Override
        public boolean execute(@NotNull PsiElement element) {
            final boolean isExpressionName = element.getNode().getElementType() == AngularJSElementTypes.MESSAGE_FORMAT_EXPRESSION_NAME;
            ref.set(element);
            return !isExpressionName;
        }
    });
    if (ref.isNull()) {
        LOG.error("AngularJS message format expression does not have name");
        return null;
    } else {
        return ref.get();
    }
}
Also used : Ref(com.intellij.openapi.util.Ref) PsiElement(com.intellij.psi.PsiElement) PsiElementProcessor(com.intellij.psi.search.PsiElementProcessor)

Aggregations

PsiElementProcessor (com.intellij.psi.search.PsiElementProcessor)37 PsiElement (com.intellij.psi.PsiElement)20 NotNull (org.jetbrains.annotations.NotNull)12 ArrayList (java.util.ArrayList)8 ASTNode (com.intellij.lang.ASTNode)4 PsiFile (com.intellij.psi.PsiFile)4 IncorrectOperationException (com.intellij.util.IncorrectOperationException)4 PsiClassListCellRenderer (com.intellij.ide.util.PsiClassListCellRenderer)3 FileType (com.intellij.openapi.fileTypes.FileType)3 TextRange (com.intellij.openapi.util.TextRange)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 PsiReference (com.intellij.psi.PsiReference)3 XmlFile (com.intellij.psi.xml.XmlFile)3 List (java.util.List)3 Nullable (org.jetbrains.annotations.Nullable)3 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)2 Project (com.intellij.openapi.project.Project)2 Ref (com.intellij.openapi.util.Ref)2 CompositePsiElement (com.intellij.psi.impl.source.tree.CompositePsiElement)2 CachedValueProvider (com.intellij.psi.util.CachedValueProvider)2