+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.structuralsearch.impl.matcher.handlers;
import com.intellij.dupLocator.iterators.ArrayBackedNodeIterator;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
-import com.intellij.structuralsearch.impl.matcher.GlobalMatchingVisitor;
import com.intellij.structuralsearch.impl.matcher.MatchContext;
import com.intellij.structuralsearch.impl.matcher.iterators.SsrFilteringNodeIterator;
import java.util.List;
/**
- * Created by IntelliJ IDEA.
- * User: maxim
+ * @author maxim
* Date: 31.12.2004
* Time: 12:01:29
- * To change this template use File | Settings | File Templates.
*/
public class DeclarationStatementHandler extends MatchingHandler {
private MatchingHandler myCommentHandler;
if (!super.match(patternNode,matchedNode,context)) return false;
final PsiDeclarationStatement dcl = (PsiDeclarationStatement)patternNode;
if (matchedNode instanceof PsiDeclarationStatement) {
- return GlobalMatchingVisitor.continueMatchingSequentially(
- new SsrFilteringNodeIterator(patternNode.getFirstChild()),
- new SsrFilteringNodeIterator(matchedNode.getFirstChild()),
- context
- );
+ return context.getMatcher().matchSequentially(new SsrFilteringNodeIterator(patternNode.getFirstChild()),
+ new SsrFilteringNodeIterator(matchedNode.getFirstChild()));
}
final PsiElement[] declared = dcl.getDeclaredElements();
// declaration statement could wrap class or dcl
if (declared.length > 0 && !(matchedNode.getParent() instanceof PsiDeclarationStatement) /* skip twice matching for child*/) {
if (!(matchedNode instanceof PsiField)) {
- return GlobalMatchingVisitor.continueMatchingSequentially(
+ return context.getMatcher().matchSequentially(
new ArrayBackedNodeIterator(declared),
- new CountingNodeIterator(declared.length, new SsrFilteringNodeIterator(matchedNode)),
- context
+ new CountingNodeIterator(declared.length, new SsrFilteringNodeIterator(matchedNode))
);
}
}
node = PsiTreeUtil.skipSiblingsForward(node, PsiWhiteSpace.class);
}
- boolean result = GlobalMatchingVisitor.continueMatchingSequentially(
+ boolean result = context.getMatcher().matchSequentially(
new ArrayBackedNodeIterator(declared),
- new ArrayBackedNodeIterator(matchNodes.toArray(new PsiElement[matchNodes.size()])),
- context
+ new ArrayBackedNodeIterator(matchNodes.toArray(new PsiElement[matchNodes.size()]))
);
if (result && declared[0] instanceof PsiVariable) {
@Override
public boolean shouldAdvanceTheMatchFor(PsiElement patternElement, PsiElement matchedElement) {
- if (patternElement instanceof PsiComment &&
- ( matchedElement instanceof PsiField ||
- matchedElement instanceof PsiClass
- )
- ) {
+ if (patternElement instanceof PsiComment && (matchedElement instanceof PsiField || matchedElement instanceof PsiClass)) {
return false;
}
* @param el2 the tree element for matching
* @return true if equal and false otherwise
*/
+ @Override
public boolean match(final PsiElement el1, final PsiElement el2) {
if (el1 == el2) return true;
if (el1 == null) {
* @param nodes2 the tree element for matching
* @return if they are equal and false otherwise
*/
+ @Override
public boolean matchSequentially(NodeIterator nodes, NodeIterator nodes2) {
if (!nodes.hasNext()) {
return !nodes2.hasNext();
}
- return matchContext.getPattern().getHandler(nodes.current()).matchSequentially(
- nodes,
- nodes2,
- matchContext
- );
- }
-
- public static boolean continueMatchingSequentially(final NodeIterator nodes, final NodeIterator nodes2, MatchContext matchContext) {
- if (!nodes.hasNext()) {
- return !nodes2.hasNext();
- }
-
- return matchContext.getPattern().getHandler(nodes.current()).matchSequentially(
- nodes,
- nodes2,
- matchContext
- );
+ return matchContext.getPattern().getHandler(nodes.current()).matchSequentially(nodes, nodes2, matchContext);
}
/**