regex: escaped closing square bracket is redundant for Java Regex

bug introduced by fix for WEB-45812

GitOrigin-RevId: 18cb5cac57440ee66bd3fde6f980390d8f7f0f8e
This commit is contained in:
Bas Leijdekkers
2020-06-08 16:14:50 +02:00
committed by intellij-monorepo-bot
parent f5516ff118
commit 07a09bb005
4 changed files with 107 additions and 97 deletions

View File

@@ -208,22 +208,22 @@ class _RegExLexer implements FlexLexer {
"\1\43\1\44\1\2\1\45\1\46\1\24\1\47\1\50"+
"\1\51\1\52\1\53\1\54\1\26\1\55\1\56\1\57"+
"\1\60\3\57\1\26\1\57\1\26\1\57\1\61\1\62"+
"\3\0\1\63\1\64\1\65\1\66\1\67\1\66\1\70"+
"\1\71\1\72\1\73\1\12\1\73\1\74\2\75\1\76"+
"\1\77\1\12\1\100\1\101\1\102\1\103\1\104\1\105"+
"\1\106\1\12\1\107\1\110\1\111\1\112\1\113\1\114"+
"\1\115\1\116\1\117\1\120\1\121\1\122\1\12\1\123"+
"\1\124\1\0\1\125\2\26\1\126\2\61\1\127\1\130"+
"\1\0\1\131\1\132\1\133\1\134\1\135\1\0\1\136"+
"\1\137\1\140\1\141\2\0\1\142\6\0\1\143\1\144"+
"\1\145\1\146\2\147\1\101\1\150\1\151\1\152\1\153"+
"\1\154\1\155\1\156\1\157\1\160\1\161\1\162\1\163"+
"\1\0\1\164\1\165\1\166\1\0\1\167\1\0\1\170"+
"\4\0\1\143\2\147\1\101\1\171\1\153\1\172\1\173"+
"\1\174\1\143\1\0\1\175\1\153\1\0\1\176";
"\3\0\1\63\1\64\1\65\1\66\1\67\1\70\1\71"+
"\1\72\1\73\1\12\1\73\1\74\2\75\1\76\1\77"+
"\1\12\1\100\1\101\1\102\1\103\1\104\1\105\1\106"+
"\1\12\1\107\1\110\1\111\1\112\1\113\1\114\1\115"+
"\1\116\1\117\1\120\1\121\1\122\1\12\1\123\1\124"+
"\1\0\1\125\2\26\1\126\2\61\1\127\1\130\1\0"+
"\1\131\1\132\1\133\1\134\1\135\1\0\1\136\1\137"+
"\1\140\1\141\2\0\1\142\6\0\1\143\1\144\1\145"+
"\1\146\2\147\1\101\1\150\1\151\1\152\1\153\1\154"+
"\1\155\1\156\1\157\1\160\1\161\1\162\1\163\1\0"+
"\1\164\1\165\1\166\1\0\1\167\1\0\1\170\4\0"+
"\1\143\2\147\1\101\1\171\1\153\1\172\1\173\1\174"+
"\1\143\1\0\1\175\1\153\1\0\1\176";
private static int [] zzUnpackAction() {
int [] result = new int[204];
int [] result = new int[203];
int offset = 0;
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
return result;
@@ -260,23 +260,23 @@ class _RegExLexer implements FlexLexer {
"\0\u052b\0\u052b\0\u052b\0\u052b\0\u0999\0\u09d8\0\u0a17\0\u0a56"+
"\0\u0a95\0\u0ad4\0\u0b13\0\u0b52\0\u0b91\0\u0bd0\0\u0c0f\0\u0c4e"+
"\0\u052b\0\u052b\0\u052b\0\u0c8d\0\u052b\0\u052b\0\u052b\0\u052b"+
"\0\u052b\0\u0ccc\0\u0d0b\0\u052b\0\u052b\0\u0d4a\0\u052b\0\u052b"+
"\0\u052b\0\u052b\0\u0d89\0\u0dc8\0\u052b\0\u0e07\0\u0e46\0\u052b"+
"\0\u052b\0\u0e85\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b"+
"\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u0ec4\0\u052b"+
"\0\u052b\0\u0f03\0\u052b\0\u0f42\0\u052b\0\u052b\0\u052b\0\u0f81"+
"\0\u052b\0\u052b\0\u0fc0\0\u0fff\0\u052b\0\u052b\0\u052b\0\u052b"+
"\0\u103e\0\u052b\0\u052b\0\u052b\0\u052b\0\u107d\0\u10bc\0\u052b"+
"\0\u10fb\0\u113a\0\u1179\0\u11b8\0\u11f7\0\u1236\0\u1275\0\u052b"+
"\0\u052b\0\u052b\0\u12b4\0\u12f3\0\u1332\0\u052b\0\u1371\0\u052b"+
"\0\u13b0\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b"+
"\0\u052b\0\u13ef\0\u052b\0\u052b\0\u052b\0\u142e\0\u052b\0\u146d"+
"\0\u052b\0\u14ac\0\u14eb\0\u152a\0\u1569\0\u15a8\0\u15e7\0\u052b"+
"\0\u052b\0\u052b\0\u1626\0\u052b\0\u052b\0\u052b\0\u052b\0\u1665"+
"\0\u052b\0\u16a4\0\u16e3\0\u052b";
"\0\u0ccc\0\u0d0b\0\u052b\0\u052b\0\u0d4a\0\u052b\0\u052b\0\u052b"+
"\0\u052b\0\u0d89\0\u0dc8\0\u052b\0\u0e07\0\u0e46\0\u052b\0\u052b"+
"\0\u0e85\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b"+
"\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u0ec4\0\u052b\0\u052b"+
"\0\u0f03\0\u052b\0\u0f42\0\u052b\0\u052b\0\u052b\0\u0f81\0\u052b"+
"\0\u052b\0\u0fc0\0\u0fff\0\u052b\0\u052b\0\u052b\0\u052b\0\u103e"+
"\0\u052b\0\u052b\0\u052b\0\u052b\0\u107d\0\u10bc\0\u052b\0\u10fb"+
"\0\u113a\0\u1179\0\u11b8\0\u11f7\0\u1236\0\u1275\0\u052b\0\u052b"+
"\0\u052b\0\u12b4\0\u12f3\0\u1332\0\u052b\0\u1371\0\u052b\0\u13b0"+
"\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b"+
"\0\u13ef\0\u052b\0\u052b\0\u052b\0\u142e\0\u052b\0\u146d\0\u052b"+
"\0\u14ac\0\u14eb\0\u152a\0\u1569\0\u15a8\0\u15e7\0\u052b\0\u052b"+
"\0\u052b\0\u1626\0\u052b\0\u052b\0\u052b\0\u052b\0\u1665\0\u052b"+
"\0\u16a4\0\u16e3\0\u052b";
private static int [] zzUnpackRowMap() {
int [] result = new int[204];
int [] result = new int[203];
int offset = 0;
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
return result;
@@ -334,77 +334,77 @@ class _RegExLexer implements FlexLexer {
"\2\122\1\121\1\122\2\121\2\122\1\123\3\121\1\122"+
"\3\121\4\0\1\124\210\0\1\125\67\0\1\126\4\0"+
"\1\127\31\0\2\127\3\0\2\127\1\130\43\0\1\131"+
"\53\0\1\132\3\133\1\134\1\135\1\133\1\136\1\133"+
"\2\132\1\137\1\140\1\132\6\133\2\141\1\142\1\143"+
"\3\144\3\145\1\146\2\147\2\150\3\151\1\152\1\153"+
"\1\154\1\155\1\156\1\157\2\154\1\132\1\160\1\161"+
"\1\140\1\162\2\132\1\145\1\152\3\132\1\163\1\152"+
"\2\132\1\140\45\0\1\164\33\0\2\53\5\0\5\53"+
"\53\0\1\132\3\133\1\134\1\135\1\133\1\135\1\133"+
"\2\132\1\136\1\137\1\132\6\133\2\140\1\141\1\142"+
"\3\143\3\144\1\145\2\146\2\147\3\150\1\151\1\152"+
"\1\153\1\154\1\155\1\156\2\153\1\132\1\157\1\160"+
"\1\137\1\161\2\132\1\144\1\151\3\132\1\162\1\151"+
"\2\132\1\137\45\0\1\163\33\0\2\53\5\0\5\53"+
"\6\0\32\53\1\0\2\53\1\0\1\53\2\0\2\53"+
"\4\0\1\53\20\0\1\55\31\0\2\55\3\0\2\55"+
"\26\0\1\165\72\0\1\166\21\0\1\167\43\0\1\166"+
"\1\170\15\0\1\171\13\0\1\172\25\0\1\173\26\0"+
"\1\174\21\0\1\175\43\0\2\174\6\0\6\132\3\133"+
"\2\132\1\137\1\176\7\132\3\141\1\177\3\152\3\145"+
"\1\146\2\147\2\150\3\151\1\152\1\153\1\154\1\155"+
"\1\156\1\157\2\154\1\132\1\160\1\161\1\176\1\152"+
"\2\132\2\152\3\132\1\163\1\152\2\132\1\176\71\0"+
"\1\200\5\0\6\132\1\133\1\132\1\133\2\132\1\137"+
"\10\132\2\141\1\152\1\177\3\152\3\145\1\146\2\147"+
"\2\150\3\151\1\152\1\153\1\154\1\155\1\156\1\157"+
"\2\154\1\132\1\160\1\161\1\132\1\152\2\132\2\152"+
"\3\132\1\163\1\152\3\132\11\0\1\105\12\0\23\105"+
"\26\0\1\164\72\0\1\165\21\0\1\166\43\0\1\165"+
"\1\167\15\0\1\170\13\0\1\171\25\0\1\172\26\0"+
"\1\173\21\0\1\174\43\0\2\173\6\0\6\132\3\133"+
"\2\132\1\136\1\175\7\132\3\140\1\176\3\151\3\144"+
"\1\145\2\146\2\147\3\150\1\151\1\152\1\153\1\154"+
"\1\155\1\156\2\153\1\132\1\157\1\160\1\175\1\151"+
"\2\132\2\151\3\132\1\162\1\151\2\132\1\175\71\0"+
"\1\177\5\0\6\132\1\133\1\132\1\133\2\132\1\136"+
"\10\132\2\140\1\151\1\176\3\151\3\144\1\145\2\146"+
"\2\147\3\150\1\151\1\152\1\153\1\154\1\155\1\156"+
"\2\153\1\132\1\157\1\160\1\132\1\151\2\132\2\151"+
"\3\132\1\162\1\151\3\132\11\0\1\105\12\0\23\105"+
"\2\0\3\105\3\0\2\105\1\0\1\105\2\0\2\105"+
"\4\0\1\105\14\0\1\106\12\0\23\106\2\0\3\106"+
"\3\0\2\106\1\0\1\106\2\0\2\106\4\0\1\106"+
"\13\0\7\110\5\0\32\110\1\0\2\110\1\0\1\110"+
"\2\0\2\110\4\0\1\110\12\0\1\201\70\0\1\202"+
"\76\0\1\202\5\0\1\203\70\0\1\202\7\0\1\204"+
"\1\0\1\204\1\0\1\205\6\0\23\204\2\205\3\204"+
"\2\205\1\0\2\204\1\0\1\204\2\0\2\204\4\0"+
"\1\204\72\0\1\202\11\0\2\53\5\0\5\53\6\0"+
"\32\53\1\0\2\53\1\0\1\53\2\0\2\53\1\202"+
"\3\0\1\53\12\0\1\206\57\0\1\202\14\0\1\207"+
"\17\0\2\210\1\0\1\210\4\0\3\210\5\0\4\210"+
"\3\0\2\210\23\0\1\211\17\0\1\212\17\0\1\213"+
"\20\0\1\214\1\215\2\0\1\216\1\217\1\220\1\221"+
"\1\0\1\222\1\223\6\0\1\224\76\0\1\225\2\0"+
"\1\226\4\0\1\127\31\0\2\127\3\0\2\127\1\227"+
"\25\0\1\230\2\0\1\231\4\0\1\232\31\0\2\232"+
"\3\0\2\232\36\0\1\233\31\0\2\233\3\0\2\233"+
"\1\234\24\0\1\235\76\0\1\236\43\0\1\237\3\0"+
"\2\237\5\0\1\240\1\241\12\0\77\242\47\0\1\243"+
"\4\0\1\244\1\243\70\0\2\245\3\0\2\245\25\0"+
"\1\246\20\0\2\247\1\0\1\247\4\0\3\247\5\0"+
"\4\247\3\0\2\247\25\0\1\250\20\0\2\251\1\0"+
"\1\251\4\0\3\251\5\0\4\251\3\0\2\251\104\0"+
"\1\252\1\253\16\0\1\236\43\0\1\237\3\0\2\237"+
"\30\0\1\254\100\0\1\204\1\0\1\204\1\0\1\205"+
"\6\0\23\204\2\205\3\204\2\205\1\0\2\204\1\0"+
"\1\204\2\0\2\204\4\0\1\204\10\0\1\255\17\0"+
"\2\210\1\0\1\210\4\0\3\210\5\0\4\210\3\0"+
"\2\210\104\0\1\256\3\0\1\257\4\0\1\220\71\0"+
"\1\260\5\0\1\261\1\0\3\262\1\0\73\262\5\0"+
"\1\263\76\0\1\225\2\0\1\226\4\0\1\227\31\0"+
"\2\227\3\0\2\227\26\0\1\264\76\0\1\265\2\0"+
"\1\266\4\0\1\232\31\0\2\232\3\0\2\232\26\0"+
"\1\267\7\0\1\233\31\0\2\233\3\0\2\233\1\270"+
"\25\0\1\271\7\0\1\272\31\0\2\272\3\0\2\272"+
"\50\0\1\273\62\0\1\274\34\0\1\275\3\0\2\275"+
"\70\0\2\276\3\0\2\276\70\0\1\277\4\0\2\277"+
"\70\0\1\300\4\0\2\300\70\0\2\301\3\0\2\301"+
"\46\0\2\302\1\0\1\302\4\0\3\302\5\0\4\302"+
"\3\0\2\302\46\0\2\303\1\0\1\303\4\0\3\303"+
"\5\0\4\303\3\0\2\303\21\0\3\262\1\304\73\262"+
"\5\0\1\305\76\0\1\267\7\0\1\270\31\0\2\270"+
"\3\0\2\270\26\0\1\306\7\0\1\272\31\0\2\272"+
"\3\0\2\272\26\0\1\144\141\0\1\275\3\0\2\275"+
"\26\0\1\307\41\0\2\310\3\0\2\310\70\0\2\307"+
"\3\0\2\307\70\0\1\311\4\0\2\311\46\0\2\312"+
"\1\0\1\312\4\0\3\312\5\0\4\312\3\0\2\312"+
"\26\0\1\307\41\0\2\313\3\0\2\313\46\0\2\314"+
"\1\0\1\314\4\0\3\314\5\0\4\314\3\0\2\314"+
"\26\0\1\307\71\0";
"\2\0\2\110\4\0\1\110\12\0\1\200\70\0\1\201"+
"\76\0\1\201\5\0\1\202\70\0\1\201\7\0\1\203"+
"\1\0\1\203\1\0\1\204\6\0\23\203\2\204\3\203"+
"\2\204\1\0\2\203\1\0\1\203\2\0\2\203\4\0"+
"\1\203\72\0\1\201\11\0\2\53\5\0\5\53\6\0"+
"\32\53\1\0\2\53\1\0\1\53\2\0\2\53\1\201"+
"\3\0\1\53\12\0\1\205\57\0\1\201\14\0\1\206"+
"\17\0\2\207\1\0\1\207\4\0\3\207\5\0\4\207"+
"\3\0\2\207\23\0\1\210\17\0\1\211\17\0\1\212"+
"\20\0\1\213\1\214\2\0\1\215\1\216\1\217\1\220"+
"\1\0\1\221\1\222\6\0\1\223\76\0\1\224\2\0"+
"\1\225\4\0\1\127\31\0\2\127\3\0\2\127\1\226"+
"\25\0\1\227\2\0\1\230\4\0\1\231\31\0\2\231"+
"\3\0\2\231\36\0\1\232\31\0\2\232\3\0\2\232"+
"\1\233\24\0\1\234\76\0\1\235\43\0\1\236\3\0"+
"\2\236\5\0\1\237\1\240\12\0\77\241\47\0\1\242"+
"\4\0\1\243\1\242\70\0\2\244\3\0\2\244\25\0"+
"\1\245\20\0\2\246\1\0\1\246\4\0\3\246\5\0"+
"\4\246\3\0\2\246\25\0\1\247\20\0\2\250\1\0"+
"\1\250\4\0\3\250\5\0\4\250\3\0\2\250\104\0"+
"\1\251\1\252\16\0\1\235\43\0\1\236\3\0\2\236"+
"\30\0\1\253\100\0\1\203\1\0\1\203\1\0\1\204"+
"\6\0\23\203\2\204\3\203\2\204\1\0\2\203\1\0"+
"\1\203\2\0\2\203\4\0\1\203\10\0\1\254\17\0"+
"\2\207\1\0\1\207\4\0\3\207\5\0\4\207\3\0"+
"\2\207\104\0\1\255\3\0\1\256\4\0\1\217\71\0"+
"\1\257\5\0\1\260\1\0\3\261\1\0\73\261\5\0"+
"\1\262\76\0\1\224\2\0\1\225\4\0\1\226\31\0"+
"\2\226\3\0\2\226\26\0\1\263\76\0\1\264\2\0"+
"\1\265\4\0\1\231\31\0\2\231\3\0\2\231\26\0"+
"\1\266\7\0\1\232\31\0\2\232\3\0\2\232\1\267"+
"\25\0\1\270\7\0\1\271\31\0\2\271\3\0\2\271"+
"\50\0\1\272\62\0\1\273\34\0\1\274\3\0\2\274"+
"\70\0\2\275\3\0\2\275\70\0\1\276\4\0\2\276"+
"\70\0\1\277\4\0\2\277\70\0\2\300\3\0\2\300"+
"\46\0\2\301\1\0\1\301\4\0\3\301\5\0\4\301"+
"\3\0\2\301\46\0\2\302\1\0\1\302\4\0\3\302"+
"\5\0\4\302\3\0\2\302\21\0\3\261\1\303\73\261"+
"\5\0\1\304\76\0\1\266\7\0\1\267\31\0\2\267"+
"\3\0\2\267\26\0\1\305\7\0\1\271\31\0\2\271"+
"\3\0\2\271\26\0\1\143\141\0\1\274\3\0\2\274"+
"\26\0\1\306\41\0\2\307\3\0\2\307\70\0\2\306"+
"\3\0\2\306\70\0\1\310\4\0\2\310\46\0\2\311"+
"\1\0\1\311\4\0\3\311\5\0\4\311\3\0\2\311"+
"\26\0\1\306\41\0\2\312\3\0\2\312\46\0\2\313"+
"\1\0\1\313\4\0\3\313\5\0\4\313\3\0\2\313"+
"\26\0\1\306\71\0";
private static int [] zzUnpackTrans() {
int [] result = new int[5922];
@@ -450,7 +450,7 @@ class _RegExLexer implements FlexLexer {
"\1\1\1\11\1\0\2\11\1\1\1\11\1\1\1\11"+
"\1\1\1\11\1\1\1\11\1\1\3\11\1\1\2\11"+
"\1\1\3\11\2\1\1\11\1\1\4\11\11\1\3\0"+
"\3\11\1\1\5\11\2\1\2\11\1\1\4\11\2\1"+
"\3\11\1\1\4\11\2\1\2\11\1\1\4\11\2\1"+
"\1\11\2\1\2\11\1\1\14\11\1\1\2\11\1\0"+
"\1\11\1\1\3\11\1\1\2\11\1\0\1\1\4\11"+
"\1\0\4\11\2\0\1\11\6\0\1\1\3\11\3\1"+
@@ -459,7 +459,7 @@ class _RegExLexer implements FlexLexer {
"\1\0\1\11\1\1\1\0\1\11";
private static int [] zzUnpackAttribute() {
int [] result = new int[204];
int [] result = new int[203];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;

View File

@@ -253,7 +253,7 @@ BACK_REFERENCES_GROUP = [1-9][0-9]{0,2}
{ESCAPE} {LBRACE} { return (allowDanglingMetacharacters != TRUE) ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; }
{ESCAPE} {RBRACE} { return (allowDanglingMetacharacters == FALSE) ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; }
{ESCAPE} {RBRACKET} { return (allowDanglingMetacharacters != TRUE) ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; }
{ESCAPE} {RBRACKET} { return (allowDanglingMetacharacters == FALSE) ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; }
{ESCAPE} {META2} { return RegExpTT.ESC_CHARACTER; }
}
{ESCAPE} {META1} { return RegExpTT.ESC_CHARACTER; }

View File

@@ -226,6 +226,7 @@ public class RegExpParsingTest extends ParsingTestCase {
public void testEscapes27() throws IOException { doCodeTest("[^\\]]"); }
public void testEscapes28() throws IOException { doCodeTest("[a\\]]"); }
public void testEscapes29() throws IOException { doCodeTest("[^a\\]]"); }
public void testEscapes30() throws IOException { doCodeTest("\\[\\]$"); }
public void testAnchors1() throws IOException { doCodeTest("^*"); }
public void testAnchors2() throws IOException { doCodeTest("$*"); }

View File

@@ -0,0 +1,9 @@
REGEXP_FILE
RegExpPatternImpl: <\[\]$>
RegExpBranchImpl: <\[\]$>
RegExpCharImpl: <\[>
PsiElement(ESC_CHARACTER)('\[')
RegExpCharImpl: <\]>
PsiElement(REDUNDANT_ESCAPE)('\]')
RegExpBoundaryImpl: <$>
PsiElement(DOLLAR)('$')