mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 18:05:27 +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();
|
||||
|
||||
public RegExpMatch() {}
|
||||
|
||||
public RegExpMatch(int start, int end) {
|
||||
add(start, end);
|
||||
}
|
||||
|
||||
public void add(int start, int end) {
|
||||
groups.add(start);
|
||||
groups.add(end);
|
||||
|
||||
@@ -51,9 +51,11 @@ public class EcmaScriptRegExpMatcherProvider implements RegExpMatcherProvider {
|
||||
"var match;\n" +
|
||||
"\n" +
|
||||
"var RegExpMatch = Java.type(\"org.intellij.lang.regexp.RegExpMatch\");\n" +
|
||||
"var prev = null;\n" +
|
||||
"while ((match = regexp.exec(str)) !== null) {\n" +
|
||||
" var r = new RegExpMatch();\n" +
|
||||
" r.add(match.index, regexp.lastIndex);\n" +
|
||||
" var r = new RegExpMatch(match.index, regexp.lastIndex);\n" +
|
||||
" if (r.equals(prev)) break;\n" +
|
||||
" prev = r;\n" +
|
||||
" result.add(r);\n" +
|
||||
"}\n" +
|
||||
"result";
|
||||
@@ -61,7 +63,7 @@ public class EcmaScriptRegExpMatcherProvider implements RegExpMatcherProvider {
|
||||
bindings.put("result", new SmartList<>());
|
||||
@SuppressWarnings("unchecked") final List<RegExpMatch> result = (List<RegExpMatch>)engine.eval(script, bindings);
|
||||
CheckRegExpForm.setMatches(regExpFile, result);
|
||||
return RegExpMatchResult.FOUND;
|
||||
return result.isEmpty() ? RegExpMatchResult.NO_MATCH : RegExpMatchResult.FOUND;
|
||||
}
|
||||
catch (Exception e) {
|
||||
return RegExpMatchResult.BAD_REGEXP;
|
||||
|
||||
Reference in New Issue
Block a user