mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: fix php searching
This commit is contained in:
+9
-5
@@ -1,10 +1,9 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.dupLocator.iterators;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Node iterator interface
|
||||
*/
|
||||
public abstract class NodeIterator implements Cloneable {
|
||||
public abstract boolean hasNext();
|
||||
public abstract PsiElement current();
|
||||
@@ -19,12 +18,17 @@ public abstract class NodeIterator implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public void rewindTo(@NotNull PsiElement element) {
|
||||
while (current() != element) {
|
||||
rewind();
|
||||
}
|
||||
}
|
||||
|
||||
public NodeIterator clone() {
|
||||
try {
|
||||
return (NodeIterator) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -46,6 +46,7 @@ public abstract class MatchingHandler {
|
||||
public boolean matchSequentially(NodeIterator patternNodes, NodeIterator matchNodes, MatchContext context) {
|
||||
final MatchingStrategy strategy = context.getPattern().getStrategy();
|
||||
final PsiElement currentPatternNode = patternNodes.current();
|
||||
final PsiElement currentMatchNode = matchNodes.current();
|
||||
|
||||
skipIfNecessary(matchNodes, currentPatternNode, strategy);
|
||||
skipComments(matchNodes, currentPatternNode);
|
||||
@@ -69,7 +70,12 @@ public abstract class MatchingHandler {
|
||||
|
||||
if (patternNodes.hasNext()) {
|
||||
final MatchingHandler nextHandler = context.getPattern().getHandler(patternNodes.current());
|
||||
return nextHandler.matchSequentially(patternNodes, matchNodes, context);
|
||||
if (nextHandler.matchSequentially(patternNodes, matchNodes, context)) {
|
||||
return true;
|
||||
} else {
|
||||
patternNodes.rewindTo(currentPatternNode);
|
||||
matchNodes.rewindTo(currentMatchNode);
|
||||
}
|
||||
} else {
|
||||
// match was found
|
||||
return handler.isMatchSequentiallySucceeded(matchNodes);
|
||||
|
||||
Reference in New Issue
Block a user