diff --git a/RegExpSupport/gen/org/intellij/lang/regexp/_RegExLexer.java b/RegExpSupport/gen/org/intellij/lang/regexp/_RegExLexer.java index 9040c9d8e677..31b696880e0e 100644 --- a/RegExpSupport/gen/org/intellij/lang/regexp/_RegExLexer.java +++ b/RegExpSupport/gen/org/intellij/lang/regexp/_RegExLexer.java @@ -29,19 +29,20 @@ class _RegExLexer implements FlexLexer { public static final int YYINITIAL = 0; public static final int QUOTED = 2; public static final int EMBRACED = 4; - public static final int CLASS1 = 6; - public static final int NEGATE_CLASS1 = 8; - public static final int CLASS2 = 10; - public static final int NEGATE_CLASS2 = 12; - public static final int PROP = 14; - public static final int NAMED = 16; - public static final int OPTIONS = 18; - public static final int COMMENT = 20; - public static final int NAMED_GROUP = 22; - public static final int QUOTED_NAMED_GROUP = 24; - public static final int PY_NAMED_GROUP_REF = 26; - public static final int PY_COND_REF = 28; - public static final int BRACKET_EXPRESSION = 30; + public static final int QUANTIFIER = 6; + public static final int CLASS1 = 8; + public static final int NEGATE_CLASS1 = 10; + public static final int CLASS2 = 12; + public static final int NEGATE_CLASS2 = 14; + public static final int PROP = 16; + public static final int NAMED = 18; + public static final int OPTIONS = 20; + public static final int COMMENT = 22; + public static final int NAMED_GROUP = 24; + public static final int QUOTED_NAMED_GROUP = 26; + public static final int PY_NAMED_GROUP_REF = 28; + public static final int PY_COND_REF = 30; + public static final int BRACKET_EXPRESSION = 32; /** * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l @@ -51,7 +52,8 @@ class _RegExLexer implements FlexLexer { */ private static final int ZZ_LEXSTATE[] = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, - 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15 + 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, + 16, 16 }; /** @@ -186,24 +188,25 @@ class _RegExLexer implements FlexLexer { private static final int [] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = - "\12\0\1\1\5\0\1\2\1\3\1\4\1\5\1\6"+ + "\13\0\1\1\5\0\1\2\1\3\1\4\1\5\1\6"+ "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\1\16"+ "\1\17\1\20\1\21\1\22\1\2\1\23\1\24\1\25"+ "\1\26\1\27\1\30\1\31\1\30\1\32\1\33\1\34"+ "\1\10\1\35\1\2\1\36\1\37\1\23\1\40\1\41"+ - "\1\42\1\43\1\44\1\45\1\1\1\26\1\46\1\47"+ - "\2\50\1\51\1\52\1\0\1\53\1\54\1\55\1\56"+ - "\1\57\1\60\1\10\1\61\1\62\1\63\1\64\1\10"+ - "\1\64\1\65\2\66\1\67\1\70\1\71\1\72\1\73"+ - "\1\74\1\75\1\10\1\76\1\77\1\100\1\0\1\101"+ - "\1\102\1\103\1\104\1\0\1\105\1\106\1\107\1\110"+ - "\1\111\1\0\1\112\1\0\1\113\1\0\1\114\1\115"+ - "\1\116\2\72\1\117\1\120\1\121\1\122\1\123\1\124"+ - "\1\125\1\126\1\0\1\113\1\0\1\127\2\72\1\117"+ - "\1\130\1\113\1\72\1\117\1\72\1\131\4\72"; + "\1\42\1\43\1\44\1\45\1\1\1\25\1\46\1\47"+ + "\2\50\1\51\1\0\1\52\1\0\1\53\1\54\1\55"+ + "\1\56\1\57\1\60\1\10\1\61\1\62\1\63\1\64"+ + "\1\10\1\64\1\65\2\66\1\67\1\70\1\71\1\72"+ + "\1\73\1\74\1\75\1\10\1\76\1\77\1\100\1\0"+ + "\1\101\1\102\1\103\1\104\1\0\1\105\1\106\1\107"+ + "\1\110\1\111\1\0\1\112\1\0\1\113\1\0\1\114"+ + "\1\0\1\115\1\116\1\117\2\72\1\120\1\121\1\122"+ + "\1\123\1\124\1\125\1\126\1\127\2\0\1\114\1\0"+ + "\1\130\2\72\1\120\1\131\1\114\1\72\1\120\1\72"+ + "\1\132\4\72"; private static int [] zzUnpackAction() { - int [] result = new int[139]; + int [] result = new int[144]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -230,25 +233,25 @@ class _RegExLexer implements FlexLexer { private static final String ZZ_ROWMAP_PACKED_0 = "\0\0\0\76\0\174\0\272\0\370\0\u0136\0\u0174\0\u01b2"+ "\0\u01f0\0\u022e\0\u026c\0\u02aa\0\u02e8\0\u0326\0\u0364\0\u03a2"+ - "\0\u03e0\0\u03e0\0\u041e\0\u03e0\0\u03e0\0\u045c\0\u049a\0\u03e0"+ - "\0\u03e0\0\u03e0\0\u03e0\0\u03e0\0\u03e0\0\u03e0\0\u03e0\0\u03e0"+ - "\0\u03e0\0\u04d8\0\u03e0\0\u0516\0\u03e0\0\u0554\0\u03e0\0\u03e0"+ - "\0\u03e0\0\u0592\0\u03e0\0\u05d0\0\u03e0\0\u060e\0\u03e0\0\u064c"+ - "\0\u03e0\0\u03e0\0\u045c\0\u03e0\0\u03e0\0\u03e0\0\u068a\0\u06c8"+ - "\0\u03e0\0\u03e0\0\u0706\0\u03e0\0\u03e0\0\u03e0\0\u0744\0\u0782"+ - "\0\u03e0\0\u07c0\0\u07fe\0\u03e0\0\u083c\0\u087a\0\u03e0\0\u03e0"+ - "\0\u03e0\0\u03e0\0\u03e0\0\u03e0\0\u08b8\0\u08f6\0\u03e0\0\u03e0"+ - "\0\u0934\0\u03e0\0\u03e0\0\u03e0\0\u03e0\0\u0972\0\u09b0\0\u03e0"+ - "\0\u03e0\0\u09ee\0\u03e0\0\u03e0\0\u03e0\0\u0a2c\0\u03e0\0\u03e0"+ - "\0\u03e0\0\u03e0\0\u0a6a\0\u0aa8\0\u03e0\0\u03e0\0\u03e0\0\u03e0"+ - "\0\u0ae6\0\u03e0\0\u0b24\0\u0b62\0\u0ba0\0\u03e0\0\u03e0\0\u03e0"+ - "\0\u0bde\0\u0c1c\0\u0c5a\0\u03e0\0\u03e0\0\u03e0\0\u03e0\0\u03e0"+ - "\0\u03e0\0\u03e0\0\u0c98\0\u0cd6\0\u0d14\0\u03e0\0\u0d52\0\u03e0"+ - "\0\u0d90\0\u03e0\0\u03e0\0\u0dce\0\u0e0c\0\u0e4a\0\u03e0\0\u0e88"+ - "\0\u0ec6\0\u0f04\0\u0f42"; + "\0\u03e0\0\u041e\0\u041e\0\u045c\0\u041e\0\u049a\0\u04d8\0\u0516"+ + "\0\u041e\0\u041e\0\u041e\0\u041e\0\u041e\0\u041e\0\u041e\0\u041e"+ + "\0\u041e\0\u041e\0\u0554\0\u041e\0\u041e\0\u0592\0\u05d0\0\u041e"+ + "\0\u041e\0\u041e\0\u060e\0\u041e\0\u064c\0\u041e\0\u068a\0\u041e"+ + "\0\u06c8\0\u041e\0\u049a\0\u04d8\0\u041e\0\u041e\0\u041e\0\u0706"+ + "\0\u0744\0\u041e\0\u041e\0\u0782\0\u041e\0\u041e\0\u041e\0\u07c0"+ + "\0\u07fe\0\u083c\0\u041e\0\u087a\0\u08b8\0\u041e\0\u08f6\0\u0934"+ + "\0\u041e\0\u041e\0\u041e\0\u041e\0\u041e\0\u041e\0\u0972\0\u09b0"+ + "\0\u041e\0\u041e\0\u09ee\0\u041e\0\u041e\0\u041e\0\u041e\0\u0a2c"+ + "\0\u0a6a\0\u041e\0\u041e\0\u0aa8\0\u041e\0\u041e\0\u041e\0\u0ae6"+ + "\0\u041e\0\u041e\0\u041e\0\u041e\0\u0b24\0\u0b62\0\u041e\0\u041e"+ + "\0\u041e\0\u041e\0\u0ba0\0\u041e\0\u0bde\0\u041e\0\u0c1c\0\u0c5a"+ + "\0\u0c98\0\u041e\0\u041e\0\u041e\0\u0cd6\0\u0d14\0\u0d52\0\u041e"+ + "\0\u041e\0\u041e\0\u041e\0\u041e\0\u041e\0\u041e\0\u0d90\0\u0dce"+ + "\0\u0e0c\0\u0e4a\0\u041e\0\u0e88\0\u041e\0\u0ec6\0\u041e\0\u041e"+ + "\0\u0f04\0\u0f42\0\u0f80\0\u041e\0\u0fbe\0\u0ffc\0\u103a\0\u1078"; private static int [] zzUnpackRowMap() { - int [] result = new int[139]; + int [] result = new int[144]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -271,83 +274,88 @@ class _RegExLexer implements FlexLexer { private static final int [] ZZ_TRANS = zzUnpackTrans(); private static final String ZZ_TRANS_PACKED_0 = - "\3\21\1\22\1\23\1\24\1\25\1\21\1\26\1\21"+ - "\1\27\2\21\1\30\1\31\1\21\1\32\1\33\1\34"+ - "\1\35\1\36\1\37\34\21\1\40\2\21\1\40\1\21"+ - "\1\40\5\21\1\41\12\21\1\42\63\21\1\43\2\44"+ - "\4\43\1\45\3\43\1\46\3\43\1\44\1\32\5\43"+ - "\26\46\1\44\3\46\3\43\1\46\1\47\11\43\11\50"+ - "\1\51\1\52\52\50\3\0\26\50\1\53\44\50\3\0"+ - "\6\50\6\21\1\25\1\21\1\54\1\55\1\56\2\21"+ - "\1\30\44\21\1\57\2\21\1\57\1\21\1\57\1\21"+ - "\1\60\4\21\6\50\1\25\1\50\1\26\1\50\1\27"+ - "\2\50\1\30\2\50\1\61\44\50\1\40\1\21\1\40"+ - "\6\50\6\43\1\62\1\43\1\63\1\43\1\27\21\43"+ - "\1\64\1\43\1\64\2\43\1\64\2\43\1\64\1\43"+ - "\1\64\7\43\1\64\4\43\1\64\20\43\1\62\1\43"+ - "\1\63\1\43\1\27\63\43\5\65\1\66\5\65\1\67"+ - "\1\65\1\70\10\65\26\67\1\65\3\67\3\65\1\67"+ - "\4\65\1\71\5\65\65\13\1\72\10\13\13\65\1\73"+ - "\12\65\26\73\1\65\3\73\3\65\1\73\6\65\1\74"+ - "\16\65\1\73\12\65\26\73\1\65\3\73\1\65\1\75"+ - "\1\65\1\73\17\65\1\66\5\65\1\73\12\65\26\73"+ - "\1\65\3\73\3\65\1\73\13\65\2\44\2\65\1\66"+ - "\5\65\1\73\3\65\1\44\6\65\26\73\1\44\3\73"+ - "\3\65\1\73\12\65\13\76\1\46\4\76\1\32\5\76"+ - "\26\46\1\76\3\46\3\76\1\46\4\76\1\77\5\76"+ - "\120\0\1\100\64\0\1\101\1\102\5\0\1\103\55\0"+ - "\1\104\1\105\1\106\4\107\1\104\1\110\1\104\1\110"+ - "\1\111\1\104\1\112\1\113\1\104\1\110\5\107\2\114"+ - "\1\115\1\116\3\117\3\120\1\121\2\122\2\123\3\124"+ - "\1\111\1\125\1\126\1\127\1\105\1\130\1\131\1\132"+ - "\2\104\1\113\1\111\1\104\1\113\1\104\1\113\6\104"+ - "\47\0\1\133\27\0\2\44\14\0\1\44\34\0\1\44"+ - "\22\0\2\46\1\0\2\46\5\0\5\46\6\0\32\46"+ - "\3\0\1\46\23\0\1\134\75\0\1\135\1\136\5\0"+ - "\1\103\47\0\1\137\5\0\1\104\1\105\1\106\4\107"+ - "\1\104\3\110\1\111\1\104\1\112\1\113\1\104\1\110"+ - "\5\107\2\114\1\115\1\116\3\117\3\120\1\121\2\122"+ - "\2\123\3\124\1\111\1\125\1\126\1\127\1\105\1\130"+ - "\1\131\1\132\2\104\1\113\1\111\1\104\1\113\1\104"+ - "\1\113\6\104\71\0\1\140\17\0\1\67\12\0\26\67"+ - "\1\0\3\67\3\0\1\67\25\0\1\70\12\0\26\70"+ - "\1\0\3\70\3\0\1\70\13\0\2\73\10\0\5\73"+ - "\6\0\32\73\3\0\1\73\23\0\1\141\70\0\1\142"+ - "\37\0\1\143\13\0\1\144\1\145\6\0\1\146\1\0"+ - "\1\146\1\147\1\150\1\151\11\0\1\101\75\0\1\152"+ - "\1\153\64\0\2\105\51\0\1\105\23\0\1\154\51\0"+ - "\1\154\27\0\1\155\147\0\1\156\1\157\14\0\76\160"+ - "\1\0\2\161\3\0\1\162\20\0\2\161\1\0\1\161"+ - "\4\0\3\161\5\0\2\161\3\0\1\161\22\0\2\163"+ - "\24\0\2\163\1\0\1\163\4\0\3\163\5\0\2\163"+ - "\3\0\1\163\101\0\1\164\1\165\25\0\1\166\144\0"+ - "\1\167\12\0\1\170\75\0\1\171\1\172\1\0\5\173"+ - "\1\0\70\173\11\0\1\152\66\0\1\174\51\0\1\174"+ - "\52\0\1\175\45\0\2\176\24\0\2\176\1\0\1\176"+ - "\4\0\3\176\5\0\2\176\3\0\1\176\22\0\2\177"+ - "\4\0\1\200\17\0\2\177\1\0\1\177\4\0\3\177"+ - "\5\0\2\177\3\0\1\177\22\0\2\201\24\0\2\201"+ - "\1\0\1\201\4\0\3\201\5\0\2\201\3\0\1\201"+ - "\21\0\5\173\1\202\70\173\2\0\1\203\51\0\1\203"+ - "\30\0\1\117\67\0\2\204\4\0\1\176\17\0\2\204"+ + "\3\22\1\23\1\24\1\25\1\26\1\22\1\27\1\22"+ + "\1\30\2\22\1\31\1\32\1\22\1\33\1\34\1\35"+ + "\1\36\1\37\1\40\34\22\1\41\2\22\1\41\1\22"+ + "\1\41\5\22\1\42\12\22\1\43\63\22\7\44\1\45"+ + "\3\44\1\46\4\44\1\33\5\44\26\46\1\44\3\46"+ + "\3\44\1\46\13\44\2\47\4\44\1\45\7\44\1\47"+ + "\34\44\1\47\7\44\1\50\11\44\11\51\1\52\1\53"+ + "\52\51\3\0\26\51\1\54\44\51\3\0\6\51\6\22"+ + "\1\26\1\22\1\55\1\56\1\57\2\22\1\31\44\22"+ + "\1\60\2\22\1\60\1\22\1\60\1\22\1\61\4\22"+ + "\6\51\1\26\1\51\1\27\1\51\1\30\2\51\1\31"+ + "\2\51\1\62\44\51\1\41\1\22\1\41\6\51\6\44"+ + "\1\63\1\44\1\64\1\44\1\30\21\44\1\65\1\44"+ + "\1\65\2\44\1\65\2\44\1\65\1\44\1\65\7\44"+ + "\1\65\4\44\1\65\20\44\1\63\1\44\1\64\1\44"+ + "\1\30\63\44\5\66\1\67\5\66\1\70\1\66\1\71"+ + "\10\66\26\70\1\66\3\70\3\66\1\70\4\66\1\72"+ + "\5\66\65\14\1\73\10\14\13\66\1\74\12\66\26\74"+ + "\1\66\3\74\3\66\1\74\6\66\1\75\16\66\1\74"+ + "\12\66\26\74\1\66\3\74\1\66\1\76\1\66\1\74"+ + "\17\66\1\67\5\66\1\74\12\66\26\74\1\66\3\74"+ + "\3\66\1\74\13\66\2\47\2\66\1\67\5\66\1\74"+ + "\3\66\1\47\6\66\26\74\1\47\3\74\3\66\1\74"+ + "\12\66\13\77\1\46\4\77\1\33\5\77\26\46\1\77"+ + "\3\46\3\77\1\46\4\77\1\100\5\77\120\0\1\101"+ + "\54\0\2\102\14\0\1\102\34\0\1\102\32\0\1\103"+ + "\1\104\5\0\1\105\55\0\1\106\1\107\1\110\4\111"+ + "\1\106\1\112\1\106\1\112\1\113\1\106\1\114\1\115"+ + "\1\106\1\112\5\111\2\116\1\117\1\120\3\121\3\122"+ + "\1\123\2\124\2\125\3\126\1\113\1\127\1\130\1\131"+ + "\1\107\1\132\1\133\1\134\2\106\1\115\1\113\1\106"+ + "\1\115\1\106\1\115\6\106\47\0\1\135\27\0\2\46"+ + "\1\0\2\46\5\0\5\46\6\0\32\46\3\0\1\46"+ + "\13\0\2\47\14\0\1\47\34\0\1\47\32\0\1\136"+ + "\75\0\1\137\1\140\5\0\1\105\47\0\1\141\5\0"+ + "\1\106\1\107\1\110\4\111\1\106\3\112\1\113\1\106"+ + "\1\114\1\115\1\106\1\112\5\111\2\116\1\117\1\120"+ + "\3\121\3\122\1\123\2\124\2\125\3\126\1\113\1\127"+ + "\1\130\1\131\1\107\1\132\1\133\1\134\2\106\1\115"+ + "\1\113\1\106\1\115\1\106\1\115\6\106\71\0\1\142"+ + "\17\0\1\70\12\0\26\70\1\0\3\70\3\0\1\70"+ + "\25\0\1\71\12\0\26\71\1\0\3\71\3\0\1\71"+ + "\13\0\2\74\10\0\5\74\6\0\32\74\3\0\1\74"+ + "\23\0\1\143\70\0\1\144\37\0\1\145\13\0\1\146"+ + "\1\147\6\0\1\150\1\0\1\150\1\151\1\152\1\153"+ + "\1\0\2\102\4\0\1\154\7\0\1\102\34\0\1\102"+ + "\7\0\1\155\22\0\1\103\75\0\1\156\1\157\64\0"+ + "\2\107\51\0\1\107\23\0\1\160\51\0\1\160\27\0"+ + "\1\161\147\0\1\162\1\163\14\0\76\164\1\0\2\165"+ + "\3\0\1\166\20\0\2\165\1\0\1\165\4\0\3\165"+ + "\5\0\2\165\3\0\1\165\22\0\2\167\24\0\2\167"+ + "\1\0\1\167\4\0\3\167\5\0\2\167\3\0\1\167"+ + "\101\0\1\170\1\171\25\0\1\172\144\0\1\173\12\0"+ + "\1\174\75\0\1\175\1\176\1\0\5\177\1\0\70\177"+ + "\1\0\2\200\14\0\1\200\34\0\1\200\32\0\1\156"+ + "\66\0\1\201\51\0\1\201\52\0\1\202\45\0\2\203"+ + "\24\0\2\203\1\0\1\203\4\0\3\203\5\0\2\203"+ + "\3\0\1\203\22\0\2\204\4\0\1\205\17\0\2\204"+ "\1\0\1\204\4\0\3\204\5\0\2\204\3\0\1\204"+ - "\22\0\2\205\24\0\2\205\1\0\1\205\4\0\3\205"+ - "\5\0\2\205\3\0\1\205\22\0\2\206\4\0\1\176"+ - "\17\0\2\206\1\0\1\206\4\0\3\206\5\0\2\206"+ - "\3\0\1\206\22\0\2\207\24\0\2\207\1\0\1\207"+ - "\4\0\3\207\5\0\2\207\3\0\1\207\22\0\2\210"+ - "\4\0\1\176\17\0\2\210\1\0\1\210\4\0\3\210"+ - "\5\0\2\210\3\0\1\210\22\0\2\211\4\0\1\176"+ - "\17\0\2\211\1\0\1\211\4\0\3\211\5\0\2\211"+ - "\3\0\1\211\22\0\2\212\4\0\1\176\17\0\2\212"+ + "\22\0\2\206\24\0\2\206\1\0\1\206\4\0\3\206"+ + "\5\0\2\206\3\0\1\206\21\0\5\177\1\207\70\177"+ + "\1\0\2\200\4\0\1\154\7\0\1\200\34\0\1\200"+ + "\23\0\1\210\51\0\1\210\30\0\1\121\67\0\2\211"+ + "\4\0\1\203\17\0\2\211\1\0\1\211\4\0\3\211"+ + "\5\0\2\211\3\0\1\211\22\0\2\212\24\0\2\212"+ "\1\0\1\212\4\0\3\212\5\0\2\212\3\0\1\212"+ - "\22\0\2\213\4\0\1\176\17\0\2\213\1\0\1\213"+ - "\4\0\3\213\5\0\2\213\3\0\1\213\22\0\2\213"+ - "\4\0\1\200\17\0\2\213\1\0\1\213\4\0\3\213"+ - "\5\0\2\213\3\0\1\213\21\0"; + "\22\0\2\213\4\0\1\203\17\0\2\213\1\0\1\213"+ + "\4\0\3\213\5\0\2\213\3\0\1\213\22\0\2\214"+ + "\24\0\2\214\1\0\1\214\4\0\3\214\5\0\2\214"+ + "\3\0\1\214\22\0\2\215\4\0\1\203\17\0\2\215"+ + "\1\0\1\215\4\0\3\215\5\0\2\215\3\0\1\215"+ + "\22\0\2\216\4\0\1\203\17\0\2\216\1\0\1\216"+ + "\4\0\3\216\5\0\2\216\3\0\1\216\22\0\2\217"+ + "\4\0\1\203\17\0\2\217\1\0\1\217\4\0\3\217"+ + "\5\0\2\217\3\0\1\217\22\0\2\220\4\0\1\203"+ + "\17\0\2\220\1\0\1\220\4\0\3\220\5\0\2\220"+ + "\3\0\1\220\22\0\2\220\4\0\1\205\17\0\2\220"+ + "\1\0\1\220\4\0\3\220\5\0\2\220\3\0\1\220"+ + "\21\0"; private static int [] zzUnpackTrans() { - int [] result = new int[3968]; + int [] result = new int[4278]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -385,18 +393,18 @@ class _RegExLexer implements FlexLexer { private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\12\0\1\1\5\0\2\11\1\1\2\11\2\1\12\11"+ - "\1\1\1\11\1\1\1\11\1\1\3\11\1\1\1\11"+ - "\1\1\1\11\1\1\1\11\1\1\2\11\1\1\3\11"+ - "\2\1\2\11\1\1\3\11\2\1\1\11\1\0\1\1"+ - "\1\11\2\1\6\11\2\1\2\11\1\1\4\11\2\1"+ - "\2\11\1\1\3\11\1\0\4\11\1\0\1\1\4\11"+ - "\1\0\1\11\1\0\1\1\1\0\3\11\3\1\7\11"+ - "\1\0\1\1\1\0\1\11\1\1\1\11\1\1\2\11"+ - "\3\1\1\11\4\1"; + "\13\0\1\1\5\0\2\11\1\1\1\11\3\1\12\11"+ + "\1\1\2\11\2\1\3\11\1\1\1\11\1\1\1\11"+ + "\1\1\1\11\1\1\1\11\2\1\3\11\2\1\2\11"+ + "\1\1\3\11\2\1\1\0\1\11\1\0\1\1\1\11"+ + "\2\1\6\11\2\1\2\11\1\1\4\11\2\1\2\11"+ + "\1\1\3\11\1\0\4\11\1\0\1\1\4\11\1\0"+ + "\1\11\1\0\1\11\1\0\1\1\1\0\3\11\3\1"+ + "\7\11\2\0\1\1\1\0\1\11\1\1\1\11\1\1"+ + "\2\11\3\1\1\11\4\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[139]; + int [] result = new int[144]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -753,107 +761,107 @@ class _RegExLexer implements FlexLexer { case 1: { yypopstate(); return RegExpTT.COMMENT; } - case 90: break; + case 91: break; case 2: { return RegExpTT.CHARACTER; } - case 91: break; + case 92: break; case 3: { return RegExpTT.DOT; } - case 92: break; + case 93: break; case 4: { capturingGroupCount++; return RegExpTT.GROUP_BEGIN; } - case 93: break; + case 94: break; case 5: { return RegExpTT.GROUP_END; } - case 94: break; - case 6: - { if (yystate() != CLASS2) { yypushstate(EMBRACED); return RegExpTT.LBRACE; } return RegExpTT.CHARACTER; - } case 95: break; + case 6: + { if (yystate() != CLASS2 && !allowDanglingMetacharacters) { yypushstate(QUANTIFIER); return RegExpTT.LBRACE; } return RegExpTT.CHARACTER; + } + case 96: break; case 7: { yypushstate(CLASS2); return RegExpTT.CLASS_BEGIN; } - case 96: break; + case 97: break; case 8: { return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; } - case 97: break; + case 98: break; case 9: { return RegExpTT.MINUS; } - case 98: break; + case 99: break; case 10: { return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER; } - case 99: break; + case 100: break; case 11: { return RegExpTT.CARET; } - case 100: break; + case 101: break; case 12: { return RegExpTT.DOLLAR; } - case 101: break; + case 102: break; case 13: { return RegExpTT.QUEST; } - case 102: break; + case 103: break; case 14: { return RegExpTT.STAR; } - case 103: break; + case 104: break; case 15: { return RegExpTT.PLUS; } - case 104: break; + case 105: break; case 16: { return RegExpTT.UNION; } - case 105: break; + case 106: break; case 17: { return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CTRL_CHARACTER; } - case 106: break; + case 107: break; case 18: { if (commentMode) { yypushstate(COMMENT); return RegExpTT.COMMENT; } else return RegExpTT.CHARACTER; } - case 107: break; + case 108: break; case 19: { yypopstate(); yypushback(1); } - case 108: break; - case 20: - { return RegExpTT.NUMBER; - } case 109: break; - case 21: + case 20: { yypopstate(); return RegExpTT.RBRACE; } case 110: break; - case 22: + case 21: { return RegExpTT.NAME; } case 111: break; + case 22: + { return RegExpTT.NUMBER; + } + case 112: break; case 23: { return RegExpTT.COMMA; } - case 112: break; + case 113: break; case 24: { assert false : yytext(); } - case 113: break; + case 114: break; case 25: { yybegin(CLASS2); return RegExpTT.CHARACTER; } - case 114: break; + case 115: break; case 26: { yybegin(CLASS1); return RegExpTT.CARET; } - case 115: break; + case 116: break; case 27: { if (allowNestedCharacterClasses) { yypushstate(CLASS2); @@ -861,81 +869,81 @@ class _RegExLexer implements FlexLexer { } return RegExpTT.CHARACTER; } - case 116: break; + case 117: break; case 28: { yypopstate(); return RegExpTT.CLASS_END; } - case 117: break; + case 118: break; case 29: { return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.ESC_CHARACTER; } - case 118: break; + case 119: break; case 30: { yybegin(CLASS2); return RegExpTT.CARET; } - case 119: break; + case 120: break; case 31: { yypopstate(); yypushstate(EMBRACED); return RegExpTT.LBRACE; } - case 120: break; + case 121: break; case 32: { yypopstate(); return RegExpTT.CATEGORY_SHORT_HAND; } - case 121: break; + case 122: break; case 33: { yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER; } - case 122: break; + case 123: break; case 34: { yybegin(YYINITIAL); return RegExpTT.GROUP_END; } - case 123: break; + case 124: break; case 35: { handleOptions(); return RegExpTT.OPTIONS_ON; } - case 124: break; + case 125: break; case 36: { handleOptions(); return RegExpTT.OPTIONS_OFF; } - case 125: break; + case 126: break; case 37: { yybegin(YYINITIAL); return RegExpTT.COLON; } - case 126: break; + case 127: break; case 38: { yybegin(YYINITIAL); return RegExpTT.GT; } - case 127: break; + case 128: break; case 39: { yybegin(YYINITIAL); return RegExpTT.QUOTE; } - case 128: break; + case 129: break; case 40: { return RegExpTT.BAD_CHARACTER; } - case 129: break; + case 130: break; case 41: { yybegin(OPTIONS); return RegExpTT.SET_OPTIONS; } - case 130: break; + case 131: break; case 42: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { if (allowEmptyCharacterClass) yypushstate(CLASS2); else yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN; } - case 131: break; + case 132: break; case 43: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { yypushstate(NEGATE_CLASS2); return RegExpTT.CLASS_BEGIN; } - case 132: break; + case 133: break; case 44: { return RegExpTT.REDUNDANT_ESCAPE; } - case 133: break; + case 134: break; case 45: { if (allowOctalNoLeadingZero) { CharSequence s = yytext(); @@ -957,79 +965,79 @@ class _RegExLexer implements FlexLexer { } return RegExpTT.BACKREF; } - case 134: break; + case 135: break; case 46: { return (allowOctalNoLeadingZero ? RegExpTT.OCT_CHAR : RegExpTT.BAD_OCT_VALUE); } - case 135: break; + case 136: break; case 47: { return (yystate() == CLASS2) ? RegExpTT.REDUNDANT_ESCAPE : RegExpTT.ESC_CHARACTER; } - case 136: break; + case 137: break; case 48: { return RegExpTT.ESC_CHARACTER; } - case 137: break; + case 138: break; case 49: { return (yystate() == CLASS2) ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; } - case 138: break; + case 139: break; case 50: { return commentMode ? RegExpTT.CHARACTER : RegExpTT.REDUNDANT_ESCAPE; } - case 139: break; + case 140: break; case 51: { return RegExpTT.ESC_CTRL_CHARACTER; } - case 140: break; + case 141: break; case 52: { return yystate() != CLASS2 ? RegExpTT.BOUNDARY : RegExpTT.ESC_CHARACTER; } - case 141: break; + case 142: break; case 53: { return RegExpTT.CHAR_CLASS; } - case 142: break; + case 143: break; case 54: { if (xmlSchemaMode) return RegExpTT.CHAR_CLASS; else return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; } - case 143: break; + case 144: break; case 55: { yypushstate(PROP); return RegExpTT.PROPERTY; } - case 144: break; + case 145: break; case 56: { return allowTransformationEscapes ? RegExpTT.CHAR_CLASS : StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; } - case 145: break; + case 146: break; case 57: { yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN; } - case 146: break; + case 147: break; case 58: { return RegExpTT.BAD_HEX_VALUE; } - case 147: break; + case 148: break; case 59: { return allowTransformationEscapes ? RegExpTT.CHAR_CLASS : StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN; } - case 148: break; + case 149: break; case 60: { return (allowHexDigitClass || allowHorizontalWhitespaceClass ? RegExpTT.CHAR_CLASS : StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN); } - case 149: break; + case 150: break; case 61: { yypushstate(NAMED); return RegExpTT.NAMED_CHARACTER; } - case 150: break; + case 151: break; case 62: { yypopstate(); return RegExpTT.QUOTE_END; } - case 151: break; + case 152: break; case 63: { yybegin(CLASS2); return RegExpTT.REDUNDANT_ESCAPE; } - case 152: break; + case 153: break; case 64: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints @@ -1040,7 +1048,7 @@ class _RegExLexer implements FlexLexer { } return RegExpTT.CHARACTER; } - case 153: break; + case 154: break; case 65: { if (allowPosixBracketExpressions) { yybegin(BRACKET_EXPRESSION); @@ -1050,75 +1058,82 @@ class _RegExLexer implements FlexLexer { return RegExpTT.CHARACTER; } } - case 154: break; + case 155: break; case 66: { if (allowNestedCharacterClasses) return RegExpTT.ANDAND; else yypushback(1); return RegExpTT.CHARACTER; } - case 155: break; + case 156: break; case 67: { yybegin(CLASS2); return RegExpTT.BRACKET_EXPRESSION_END; } - case 156: break; + case 157: break; case 68: { yybegin(PY_COND_REF); return RegExpTT.PYTHON_COND_REF; } - case 157: break; + case 158: break; case 69: { yybegin(NAMED_GROUP); capturingGroupCount++; return RegExpTT.RUBY_NAMED_GROUP; } - case 158: break; + case 159: break; case 70: { yybegin(QUOTED_NAMED_GROUP); capturingGroupCount++; return RegExpTT.RUBY_QUOTED_NAMED_GROUP; } - case 159: break; + case 160: break; case 71: { return RegExpTT.NON_CAPT_GROUP; } - case 160: break; + case 161: break; case 72: { return RegExpTT.POS_LOOKAHEAD; } - case 161: break; + case 162: break; case 73: { return RegExpTT.NEG_LOOKAHEAD; } - case 162: break; + case 163: break; case 74: + // lookahead expression with fixed base length + zzMarkedPos = Character.offsetByCodePoints + (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); + { yypushstate(QUANTIFIER); return RegExpTT.LBRACE; + } + case 164: break; + case 75: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { if (allowEmptyCharacterClass) yypushstate(CLASS2); else yypushstate(NEGATE_CLASS1); return RegExpTT.CLASS_BEGIN; } - case 163: break; - case 75: + case 165: break; + case 76: { return RegExpTT.OCT_CHAR; } - case 164: break; - case 76: + case 166: break; + case 77: { yybegin(NAMED_GROUP); return RegExpTT.RUBY_NAMED_GROUP_CALL; } - case 165: break; - case 77: + case 167: break; + case 78: { yybegin(QUOTED_NAMED_GROUP); return RegExpTT.RUBY_QUOTED_NAMED_GROUP_CALL; } - case 166: break; - case 78: + case 168: break; + case 79: { if (xmlSchemaMode) { yypushback(1); return RegExpTT.CHAR_CLASS; } else return RegExpTT.CTRL; } - case 167: break; - case 79: + case 169: break; + case 80: { return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN; } - case 168: break; - case 80: + case 170: break; + case 81: { yybegin(NAMED_GROUP); return RegExpTT.RUBY_NAMED_GROUP_REF; } - case 169: break; - case 81: + case 171: break; + case 82: { yybegin(QUOTED_NAMED_GROUP); return RegExpTT.RUBY_QUOTED_NAMED_GROUP_REF; } - case 170: break; - case 82: + case 172: break; + case 83: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); @@ -1128,35 +1143,35 @@ class _RegExLexer implements FlexLexer { } return RegExpTT.CHARACTER; } - case 171: break; - case 83: + case 173: break; + case 84: { yybegin(NAMED_GROUP); capturingGroupCount++; return RegExpTT.PYTHON_NAMED_GROUP; } - case 172: break; - case 84: + case 174: break; + case 85: { yybegin(PY_NAMED_GROUP_REF); return RegExpTT.PYTHON_NAMED_GROUP_REF; } - case 173: break; - case 85: + case 175: break; + case 86: { return RegExpTT.POS_LOOKBEHIND; } - case 174: break; - case 86: + case 176: break; + case 87: { return RegExpTT.NEG_LOOKBEHIND; } - case 175: break; - case 87: + case 177: break; + case 88: { return RegExpTT.HEX_CHAR; } - case 176: break; - case 88: + case 178: break; + case 89: { return RegExpTT.COMMENT; } - case 177: break; - case 89: + case 179: break; + case 90: { return RegExpTT.UNICODE_CHAR; } - case 178: break; + case 180: break; default: zzScanError(ZZ_NO_MATCH); } diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpHighlighter.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpHighlighter.java index 3ad677c6726a..f88d376f99f7 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpHighlighter.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpHighlighter.java @@ -94,7 +94,6 @@ public class RegExpHighlighter extends SyntaxHighlighterBase { ourMap.put(RegExpTT.ESC_CTRL_CHARACTER, CHAR_CLASS); ourMap.put(RegExpTT.NAMED_CHARACTER, CHAR_CLASS); ourMap.put(RegExpTT.CATEGORY_SHORT_HAND, CHAR_CLASS); - ourMap.put(RegExpTT.CATEGORY_SHORT_HAND, CHAR_CLASS); ourMap.put(RegExpTT.RUBY_NAMED_GROUP_REF, CHAR_CLASS); ourMap.put(RegExpTT.RUBY_NAMED_GROUP_CALL, CHAR_CLASS); ourMap.put(RegExpTT.RUBY_QUOTED_NAMED_GROUP_REF, CHAR_CLASS); diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpParser.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpParser.java index 9c16d5334237..9fbe8d74d75c 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpParser.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpParser.java @@ -30,10 +30,6 @@ public class RegExpParser implements PsiParser { private static final TokenSet PROPERTY_TOKENS = TokenSet.create(RegExpTT.NUMBER, RegExpTT.COMMA, RegExpTT.NAME, RegExpTT.RBRACE); private final EnumSet myCapabilities; - public RegExpParser() { - myCapabilities = EnumSet.noneOf(RegExpCapability.class); - } - public RegExpParser(EnumSet capabilities) { myCapabilities = capabilities; } @@ -82,7 +78,6 @@ public class RegExpParser implements PsiParser { /** * BRANCH ::= ATOM BRANCH | "" */ - @SuppressWarnings({"StatementWithEmptyBody"}) private boolean parseBranch(PsiBuilder builder) { final PsiBuilder.Marker marker = builder.mark(); @@ -97,7 +92,8 @@ public class RegExpParser implements PsiParser { return false; } - while (parseAtom(builder)) ; + //noinspection StatementWithEmptyBody + while (parseAtom(builder)) {} marker.done(RegExpElementTypes.BRANCH); return true; @@ -141,10 +137,6 @@ public class RegExpParser implements PsiParser { if (minOmitted) { builder.advanceLexer(); } - else if (builder.getTokenType() != RegExpTT.NUMBER && myCapabilities.contains(RegExpCapability.DANGLING_METACHARACTERS)) { - marker.done(RegExpTT.CHARACTER); - return true; - } else { checkMatches(builder, RegExpTT.NUMBER, "Number expected"); } @@ -214,37 +206,26 @@ public class RegExpParser implements PsiParser { if (builder.getTokenType() == RegExpTT.CARET) { builder.advanceLexer(); } - - // DEFLIST - if (parseClassIntersection(builder)) { - while (RegExpTT.CHARACTERS.contains(builder.getTokenType()) || - builder.getTokenType() == RegExpTT.CHAR_CLASS || - builder.getTokenType() == RegExpTT.CLASS_BEGIN || - builder.getTokenType() == RegExpTT.PROPERTY || - builder.getTokenType() == RegExpTT.BRACKET_EXPRESSION_BEGIN) { - parseClassIntersection(builder); - } - } + parseClassIntersection(builder); checkMatches(builder, RegExpTT.CLASS_END, "Unclosed character class"); marker.done(RegExpElementTypes.CLASS); return marker; } - private boolean parseClassIntersection(PsiBuilder builder) { + private void parseClassIntersection(PsiBuilder builder) { final PsiBuilder.Marker marker = builder.mark(); parseClassdef(builder); if (RegExpTT.ANDAND != builder.getTokenType()) { marker.drop(); - return true; + return; } while (RegExpTT.ANDAND == builder.getTokenType()) { builder.advanceLexer(); parseClassdef(builder); } marker.done(RegExpElementTypes.INTERSECTION); - return true; } private boolean parseClassdef(PsiBuilder builder) { @@ -463,10 +444,6 @@ public class RegExpParser implements PsiParser { marker.drop(); return parseClass(builder); } - else if (type == RegExpTT.LBRACE && myCapabilities.contains(RegExpCapability.DANGLING_METACHARACTERS)) { - builder.advanceLexer(); - marker.done(RegExpElementTypes.CHAR); - } else { marker.drop(); return null; diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpParserDefinition.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpParserDefinition.java index e8a134eb491d..1117a78d20bd 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpParserDefinition.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpParserDefinition.java @@ -49,6 +49,10 @@ public class RegExpParserDefinition implements ParserDefinition { CAPABILITIES.add(capability); Disposer.register(parentDisposable, () -> CAPABILITIES.remove(capability)); } + else { + CAPABILITIES.remove(capability); + Disposer.register(parentDisposable, () -> CAPABILITIES.add(capability)); + } } @NotNull diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpTT.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpTT.java index 2da30a8be0da..79427fd04e2a 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpTT.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpTT.java @@ -25,35 +25,46 @@ public interface RegExpTT { IElementType NAME = new RegExpElementType("NAME"); IElementType COMMA = new RegExpElementType("COMMA"); - // "\\Q" + /** "\\Q" */ IElementType QUOTE_BEGIN = new RegExpElementType("QUOTE_BEGIN"); - // "\\E" + /** "\\E" */ IElementType QUOTE_END = new RegExpElementType("QUOTE_END"); - // "\\" 0-9 + /** "\\" 0-9 */ IElementType BACKREF = new RegExpElementType("BACKREF"); + /** "{" */ IElementType LBRACE = new RegExpElementType("LBRACE"); + /** "}" */ IElementType RBRACE = new RegExpElementType("RBRACE"); - // "[" + /** "[" */ IElementType CLASS_BEGIN = new RegExpElementType("CLASS_BEGIN"); - // "]" + /** "]" */ IElementType CLASS_END = new RegExpElementType("CLASS_END"); + /** "&&" */ IElementType ANDAND = new RegExpElementType("ANDAND"); - // "[:" + /** "[:" */ IElementType BRACKET_EXPRESSION_BEGIN = new RegExpElementType("BRACKET_EXPRESSION_BEGIN"); - // ":]" + /** ":]" */ IElementType BRACKET_EXPRESSION_END = new RegExpElementType("BRACKET_EXPRESSION_END"); + /** "(" */ IElementType GROUP_BEGIN = new RegExpElementType("GROUP_BEGIN"); + /** ")" */ IElementType GROUP_END = new RegExpElementType("GROUP_END"); + /** "(?:" or "(?>" */ IElementType NON_CAPT_GROUP = new RegExpElementType("NON_CAPT_GROUP"); + /** "(?<=" */ IElementType POS_LOOKBEHIND = new RegExpElementType("POS_LOOKBEHIND"); + /** "(? in Python/Ruby named group + /** ">" in Python/Ruby named group */ IElementType GT = new RegExpElementType("GT"); - // ' in Ruby quoted named group + /* "'" in Ruby quoted named group */ IElementType QUOTE = new RegExpElementType("QUOTE"); - // "\b" | "\t" | "\f" | "\r" | "\n" + /** "\b" | "\t" | "\f" | "\r" | "\n" */ IElementType CTRL_CHARACTER = new RegExpElementType("CTRL_CHARACTER"); - // "\\" ("t" | "n" | "r" | "f" | "a" | "e") + /** "\\" ("t" | "n" | "r" | "f" | "a" | "e") */ IElementType ESC_CTRL_CHARACTER = new RegExpElementType("ESC_CTRL_CHARACTER"); - // "\\" ("." | "|" | "$" | "^" | "?" | "*" | "+" | "[" | "{" | "(" | ")") + /** "\\" ("." | "|" | "$" | "^" | "?" | "*" | "+" | "[" | "{" | "(" | ")") */ IElementType ESC_CHARACTER = new RegExpElementType("ESC_CHARACTER"); - // "\\" ("w" | "W" | "s" | "S" | "d" | "D" | "v" | "V" | "h" | "H" | "X" | "R") + /** "\\" ("w" | "W" | "s" | "S" | "d" | "D" | "v" | "V" | "h" | "H" | "X" | "R") */ IElementType CHAR_CLASS = new RegExpElementType("CHAR_CLASS"); - // "\\u" XXXX + /** "\\u" XXXX */ IElementType UNICODE_CHAR = new RegExpElementType("UNICODE_CHAR"); - // "\\x" XX + /** "\\x" XX */ IElementType HEX_CHAR = new RegExpElementType("HEX_CHAR"); - // "\\0" OOO + /** "\\0" OOO */ IElementType OCT_CHAR = new RegExpElementType("OCT_CHAR"); - // "\\c" x + /** "\\c" x */ IElementType CTRL = new RegExpElementType("CTRL"); - // "\\p" | "\\P" + /** "\\p" | "\\P" */ IElementType PROPERTY = new RegExpElementType("PROPERTY"); - // "\\N + /** "\\N */ IElementType NAMED_CHARACTER = new RegExpElementType("NAMED_CHARACTER"); - // "L" | "M" | "Z" | "S" | "N" | "P" | "C" after a property escape + /** "L" | "M" | "Z" | "S" | "N" | "P" | "C" after a property escape */ IElementType CATEGORY_SHORT_HAND = new RegExpElementType("CATEGORY_SHORT_HAND"); - // e.g. "\\#" but also "\\q" which is not a valid escape actually + /** e.g. "\\#" but also "\\q" which is not a valid escape actually */ IElementType REDUNDANT_ESCAPE = new RegExpElementType("REDUNDANT_ESCAPE"); IElementType MINUS = new RegExpElementType("MINUS"); @@ -113,25 +125,25 @@ public interface RegExpTT { IElementType OPTIONS_ON = new RegExpElementType("OPTIONS_ON"); IElementType OPTIONS_OFF = new RegExpElementType("OPTIONS_OFF"); - // (?P... + /** (?P... */ IElementType PYTHON_NAMED_GROUP = new RegExpElementType("PYTHON_NAMED_GROUP"); - // (?P=name) + /** (?P=name) */ IElementType PYTHON_NAMED_GROUP_REF = new RegExpElementType("PYTHON_NAMED_GROUP_REF"); - // (?(id/name)yes-pattern|no-pattern) + /** (?(id/name)yes-pattern|no-pattern) */ IElementType PYTHON_COND_REF = new RegExpElementType("PYTHON_COND_REF"); - // (?... + /** (?... */ IElementType RUBY_NAMED_GROUP = new RegExpElementType("RUBY_NAMED_GROUP"); - // \k + /** \k */ IElementType RUBY_NAMED_GROUP_REF = new RegExpElementType("RUBY_NAMED_GROUP_REF"); - // \g + /** \g */ IElementType RUBY_NAMED_GROUP_CALL = new RegExpElementType("RUBY_NAMED_GROUP_CALL"); - // (?'name'... + /** (?'name'... */ IElementType RUBY_QUOTED_NAMED_GROUP = new RegExpElementType("RUBY_QUOTED_NAMED_GROUP"); - // \k'name' + /** \k'name' */ IElementType RUBY_QUOTED_NAMED_GROUP_REF = new RegExpElementType("RUBY_QUOTED_NAMED_GROUP_REF"); - // \g'name' + /** \g'name' */ IElementType RUBY_QUOTED_NAMED_GROUP_CALL = new RegExpElementType("RUBY_QUOTED_NAMED_GROUP_CALL"); TokenSet CHARACTERS = TokenSet.create(CHARACTER, diff --git a/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex b/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex index d90f4964e2b2..49b2d978ec20 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex +++ b/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex @@ -74,6 +74,7 @@ import java.util.EnumSet; %xstate QUOTED %xstate EMBRACED +%xstate QUANTIFIER %xstate CLASS1 %xstate NEGATE_CLASS1 %state CLASS2 @@ -217,14 +218,19 @@ HEX_CHAR=[0-9a-fA-F] /* "{" \d+(,\d*)? "}" */ /* "}" outside counted closure is treated as regular character */ -{LBRACE} { if (yystate() != CLASS2) { yypushstate(EMBRACED); return RegExpTT.LBRACE; } return RegExpTT.CHARACTER; } +{LBRACE} / [:digit:]+ {RBRACE} { yypushstate(QUANTIFIER); return RegExpTT.LBRACE; } +{LBRACE} / [:digit:]+ "," [:digit:]+ {RBRACE} { yypushstate(QUANTIFIER); return RegExpTT.LBRACE; } +{LBRACE} { if (yystate() != CLASS2 && !allowDanglingMetacharacters) { yypushstate(QUANTIFIER); return RegExpTT.LBRACE; } return RegExpTT.CHARACTER; } + { + [:digit:]+ { return RegExpTT.NUMBER; } + "," { return RegExpTT.COMMA; } + {RBRACE} { yypopstate(); return RegExpTT.RBRACE; } + {ANY} { yypopstate(); yypushback(1); } +} { "^" { return RegExpTT.CARET; } {NAME} { return RegExpTT.NAME; } - [:digit:]+ { return RegExpTT.NUMBER; } - "," { return RegExpTT.COMMA; } - {RBRACE} { yypopstate(); return RegExpTT.RBRACE; } {ANY} { yypopstate(); yypushback(1); } } diff --git a/RegExpSupport/test/org/intellij/lang/regexp/RegExpCompletionTest.java b/RegExpSupport/test/org/intellij/lang/regexp/RegExpCompletionTest.java index abdee64fbc05..c674c11b31bd 100644 --- a/RegExpSupport/test/org/intellij/lang/regexp/RegExpCompletionTest.java +++ b/RegExpSupport/test/org/intellij/lang/regexp/RegExpCompletionTest.java @@ -60,7 +60,7 @@ public class RegExpCompletionTest extends CodeInsightFixtureTestCase { } public void testNamedCharacter() { - myFixture.configureByText(RegExpFileType.INSTANCE, "\\\\N{SMILE}"); + myFixture.configureByText(RegExpFileType.INSTANCE, "\\N{SMILE}"); final LookupElement[] elements = myFixture.completeBasic(); final List strings = ContainerUtil.map(elements, LookupElement::getLookupString); assertEquals(Arrays.asList("SMILE", "SMILING FACE WITH SMILING EYES", "SMILING FACE WITH HEART-SHAPED EYES", @@ -89,7 +89,9 @@ public class RegExpCompletionTest extends CodeInsightFixtureTestCase { } public void testPropertyAlpha() throws Throwable { - doTest(); + myFixture.configureByText(RegExpFileType.INSTANCE, "\\P{Alp}"); + myFixture.completeBasic(); + myFixture.checkResult("\\P{Alpha}"); } public void doTest() throws Throwable { diff --git a/RegExpSupport/test/org/intellij/lang/regexp/RegExpParsingTest.java b/RegExpSupport/test/org/intellij/lang/regexp/RegExpParsingTest.java index 1d057c835fd0..95887f56a1b3 100644 --- a/RegExpSupport/test/org/intellij/lang/regexp/RegExpParsingTest.java +++ b/RegExpSupport/test/org/intellij/lang/regexp/RegExpParsingTest.java @@ -188,6 +188,7 @@ public class RegExpParsingTest extends ParsingTestCase { public void testGroups37() throws IOException { doCodeTest("(?P=name)"); } public void testGroups38() throws IOException { doCodeTest("\\g'name'"); } public void testGroups39() throws IOException { doCodeTest("(?(name)yes-pattern|no-pattern)"); } + public void testGroups40() throws IOException { doCodeTest("(?(name)yes-pattern|{"); } public void testEscapes1() throws IOException { doCodeTest("\\q"); } public void testEscapes2() throws IOException { doCodeTest("\\#"); } @@ -243,6 +244,7 @@ public class RegExpParsingTest extends ParsingTestCase { public void testNamedchars11() throws IOException { doCodeTest("[:^xdigit:]+"); } public void testNamedchars12() throws IOException { doCodeTest("\\p{InArabic Extended-A}"); } public void testNamedchars13() throws IOException { doCodeTest("\\N{Mahjong Tile Winter}"); } + public void testNamedchars14() throws IOException { doCodeTest("[\\N{Mahjong Tile Winter}]"); } public void testBackrefs1() throws IOException { doCodeTest("(ac*)c*d[ac]*\\1"); } public void testBackrefs2() throws IOException { doCodeTest("(.)=\\1"); } @@ -335,4 +337,43 @@ public class RegExpParsingTest extends ParsingTestCase { public void testParse1() throws IOException { doCodeTest("123 | 456"); } public void testParse2() throws IOException { doCodeTest("1**"); } public void testParse3() throws IOException { doCodeTest("(([hH][tT]{2}[pP]|[fF][tT][pP])://)?[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)*"); } + + public void testPosixBracketExpression1() throws IOException { + RegExpParserDefinition.setTestCapability(RegExpCapability.POSIX_BRACKET_EXPRESSIONS, getTestRootDisposable()); + doCodeTest("[[:alpha:]]"); + } + + public void testPosixBracketExpression2() throws IOException { + RegExpParserDefinition.setTestCapability(RegExpCapability.POSIX_BRACKET_EXPRESSIONS, getTestRootDisposable()); + doCodeTest("[[:^alpha:]]"); + } + + public void testCategoryShorthand1() throws IOException { + doCodeTest("\\pL"); + } + + public void testCategoryShorthand2() throws IOException { + RegExpParserDefinition.setTestCapability(RegExpCapability.UNICODE_CATEGORY_SHORTHAND, getTestRootDisposable()); + doCodeTest("\\pL"); + } + + public void testOmitNumberInQuantifier() throws IOException { + RegExpParserDefinition.setTestCapability(RegExpCapability.OMIT_NUMBERS_IN_QUANTIFIERS, getTestRootDisposable()); + doCodeTest("a{,3}"); + } + + public void testDanglingMetaCharacter1() throws IOException { + RegExpParserDefinition.setTestCapability(RegExpCapability.DANGLING_METACHARACTERS, getTestRootDisposable()); + doCodeTest("{"); + } + + public void testDanglingMetaCharacter2() throws IOException { + RegExpParserDefinition.setTestCapability(RegExpCapability.DANGLING_METACHARACTERS, getTestRootDisposable()); + doCodeTest("a{a"); + } + + public void testDanglingMetaCharacters3() throws IOException { + RegExpParserDefinition.setTestCapability(RegExpCapability.DANGLING_METACHARACTERS, getTestRootDisposable()); + doCodeTest("{{E1:\\s*(?P([^\\n]+\\+)?[0-9]+)( *\\|[^\\n]*)?}}"); + } } diff --git a/RegExpSupport/testData/completion/PropertyAlpha.regexp b/RegExpSupport/testData/completion/PropertyAlpha.regexp deleted file mode 100644 index 96509136743d..000000000000 --- a/RegExpSupport/testData/completion/PropertyAlpha.regexp +++ /dev/null @@ -1 +0,0 @@ -\\p{Alp} diff --git a/RegExpSupport/testData/completion/PropertyAlphaExpected.regexp b/RegExpSupport/testData/completion/PropertyAlphaExpected.regexp deleted file mode 100644 index 03696e617f4c..000000000000 --- a/RegExpSupport/testData/completion/PropertyAlphaExpected.regexp +++ /dev/null @@ -1 +0,0 @@ -\\p{Alpha} diff --git a/RegExpSupport/testData/psi/CategoryShorthand1.txt b/RegExpSupport/testData/psi/CategoryShorthand1.txt new file mode 100644 index 000000000000..434b72be7435 --- /dev/null +++ b/RegExpSupport/testData/psi/CategoryShorthand1.txt @@ -0,0 +1,6 @@ +REGEXP_FILE + RegExpPatternImpl: <\pL> + RegExpBranchImpl: <\pL> + RegExpPropertyImpl: <\pL> + PsiElement(PROPERTY)('\p') + PsiElement(CATEGORY_SHORT_HAND)('L') \ No newline at end of file diff --git a/RegExpSupport/testData/psi/CategoryShorthand2.txt b/RegExpSupport/testData/psi/CategoryShorthand2.txt new file mode 100644 index 000000000000..0ed54e7ffe0f --- /dev/null +++ b/RegExpSupport/testData/psi/CategoryShorthand2.txt @@ -0,0 +1,8 @@ +REGEXP_FILE + RegExpPatternImpl: <\pL> + RegExpBranchImpl: <\pL> + RegExpPropertyImpl: <\pL> + PsiElement(PROPERTY)('\p') + PsiErrorElement:Category shorthand not allowed in this regular expression dialect + + PsiElement(CATEGORY_SHORT_HAND)('L') \ No newline at end of file diff --git a/RegExpSupport/testData/psi/DanglingMetaCharacter1.txt b/RegExpSupport/testData/psi/DanglingMetaCharacter1.txt new file mode 100644 index 000000000000..e0d7a18360da --- /dev/null +++ b/RegExpSupport/testData/psi/DanglingMetaCharacter1.txt @@ -0,0 +1,5 @@ +REGEXP_FILE + RegExpPatternImpl: <{> + RegExpBranchImpl: <{> + RegExpCharImpl: <{> + PsiElement(CHARACTER)('{') \ No newline at end of file diff --git a/RegExpSupport/testData/psi/DanglingMetaCharacter2.txt b/RegExpSupport/testData/psi/DanglingMetaCharacter2.txt new file mode 100644 index 000000000000..9bc38c167606 --- /dev/null +++ b/RegExpSupport/testData/psi/DanglingMetaCharacter2.txt @@ -0,0 +1,9 @@ +REGEXP_FILE + RegExpPatternImpl: + RegExpBranchImpl: + RegExpCharImpl: + PsiElement(CHARACTER)('a') + RegExpCharImpl: <{> + PsiElement(CHARACTER)('{') + RegExpCharImpl: + PsiElement(CHARACTER)('a') \ No newline at end of file diff --git a/RegExpSupport/testData/psi/DanglingMetaCharacters3.txt b/RegExpSupport/testData/psi/DanglingMetaCharacters3.txt new file mode 100644 index 000000000000..6924d84d2353 --- /dev/null +++ b/RegExpSupport/testData/psi/DanglingMetaCharacters3.txt @@ -0,0 +1,84 @@ +REGEXP_FILE + RegExpPatternImpl: <{{E1:\s*(?P([^\n]+\+)?[0-9]+)( *\|[^\n]*)?}}> + RegExpBranchImpl: <{{E1:\s*(?P([^\n]+\+)?[0-9]+)( *\|[^\n]*)?}}> + RegExpCharImpl: <{> + PsiElement(CHARACTER)('{') + RegExpCharImpl: <{> + PsiElement(CHARACTER)('{') + RegExpCharImpl: + PsiElement(CHARACTER)('E') + RegExpCharImpl: <1> + PsiElement(CHARACTER)('1') + RegExpCharImpl: <:> + PsiElement(CHARACTER)(':') + RegExpClosureImpl: <\s*> + RegExpSimpleClassImpl: <\s> + PsiElement(CHAR_CLASS)('\s') + RegExpQuantifierImpl: <*> + PsiElement(STAR)('*') + RegExpGroupImpl: <(?P([^\n]+\+)?[0-9]+)> + PsiElement(PYTHON_NAMED_GROUP)('(?P<') + PsiElement(NAME)('ref') + PsiElement(GT)('>') + RegExpPatternImpl: <([^\n]+\+)?[0-9]+> + RegExpBranchImpl: <([^\n]+\+)?[0-9]+> + RegExpClosureImpl: <([^\n]+\+)?> + RegExpGroupImpl: <([^\n]+\+)> + PsiElement(GROUP_BEGIN)('(') + RegExpPatternImpl: <[^\n]+\+> + RegExpBranchImpl: <[^\n]+\+> + RegExpClosureImpl: <[^\n]+> + RegExpClassImpl: <[^\n]> + PsiElement(CLASS_BEGIN)('[') + PsiElement(CARET)('^') + RegExpCharImpl: <\n> + PsiElement(ESC_CTRL_CHARACTER)('\n') + PsiElement(CLASS_END)(']') + RegExpQuantifierImpl: <+> + PsiElement(PLUS)('+') + RegExpCharImpl: <\+> + PsiElement(ESC_CHARACTER)('\+') + PsiElement(GROUP_END)(')') + RegExpQuantifierImpl: + PsiElement(QUEST)('?') + RegExpClosureImpl: <[0-9]+> + RegExpClassImpl: <[0-9]> + PsiElement(CLASS_BEGIN)('[') + RegExpCharRangeImpl: <0-9> + RegExpCharImpl: <0> + PsiElement(CHARACTER)('0') + PsiElement(MINUS)('-') + RegExpCharImpl: <9> + PsiElement(CHARACTER)('9') + PsiElement(CLASS_END)(']') + RegExpQuantifierImpl: <+> + PsiElement(PLUS)('+') + PsiElement(GROUP_END)(')') + RegExpClosureImpl: <( *\|[^\n]*)?> + RegExpGroupImpl: <( *\|[^\n]*)> + PsiElement(GROUP_BEGIN)('(') + RegExpPatternImpl: < *\|[^\n]*> + RegExpBranchImpl: < *\|[^\n]*> + RegExpClosureImpl: < *> + RegExpCharImpl: < > + PsiElement(CHARACTER)(' ') + RegExpQuantifierImpl: <*> + PsiElement(STAR)('*') + RegExpCharImpl: <\|> + PsiElement(ESC_CHARACTER)('\|') + RegExpClosureImpl: <[^\n]*> + RegExpClassImpl: <[^\n]> + PsiElement(CLASS_BEGIN)('[') + PsiElement(CARET)('^') + RegExpCharImpl: <\n> + PsiElement(ESC_CTRL_CHARACTER)('\n') + PsiElement(CLASS_END)(']') + RegExpQuantifierImpl: <*> + PsiElement(STAR)('*') + PsiElement(GROUP_END)(')') + RegExpQuantifierImpl: + PsiElement(QUEST)('?') + RegExpCharImpl: <}> + PsiElement(CHARACTER)('}') + RegExpCharImpl: <}> + PsiElement(CHARACTER)('}') \ No newline at end of file diff --git a/RegExpSupport/testData/psi/Groups40.txt b/RegExpSupport/testData/psi/Groups40.txt new file mode 100644 index 000000000000..7aa164983d9f --- /dev/null +++ b/RegExpSupport/testData/psi/Groups40.txt @@ -0,0 +1,38 @@ +REGEXP_FILE + RegExpPatternImpl: <(?(name)yes-pattern|{> + RegExpBranchImpl: <(?(name)yes-pattern|{> + RegExpClosureImpl: <(?(name)yes-pattern|{> + RegExpPyCondRefImpl: <(?(name)yes-pattern|> + PsiElement(PYTHON_COND_REF)('(?(') + PsiElement(NAME)('name') + PsiElement(GROUP_END)(')') + RegExpBranchImpl: + RegExpCharImpl: + PsiElement(CHARACTER)('y') + RegExpCharImpl: + PsiElement(CHARACTER)('e') + RegExpCharImpl: + PsiElement(CHARACTER)('s') + RegExpCharImpl: <-> + PsiElement(MINUS)('-') + RegExpCharImpl:

+ PsiElement(CHARACTER)('p') + RegExpCharImpl: + PsiElement(CHARACTER)('a') + RegExpCharImpl: + PsiElement(CHARACTER)('t') + RegExpCharImpl: + PsiElement(CHARACTER)('t') + RegExpCharImpl: + PsiElement(CHARACTER)('e') + RegExpCharImpl: + PsiElement(CHARACTER)('r') + RegExpCharImpl: + PsiElement(CHARACTER)('n') + PsiElement(UNION)('|') + PsiErrorElement:Dangling metacharacter + + RegExpQuantifierImpl: <{> + PsiElement(LBRACE)('{') + PsiErrorElement:Number expected + \ No newline at end of file diff --git a/RegExpSupport/testData/psi/Namedchars14.txt b/RegExpSupport/testData/psi/Namedchars14.txt new file mode 100644 index 000000000000..32f06116addb --- /dev/null +++ b/RegExpSupport/testData/psi/Namedchars14.txt @@ -0,0 +1,11 @@ +REGEXP_FILE + RegExpPatternImpl: <[\N{Mahjong Tile Winter}]> + RegExpBranchImpl: <[\N{Mahjong Tile Winter}]> + RegExpClassImpl: <[\N{Mahjong Tile Winter}]> + PsiElement(CLASS_BEGIN)('[') + RegExpNamedCharacterImpl: <\N{Mahjong Tile Winter}> + PsiElement(NAMED_CHARACTER)('\N') + PsiElement(LBRACE)('{') + PsiElement(NAME)('Mahjong Tile Winter') + PsiElement(RBRACE)('}') + PsiElement(CLASS_END)(']') \ No newline at end of file diff --git a/RegExpSupport/testData/psi/OmitNumberInQuantifier.txt b/RegExpSupport/testData/psi/OmitNumberInQuantifier.txt new file mode 100644 index 000000000000..461b9d456518 --- /dev/null +++ b/RegExpSupport/testData/psi/OmitNumberInQuantifier.txt @@ -0,0 +1,11 @@ +REGEXP_FILE + RegExpPatternImpl: + RegExpBranchImpl: + RegExpClosureImpl: + RegExpCharImpl: + PsiElement(CHARACTER)('a') + RegExpQuantifierImpl: <{,3}> + PsiElement(LBRACE)('{') + PsiElement(COMMA)(',') + PsiElement(NUMBER)('3') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/RegExpSupport/testData/psi/PosixBracketExpression1.txt b/RegExpSupport/testData/psi/PosixBracketExpression1.txt new file mode 100644 index 000000000000..4a983b5060fe --- /dev/null +++ b/RegExpSupport/testData/psi/PosixBracketExpression1.txt @@ -0,0 +1,10 @@ +REGEXP_FILE + RegExpPatternImpl: <[[:alpha:]]> + RegExpBranchImpl: <[[:alpha:]]> + RegExpClassImpl: <[[:alpha:]]> + PsiElement(CLASS_BEGIN)('[') + RegExpPosixBracketExpressionImpl: <[:alpha:]> + PsiElement(BRACKET_EXPRESSION_BEGIN)('[:') + PsiElement(NAME)('alpha') + PsiElement(BRACKET_EXPRESSION_END)(':]') + PsiElement(CLASS_END)(']') \ No newline at end of file diff --git a/RegExpSupport/testData/psi/PosixBracketExpression2.txt b/RegExpSupport/testData/psi/PosixBracketExpression2.txt new file mode 100644 index 000000000000..b4f40d64f753 --- /dev/null +++ b/RegExpSupport/testData/psi/PosixBracketExpression2.txt @@ -0,0 +1,11 @@ +REGEXP_FILE + RegExpPatternImpl: <[[:^alpha:]]> + RegExpBranchImpl: <[[:^alpha:]]> + RegExpClassImpl: <[[:^alpha:]]> + PsiElement(CLASS_BEGIN)('[') + RegExpPosixBracketExpressionImpl: <[:^alpha:]> + PsiElement(BRACKET_EXPRESSION_BEGIN)('[:') + PsiElement(CARET)('^') + PsiElement(NAME)('alpha') + PsiElement(BRACKET_EXPRESSION_END)(':]') + PsiElement(CLASS_END)(']') \ No newline at end of file diff --git a/RegExpSupport/testData/psi/Simple21.txt b/RegExpSupport/testData/psi/Simple21.txt index c9021407c61a..1b2b14565e72 100644 --- a/RegExpSupport/testData/psi/Simple21.txt +++ b/RegExpSupport/testData/psi/Simple21.txt @@ -1,6 +1,6 @@ REGEXP_FILE - RegExpPatternImpl: - RegExpBranchImpl: + RegExpPatternImpl: + RegExpBranchImpl: RegExpClosureImpl: RegExpCharImpl: PsiElement(CHARACTER)('a') @@ -10,7 +10,11 @@ REGEXP_FILE PsiElement(COMMA)(',') PsiErrorElement:'}' or number expected - PsiElement(NAME)('foo') - PsiErrorElement:Pattern expected - - PsiElement(RBRACE)('}') \ No newline at end of file + RegExpCharImpl: + PsiElement(CHARACTER)('f') + RegExpCharImpl: + PsiElement(CHARACTER)('o') + RegExpCharImpl: + PsiElement(CHARACTER)('o') + RegExpCharImpl: <}> + PsiElement(CHARACTER)('}') \ No newline at end of file diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/testOnly/TestOnlyInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/testOnly/TestOnlyInspection.java index 9b6c54797b6e..d90d84581a04 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/testOnly/TestOnlyInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/testOnly/TestOnlyInspection.java @@ -59,6 +59,14 @@ public class TestOnlyInspection extends BaseJavaBatchLocalInspectionTool { validate(e, e.resolveMethod(), h); } + @Override + public void visitMethodReferenceExpression(PsiMethodReferenceExpression expression) { + PsiElement resolve = expression.resolve(); + if (resolve instanceof PsiMethod) { + validate(expression, (PsiMethod)resolve, h); + } + } + @Override public void visitReferenceExpression(PsiReferenceExpression reference) { PsiElement resolve = reference.resolve(); diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateConstructorHandler.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateConstructorHandler.java index be0fcadea2eb..5328635a459f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateConstructorHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateConstructorHandler.java @@ -193,7 +193,9 @@ public class GenerateConstructorHandler extends GenerateMembersHandlerBase { private static List filterOutAlreadyInsertedConstructors(PsiClass aClass, List constructors) { boolean alreadyExist = true; for (GenerationInfo constructor : constructors) { - alreadyExist &= aClass.findMethodBySignature((PsiMethod)constructor.getPsiMember(), false) != null; + PsiMethod existingMethod = aClass.findMethodBySignature((PsiMethod)constructor.getPsiMember(), false); + + alreadyExist &= existingMethod != null && existingMethod.isPhysical(); } if (alreadyExist) { return Collections.emptyList(); diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateEqualsHandler.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateEqualsHandler.java index 55e6aac1da51..2917b83b8368 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateEqualsHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateEqualsHandler.java @@ -57,8 +57,8 @@ public class GenerateEqualsHandler extends GenerateMembersHandlerBase { final PsiMethod equalsMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getEqualsSignature(project, scope)); final PsiMethod hashCodeMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getHashCodeSignature()); - boolean needEquals = equalsMethod == null; - boolean needHashCode = hashCodeMethod == null; + boolean needEquals = needToGenerateMethod(equalsMethod); + boolean needHashCode = needToGenerateMethod(hashCodeMethod); if (!needEquals && !needHashCode) { String text = aClass instanceof PsiAnonymousClass ? CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning.anonymous") @@ -107,6 +107,10 @@ public class GenerateEqualsHandler extends GenerateMembersHandlerBase { return DUMMY_RESULT; } + static boolean needToGenerateMethod(PsiMethod equalsMethod) { + return equalsMethod == null || !equalsMethod.isPhysical(); + } + private static boolean hasNonStaticFields(PsiClass aClass) { for (PsiField field : aClass.getFields()) { if (!field.hasModifierProperty(PsiModifier.STATIC)) { diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateEqualsHelper.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateEqualsHelper.java index 759cb8b993c3..f2759656e989 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateEqualsHelper.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateEqualsHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package com.intellij.codeInsight.generation; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Pair; import com.intellij.psi.*; import com.intellij.psi.codeStyle.*; import com.intellij.psi.search.GlobalSearchScope; @@ -113,12 +112,12 @@ public class GenerateEqualsHelper implements Runnable { public Collection generateMembers() throws IncorrectOperationException { PsiMethod equals = null; - if (myEqualsFields != null && findMethod(myClass, getEqualsSignature(myProject, myClass.getResolveScope())) == null) { + if (myEqualsFields != null && GenerateEqualsHandler.needToGenerateMethod(findMethod(myClass, getEqualsSignature(myProject, myClass.getResolveScope())))) { equals = createEquals(); } PsiMethod hashCode = null; - if (myHashCodeFields != null && findMethod(myClass, getHashCodeSignature()) == null) { + if (myHashCodeFields != null && GenerateEqualsHandler.needToGenerateMethod(findMethod(myClass, getHashCodeSignature()))) { if (myHashCodeFields.length > 0) { hashCode = createHashCode(); } diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/PsiFieldMember.java b/java/java-impl/src/com/intellij/codeInsight/generation/PsiFieldMember.java index 6fac08ec8600..f318681b0541 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/PsiFieldMember.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/PsiFieldMember.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,6 +86,6 @@ public class PsiFieldMember extends PsiElementClassMember implements P @Nullable private static PsiMethod createMethodIfNotExists(PsiClass aClass, final PsiMethod template) { PsiMethod existing = aClass.findMethodBySignature(template, false); - return existing == null ? template : null; + return existing == null || !existing.isPhysical() ? template : null; } } diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/PsiGenerationInfo.java b/java/java-impl/src/com/intellij/codeInsight/generation/PsiGenerationInfo.java index 6b9ee11a6cde..756155aadd2f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/PsiGenerationInfo.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/PsiGenerationInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class PsiGenerationInfo extends GenerationInfoBase i else { existingMember = null; } - if (existingMember == null || !myMergeIfExists) { + if (existingMember == null || !existingMember.isPhysical() || !myMergeIfExists) { PsiElement newMember = GenerateMembersUtil.insert(aClass, myMember, anchor, before); myMember = (T)JavaCodeStyleManager.getInstance(aClass.getProject()).shortenClassReferences(newMember); LOG.assertTrue(myMember.isValid(), myMember); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateToStringTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateToStringTest.java index 3f7082139ee0..23636d272e4a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateToStringTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateToStringTest.java @@ -22,6 +22,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.testFramework.LightCodeInsightTestCase; import org.jetbrains.java.generate.GenerateToStringWorker; +import org.jetbrains.java.generate.config.ReplacePolicy; import org.jetbrains.java.generate.template.TemplateResource; import java.util.Collections; @@ -44,7 +45,8 @@ public class GenerateToStringTest extends LightCodeInsightTestCase { final PsiClass clazz = PsiTreeUtil.getParentOfType(elementAt, PsiClass.class); assertNotNull(clazz); WriteAction.run(() -> { - new GenerateToStringWorker(clazz, editor, false).execute(Collections.emptyList(), templateResource); + final GenerateToStringWorker worker = new GenerateToStringWorker(clazz, editor, false); + worker.execute(Collections.emptyList(), templateResource, ReplacePolicy.getInstance()); }); checkResultByFile("/codeInsight/generateToString/after" + getTestName(false) + ".java"); } diff --git a/platform/lang-impl/src/com/intellij/application/options/DefaultSchemeActions.java b/platform/lang-impl/src/com/intellij/application/options/DefaultSchemeActions.java index 30067598dd3e..060ba5029f22 100644 --- a/platform/lang-impl/src/com/intellij/application/options/DefaultSchemeActions.java +++ b/platform/lang-impl/src/com/intellij/application/options/DefaultSchemeActions.java @@ -81,6 +81,13 @@ public abstract class DefaultSchemeActions { public void actionPerformed(AnActionEvent e) { doReset(); } + + @Override + public void update(AnActionEvent e) { + Presentation p = e.getPresentation(); + T currentScheme = getCurrentScheme(); + p.setEnabled(currentScheme != null && isResetAvailable(currentScheme)); + } } @@ -188,6 +195,10 @@ public abstract class DefaultSchemeActions { protected abstract boolean isDeleteAvailable(@NotNull T scheme); + protected boolean isResetAvailable(@NotNull T scheme) { + return true; + } + protected abstract void doExport(@NotNull T scheme, @NotNull String exporterName); @Nullable diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorSchemeActions.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorSchemeActions.java new file mode 100644 index 000000000000..4e9903ff224e --- /dev/null +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorSchemeActions.java @@ -0,0 +1,128 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.application.options.colors; + +import com.intellij.application.options.DefaultSchemeActions; +import com.intellij.application.options.SaveSchemeDialog; +import com.intellij.openapi.application.ApplicationBundle; +import com.intellij.openapi.editor.colors.EditorColorsScheme; +import com.intellij.openapi.editor.colors.impl.AbstractColorsScheme; +import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl; +import com.intellij.openapi.editor.colors.impl.EmptyColorScheme; +import com.intellij.openapi.editor.colors.impl.ReadOnlyColorsScheme; +import com.intellij.openapi.options.*; +import com.intellij.openapi.project.DefaultProjectFactory; +import com.intellij.openapi.ui.MessageType; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.util.List; + +public abstract class ColorSchemeActions extends DefaultSchemeActions { + private final ColorAndFontOptions myOptions; + private JComponent myParentComponent; + + public ColorSchemeActions(@NotNull JComponent parentComponent, @NotNull ColorAndFontOptions options) { + myOptions = options; + myParentComponent = parentComponent; + } + + @Override + protected void doImport(@NotNull String importerName) { + final SchemeImporter importer = SchemeImporterEP.getImporter(importerName, EditorColorsScheme.class); + if (importer != null) { + VirtualFile importSource = SchemeImportUtil.selectImportSource(importer.getSourceExtensions(), myParentComponent, null); + if (importSource != null) { + try { + EditorColorsScheme imported = + importer.importScheme(DefaultProjectFactory.getInstance().getDefaultProject(), importSource, myOptions.getSelectedScheme(), + name -> { + String newName = myOptions.getUniqueName(name != null ? name : "Unnamed"); + AbstractColorsScheme newScheme = new EditorColorsSchemeImpl(EmptyColorScheme.INSTANCE); + newScheme.setName(newName); + newScheme.setDefaultMetaInfo(EmptyColorScheme.INSTANCE); + return newScheme; + }); + if (imported != null) { + myOptions.addImportedScheme(imported); + } + } + catch (SchemeImportException e) { + SchemeImportUtil.showStatus(myParentComponent, "Import failed: " + e.getMessage(), MessageType.ERROR); + } + } + } + } + + @Override + protected void doReset() { + EditorColorsScheme currentScheme = getCurrentScheme(); + if (currentScheme != null) { + if (Messages + .showOkCancelDialog(ApplicationBundle.message("color.scheme.reset.message"), + ApplicationBundle.message("color.scheme.reset.title"), Messages.getQuestionIcon()) == Messages.OK) { + myOptions.resetSchemeToOriginal(currentScheme.getName()); + } + } + } + + @Override + protected void doSaveAs() { + List names = ContainerUtil.newArrayList(myOptions.getSchemeNames()); + String selectedName = AbstractColorsScheme.getDisplayName(myOptions.getSelectedScheme()); + SaveSchemeDialog dialog = + new SaveSchemeDialog(myParentComponent, ApplicationBundle.message("title.save.color.scheme.as"), names, selectedName); + if (dialog.showAndGet()) { + myOptions.saveSchemeAs(dialog.getSchemeName()); + } + } + + @Override + protected void doDelete() { + EditorColorsScheme currentScheme = getCurrentScheme(); + if (currentScheme != null) { + myOptions.removeScheme(currentScheme.getName()); + } + } + + @Override + protected boolean isDeleteAvailable(@NotNull EditorColorsScheme scheme) { + return !ColorAndFontOptions.isReadOnly(scheme) && ColorAndFontOptions.canBeDeleted(scheme); + } + + @Override + protected boolean isResetAvailable(@NotNull EditorColorsScheme scheme) { + AbstractColorsScheme originalScheme = + scheme instanceof AbstractColorsScheme ? ((AbstractColorsScheme)scheme).getOriginal() : null; + return + !ColorAndFontOptions.isReadOnly(scheme) && + scheme.getName().startsWith(SchemeManager.EDITABLE_COPY_PREFIX) && + originalScheme instanceof ReadOnlyColorsScheme; + } + + @Override + protected void doExport(@NotNull EditorColorsScheme scheme, @NotNull String exporterName) { + // Unsupported for now. + } + + @Override + protected Class getSchemeType() { + return EditorColorsScheme.class; + } +} diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java b/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java index ea5812a23553..699970f53884 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java @@ -16,24 +16,14 @@ package com.intellij.application.options.colors; -import com.intellij.application.options.ImportSourceChooserDialog; -import com.intellij.application.options.SaveSchemeDialog; import com.intellij.application.options.SkipSelfSearchComponent; import com.intellij.openapi.application.ApplicationBundle; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.impl.AbstractColorsScheme; -import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl; -import com.intellij.openapi.editor.colors.impl.EmptyColorScheme; -import com.intellij.openapi.editor.colors.impl.ReadOnlyColorsScheme; import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.options.*; -import com.intellij.openapi.project.DefaultProjectFactory; import com.intellij.openapi.ui.ComboBox; -import com.intellij.openapi.ui.MessageType; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.ui.ManageSchemesComboAction; import com.intellij.util.EventDispatcher; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBInsets; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -42,16 +32,12 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.List; public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { private final ColorAndFontOptions myOptions; private ComboBox mySchemeComboBox; - - private JButton myDeleteButton; - private JButton myResetButton; - private JButton myImportButton; + private JLabel myHintLabel; private final EventDispatcher myDispatcher = EventDispatcher.create(ColorAndFontSettingsListener.class); @@ -73,18 +59,10 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { String selectedName = getSelectedSchemeName(); if (selectedName != null) { EditorColorsScheme selected = myOptions.selectScheme(selectedName); - final boolean readOnly = ColorAndFontOptions.isReadOnly(selected); - myDeleteButton.setEnabled(!readOnly && ColorAndFontOptions.canBeDeleted(selected)); - myHintLabel.setVisible(readOnly); + myHintLabel.setVisible(ColorAndFontOptions.isReadOnly(selected)); if (areSchemesLoaded()) { myDispatcher.getMulticaster().schemeChanged(SchemesPanel.this); } - AbstractColorsScheme originalScheme = - selected instanceof AbstractColorsScheme ? ((AbstractColorsScheme)selected).getOriginal() : null; - myResetButton.setEnabled( - !readOnly && - selectedName.startsWith(SchemeManager.EDITABLE_COPY_PREFIX) && - originalScheme instanceof ReadOnlyColorsScheme); } } }); @@ -107,61 +85,20 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { mySchemeComboBox = new ComboBox<>(); panel.add(mySchemeComboBox, - new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new JBInsets(0, 0, 5, 10), + new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new JBInsets(0, 0, 5, 10), 0, 0)); - - JButton saveAsButton = new JButton(ApplicationBundle.message("button.save.as")); - saveAsButton.addActionListener(new ActionListener() { + ManageSchemesComboAction schemesComboAction = new ManageSchemesComboAction(new ColorSchemeActions(this, myOptions) { + @Nullable @Override - public void actionPerformed(@NotNull ActionEvent e) { - showSaveAsDialog(); + protected EditorColorsScheme getCurrentScheme() { + return myOptions.getScheme(getSelectedSchemeName()); } }); - panel.add(saveAsButton, - new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new JBInsets(0, 0, 5, 5), + JButton manageButton = schemesComboAction.createCombo(); + panel.add(manageButton, + new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new JBInsets(0, 0, 5, 5), 0, 0)); - - myDeleteButton = new JButton(ApplicationBundle.message("button.delete")); - myDeleteButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(@NotNull ActionEvent e) { - String selectedName = getSelectedSchemeName(); - if (selectedName != null) { - myOptions.removeScheme(selectedName); - } - } - }); - panel.add(myDeleteButton, - new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new JBInsets(0, 0, 5, 5), 0, - 0)); - myResetButton = new JButton(ApplicationBundle.message("color.scheme.reset")); - myResetButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(@NotNull ActionEvent e) { - String selectedName = getSelectedSchemeName(); - if (selectedName != null) { - if (Messages - .showOkCancelDialog(ApplicationBundle.message("color.scheme.reset.message"), - ApplicationBundle.message("color.scheme.reset.title"), Messages.getQuestionIcon()) == Messages.OK) { - myOptions.resetSchemeToOriginal(selectedName); - } - } - } - }); - panel.add(myResetButton, - new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new JBInsets(0, 0, 5, 5), 0, - 0)); - myImportButton = new JButton("Import..."); - myImportButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - chooseAndImport(); - } - }); - myImportButton.setVisible(isImportAvailable()); - panel.add(myImportButton, - new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new JBInsets(0, 0, 5, 5), 0, - 0)); + myHintLabel = new JLabel(ApplicationBundle.message("hint.readonly.scheme.cannot.be.modified")); myHintLabel.setEnabled(false); panel.add(myHintLabel, @@ -189,15 +126,6 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { return panel; } - private void showSaveAsDialog() { - List names = ContainerUtil.newArrayList(myOptions.getSchemeNames()); - String selectedName = AbstractColorsScheme.getDisplayName(myOptions.getSelectedScheme()); - SaveSchemeDialog dialog = new SaveSchemeDialog(this, ApplicationBundle.message("title.save.color.scheme.as"), names, selectedName); - if (dialog.showAndGet()) { - myOptions.saveSchemeAs(dialog.getSchemeName()); - } - } - @Deprecated public boolean updateDescription(boolean modified) { EditorColorsScheme scheme = myOptions.getSelectedScheme(); @@ -245,44 +173,6 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { myDispatcher.addListener(listener); } - private void chooseAndImport() { - ImportSourceChooserDialog importSourceChooserDialog = - new ImportSourceChooserDialog<>(this, EditorColorsScheme.class); - if (importSourceChooserDialog.showAndGet()) { - final String selectedImporterName = importSourceChooserDialog.getSelectedSourceName(); - if (selectedImporterName != null) { - final SchemeImporter importer = SchemeImporterEP.getImporter(selectedImporterName, EditorColorsScheme.class); - if (importer != null) { - VirtualFile importSource = SchemeImportUtil.selectImportSource(importer.getSourceExtensions(), this, null); - if (importSource != null) { - try { - EditorColorsScheme imported = - importer.importScheme(DefaultProjectFactory.getInstance().getDefaultProject(), importSource, myOptions.getSelectedScheme(), - name -> { - String newName = myOptions.getUniqueName(name); - AbstractColorsScheme newScheme = new EditorColorsSchemeImpl(EmptyColorScheme.INSTANCE); - newScheme.setName(newName); - newScheme.setDefaultMetaInfo(EmptyColorScheme.INSTANCE); - return newScheme; - }); - if (imported != null) { - myOptions.addImportedScheme(imported); - } - - } - catch (SchemeImportException e) { - SchemeImportUtil.showStatus(myImportButton, "Import failed: " + e.getMessage(), MessageType.ERROR); - } - } - } - } - } - } - - private static boolean isImportAvailable() { - return !SchemeImporterEP.getExtensions(EditorColorsScheme.class).isEmpty(); - } - private final static class MySchemeItem { private EditorColorsScheme myScheme; diff --git a/platform/platform-api/src/com/intellij/ui/content/TabbedContent.java b/platform/platform-api/src/com/intellij/ui/content/TabbedContent.java index f473229b6c46..f3606dac8238 100644 --- a/platform/platform-api/src/com/intellij/ui/content/TabbedContent.java +++ b/platform/platform-api/src/com/intellij/ui/content/TabbedContent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,6 @@ public interface TabbedContent extends Content { void addContent(@NotNull JComponent content, @NotNull String name, boolean selectTab); void removeContent(@NotNull JComponent content); - void renameContent(@NotNull JComponent tab, @NotNull String newTabName); void selectContent(int index); List> getTabs(); String getTitlePrefix(); diff --git a/platform/platform-impl/src/com/intellij/openapi/application/ClipboardAnalyzeListener.java b/platform/platform-impl/src/com/intellij/openapi/application/ClipboardAnalyzeListener.java index 40976e67ff8b..b1a95cd77f4a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/ClipboardAnalyzeListener.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/ClipboardAnalyzeListener.java @@ -18,7 +18,6 @@ package com.intellij.openapi.application; import com.intellij.Patches; import com.intellij.openapi.application.ex.ClipboardUtil; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.wm.IdeFrame; import com.intellij.util.Alarm; import org.jetbrains.annotations.NotNull; @@ -54,7 +53,6 @@ public abstract class ClipboardAnalyzeListener extends ApplicationActivationList @Override public void applicationDeactivated(IdeFrame ideFrame) { - if (SystemInfo.isMac) return; myCachedClipboardValue = ClipboardUtil.getTextInClipboard(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/textarea/TextComponentSelectionModel.java b/platform/platform-impl/src/com/intellij/openapi/editor/textarea/TextComponentSelectionModel.java index feec65f524da..a4fa28a9f466 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/textarea/TextComponentSelectionModel.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/textarea/TextComponentSelectionModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import com.intellij.openapi.editor.markup.TextAttributes; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import javax.swing.text.JTextComponent; /** @@ -160,7 +161,9 @@ public class TextComponentSelectionModel implements SelectionModel { @Override public void copySelectionToClipboard() { - EditorCopyPasteHelper.getInstance().copySelectionToClipboard(myEditor); + if (! (myTextComponent instanceof JPasswordField)) { + EditorCopyPasteHelper.getInstance().copySelectionToClipboard(myEditor); + } } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/BaseLabel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/BaseLabel.java index 001c425d5416..d5e16d371260 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/BaseLabel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/BaseLabel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package com.intellij.openapi.wm.impl.content; import com.intellij.ide.ui.AntialiasingType; -import com.intellij.openapi.util.Iconable; import com.intellij.openapi.wm.ToolWindow; import com.intellij.ui.EngravedTextGraphics; import com.intellij.ui.Gray; @@ -114,18 +113,13 @@ public class BaseLabel extends JLabel { setToolTipText(content.getDescription()); - final boolean show = Boolean.TRUE.equals(content.getUserData(ToolWindow.SHOW_CONTENT_ICON)) - || content.getComponent() instanceof Iconable; - Icon icon = content.getIcon(); - if (content.getComponent() instanceof Iconable) { // handling tabbed content after 'split group' action - icon = ((Iconable)content.getComponent()).getIcon(Iconable.ICON_FLAG_VISIBILITY); - } + final boolean show = Boolean.TRUE.equals(content.getUserData(ToolWindow.SHOW_CONTENT_ICON)); if (show) { if (isSelected) { - setIcon(icon); + setIcon(content.getIcon()); } else { - setIcon(icon != null ? new WatermarkIcon(icon, .5f) : null); + setIcon(content.getIcon() != null ? new WatermarkIcon(content.getIcon(), .5f) : null); } } else { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/TabbedContentTabLabel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/TabbedContentTabLabel.java index 3b03307e5637..7537e337e5ba 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/TabbedContentTabLabel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/TabbedContentTabLabel.java @@ -19,19 +19,14 @@ import com.intellij.ide.IdeEventQueue; import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.Iconable; import com.intellij.openapi.util.Pair; import com.intellij.reference.SoftReference; import com.intellij.ui.ClickListener; import com.intellij.ui.components.JBList; import com.intellij.ui.content.TabbedContent; -import com.intellij.util.ContentUtilEx; import com.intellij.util.NotNullFunction; -import com.intellij.util.ui.EmptyIcon; import com.intellij.util.ui.UIUtil; -import com.intellij.util.ui.WatermarkIcon; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -57,7 +52,7 @@ public class TabbedContentTabLabel extends ContentTabLabel { } }; private final TabbedContent myContent; - @Nullable private Reference myPopupReference = null; + private Reference myPopupReference = null; public TabbedContentTabLabel(TabbedContent content, TabContentLayout layout) { super(content, layout); @@ -73,7 +68,7 @@ public class TabbedContentTabLabel extends ContentTabLabel { private void showPopup() { IdeEventQueue.getInstance().getPopupManager().closeAllPopups(); - ArrayList names = new ArrayList<>(); + ArrayList names = new ArrayList(); for (Pair tab : myContent.getTabs()) { names.add(tab.first); } @@ -86,9 +81,7 @@ public class TabbedContentTabLabel extends ContentTabLabel { @NotNull @Override public JComponent fun(Object dom) { - String tabName = dom.toString(); - label.setText(tabName); - setIconInPopupLabel(label, tabName); + label.setText(dom.toString()); return label; } }); @@ -99,67 +92,19 @@ public class TabbedContentTabLabel extends ContentTabLabel { myContent.selectContent(index); } }).createPopup(); - myPopupReference = new WeakReference<>(popup); + myPopupReference = new WeakReference(popup); popup.showUnderneathOf(this); } - private void setIconInPopupLabel(JLabel label, String tabName) { - Icon baseIcon = getBaseIcon(); - boolean hasIconsInTabs = baseIcon != null; - for (Pair nextTabWithName : myContent.getTabs()) { - if (nextTabWithName.getFirst().equals(tabName)) { - JComponent tab = nextTabWithName.getSecond(); - Icon tabIcon = null; - if (tab instanceof Iconable) { - tabIcon = ((Iconable)tab).getIcon(Iconable.ICON_FLAG_VISIBILITY); - if (hasIconsInTabs && tabIcon == null) { - tabIcon = EmptyIcon.create(baseIcon); - } - } - label.setIcon(tabIcon); - } - } - } - - @Nullable - private Icon getBaseIcon() { - Icon baseIcon = null; - for (Pair nextTabWithName : myContent.getTabs()) { - JComponent tabComponent = nextTabWithName.getSecond(); - if (tabComponent instanceof Iconable) { - Icon tabIcon = ((Iconable)tabComponent).getIcon(Iconable.ICON_FLAG_VISIBILITY); - if (tabIcon != null) { - baseIcon = tabIcon; - break; - } - } - } - return baseIcon; - } - @Override public void update() { super.update(); if (myContent != null) { - String tabName = myContent.getTabName(); - setText(tabName); - setTabIcon(tabName, this); + setText(myContent.getTabName()); } setHorizontalAlignment(LEFT); } - private void setTabIcon(String tabName, JLabel jLabel) { - for (Pair nextTabWithName : myContent.getTabs()) { - if (tabName != null && nextTabWithName.getFirst().equals(ContentUtilEx.getTabNameWithoutPrefix(myContent, tabName))) { - JComponent tab = nextTabWithName.getSecond(); - if (tab instanceof Iconable) { - Icon baseIcon = ((Iconable)tab).getIcon(Iconable.ICON_FLAG_VISIBILITY); - jLabel.setIcon(isSelected() || baseIcon == null ? baseIcon : new WatermarkIcon(baseIcon, .5f)); - } - } - } - } - @Override public Dimension getPreferredSize() { final Dimension size = super.getPreferredSize(); diff --git a/platform/platform-impl/src/com/intellij/ui/content/impl/TabbedContentImpl.java b/platform/platform-impl/src/com/intellij/ui/content/impl/TabbedContentImpl.java index a9e3af62790d..cd52c0383806 100644 --- a/platform/platform-impl/src/com/intellij/ui/content/impl/TabbedContentImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/content/impl/TabbedContentImpl.java @@ -17,12 +17,10 @@ package com.intellij.ui.content.impl; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.Iconable; import com.intellij.openapi.util.Pair; import com.intellij.ui.content.ContentManager; import com.intellij.ui.content.TabbedContent; import com.intellij.util.ContentUtilEx; -import com.intellij.util.ui.WatermarkIcon; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -35,7 +33,7 @@ import java.util.List; * @author Konstantin Bulenkov */ public class TabbedContentImpl extends ContentImpl implements TabbedContent { - private final List> myTabs = new ArrayList<>(); + private final List> myTabs = new ArrayList>(); private String myPrefix; public TabbedContentImpl(JComponent component, String displayName, boolean isPinnable, String titlePrefix) { @@ -86,25 +84,6 @@ public class TabbedContentImpl extends ContentImpl implements TabbedContent { } } - @Override - public void renameContent(@NotNull JComponent tab, @NotNull String newTabName) { - Pair toRemove = null; - for (Pair existingTab : myTabs) { - if (existingTab.second == tab) { - toRemove = existingTab; - break; - } - } - int index = myTabs.indexOf(toRemove); - if (index != -1) { - myTabs.remove(index); - } - myTabs.add(Pair.create(newTabName, tab)); - if (getComponent() == tab) { - super.setDisplayName(newTabName); - } - } - @Override public String getDisplayName() { return getTabName(); @@ -168,23 +147,9 @@ public class TabbedContentImpl extends ContentImpl implements TabbedContent { myPrefix = titlePrefix; } - @Override - public void setIcon(Icon icon) { - for (Pair nextTabWithName : getTabs()) { - if (nextTabWithName.getFirst().equals(ContentUtilEx.getTabNameWithoutPrefix(this, getTabName()))) { - JComponent tab = nextTabWithName.getSecond(); - if (tab instanceof Iconable) { - Icon baseIcon = ((Iconable)tab).getIcon(Iconable.ICON_FLAG_VISIBILITY); - super.setIcon(isSelected() || baseIcon == null ? baseIcon : new WatermarkIcon(baseIcon, .5f)); - break; - } - } - } - } - @Override public void split() { - List> copy = new ArrayList<>(myTabs); + List> copy = new ArrayList>(myTabs); int selectedTab = ContentUtilEx.getSelectedTab(this); ContentManager manager = getManager(); String prefix = getTitlePrefix(); @@ -196,7 +161,6 @@ public class TabbedContentImpl extends ContentImpl implements TabbedContent { final String tabName = copy.get(i).first; ContentUtilEx.addTabbedContent(manager, component, prefix, tabName, select); } - setShouldDisposeContent(false); Disposer.dispose(this); } diff --git a/platform/platform-impl/src/com/intellij/util/ContentUtilEx.java b/platform/platform-impl/src/com/intellij/util/ContentUtilEx.java index 52f6ea2d0e2e..e699fbc8dd81 100644 --- a/platform/platform-impl/src/com/intellij/util/ContentUtilEx.java +++ b/platform/platform-impl/src/com/intellij/util/ContentUtilEx.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentFactory; import com.intellij.ui.content.ContentManager; @@ -196,10 +195,4 @@ public class ContentUtilEx extends ContentsUtil { } return -1; } - - @Nullable - public static String getTabNameWithoutPrefix(@NotNull TabbedContent content, @NotNull String fullTabName) { - String prefix = content.getTitlePrefix(); - return prefix == null ? fullTabName : StringUtil.trimStart(fullTabName, getFullPrefix(prefix)); - } } diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestUtil.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestUtil.java index d728092e977f..6ef8cd39c93c 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestUtil.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestUtil.java @@ -17,7 +17,6 @@ package com.intellij.testGuiFramework.framework; import com.intellij.diagnostic.AbstractMessage; import com.intellij.diagnostic.MessagePool; -import com.intellij.ide.GeneralSettings; import com.intellij.ide.PrivacyPolicy; import com.intellij.ide.RecentProjectsManager; import com.intellij.openapi.actionSystem.ActionManager; @@ -159,12 +158,8 @@ public final class GuiTestUtil { // Called by IdeTestApplication via reflection. @SuppressWarnings("unused") public static void setUpDefaultGeneralSettings() { - //setGuiTestingMode(true); - GeneralSettings.getInstance().setShowTipsOnStartup(false); - setUpDefaultProjectCreationLocationPath(); - setUpSdks(); } public static String getSystemJdk() { @@ -179,11 +174,6 @@ public final class GuiTestUtil { return jdkHome; } - public static void setupGitPath() { - //GitVcsApplicationSettings settings = GitVcsApplicationSettings.getInstance(); - //settings.setPathToGit(GitExecutor.PathHolder.GIT_EXECUTABLE); - } - public static void setUpSdks() { String jdkHome = getSystemPropertyOrEnvironmentVariable(JDK_HOME_FOR_TESTS); @@ -224,6 +214,9 @@ public final class GuiTestUtil { JavaSdk javaSdk = JavaSdk.getInstance(); + //in case of running different from IntelliJ or Android Studio IDE (PyCharm for example) + if (javaSdk == null) return; + String jdk_name = "JDK"; final Sdk newJdk = javaSdk.createJdk(jdk_name, path.toString(), false); final Sdk foundJdk = ProjectJdkTable.getInstance().findJdk(newJdk.getName(), newJdk.getSdkType().getName()); diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/IdeTestApplication.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/IdeTestApplication.java index 3c7ed45ae234..f592c76d3556 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/IdeTestApplication.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/IdeTestApplication.java @@ -109,7 +109,6 @@ public class IdeTestApplication { ClassLoader ideClassLoader = ourInstance.getIdeClassLoader(); Class clazz = ideClassLoader.loadClass(GuiTestUtil.class.getCanonicalName()); method("waitForIdeToStart").in(clazz).invoke(); - method("setUpDefaultGeneralSettings").in(clazz).invoke(); } return ourInstance; diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.java index d4026a072d1e..82c9d25af17f 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.java @@ -15,13 +15,14 @@ */ package com.intellij.testGuiFramework.impl; +import com.intellij.ide.GeneralSettings; import com.intellij.testGuiFramework.framework.GuiTestBase; +import com.intellij.testGuiFramework.framework.GuiTestUtil; import com.intellij.util.net.HttpConfigurable; import org.fest.swing.core.FastRobot; import java.lang.reflect.InvocationTargetException; -import static com.intellij.testGuiFramework.framework.GuiTestUtil.setUpDefaultProjectCreationLocationPath; /** * @author Sergey Karashevich @@ -34,30 +35,43 @@ public class GuiTestCase extends GuiTestBase { super(); } - @Override - public void setUp() throws Exception { - super.setUp(); + public static class GuiSettings { - setUpDefaultProjectCreationLocationPath(); - myRobot = new FastRobot(); + private static final Object lock = new Object(); + + private static GuiSettings SETTINGS; + + public static GuiSettings setUp() { + synchronized (lock) { + if (SETTINGS == null) SETTINGS = new GuiSettings(); + return SETTINGS; + } + } + + GuiSettings(){ + GeneralSettings.getInstance().setShowTipsOnStartup(false); + GuiTestUtil.setUpDefaultProjectCreationLocationPath(); + GuiTestUtil.setUpSdks(); + HttpConfigurable ideSettings = HttpConfigurable.getInstance(); + ideSettings.USE_HTTP_PROXY = false; + ideSettings.PROXY_HOST = ""; + ideSettings.PROXY_PORT = 80; + if (IS_UNDER_TEAMCITY) GitSettings.INSTANCE.setup(); + } - setIdeSettings(); - if (IS_UNDER_TEAMCITY) GitSettings.INSTANCE.setup(); } - @Override - public void tearDown() throws InvocationTargetException, InterruptedException { - GitSettings.INSTANCE.restore(); - super.tearDown(); + @Override + public void setUp() throws Exception { + super.setUp(); + myRobot = new FastRobot(); + GuiSettings.setUp(); + } + + @Override + public void tearDown() throws InvocationTargetException, InterruptedException { + GitSettings.INSTANCE.restore(); + super.tearDown(); + } + } - - private static void setIdeSettings() { - // Clear HTTP proxy settings, in case a test changed them. - HttpConfigurable ideSettings = HttpConfigurable.getInstance(); - ideSettings.USE_HTTP_PROXY = false; - ideSettings.PROXY_HOST = ""; - ideSettings.PROXY_PORT = 80; - } - - -} diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 827945914bfa..bab44c2d6d12 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -305,14 +305,14 @@ vcs.log.open.another.log.visible=false vcs.log.open.another.log.visible.description=An action that opens a new tab with log vcs.log.keep.up.to.date=true vcs.log.keep.up.to.date.description=Load log on start after heavy tasks are completed and keep it up to date even when not visible -vcs.log.labels.redesign=true -vcs.log.labels.redesign.description=Show branch labels on the right with combined tag icons, do not display tag names, combine tracked branches, display detached heads with an exclamation mark vcs.log.highlight.not.indexed=false vcs.log.highlight.not.indexed.description=Highlight commits that are not indexed vcs.log.index.git=true vcs.log.index.git.description=Index all commits in Git repository for fast filtering vcs.log.graph.history=false vcs.log.graph.history.description=Action in context menu that opens a new log tab filtered by file in context +vcs.log.labels.left.aligned=false +vcs.log.labels.left.aligned.description=Align labels in Log table to the left vcs.executable.validator.timeout.sec=60 vcs.unversioned.files.in.commit=true diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchClipboardTracker.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchClipboardTracker.java index eeac82f9942b..3781d080c952 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchClipboardTracker.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/PatchClipboardTracker.java @@ -22,6 +22,7 @@ import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.diff.impl.patch.PatchReader; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.VcsApplicationSettings; +import com.intellij.openapi.wm.IdeFrame; import com.intellij.util.messages.MessageBusConnection; import org.jetbrains.annotations.NotNull; @@ -43,6 +44,19 @@ public class PatchClipboardTracker extends ApplicationComponent.Adapter { } private static class PatchClipboardListener extends ClipboardAnalyzeListener { + @Override + public void applicationActivated(IdeFrame ideFrame) { + // we can't get clipboard details especially content size, so we should avoid clipboard processing when it's possible; + if (!VcsApplicationSettings.getInstance().DETECT_PATCH_ON_THE_FLY) return; + super.applicationActivated(ideFrame); + } + + @Override + public void applicationDeactivated(IdeFrame ideFrame) { + if (!VcsApplicationSettings.getInstance().DETECT_PATCH_ON_THE_FLY) return; + super.applicationDeactivated(ideFrame); + } + @Override protected void handle(@NotNull Project project, @NotNull String value) { new ApplyPatchFromClipboardAction.MyApplyPatchFromClipboardDialog(project, value).show(); @@ -50,7 +64,6 @@ public class PatchClipboardTracker extends ApplicationComponent.Adapter { @Override public boolean canHandle(@NotNull String value) { - if (!VcsApplicationSettings.getInstance().DETECT_PATCH_ON_THE_FLY) return false; return PatchReader.isPatchContent(value); } } diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/RefGroup.java b/platform/vcs-log/api/src/com/intellij/vcs/log/RefGroup.java index 3f54510a1060..143cefe413f0 100644 --- a/platform/vcs-log/api/src/com/intellij/vcs/log/RefGroup.java +++ b/platform/vcs-log/api/src/com/intellij/vcs/log/RefGroup.java @@ -31,8 +31,8 @@ public interface RefGroup { List getRefs(); /** - * Returns the background color of this ref group, which will be used to paint it on the Branches panel. + * Returns the colors of this ref group, which will be used to paint it in the table. */ @NotNull - Color getBgColor(); + List getColors(); } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/SimpleRefGroup.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/SimpleRefGroup.java new file mode 100644 index 000000000000..38dc14b96af4 --- /dev/null +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/SimpleRefGroup.java @@ -0,0 +1,83 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.vcs.log.impl; + +import com.intellij.util.ObjectUtils; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.MultiMap; +import com.intellij.vcs.log.RefGroup; +import com.intellij.vcs.log.VcsRef; +import com.intellij.vcs.log.VcsRefType; +import org.jetbrains.annotations.NotNull; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class SimpleRefGroup implements RefGroup { + @NotNull private final String myName; + @NotNull private final List myRefs; + + public SimpleRefGroup(@NotNull String name, @NotNull List refs) { + myName = name; + myRefs = refs; + } + + @Override + public boolean isExpanded() { + return false; + } + + @NotNull + @Override + public String getName() { + return myName; + } + + @NotNull + @Override + public List getRefs() { + return myRefs; + } + + @NotNull + @Override + public List getColors() { + return getColors(myRefs); + } + + @NotNull + public static List getColors(@NotNull Collection refs) { + MultiMap referencesByType = ContainerUtil.groupBy(refs, VcsRef::getType); + if (referencesByType.size() == 1) { + Map.Entry> firstItem = + ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(referencesByType.entrySet())); + boolean multiple = firstItem.getValue().size() > 1; + Color color = firstItem.getKey().getBackgroundColor(); + return multiple ? Arrays.asList(color, color) : Collections.singletonList(color); + } + else { + List colorsList = ContainerUtil.newArrayList(); + for (VcsRefType type : referencesByType.keySet()) { + if (referencesByType.get(type).size() > 1) { + colorsList.add(type.getBackgroundColor()); + } + colorsList.add(type.getBackgroundColor()); + } + return colorsList; + } + } +} diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/SingletonRefGroup.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/SingletonRefGroup.java index 9a7738aa6829..5fa6e35c09b5 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/SingletonRefGroup.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/SingletonRefGroup.java @@ -52,7 +52,7 @@ public class SingletonRefGroup implements RefGroup { @NotNull @Override - public Color getBgColor() { - return myRef.getType().getBackgroundColor(); + public List getColors() { + return Collections.singletonList(myRef.getType().getBackgroundColor()); } } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/BranchFilterPopupComponent.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/BranchFilterPopupComponent.java index 64cf48910e4a..62e3ffdbcfd3 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/BranchFilterPopupComponent.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/BranchFilterPopupComponent.java @@ -110,7 +110,7 @@ public class BranchFilterPopupComponent extends MultipleValueFilterPopupComponen @NotNull @Override public AnAction createAction(@NotNull String name) { - return new PredefinedValueAction(Collections.singletonList(name)) { + return new PredefinedValueAction(name) { @Override public void actionPerformed(@NotNull AnActionEvent e) { myFilterModel.setFilter(myFilterModel.createFilter(myValues)); // does not add to recent @@ -126,7 +126,7 @@ public class BranchFilterPopupComponent extends MultipleValueFilterPopupComponen @NotNull @Override protected AnAction createCollapsedAction(String actionName) { - return createPredefinedValueAction(Collections.singletonList(actionName)); // adds to recent + return new PredefinedValueAction(actionName); // adds to recent } } } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/BranchPopupBuilder.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/BranchPopupBuilder.java index a73ffe42eb33..07eb471a322d 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/BranchPopupBuilder.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/BranchPopupBuilder.java @@ -127,10 +127,7 @@ public abstract class BranchPopupBuilder { private static void putActionsForReferences(List references, Groups actions) { for (final RefGroup refGroup : references) { if (refGroup instanceof SingletonRefGroup) { - String name = refGroup.getName(); - if (!actions.singletonGroups.contains(name)) { - actions.singletonGroups.add(name); - } + actions.singletonGroups.add(refGroup.getName()); } else if (refGroup.isExpanded()) { addToGroup(refGroup, actions.expandedGroups); @@ -142,20 +139,9 @@ public abstract class BranchPopupBuilder { } private static void addToGroup(final RefGroup refGroup, TreeMap> groupToAdd) { - TreeSet existingGroup = groupToAdd.get(refGroup.getName()); - - TreeSet actions = new TreeSet<>(); + TreeSet groupActions = groupToAdd.computeIfAbsent(refGroup.getName(), key -> new TreeSet<>()); for (VcsRef ref : refGroup.getRefs()) { - actions.add(ref.getName()); - } - - if (existingGroup == null) { - groupToAdd.put(refGroup.getName(), actions); - } - else { - for (String action : actions) { - existingGroup.add(action); - } + groupActions.add(ref.getName()); } } } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/MultipleValueFilterPopupComponent.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/MultipleValueFilterPopupComponent.java index 64f06bf85dcf..52fbca05a873 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/MultipleValueFilterPopupComponent.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/MultipleValueFilterPopupComponent.java @@ -84,11 +84,6 @@ abstract class MultipleValueFilterPopupComponent ex return StringUtil.join(values, ", "); } - @NotNull - protected AnAction createPredefinedValueAction(@NotNull List values) { - return new PredefinedValueAction(values); - } - @NotNull protected AnAction createSelectMultipleValuesAction() { return new SelectMultipleValuesAction(); @@ -105,6 +100,10 @@ abstract class MultipleValueFilterPopupComponent ex @NotNull protected final List myValues; + public PredefinedValueAction(@NotNull String value) { + this(Collections.singletonList(value)); + } + public PredefinedValueAction(@NotNull List values) { super(null, tooltip(values), null); getTemplatePresentation().setText(displayableText(values), false); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/UserFilterPopupComponent.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/UserFilterPopupComponent.java index 65fca30b3871..7cb3aa3d2ec8 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/UserFilterPopupComponent.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/UserFilterPopupComponent.java @@ -15,9 +15,12 @@ */ package com.intellij.vcs.log.ui.filter; -import com.intellij.openapi.actionSystem.ActionGroup; -import com.intellij.openapi.actionSystem.DefaultActionGroup; +import com.intellij.ide.DataManager; +import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.ui.popup.ListPopup; import com.intellij.openapi.util.Couple; +import com.intellij.openapi.vcs.ui.FlatSpeedSearchPopup; +import com.intellij.ui.popup.PopupFactoryImpl; import com.intellij.util.containers.ContainerUtil; import com.intellij.vcs.log.VcsLogUserFilter; import com.intellij.vcs.log.data.VcsLogData; @@ -29,20 +32,22 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; +import java.util.TreeSet; /** * Show a popup to select a user or enter the user name. */ class UserFilterPopupComponent extends MultipleValueFilterPopupComponent { @NotNull private final VcsLogData myLogData; + @NotNull private final List myAllUsers; UserFilterPopupComponent(@NotNull VcsLogUiProperties uiProperties, @NotNull VcsLogData logData, @NotNull FilterModel filterModel) { super("User", uiProperties, filterModel); myLogData = logData; + myAllUsers = collectUsers(logData); } @NotNull @@ -63,12 +68,23 @@ class UserFilterPopupComponent extends MultipleValueFilterPopupComponent> getRecentValuesFromSettings() { @@ -83,11 +99,55 @@ class UserFilterPopupComponent extends MultipleValueFilterPopupComponent getAllValues() { - return ContainerUtil.map(myLogData.getAllUsers(), user -> { + return myAllUsers; + } + + @NotNull + @Override + protected ListPopup createPopupMenu() { + ActionGroup actionGroup = createActionGroup(); + ActionGroup speedsearchGroup = createSpeedSearchActionGroup(); + return new UserLogSpeedSearchPopup(new DefaultActionGroup(actionGroup, speedsearchGroup), + DataManager.getInstance().getDataContext(this)); + } + + @NotNull + private static List collectUsers(@NotNull VcsLogData logData) { + List users = ContainerUtil.map(logData.getAllUsers(), user -> { String shortPresentation = VcsUserUtil.getShortPresentation(user); Couple firstAndLastName = VcsUserUtil.getFirstAndLastName(shortPresentation); if (firstAndLastName == null) return shortPresentation; return VcsUserUtil.capitalizeName(firstAndLastName.first) + " " + VcsUserUtil.capitalizeName(firstAndLastName.second); }); + TreeSet sortedUniqueUsers = new TreeSet<>(users); + return new ArrayList<>(sortedUniqueUsers); + } + + private static class UserLogSpeedSearchPopup extends FlatSpeedSearchPopup { + public UserLogSpeedSearchPopup(@NotNull DefaultActionGroup actionGroup, @NotNull DataContext dataContext) { + super(null, actionGroup, dataContext, null, false); + } + + @Override + public boolean shouldBeShowing(Object value) { + if (!super.shouldBeShowing(value)) return false; + if (!(value instanceof PopupFactoryImpl.ActionItem)) return true; + + AnAction action = ((PopupFactoryImpl.ActionItem)value).getAction(); + if (getSpeedSearch().isHoldingFilter()) { + if (action instanceof MultipleValueFilterPopupComponent.PredefinedValueAction) { + return action instanceof SpeedsearchAction || + ((MultipleValueFilterPopupComponent.PredefinedValueAction)action).myValues.size() > 1; + } + return true; + } + else { + return !isSpeedsearchAction(action); + } + } + } + + private class SpeedsearchPredefinedValueAction extends PredefinedValueAction implements FlatSpeedSearchPopup.SpeedsearchAction { + public SpeedsearchPredefinedValueAction(String user) {super(user);} } } \ No newline at end of file diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/ReferencesPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/ReferencesPanel.java index 103e11251201..ab5575fc11c1 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/ReferencesPanel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/ReferencesPanel.java @@ -15,25 +15,27 @@ */ package com.intellij.vcs.log.ui.frame; +import com.intellij.ui.ColorUtil; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.panels.Wrapper; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.UIUtil; import com.intellij.vcs.log.VcsRef; import com.intellij.vcs.log.VcsRefType; -import com.intellij.vcs.log.ui.render.GraphCommitCellRenderer; import com.intellij.vcs.log.ui.render.LabelIcon; import com.intellij.vcs.log.ui.render.RectanglePainter; -import com.intellij.vcs.log.ui.render.RectangleReferencePainter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import java.util.*; +import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.Map; import static com.intellij.openapi.vcs.history.VcsHistoryUtil.getCommitDetailsFont; import static com.intellij.vcs.log.ui.frame.CommitPanel.getCommitDetailsBackground; @@ -73,37 +75,28 @@ public class ReferencesPanel extends JPanel { int height = getIconHeight(); JBLabel firstLabel = null; - if (GraphCommitCellRenderer.isRedesignedLabels()) { - for (Map.Entry> typeAndRefs : myGroupedVisibleReferences.entrySet()) { - VcsRefType type = typeAndRefs.getKey(); - Collection refs = typeAndRefs.getValue(); - int refIndex = 0; - for (VcsRef reference : refs) { - Icon icon = createIcon(type, refs, refIndex, height); - String ending = (refIndex != refs.size() - 1) ? "," : ""; - String text = reference.getName() + ending; - JBLabel label = createLabel(text, icon); - if (firstLabel == null) { - firstLabel = label; - add(label); - } - else { - addWrapped(label, firstLabel); - } - refIndex++; + for (Map.Entry> typeAndRefs : myGroupedVisibleReferences.entrySet()) { + VcsRefType type = typeAndRefs.getKey(); + Collection refs = typeAndRefs.getValue(); + int refIndex = 0; + for (VcsRef reference : refs) { + Icon icon = createIcon(type, refs, refIndex, height); + String ending = (refIndex != refs.size() - 1) ? "," : ""; + String text = reference.getName() + ending; + JBLabel label = createLabel(text, icon); + if (firstLabel == null) { + firstLabel = label; + add(label); } - } - if (getHiddenReferencesSize() > 0) { - JBLabel label = createRestLabel(getHiddenReferencesSize()); - addWrapped(label, ObjectUtils.assertNotNull(firstLabel)); + else { + addWrapped(label, firstLabel); + } + refIndex++; } } - else { - for (Map.Entry> typeAndRefs : myGroupedVisibleReferences.entrySet()) { - for (VcsRef reference : typeAndRefs.getValue()) { - add(new ReferencePanel(reference)); - } - } + if (getHiddenReferencesSize() > 0) { + JBLabel label = createRestLabel(getHiddenReferencesSize()); + addWrapped(label, ObjectUtils.assertNotNull(firstLabel)); } setVisible(!myGroupedVisibleReferences.isEmpty()); revalidate(); @@ -165,6 +158,17 @@ public class ReferencesPanel extends JPanel { return getCommitDetailsBackground(); } + @NotNull + public static Color getLabelColor(@NotNull Color color) { + if (UIUtil.isUnderDarcula()) { + color = ColorUtil.darker(color, 6); + } + else { + color = ColorUtil.brighter(color, 6); + } + return ColorUtil.desaturate(color, 3); + } + private static class ReferencePanel extends JPanel { @NotNull private final RectanglePainter myLabelPainter; @NotNull private final VcsRef myReference; @@ -178,7 +182,7 @@ public class ReferencesPanel extends JPanel { @Override public void paint(Graphics g) { myLabelPainter.paint((Graphics2D)g, myReference.getName(), 0, 0, - RectangleReferencePainter.getLabelColor(myReference.getType().getBackgroundColor())); + getLabelColor(myReference.getType().getBackgroundColor())); } @Override diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java index 29d4577511f8..7e9d6232f324 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java @@ -1,6 +1,5 @@ package com.intellij.vcs.log.ui.render; -import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.changes.issueLinks.IssueLinkRenderer; import com.intellij.ui.SimpleColoredComponent; @@ -34,7 +33,7 @@ public class GraphCommitCellRenderer extends TypeSafeTableCellRenderer refs = cell.getRefsToThisCommit(); if (!refs.isEmpty()) { myTooltipPainter.customizePainter(myComponent, refs, myComponent.getBackground(), myComponent.getForeground(), true/*counterintuitive, but true*/, getColumnWidth()); - if (getReferencesWidth(row) >= getColumnWidth() - point.getX()) { - return new TooltipReferencesPanel(myLogData, myTooltipPainter, refs); + if (myTooltipPainter.isLeftAligned()) { + double distance = point.getX() - myTemplateComponent.getGraphWidth(cell.getPrintElements()); + if (distance > 0 && distance <= getReferencesWidth(row, cell)) { + return new TooltipReferencesPanel(myLogData, myTooltipPainter, refs); + } + } + else { + if (getColumnWidth() - point.getX() <= getReferencesWidth(row, cell)) { + return new TooltipReferencesPanel(myLogData, myTooltipPainter, refs); + } } } return null; @@ -83,7 +84,10 @@ public class GraphCommitCellRenderer extends TypeSafeTableCellRenderer refs = cell.getRefsToThisCommit(); if (!refs.isEmpty()) { myTemplateComponent.customize(cell, myGraphTable.isRowSelected(row), myGraphTable.hasFocus(), @@ -122,7 +126,7 @@ public class GraphCommitCellRenderer extends TypeSafeTableCellRenderer printElements) { + double maxIndex = getMaxGraphElementIndex(printElements); + BufferedImage image = UIUtil.createImage((int)(PaintParameters.getNodeWidth(myGraphTable.getRowHeight()) * (maxIndex + 2)), + myGraphTable.getRowHeight(), + BufferedImage.TYPE_INT_ARGB); + Graphics2D g2 = image.createGraphics(); + myPainter.draw(g2, printElements); + + int width = (int)(maxIndex * PaintParameters.getNodeWidth(myGraphTable.getRowHeight())); + return new PaintInfo(image, width); + } + + private int getGraphWidth(@NotNull Collection printElements) { + double maxIndex = getMaxGraphElementIndex(printElements); + return (int)(maxIndex * PaintParameters.getNodeWidth(myGraphTable.getRowHeight())); + } + + private double getMaxGraphElementIndex(@NotNull Collection printElements) { double maxIndex = 0; for (PrintElement printElement : printElements) { maxIndex = Math.max(maxIndex, printElement.getPositionInCurrentRow()); @@ -219,14 +240,7 @@ public class GraphCommitCellRenderer extends TypeSafeTableCellRenderer colors = group.getColors(); + LabelIcon labelIcon = new LabelIcon(height, background, colors.toArray(new Color[colors.size()])); width += labelIcon.getIconWidth() + MIDDLE_PADDING; String text = shortenRefName(group.getName(), fontMetrics, availableWidth - width); @@ -185,30 +187,6 @@ public class LabelPainter implements ReferencePainter { return refName; } - @NotNull - public static Color[] getGroupColors(@NotNull RefGroup group) { - MultiMap referencesByType = ContainerUtil.groupBy(group.getRefs(), VcsRef::getType); - Color[] colors; - if (referencesByType.size() == 1) { - Map.Entry> firstItem = - ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(referencesByType.entrySet())); - boolean multiple = firstItem.getValue().size() > 1; - Color color = firstItem.getKey().getBackgroundColor(); - colors = multiple ? new Color[]{color, color} : new Color[]{color}; - } - else { - List colorsList = ContainerUtil.newArrayList(); - for (VcsRefType type : referencesByType.keySet()) { - if (referencesByType.get(type).size() > 1) { - colorsList.add(type.getBackgroundColor()); - } - colorsList.add(type.getBackgroundColor()); - } - colors = colorsList.toArray(new Color[colorsList.size()]); - } - return colors; - } - public void paint(@NotNull Graphics2D g2, int x, int y, int height) { if (myLabels.isEmpty()) return; @@ -253,7 +231,7 @@ public class LabelPainter implements ReferencePainter { @Override public boolean isLeftAligned() { - return false; + return Registry.is("vcs.log.labels.left.aligned"); } @Override diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/RectangleReferencePainter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/RectangleReferencePainter.java deleted file mode 100644 index 2ee86d5846c8..000000000000 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/RectangleReferencePainter.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.vcs.log.ui.render; - -import com.intellij.openapi.ui.GraphicsConfig; -import com.intellij.openapi.util.Pair; -import com.intellij.ui.ColorUtil; -import com.intellij.util.ObjectUtils; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.GraphicsUtil; -import com.intellij.util.ui.JBUI; -import com.intellij.util.ui.UIUtil; -import com.intellij.vcs.log.VcsLogRefManager; -import com.intellij.vcs.log.VcsRef; -import com.intellij.vcs.log.VcsRefType; -import com.intellij.vcs.log.data.VcsLogData; -import com.intellij.vcs.log.paint.PaintParameters; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.awt.*; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -public class RectangleReferencePainter implements ReferencePainter { - @NotNull private final VcsLogData myLogData; - @NotNull private List> myLabels = ContainerUtil.newArrayList(); - private int myHeight = JBUI.scale(22); - private int myWidth = 0; - - private final RectanglePainter myLabelPainter = new RectanglePainter(false) { - @Override - protected Font getLabelFont() { - return getReferenceFont(); - } - }; - - public RectangleReferencePainter(@NotNull VcsLogData data) { - myLogData = data; - } - - @Override - public void customizePainter(@NotNull JComponent component, - @NotNull Collection references, - @NotNull Color background, - @NotNull Color foreground, - boolean isSelected, - int availableWidth) { - FontMetrics metrics = component.getFontMetrics(getReferenceFont()); - myHeight = metrics.getHeight() + RectanglePainter.TOP_TEXT_PADDING + RectanglePainter.BOTTOM_TEXT_PADDING; - myWidth = 2 * PaintParameters.LABEL_PADDING; - - myLabels = ContainerUtil.newArrayList(); - VcsLogRefManager manager = ReferencePainter.getRefManager(myLogData, references); - if (manager == null) return; - - List sorted = ContainerUtil.sorted(references, manager.getLabelsOrderComparator()); - - for (Map.Entry> entry : ContainerUtil.groupBy(sorted, VcsRef::getType).entrySet()) { - VcsRef ref = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(entry.getValue())); - String text = ref.getName() + (entry.getValue().size() > 1 ? " +" : ""); - myLabels.add(Pair.create(text, entry.getKey().getBackgroundColor())); - - myWidth += myLabelPainter.calculateSize(text, metrics).getWidth() + PaintParameters.LABEL_PADDING; - } - } - - public void paint(@NotNull Graphics2D g2, int x, int y, int height) { - if (myLabels.isEmpty()) return; - - GraphicsConfig config = GraphicsUtil.setupAAPainting(g2); - g2.setFont(getReferenceFont()); - g2.setStroke(new BasicStroke(1.5f)); - - FontMetrics fontMetrics = g2.getFontMetrics(); - - x += PaintParameters.LABEL_PADDING; - for (Pair label : myLabels) { - Dimension size = myLabelPainter.calculateSize(label.first, fontMetrics); - int paddingY = y + (height - size.height) / 2; - myLabelPainter.paint(g2, label.first, x, paddingY, getLabelColor(label.second)); - x += size.width + PaintParameters.LABEL_PADDING; - } - - config.restore(); - } - - @NotNull - public static Color getLabelColor(@NotNull Color color) { - if (UIUtil.isUnderDarcula()) { - color = ColorUtil.darker(color, 6); - } - else { - color = ColorUtil.brighter(color, 6); - } - return ColorUtil.desaturate(color, 3); - } - - public Dimension getSize() { - if (myLabels.isEmpty()) return new Dimension(); - return new Dimension(myWidth, myHeight); - } - - @Override - public boolean isLeftAligned() { - return true; - } -} diff --git a/plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringActionHandlerImpl.java b/plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringActionHandlerImpl.java index 1949e06ff318..771bf72b69fb 100644 --- a/plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringActionHandlerImpl.java +++ b/plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringActionHandlerImpl.java @@ -40,6 +40,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.generate.tostring.GenerateToStringClassFilter; import org.jetbrains.java.generate.config.Config; +import org.jetbrains.java.generate.config.ConflictResolutionPolicy; import org.jetbrains.java.generate.template.TemplateResource; import org.jetbrains.java.generate.template.toString.ToStringTemplatesManager; import org.jetbrains.java.generate.view.TemplatesPanel; @@ -116,9 +117,12 @@ public class GenerateToStringActionHandlerImpl implements GenerateToStringAction ToStringTemplatesManager.getInstance().setDefaultTemplate(template); if (template.isValidTemplate()) { + final GenerateToStringWorker worker = new GenerateToStringWorker(clazz, editor, chooser.isInsertOverrideAnnotation()); + // decide what to do if the method already exists + ConflictResolutionPolicy resolutionPolicy = worker.exitsMethodDialog(template); WriteAction.run(() -> { try { - new GenerateToStringWorker(clazz, editor, chooser.isInsertOverrideAnnotation()).execute(selectedMembers, template); + worker.execute(selectedMembers, template, resolutionPolicy); } catch (Exception e) { GenerationUtil.handleException(project, e); diff --git a/plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringWorker.java b/plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringWorker.java index 105faf66d278..799e39182a5f 100644 --- a/plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringWorker.java +++ b/plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringWorker.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,9 +121,7 @@ public class GenerateToStringWorker { return toStringMethod; } - public void execute(Collection members, TemplateResource template) throws IncorrectOperationException, GenerateCodeException { - // decide what to do if the method already exists - ConflictResolutionPolicy resolutionPolicy = exitsMethodDialog(template); + public void execute(Collection members, TemplateResource template, final ConflictResolutionPolicy resolutionPolicy) throws IncorrectOperationException, GenerateCodeException { // what insert policy should we use? resolutionPolicy.setNewMethodStrategy(getStrategy(config.getInsertNewMethodInitialOption())); diff --git a/plugins/generate-tostring/testSrc/org/jetbrains/java/generate/inspection/ToStringGeneratingTest.groovy b/plugins/generate-tostring/testSrc/org/jetbrains/java/generate/inspection/ToStringGeneratingTest.groovy index 2418b69f9e21..c54712d1ba32 100644 --- a/plugins/generate-tostring/testSrc/org/jetbrains/java/generate/inspection/ToStringGeneratingTest.groovy +++ b/plugins/generate-tostring/testSrc/org/jetbrains/java/generate/inspection/ToStringGeneratingTest.groovy @@ -151,7 +151,7 @@ class Foo { new WriteCommandAction(myFixture.project, myFixture.file) { @Override protected void run(@NotNull Result result) throws Throwable { - worker.execute(members, template) + worker.execute(members, template, policy) } }.execute() diff --git a/plugins/git4idea/src/git4idea/log/GitRefManager.java b/plugins/git4idea/src/git4idea/log/GitRefManager.java index 0179e77cd463..fd9e8e8af0d4 100644 --- a/plugins/git4idea/src/git4idea/log/GitRefManager.java +++ b/plugins/git4idea/src/git4idea/log/GitRefManager.java @@ -10,6 +10,7 @@ import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import com.intellij.vcs.log.*; +import com.intellij.vcs.log.impl.SimpleRefGroup; import com.intellij.vcs.log.impl.SingletonRefGroup; import com.intellij.vcs.log.impl.VcsLogUtil; import git4idea.GitBranch; @@ -155,7 +156,7 @@ public class GitRefManager implements VcsLogRefManager { } else { if (!repository.isOnBranch()) { - groups.add(new TableRefGroup("!", Collections.singletonList(head))); + groups.add(new SimpleRefGroup("!", Collections.singletonList(head))); sortedReferences = sortedReferences.subList(1, sortedReferences.size()); } } @@ -177,7 +178,7 @@ public class GitRefManager implements VcsLogRefManager { } } - groups.add(new TableRefGroup(name, sortedReferences)); + groups.add(new SimpleRefGroup(name, sortedReferences)); return groups; } @@ -358,8 +359,8 @@ public class GitRefManager implements VcsLogRefManager { @NotNull @Override - public Color getBgColor() { - return VcsLogStandardColors.Refs.TIP; + public List getColors() { + return Collections.singletonList(VcsLogStandardColors.Refs.TIP); } } @@ -391,41 +392,8 @@ public class GitRefManager implements VcsLogRefManager { @NotNull @Override - public Color getBgColor() { - return VcsLogStandardColors.Refs.BRANCH_REF; - } - } - - private static class TableRefGroup implements RefGroup { - @NotNull private final String myName; - @NotNull private final List myRefs; - - private TableRefGroup(@NotNull String name, @NotNull List refs) { - myName = name; - myRefs = refs; - } - - @Override - public boolean isExpanded() { - return false; - } - - @NotNull - @Override - public String getName() { - return myName; - } - - @NotNull - @Override - public List getRefs() { - return myRefs; - } - - @NotNull - @Override - public Color getBgColor() { - return myRefs.get(0).getType().getBackgroundColor(); + public List getColors() { + return Collections.singletonList(VcsLogStandardColors.Refs.BRANCH_REF); } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgRefManager.java b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgRefManager.java index ae96baf9b2cd..da53654bc4b8 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgRefManager.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgRefManager.java @@ -20,6 +20,7 @@ import com.intellij.util.Function; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import com.intellij.vcs.log.*; +import com.intellij.vcs.log.impl.SimpleRefGroup; import com.intellij.vcs.log.impl.SingletonRefGroup; import com.intellij.vcs.log.impl.VcsLogUtil; import org.jetbrains.annotations.NotNull; @@ -193,37 +194,4 @@ public class HgRefManager implements VcsLogRefManager { return Objects.hash(myName, myIsBranch); } } - - private static class SimpleRefGroup implements RefGroup { - @NotNull private final String myName; - @NotNull private final List myRefs; - - private SimpleRefGroup(@NotNull String name, @NotNull List refs) { - myName = name; - myRefs = refs; - } - - @Override - public boolean isExpanded() { - return false; - } - - @NotNull - @Override - public String getName() { - return myName; - } - - @NotNull - @Override - public List getRefs() { - return myRefs; - } - - @NotNull - @Override - public Color getBgColor() { - return myRefs.get(0).getType().getBackgroundColor(); - } - } } diff --git a/python/src/com/jetbrains/python/actions/PyExecuteSelectionAction.java b/python/src/com/jetbrains/python/actions/PyExecuteSelectionAction.java index c9b74190e31f..5d48204fc915 100644 --- a/python/src/com/jetbrains/python/actions/PyExecuteSelectionAction.java +++ b/python/src/com/jetbrains/python/actions/PyExecuteSelectionAction.java @@ -29,6 +29,8 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; +import com.intellij.ui.content.Content; +import com.intellij.ui.content.ContentManager; import com.intellij.util.Consumer; import com.jetbrains.python.console.PyCodeExecutor; import com.jetbrains.python.console.PydevConsoleRunner; @@ -59,7 +61,7 @@ public class PyExecuteSelectionAction extends AnAction { else { String line = getLineUnderCaret(editor); if (line != null) { - execute(e, line); + execute(e, line.trim()); moveCaretDown(editor); } } @@ -175,6 +177,15 @@ public class PyExecuteSelectionAction extends AnAction { .selectContentDescriptor(dataContext, project, consoles, "Select console to execute in", descriptor -> { if (descriptor != null && descriptor.getExecutionConsole() instanceof PyCodeExecutor) { consumer.consume((PyCodeExecutor)descriptor.getExecutionConsole()); + final PythonConsoleToolWindow toolWindow = PythonConsoleToolWindow.getInstance(project); + if (toolWindow != null && !toolWindow.getToolWindow().isVisible()) { + toolWindow.getToolWindow().show(null); + ContentManager contentManager = toolWindow.getToolWindow().getContentManager(); + Content content = contentManager.findContent(descriptor.getDisplayName()); + if (content != null) { + contentManager.setSelectedContent(content); + } + } } }); } @@ -219,7 +230,7 @@ public class PyExecuteSelectionAction extends AnAction { Module context) { final PythonConsoleToolWindow toolWindow = PythonConsoleToolWindow.getInstance(project); - if (toolWindow != null) { + if (toolWindow != null && toolWindow.getConsoleContentDescriptors().size() > 0) { toolWindow.activate(() -> { List descs = toolWindow.getConsoleContentDescriptors(); @@ -237,6 +248,9 @@ public class PyExecuteSelectionAction extends AnAction { public void handleConsoleInitialized(LanguageConsoleView consoleView) { if (consoleView instanceof PyCodeExecutor) { consumer.consume((PyCodeExecutor)consoleView); + if (toolWindow != null) { + toolWindow.getToolWindow().show(null); + } } } }); diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/AddSchemaPrefixIntention.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/AddSchemaPrefixIntention.java index 0f44f2b29d5a..8f27e4433d13 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/AddSchemaPrefixIntention.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/AddSchemaPrefixIntention.java @@ -57,6 +57,11 @@ public class AddSchemaPrefixIntention extends PsiElementBaseIntentionAction { return NAME; } + @Override + public boolean startInWriteAction() { + return false; + } + @Override public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { final XmlAttribute xmlns = getXmlnsDeclaration(element);