mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
Fix JS regexp tester (WEB-48205)
GitOrigin-RevId: f90744bfdaad84bc8a0dada4cc77a5ad0183bd03
This commit is contained in:
committed by
intellij-monorepo-bot
parent
81009f77ac
commit
035788aeaa
@@ -11,6 +11,12 @@ public class RegExpMatch {
|
|||||||
|
|
||||||
private final IntList groups = new IntArrayList();
|
private final IntList groups = new IntArrayList();
|
||||||
|
|
||||||
|
public RegExpMatch() {}
|
||||||
|
|
||||||
|
public RegExpMatch(int start, int end) {
|
||||||
|
add(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
public void add(int start, int end) {
|
public void add(int start, int end) {
|
||||||
groups.add(start);
|
groups.add(start);
|
||||||
groups.add(end);
|
groups.add(end);
|
||||||
|
|||||||
@@ -51,9 +51,11 @@ public class EcmaScriptRegExpMatcherProvider implements RegExpMatcherProvider {
|
|||||||
"var match;\n" +
|
"var match;\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"var RegExpMatch = Java.type(\"org.intellij.lang.regexp.RegExpMatch\");\n" +
|
"var RegExpMatch = Java.type(\"org.intellij.lang.regexp.RegExpMatch\");\n" +
|
||||||
|
"var prev = null;\n" +
|
||||||
"while ((match = regexp.exec(str)) !== null) {\n" +
|
"while ((match = regexp.exec(str)) !== null) {\n" +
|
||||||
" var r = new RegExpMatch();\n" +
|
" var r = new RegExpMatch(match.index, regexp.lastIndex);\n" +
|
||||||
" r.add(match.index, regexp.lastIndex);\n" +
|
" if (r.equals(prev)) break;\n" +
|
||||||
|
" prev = r;\n" +
|
||||||
" result.add(r);\n" +
|
" result.add(r);\n" +
|
||||||
"}\n" +
|
"}\n" +
|
||||||
"result";
|
"result";
|
||||||
@@ -61,7 +63,7 @@ public class EcmaScriptRegExpMatcherProvider implements RegExpMatcherProvider {
|
|||||||
bindings.put("result", new SmartList<>());
|
bindings.put("result", new SmartList<>());
|
||||||
@SuppressWarnings("unchecked") final List<RegExpMatch> result = (List<RegExpMatch>)engine.eval(script, bindings);
|
@SuppressWarnings("unchecked") final List<RegExpMatch> result = (List<RegExpMatch>)engine.eval(script, bindings);
|
||||||
CheckRegExpForm.setMatches(regExpFile, result);
|
CheckRegExpForm.setMatches(regExpFile, result);
|
||||||
return RegExpMatchResult.FOUND;
|
return result.isEmpty() ? RegExpMatchResult.NO_MATCH : RegExpMatchResult.FOUND;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
return RegExpMatchResult.BAD_REGEXP;
|
return RegExpMatchResult.BAD_REGEXP;
|
||||||
|
|||||||
Reference in New Issue
Block a user