Search in sources :

Example 6 with NodeIterator

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

the class MatcherImpl method checkIfShouldAttemptToMatch.

public static boolean checkIfShouldAttemptToMatch(MatchContext context, NodeIterator matchedNodes) {
    final CompiledPattern pattern = context.getPattern();
    final NodeIterator patternNodes = pattern.getNodes();
    try {
        while (true) {
            final PsiElement patternNode = patternNodes.current();
            if (patternNode == null) {
                return true;
            }
            final PsiElement matchedNode = matchedNodes.current();
            if (matchedNode == null) {
                return false;
            }
            final MatchingHandler matchingHandler = pattern.getHandler(patternNode);
            if (matchingHandler == null || !matchingHandler.canMatch(patternNode, matchedNode, context)) {
                return false;
            }
            matchedNodes.advance();
            patternNodes.advance();
        }
    } finally {
        patternNodes.reset();
        matchedNodes.reset();
    }
}
Also used : ArrayBackedNodeIterator(com.intellij.dupLocator.iterators.ArrayBackedNodeIterator) NodeIterator(com.intellij.dupLocator.iterators.NodeIterator) SsrFilteringNodeIterator(com.intellij.structuralsearch.impl.matcher.iterators.SsrFilteringNodeIterator) TopLevelMatchingHandler(com.intellij.structuralsearch.impl.matcher.handlers.TopLevelMatchingHandler) MatchingHandler(com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler)

Aggregations

NodeIterator (com.intellij.dupLocator.iterators.NodeIterator)6 ArrayBackedNodeIterator (com.intellij.dupLocator.iterators.ArrayBackedNodeIterator)2 MatchingHandler (com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler)2 SsrFilteringNodeIterator (com.intellij.structuralsearch.impl.matcher.iterators.SsrFilteringNodeIterator)2 FilteringNodeIterator (com.intellij.dupLocator.iterators.FilteringNodeIterator)1 PsiElement (com.intellij.psi.PsiElement)1 CompiledPattern (com.intellij.structuralsearch.impl.matcher.CompiledPattern)1 TopLevelMatchingHandler (com.intellij.structuralsearch.impl.matcher.handlers.TopLevelMatchingHandler)1 DocValuesIterator (com.intellij.structuralsearch.impl.matcher.iterators.DocValuesIterator)1 HierarchyNodeIterator (com.intellij.structuralsearch.impl.matcher.iterators.HierarchyNodeIterator)1 NotPredicate (com.intellij.structuralsearch.impl.matcher.predicates.NotPredicate)1