Search in sources :

Example 6 with ArrayBackedNodeIterator

use of com.intellij.dupLocator.iterators.ArrayBackedNodeIterator in project intellij-community by JetBrains.

the class XmlMatchingVisitor method visitXmlTag.

@Override
public void visitXmlTag(XmlTag tag) {
    final XmlTag another = (XmlTag) myMatchingVisitor.getElement();
    final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(tag.getName());
    myMatchingVisitor.setResult((matches(tag.getName(), another.getName()) || isTypedVar) && myMatchingVisitor.matchInAnyOrder(tag.getAttributes(), another.getAttributes()));
    if (myMatchingVisitor.getResult()) {
        final XmlTagChild[] contentChildren = tag.getValue().getChildren();
        if (contentChildren.length > 0) {
            PsiElement[] patternNodes = contentChildren;
            PsiElement[] matchedNodes = another.getValue().getChildren();
            if (contentChildren.length != 1) {
                patternNodes = filterOutWhitespace(patternNodes);
                matchedNodes = filterOutWhitespace(matchedNodes);
            }
            final boolean result = myMatchingVisitor.matchSequentially(new ArrayBackedNodeIterator(patternNodes), new ArrayBackedNodeIterator(matchedNodes));
            myMatchingVisitor.setResult(result);
        }
    }
    if (myMatchingVisitor.getResult() && isTypedVar) {
        final PsiElement[] children = another.getChildren();
        if (children.length > 1) {
            MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(tag.getName());
            myMatchingVisitor.setResult(((SubstitutionHandler) handler).handle(children[1], myMatchingVisitor.getMatchContext()));
        }
    }
}
Also used : MatchingHandler(com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler) ArrayBackedNodeIterator(com.intellij.dupLocator.iterators.ArrayBackedNodeIterator) PsiElement(com.intellij.psi.PsiElement)

Aggregations

ArrayBackedNodeIterator (com.intellij.dupLocator.iterators.ArrayBackedNodeIterator)6 Language (com.intellij.lang.Language)2 MatchingHandler (com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler)2 SsrFilteringNodeIterator (com.intellij.structuralsearch.impl.matcher.iterators.SsrFilteringNodeIterator)2 CountingNodeIterator (com.intellij.dupLocator.iterators.CountingNodeIterator)1 LanguageFileType (com.intellij.openapi.fileTypes.LanguageFileType)1 PsiElement (com.intellij.psi.PsiElement)1 LocalSearchScope (com.intellij.psi.search.LocalSearchScope)1 SubstitutionHandler (com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler)1 HierarchyNodeIterator (com.intellij.structuralsearch.impl.matcher.iterators.HierarchyNodeIterator)1 MatchingStrategy (com.intellij.structuralsearch.impl.matcher.strategies.MatchingStrategy)1 ArrayList (java.util.ArrayList)1