mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: cleanup
This commit is contained in:
+14
-15
@@ -2,11 +2,10 @@ package com.intellij.structuralsearch.impl.matcher.handlers;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
import com.intellij.structuralsearch.impl.matcher.predicates.RegExpPredicate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@@ -20,30 +19,30 @@ public class LiteralWithSubstitutionHandler extends MatchingHandler {
|
||||
private Matcher matcher;
|
||||
private final List<SubstitutionHandler> handlers;
|
||||
|
||||
public LiteralWithSubstitutionHandler(String _matchedExpression,List<SubstitutionHandler> _handlers) {
|
||||
public LiteralWithSubstitutionHandler(String _matchedExpression, List<SubstitutionHandler> _handlers) {
|
||||
matchExpression = _matchedExpression;
|
||||
handlers = _handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
|
||||
final String text = RegExpPredicate.getMeaningfulText(matchedNode);
|
||||
int offset = matchedNode.getText().indexOf(text);
|
||||
final String text = matchedNode.getText();
|
||||
if (matcher==null) {
|
||||
matcher = Pattern.compile(matchExpression).matcher(text);
|
||||
} else {
|
||||
matcher.reset(text);
|
||||
}
|
||||
|
||||
while (matcher.find()) {
|
||||
for (int i = 0; i < handlers.size(); ++i) {
|
||||
SubstitutionHandler handler = handlers.get(i);
|
||||
|
||||
if (!handler.handle(matchedNode,offset + matcher.start(i+1), offset + matcher.end(i+1),context)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (!matcher.find()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
for (int i = 0; i < handlers.size(); ++i) {
|
||||
final SubstitutionHandler handler = handlers.get(i);
|
||||
|
||||
if (!handler.handle(matchedNode, matcher.start(i + 1), matcher.end(i + 1), context)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user