mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -14,8 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* The following code was generated by JFlex 1.4.1 on 23.09.09 18:11 */
|
||||
|
||||
/* It's an automatically generated code. Do not modify it. */
|
||||
package org.intellij.lang.regexp;
|
||||
|
||||
@@ -30,8 +28,8 @@ import com.intellij.psi.StringEscapesTokenTypes;
|
||||
/**
|
||||
* This class is a scanner generated by
|
||||
* <a href="http://www.jflex.de/">JFlex</a> 1.4.1
|
||||
* on 23.09.09 18:11 from the specification file
|
||||
* <tt>C:/JetBrains/IDEA/svnPlugins/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex</tt>
|
||||
* on 04.11.09 17:54 from the specification file
|
||||
* <tt>RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex</tt>
|
||||
*/
|
||||
class _RegExLexer implements FlexLexer {
|
||||
/** initial size of the lookahead buffer */
|
||||
@@ -51,12 +49,12 @@ class _RegExLexer implements FlexLexer {
|
||||
* Translates characters to character classes
|
||||
*/
|
||||
private static final String ZZ_CMAP_PACKED =
|
||||
"\10\0\2\50\1\13\1\0\1\50\1\57\22\0\1\60\1\54\1\0"+
|
||||
"\1\56\1\15\1\0\1\47\1\0\1\4\1\5\1\17\1\20\1\46"+
|
||||
"\1\42\1\3\1\0\1\2\7\41\2\1\1\51\1\0\1\55\1\53"+
|
||||
"\1\52\1\16\1\0\1\24\1\24\1\30\1\27\1\36\1\34\1\25"+
|
||||
"\10\0\2\51\1\13\1\0\1\51\1\60\22\0\1\44\1\55\1\0"+
|
||||
"\1\57\1\15\1\0\1\50\1\0\1\4\1\5\1\17\1\20\1\47"+
|
||||
"\1\42\1\3\1\0\1\2\7\41\2\1\1\52\1\0\1\56\1\54"+
|
||||
"\1\53\1\16\1\0\1\24\1\24\1\30\1\27\1\36\1\34\1\25"+
|
||||
"\1\43\1\32\6\43\1\33\1\35\1\43\1\26\3\43\1\26\1\26"+
|
||||
"\1\43\1\25\1\10\1\12\1\11\1\14\1\44\1\0\1\23\1\24"+
|
||||
"\1\43\1\25\1\10\1\12\1\11\1\14\1\45\1\0\1\23\1\24"+
|
||||
"\1\31\1\27\1\23\1\23\2\43\1\32\4\43\1\22\1\43\1\33"+
|
||||
"\1\43\1\22\1\26\1\22\1\40\1\43\1\26\1\37\1\43\1\25"+
|
||||
"\1\6\1\21\1\7\54\0\1\43\12\0\1\43\4\0\1\43\5\0"+
|
||||
@@ -65,43 +63,43 @@ class _RegExLexer implements FlexLexer {
|
||||
"\1\43\1\0\24\43\1\0\54\43\1\0\46\43\1\0\5\43\4\0"+
|
||||
"\202\43\10\0\105\43\1\0\46\43\2\0\2\43\6\0\20\43\41\0"+
|
||||
"\46\43\2\0\1\43\7\0\47\43\110\0\33\43\5\0\3\43\56\0"+
|
||||
"\32\43\5\0\13\43\25\0\12\45\4\0\2\43\1\0\143\43\1\0"+
|
||||
"\1\43\17\0\2\43\7\0\2\43\12\45\3\43\2\0\1\43\20\0"+
|
||||
"\32\43\5\0\13\43\25\0\12\46\4\0\2\43\1\0\143\43\1\0"+
|
||||
"\1\43\17\0\2\43\7\0\2\43\12\46\3\43\2\0\1\43\20\0"+
|
||||
"\1\43\1\0\36\43\35\0\3\43\60\0\46\43\13\0\1\43\u0152\0"+
|
||||
"\66\43\3\0\1\43\22\0\1\43\7\0\12\43\4\0\12\45\25\0"+
|
||||
"\66\43\3\0\1\43\22\0\1\43\7\0\12\43\4\0\12\46\25\0"+
|
||||
"\10\43\2\0\2\43\2\0\26\43\1\0\7\43\1\0\1\43\3\0"+
|
||||
"\4\43\3\0\1\43\36\0\2\43\1\0\3\43\4\0\12\45\2\43"+
|
||||
"\4\43\3\0\1\43\36\0\2\43\1\0\3\43\4\0\12\46\2\43"+
|
||||
"\23\0\6\43\4\0\2\43\2\0\26\43\1\0\7\43\1\0\2\43"+
|
||||
"\1\0\2\43\1\0\2\43\37\0\4\43\1\0\1\43\7\0\12\45"+
|
||||
"\1\0\2\43\1\0\2\43\37\0\4\43\1\0\1\43\7\0\12\46"+
|
||||
"\2\0\3\43\20\0\11\43\1\0\3\43\1\0\26\43\1\0\7\43"+
|
||||
"\1\0\2\43\1\0\5\43\3\0\1\43\22\0\1\43\17\0\2\43"+
|
||||
"\4\0\12\45\25\0\10\43\2\0\2\43\2\0\26\43\1\0\7\43"+
|
||||
"\4\0\12\46\25\0\10\43\2\0\2\43\2\0\26\43\1\0\7\43"+
|
||||
"\1\0\2\43\1\0\5\43\3\0\1\43\36\0\2\43\1\0\3\43"+
|
||||
"\4\0\12\45\1\0\1\43\21\0\1\43\1\0\6\43\3\0\3\43"+
|
||||
"\4\0\12\46\1\0\1\43\21\0\1\43\1\0\6\43\3\0\3\43"+
|
||||
"\1\0\4\43\3\0\2\43\1\0\1\43\1\0\2\43\3\0\2\43"+
|
||||
"\3\0\3\43\3\0\10\43\1\0\3\43\55\0\11\45\25\0\10\43"+
|
||||
"\3\0\3\43\3\0\10\43\1\0\3\43\55\0\11\46\25\0\10\43"+
|
||||
"\1\0\3\43\1\0\27\43\1\0\12\43\1\0\5\43\46\0\2\43"+
|
||||
"\4\0\12\45\25\0\10\43\1\0\3\43\1\0\27\43\1\0\12\43"+
|
||||
"\1\0\5\43\3\0\1\43\40\0\1\43\1\0\2\43\4\0\12\45"+
|
||||
"\4\0\12\46\25\0\10\43\1\0\3\43\1\0\27\43\1\0\12\43"+
|
||||
"\1\0\5\43\3\0\1\43\40\0\1\43\1\0\2\43\4\0\12\46"+
|
||||
"\25\0\10\43\1\0\3\43\1\0\27\43\1\0\20\43\46\0\2\43"+
|
||||
"\4\0\12\45\25\0\22\43\3\0\30\43\1\0\11\43\1\0\1\43"+
|
||||
"\2\0\7\43\72\0\60\43\1\0\2\43\14\0\7\43\11\0\12\45"+
|
||||
"\4\0\12\46\25\0\22\43\3\0\30\43\1\0\11\43\1\0\1\43"+
|
||||
"\2\0\7\43\72\0\60\43\1\0\2\43\14\0\7\43\11\0\12\46"+
|
||||
"\47\0\2\43\1\0\1\43\2\0\2\43\1\0\1\43\2\0\1\43"+
|
||||
"\6\0\4\43\1\0\7\43\1\0\3\43\1\0\1\43\1\0\1\43"+
|
||||
"\2\0\2\43\1\0\4\43\1\0\2\43\11\0\1\43\2\0\5\43"+
|
||||
"\1\0\1\43\11\0\12\45\2\0\2\43\42\0\1\43\37\0\12\45"+
|
||||
"\1\0\1\43\11\0\12\46\2\0\2\43\42\0\1\43\37\0\12\46"+
|
||||
"\26\0\10\43\1\0\42\43\35\0\4\43\164\0\42\43\1\0\5\43"+
|
||||
"\1\0\2\43\25\0\12\45\6\0\6\43\112\0\46\43\12\0\51\43"+
|
||||
"\1\0\2\43\25\0\12\46\6\0\6\43\112\0\46\43\12\0\51\43"+
|
||||
"\7\0\132\43\5\0\104\43\5\0\122\43\6\0\7\43\1\0\77\43"+
|
||||
"\1\0\1\43\1\0\4\43\2\0\7\43\1\0\1\43\1\0\4\43"+
|
||||
"\2\0\47\43\1\0\1\43\1\0\4\43\2\0\37\43\1\0\1\43"+
|
||||
"\1\0\4\43\2\0\7\43\1\0\1\43\1\0\4\43\2\0\7\43"+
|
||||
"\1\0\7\43\1\0\27\43\1\0\37\43\1\0\1\43\1\0\4\43"+
|
||||
"\2\0\7\43\1\0\47\43\1\0\23\43\16\0\11\45\56\0\125\43"+
|
||||
"\2\0\7\43\1\0\47\43\1\0\23\43\16\0\11\46\56\0\125\43"+
|
||||
"\14\0\u026c\43\2\0\10\43\12\0\32\43\5\0\113\43\25\0\15\43"+
|
||||
"\1\0\4\43\16\0\22\43\16\0\22\43\16\0\15\43\1\0\3\43"+
|
||||
"\17\0\64\43\43\0\1\43\4\0\1\43\3\0\12\45\46\0\12\45"+
|
||||
"\6\0\130\43\10\0\51\43\127\0\35\43\51\0\12\45\36\43\2\0"+
|
||||
"\17\0\64\43\43\0\1\43\4\0\1\43\3\0\12\46\46\0\12\46"+
|
||||
"\6\0\130\43\10\0\51\43\127\0\35\43\51\0\12\46\36\43\2\0"+
|
||||
"\5\43\u038b\0\154\43\224\0\234\43\4\0\132\43\6\0\26\43\2\0"+
|
||||
"\6\43\2\0\46\43\2\0\6\43\2\0\10\43\1\0\1\43\1\0"+
|
||||
"\1\43\1\0\1\43\1\0\37\43\2\0\65\43\1\0\7\43\1\0"+
|
||||
@@ -116,7 +114,7 @@ class _RegExLexer implements FlexLexer {
|
||||
"\7\43\14\0\5\43\5\0\1\43\1\0\12\43\1\0\15\43\1\0"+
|
||||
"\5\43\1\0\1\43\1\0\2\43\1\0\2\43\1\0\154\43\41\0"+
|
||||
"\u016b\43\22\0\100\43\2\0\66\43\50\0\14\43\164\0\5\43\1\0"+
|
||||
"\207\43\23\0\12\45\7\0\32\43\6\0\32\43\13\0\131\43\3\0"+
|
||||
"\207\43\23\0\12\46\7\0\32\43\6\0\32\43\13\0\131\43\3\0"+
|
||||
"\6\43\2\0\6\43\2\0\6\43\2\0\3\43\43\0";
|
||||
|
||||
/**
|
||||
@@ -136,13 +134,13 @@ class _RegExLexer implements FlexLexer {
|
||||
"\1\27\1\30\1\31\1\32\1\33\1\34\1\3\1\35"+
|
||||
"\1\36\1\35\1\37\1\40\1\1\1\41\1\42\1\2"+
|
||||
"\1\43\1\44\1\45\1\46\1\47\1\50\1\51\1\52"+
|
||||
"\1\53\2\54\1\55\1\11\1\56\1\57\1\60\1\61"+
|
||||
"\1\62\1\63\1\64\1\65\2\0\1\66\1\67\2\57"+
|
||||
"\2\60\1\70\1\71\1\0\1\66\1\57\1\72\2\60"+
|
||||
"\1\73\1\66\3\60\1\74";
|
||||
"\1\53\1\54\2\55\1\56\1\11\1\57\1\60\1\61"+
|
||||
"\1\62\1\63\1\64\1\65\1\66\2\0\1\67\1\70"+
|
||||
"\2\60\2\61\1\71\1\72\1\0\1\67\1\60\1\73"+
|
||||
"\2\61\1\74\1\67\3\61\1\75";
|
||||
|
||||
private static int [] zzUnpackAction() {
|
||||
int [] result = new int[88];
|
||||
int [] result = new int[89];
|
||||
int offset = 0;
|
||||
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -173,14 +171,15 @@ class _RegExLexer implements FlexLexer {
|
||||
"\0\u0188\0\u024c\0\u0188\0\u027d\0\u0188\0\u02ae\0\u0188\0\u0188"+
|
||||
"\0\u0188\0\u0188\0\u0188\0\u02df\0\u0188\0\u0188\0\u01ea\0\u0188"+
|
||||
"\0\u0188\0\u0310\0\u0341\0\u0188\0\u0188\0\u0372\0\u0188\0\u0188"+
|
||||
"\0\u03a3\0\u03d4\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188\0\u0405"+
|
||||
"\0\u0188\0\u0188\0\u0188\0\u0436\0\u0467\0\u0188\0\u0188\0\u0188"+
|
||||
"\0\u0188\0\u0188\0\u0498\0\u04c9\0\u04fa\0\u0188\0\u052b\0\u055c"+
|
||||
"\0\u058d\0\u05be\0\u0188\0\u0188\0\u05ef\0\u0620\0\u0188\0\u0188"+
|
||||
"\0\u0651\0\u0682\0\u0188\0\u0188\0\u06b3\0\u06e4\0\u0188\0\u0188";
|
||||
"\0\u03a3\0\u03d4\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188"+
|
||||
"\0\u0405\0\u0188\0\u0188\0\u0188\0\u0436\0\u0467\0\u0188\0\u0188"+
|
||||
"\0\u0188\0\u0188\0\u0188\0\u0498\0\u04c9\0\u04fa\0\u0188\0\u052b"+
|
||||
"\0\u055c\0\u058d\0\u05be\0\u0188\0\u0188\0\u05ef\0\u0620\0\u0188"+
|
||||
"\0\u0188\0\u0651\0\u0682\0\u0188\0\u0188\0\u06b3\0\u06e4\0\u0188"+
|
||||
"\0\u0188";
|
||||
|
||||
private static int [] zzUnpackRowMap() {
|
||||
int [] result = new int[88];
|
||||
int [] result = new int[89];
|
||||
int offset = 0;
|
||||
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -205,36 +204,37 @@ class _RegExLexer implements FlexLexer {
|
||||
private static final String ZZ_TRANS_PACKED_0 =
|
||||
"\3\11\1\12\1\13\1\14\1\15\1\11\1\16\1\11"+
|
||||
"\1\17\1\20\1\21\1\22\1\23\1\24\1\25\1\26"+
|
||||
"\20\11\1\27\5\11\1\20\5\11\1\30\1\20\1\31"+
|
||||
"\12\11\1\32\1\0\45\11\1\33\2\34\4\33\1\35"+
|
||||
"\12\33\17\36\1\34\1\33\1\36\1\33\1\34\1\37"+
|
||||
"\12\33\11\40\1\41\1\40\1\0\45\40\6\11\1\15"+
|
||||
"\1\11\1\16\1\42\1\17\1\43\1\21\25\11\1\27"+
|
||||
"\4\11\1\44\1\43\6\11\1\43\1\11\6\45\1\46"+
|
||||
"\20\11\1\27\1\11\1\30\4\11\1\20\5\11\1\31"+
|
||||
"\1\20\12\11\1\32\1\0\45\11\1\33\2\34\4\33"+
|
||||
"\1\35\12\33\17\36\1\34\1\33\1\36\2\33\1\34"+
|
||||
"\1\37\11\33\11\40\1\41\1\40\1\0\45\40\6\11"+
|
||||
"\1\15\1\11\1\16\1\42\1\17\1\43\1\21\25\11"+
|
||||
"\1\27\5\11\1\44\1\43\6\11\1\43\6\45\1\46"+
|
||||
"\1\45\1\47\1\45\1\17\46\45\5\50\1\51\14\50"+
|
||||
"\17\52\1\50\1\53\1\52\5\50\1\54\7\50\13\10"+
|
||||
"\1\55\43\10\1\55\1\10\77\0\1\56\53\0\1\57"+
|
||||
"\47\0\1\60\1\61\1\62\4\63\1\60\1\63\1\60"+
|
||||
"\1\63\1\60\6\63\2\64\2\65\2\66\1\67\1\70"+
|
||||
"\1\67\1\71\1\72\1\73\1\72\1\74\1\75\1\61"+
|
||||
"\1\63\1\72\15\60\36\0\1\76\23\0\2\34\36\0"+
|
||||
"\1\34\3\0\1\34\14\0\2\36\17\0\20\36\1\0"+
|
||||
"\3\36\62\0\1\77\33\0\17\52\2\0\1\52\37\0"+
|
||||
"\17\53\2\0\1\53\66\0\2\100\1\101\1\102\1\103"+
|
||||
"\1\104\3\0\2\61\36\0\1\61\21\0\1\105\36\0"+
|
||||
"\1\105\17\0\61\106\1\107\2\110\20\107\2\110\2\107"+
|
||||
"\3\110\2\107\1\110\1\107\1\110\2\107\1\110\17\107"+
|
||||
"\1\111\2\112\20\111\2\112\2\111\3\112\2\111\1\112"+
|
||||
"\1\111\1\112\2\111\1\112\17\111\53\0\1\113\1\114"+
|
||||
"\4\0\5\115\1\0\53\115\2\0\1\116\36\0\1\116"+
|
||||
"\17\0\62\117\2\120\20\117\2\120\2\117\3\120\2\117"+
|
||||
"\1\120\1\117\1\120\2\117\1\120\17\117\62\121\2\122"+
|
||||
"\20\121\2\122\2\121\3\122\2\121\1\122\1\121\1\122"+
|
||||
"\2\121\1\122\17\121\5\115\1\123\53\115\2\0\1\124"+
|
||||
"\36\0\1\124\17\0\62\125\2\126\20\125\2\126\2\125"+
|
||||
"\3\126\2\125\1\126\1\125\1\126\2\125\1\126\17\125"+
|
||||
"\62\127\2\130\20\127\2\130\2\127\3\130\2\127\1\130"+
|
||||
"\1\127\1\130\2\127\1\130\17\127";
|
||||
"\17\52\1\50\1\53\1\52\6\50\1\54\6\50\13\10"+
|
||||
"\1\55\44\10\1\55\77\0\1\56\53\0\1\57\47\0"+
|
||||
"\1\60\1\61\1\62\4\63\1\60\1\63\1\60\1\63"+
|
||||
"\1\64\6\63\2\65\2\66\2\67\1\70\1\71\1\70"+
|
||||
"\1\72\1\73\1\74\1\73\1\75\1\76\1\61\1\63"+
|
||||
"\1\73\1\64\4\60\1\64\6\60\1\64\36\0\1\77"+
|
||||
"\23\0\2\34\36\0\1\34\4\0\1\34\13\0\2\36"+
|
||||
"\17\0\20\36\1\0\1\36\1\0\2\36\62\0\1\100"+
|
||||
"\32\0\17\52\2\0\1\52\37\0\17\53\2\0\1\53"+
|
||||
"\67\0\2\101\1\102\1\103\1\104\1\105\2\0\2\61"+
|
||||
"\36\0\1\61\21\0\1\106\36\0\1\106\17\0\61\107"+
|
||||
"\1\110\2\111\20\110\2\111\2\110\3\111\2\110\1\111"+
|
||||
"\1\110\1\111\2\110\1\111\17\110\1\112\2\113\20\112"+
|
||||
"\2\113\2\112\3\113\2\112\1\113\1\112\1\113\2\112"+
|
||||
"\1\113\17\112\54\0\1\114\1\115\3\0\5\116\1\0"+
|
||||
"\53\116\2\0\1\117\36\0\1\117\17\0\62\120\2\121"+
|
||||
"\20\120\2\121\2\120\3\121\2\120\1\121\1\120\1\121"+
|
||||
"\2\120\1\121\17\120\62\122\2\123\20\122\2\123\2\122"+
|
||||
"\3\123\2\122\1\123\1\122\1\123\2\122\1\123\17\122"+
|
||||
"\5\116\1\124\53\116\2\0\1\125\36\0\1\125\17\0"+
|
||||
"\62\126\2\127\20\126\2\127\2\126\3\127\2\126\1\127"+
|
||||
"\1\126\1\127\2\126\1\127\17\126\62\130\2\131\20\130"+
|
||||
"\2\131\2\130\3\131\2\130\1\131\1\130\1\131\2\130"+
|
||||
"\1\131\17\130";
|
||||
|
||||
private static int [] zzUnpackTrans() {
|
||||
int [] result = new int[1813];
|
||||
@@ -281,12 +281,12 @@ class _RegExLexer implements FlexLexer {
|
||||
"\6\0\2\1\2\11\1\1\2\11\1\3\1\1\12\11"+
|
||||
"\1\1\1\11\1\1\1\11\1\1\5\11\1\1\2\11"+
|
||||
"\1\3\2\11\2\1\2\11\1\1\1\15\1\11\2\1"+
|
||||
"\5\11\1\1\3\11\2\1\5\11\2\0\1\1\1\11"+
|
||||
"\6\11\1\1\3\11\2\1\5\11\2\0\1\1\1\11"+
|
||||
"\4\1\2\11\1\0\1\1\2\11\2\1\2\11\2\1"+
|
||||
"\2\11";
|
||||
|
||||
private static int [] zzUnpackAttribute() {
|
||||
int [] result = new int[88];
|
||||
int [] result = new int[89];
|
||||
int offset = 0;
|
||||
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -431,14 +431,7 @@ class _RegExLexer implements FlexLexer {
|
||||
|
||||
// For Demetra compatibility
|
||||
public void reset(CharSequence buffer, int initialState){
|
||||
zzBuffer = buffer;
|
||||
zzBufferArray = null;
|
||||
zzCurrentPos = zzMarkedPos = zzStartRead = 0;
|
||||
zzPushbackPos = 0;
|
||||
zzAtEOF = false;
|
||||
zzAtBOL = true;
|
||||
zzEndRead = buffer.length();
|
||||
yybegin(initialState);
|
||||
reset(buffer, 0, buffer.length(), initialState);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -650,243 +643,247 @@ class _RegExLexer implements FlexLexer {
|
||||
case 7:
|
||||
{ if (yystate() != CLASS2) yypushstate(EMBRACED); return RegExpTT.LBRACE;
|
||||
}
|
||||
case 61: break;
|
||||
case 62: break;
|
||||
case 6:
|
||||
{ return RegExpTT.GROUP_END;
|
||||
}
|
||||
case 62: break;
|
||||
case 63: break;
|
||||
case 36:
|
||||
{ yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 63: break;
|
||||
case 64: break;
|
||||
case 14:
|
||||
{ return RegExpTT.STAR;
|
||||
}
|
||||
case 64: break;
|
||||
case 65: break;
|
||||
case 40:
|
||||
{ return RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 65: break;
|
||||
case 66: break;
|
||||
case 28:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 66: break;
|
||||
case 67: break;
|
||||
case 41:
|
||||
{ return commentMode ? RegExpTT.CHARACTER : RegExpTT.REDUNDANT_ESCAPE;
|
||||
}
|
||||
case 68: break;
|
||||
case 37:
|
||||
{ return RegExpTT.REDUNDANT_ESCAPE;
|
||||
}
|
||||
case 67: break;
|
||||
case 69: break;
|
||||
case 24:
|
||||
{ return RegExpTT.COMMA;
|
||||
}
|
||||
case 68: break;
|
||||
case 56:
|
||||
case 70: break;
|
||||
case 57:
|
||||
{ return RegExpTT.POS_LOOKBEHIND;
|
||||
}
|
||||
case 69: break;
|
||||
case 71: break;
|
||||
case 39:
|
||||
{ return RegExpTT.BAD_OCT_VALUE;
|
||||
}
|
||||
case 70: break;
|
||||
case 72: break;
|
||||
case 10:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CTRL_CHARACTER;
|
||||
}
|
||||
case 71: break;
|
||||
case 73: break;
|
||||
case 30:
|
||||
{ yypopstate(); yypushstate(EMBRACED); return RegExpTT.LBRACE;
|
||||
}
|
||||
case 72: break;
|
||||
case 48:
|
||||
case 74: break;
|
||||
case 49:
|
||||
{ return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
|
||||
}
|
||||
case 73: break;
|
||||
case 57:
|
||||
case 75: break;
|
||||
case 58:
|
||||
{ return RegExpTT.NEG_LOOKBEHIND;
|
||||
}
|
||||
case 74: break;
|
||||
case 60:
|
||||
case 76: break;
|
||||
case 61:
|
||||
{ return RegExpTT.UNICODE_CHAR;
|
||||
}
|
||||
case 75: break;
|
||||
case 55:
|
||||
case 77: break;
|
||||
case 56:
|
||||
{ if (xmlSchemaMode) { yypushback(1); return RegExpTT.CHAR_CLASS; } else return RegExpTT.CTRL;
|
||||
}
|
||||
case 76: break;
|
||||
case 78: break;
|
||||
case 35:
|
||||
{ yybegin(OPTIONS); return RegExpTT.SET_OPTIONS;
|
||||
}
|
||||
case 77: break;
|
||||
case 79: break;
|
||||
case 12:
|
||||
{ return RegExpTT.DOLLAR;
|
||||
}
|
||||
case 78: break;
|
||||
case 49:
|
||||
case 80: break;
|
||||
case 50:
|
||||
{ yypopstate(); return RegExpTT.QUOTE_END;
|
||||
}
|
||||
case 79: break;
|
||||
case 52:
|
||||
case 81: break;
|
||||
case 53:
|
||||
{ return RegExpTT.POS_LOOKAHEAD;
|
||||
}
|
||||
case 80: break;
|
||||
case 82: break;
|
||||
case 22:
|
||||
{ yypopstate(); return RegExpTT.RBRACE;
|
||||
}
|
||||
case 81: break;
|
||||
case 83: break;
|
||||
case 3:
|
||||
{ return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 82: break;
|
||||
case 53:
|
||||
case 84: break;
|
||||
case 54:
|
||||
{ return RegExpTT.NEG_LOOKAHEAD;
|
||||
}
|
||||
case 83: break;
|
||||
case 41:
|
||||
case 85: break;
|
||||
case 42:
|
||||
{ return RegExpTT.ESC_CTRL_CHARACTER;
|
||||
}
|
||||
case 84: break;
|
||||
case 86: break;
|
||||
case 23:
|
||||
{ return RegExpTT.NAME;
|
||||
}
|
||||
case 85: break;
|
||||
case 50:
|
||||
case 87: break;
|
||||
case 51:
|
||||
{ return RegExpTT.ANDAND;
|
||||
}
|
||||
case 86: break;
|
||||
case 88: break;
|
||||
case 13:
|
||||
{ return RegExpTT.QUEST;
|
||||
}
|
||||
case 87: break;
|
||||
case 43:
|
||||
case 89: break;
|
||||
case 44:
|
||||
{ return RegExpTT.CHAR_CLASS;
|
||||
}
|
||||
case 88: break;
|
||||
case 90: break;
|
||||
case 17:
|
||||
{ return RegExpTT.MINUS;
|
||||
}
|
||||
case 89: break;
|
||||
case 59:
|
||||
case 91: break;
|
||||
case 60:
|
||||
{ return RegExpTT.COMMENT;
|
||||
}
|
||||
case 90: break;
|
||||
case 92: break;
|
||||
case 38:
|
||||
{ return yystate() != CLASS2 ? RegExpTT.BACKREF : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 91: break;
|
||||
case 93: break;
|
||||
case 16:
|
||||
{ return RegExpTT.UNION;
|
||||
}
|
||||
case 92: break;
|
||||
case 44:
|
||||
case 94: break;
|
||||
case 45:
|
||||
{ if (xmlSchemaMode) return RegExpTT.CHAR_CLASS; else return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
|
||||
}
|
||||
case 93: break;
|
||||
case 54:
|
||||
case 95: break;
|
||||
case 55:
|
||||
{ return RegExpTT.OCT_CHAR;
|
||||
}
|
||||
case 94: break;
|
||||
case 96: break;
|
||||
case 4:
|
||||
{ return RegExpTT.DOT;
|
||||
}
|
||||
case 95: break;
|
||||
case 97: break;
|
||||
case 32:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.GROUP_END;
|
||||
}
|
||||
case 96: break;
|
||||
case 98: break;
|
||||
case 21:
|
||||
{ return RegExpTT.NUMBER;
|
||||
}
|
||||
case 97: break;
|
||||
case 45:
|
||||
case 99: break;
|
||||
case 46:
|
||||
{ yypushstate(PROP); return RegExpTT.PROPERTY;
|
||||
}
|
||||
case 98: break;
|
||||
case 19:
|
||||
case 100: break;
|
||||
case 18:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER;
|
||||
}
|
||||
case 99: break;
|
||||
case 101: break;
|
||||
case 33:
|
||||
{ handleOptions(); return RegExpTT.OPTIONS_OFF;
|
||||
}
|
||||
case 100: break;
|
||||
case 102: break;
|
||||
case 34:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.COLON;
|
||||
}
|
||||
case 101: break;
|
||||
case 103: break;
|
||||
case 25:
|
||||
{ assert false : yytext();
|
||||
}
|
||||
case 102: break;
|
||||
case 104: break;
|
||||
case 27:
|
||||
{ yypopstate(); return RegExpTT.CLASS_END;
|
||||
}
|
||||
case 103: break;
|
||||
case 105: break;
|
||||
case 11:
|
||||
{ return RegExpTT.CARET;
|
||||
}
|
||||
case 104: break;
|
||||
case 106: break;
|
||||
case 1:
|
||||
{ handleOptions(); return RegExpTT.OPTIONS_ON;
|
||||
}
|
||||
case 105: break;
|
||||
case 107: break;
|
||||
case 29:
|
||||
{ yypopstate(); yypushback(1);
|
||||
}
|
||||
case 106: break;
|
||||
case 42:
|
||||
case 108: break;
|
||||
case 43:
|
||||
{ return yystate() != CLASS2 ? RegExpTT.BOUNDARY : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 107: break;
|
||||
case 18:
|
||||
case 109: break;
|
||||
case 19:
|
||||
{ if (commentMode) { yypushstate(COMMENT); return RegExpTT.COMMENT; } else return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 108: break;
|
||||
case 58:
|
||||
case 110: break;
|
||||
case 59:
|
||||
{ return RegExpTT.HEX_CHAR;
|
||||
}
|
||||
case 109: break;
|
||||
case 111: break;
|
||||
case 20:
|
||||
{ return RegExpTT.BAD_CHARACTER;
|
||||
}
|
||||
case 110: break;
|
||||
case 112: break;
|
||||
case 5:
|
||||
{ return RegExpTT.GROUP_BEGIN;
|
||||
}
|
||||
case 111: break;
|
||||
case 113: break;
|
||||
case 8:
|
||||
{ yypushstate(CLASS2); return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 112: break;
|
||||
case 51:
|
||||
case 114: break;
|
||||
case 52:
|
||||
{ return RegExpTT.NON_CAPT_GROUP;
|
||||
}
|
||||
case 113: break;
|
||||
case 115: break;
|
||||
case 9:
|
||||
{ return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
|
||||
}
|
||||
case 114: break;
|
||||
case 47:
|
||||
case 116: break;
|
||||
case 48:
|
||||
{ return RegExpTT.BAD_HEX_VALUE;
|
||||
}
|
||||
case 115: break;
|
||||
case 117: break;
|
||||
case 2:
|
||||
{ yypopstate(); return RegExpTT.COMMENT;
|
||||
}
|
||||
case 116: break;
|
||||
case 46:
|
||||
case 118: break;
|
||||
case 47:
|
||||
{ yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN;
|
||||
}
|
||||
case 117: break;
|
||||
case 119: break;
|
||||
case 26:
|
||||
{ yybegin(CLASS2); return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 118: break;
|
||||
case 120: break;
|
||||
case 15:
|
||||
{ return RegExpTT.PLUS;
|
||||
}
|
||||
case 119: break;
|
||||
case 121: break;
|
||||
case 31:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER;
|
||||
}
|
||||
case 120: break;
|
||||
case 122: break;
|
||||
default:
|
||||
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
|
||||
zzAtEOF = true;
|
||||
|
||||
@@ -138,6 +138,7 @@ HEX_CHAR=[0-9a-fA-F]
|
||||
{ESCAPE} {CONTROL} { return RegExpTT.ESC_CTRL_CHARACTER; }
|
||||
|
||||
{ESCAPE} [:letter:] { return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; }
|
||||
{ESCAPE} [\n\b\t\r\f ] { return commentMode ? RegExpTT.CHARACTER : RegExpTT.REDUNDANT_ESCAPE; }
|
||||
{ESCAPE} {ANY} { return RegExpTT.REDUNDANT_ESCAPE; }
|
||||
{ESCAPE} { return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; }
|
||||
|
||||
|
||||
@@ -979,4 +979,15 @@
|
||||
<expected>OK</expected>
|
||||
</test>
|
||||
</bug>
|
||||
|
||||
<bug id="IDEA-25680">
|
||||
<test info="true">
|
||||
<pattern>(?x)a\ b\ c</pattern>
|
||||
<expected>OK</expected>
|
||||
</test>
|
||||
<test verify="false" info="true">
|
||||
<pattern><![CDATA[a<weak_warning descr="Redundant character escape">\ </weak_warning>b]]></pattern>
|
||||
<expected>OK</expected>
|
||||
</test>
|
||||
</bug>
|
||||
</tests>
|
||||
|
||||
@@ -16,11 +16,9 @@
|
||||
package com.intellij.packaging.impl.artifacts;
|
||||
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.packaging.artifacts.ArtifactProperties;
|
||||
import com.intellij.packaging.artifacts.ArtifactPropertiesProvider;
|
||||
import com.intellij.packaging.artifacts.ArtifactType;
|
||||
import com.intellij.packaging.artifacts.ModifiableArtifact;
|
||||
import com.intellij.packaging.artifacts.*;
|
||||
import com.intellij.packaging.elements.CompositePackagingElement;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
@@ -37,16 +35,23 @@ public class ArtifactImpl extends UserDataHolderBase implements ModifiableArtifa
|
||||
private String myName;
|
||||
private boolean myBuildOnMake;
|
||||
private String myOutputPath;
|
||||
private final EventDispatcher<ArtifactListener> myDispatcher;
|
||||
private ArtifactType myArtifactType;
|
||||
private Map<ArtifactPropertiesProvider, ArtifactProperties<?>> myProperties;
|
||||
|
||||
public ArtifactImpl(@NotNull String name, @NotNull ArtifactType artifactType, boolean buildOnMake, @NotNull CompositePackagingElement<?> rootElement,
|
||||
String outputPath) {
|
||||
this(name, artifactType, buildOnMake, rootElement, outputPath, null);
|
||||
}
|
||||
public ArtifactImpl(@NotNull String name, @NotNull ArtifactType artifactType, boolean buildOnMake, @NotNull CompositePackagingElement<?> rootElement,
|
||||
String outputPath,
|
||||
EventDispatcher<ArtifactListener> dispatcher) {
|
||||
myName = name;
|
||||
myArtifactType = artifactType;
|
||||
myBuildOnMake = buildOnMake;
|
||||
myRootElement = rootElement;
|
||||
myOutputPath = outputPath;
|
||||
myDispatcher = dispatcher;
|
||||
myProperties = new HashMap<ArtifactPropertiesProvider, ArtifactProperties<?>>();
|
||||
resetProperties();
|
||||
}
|
||||
@@ -86,8 +91,8 @@ public class ArtifactImpl extends UserDataHolderBase implements ModifiableArtifa
|
||||
return Collections.unmodifiableCollection(myProperties.keySet());
|
||||
}
|
||||
|
||||
public ArtifactImpl createCopy() {
|
||||
final ArtifactImpl artifact = new ArtifactImpl(myName, myArtifactType, myBuildOnMake, myRootElement, myOutputPath);
|
||||
public ArtifactImpl createCopy(EventDispatcher<ArtifactListener> dispatcher) {
|
||||
final ArtifactImpl artifact = new ArtifactImpl(myName, myArtifactType, myBuildOnMake, myRootElement, myOutputPath, dispatcher);
|
||||
for (Map.Entry<ArtifactPropertiesProvider, ArtifactProperties<?>> entry : myProperties.entrySet()) {
|
||||
final ArtifactProperties newProperties = artifact.myProperties.get(entry.getKey());
|
||||
//noinspection unchecked
|
||||
@@ -97,7 +102,11 @@ public class ArtifactImpl extends UserDataHolderBase implements ModifiableArtifa
|
||||
}
|
||||
|
||||
public void setName(@NotNull String name) {
|
||||
String oldName = myName;
|
||||
myName = name;
|
||||
if (myDispatcher != null) {
|
||||
myDispatcher.getMulticaster().artifactChanged(this, oldName);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNls @Override
|
||||
|
||||
+9
-7
@@ -52,7 +52,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
@NonNls public static final String COMPONENT_NAME = "ArtifactManager";
|
||||
@NonNls public static final String PACKAGING_ELEMENT_NAME = "element";
|
||||
@NonNls public static final String TYPE_ID_ATTRIBUTE = "id";
|
||||
private final ArtifactManagerModel myModel = new ArtifactManagerModel();
|
||||
private final ArtifactManagerModel myModel;
|
||||
private final Project myProject;
|
||||
private final DefaultPackagingElementResolvingContext myResolvingContext;
|
||||
private boolean myInsideCommit = false;
|
||||
@@ -67,6 +67,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
|
||||
public ArtifactManagerImpl(Project project, VirtualFileManager virtualFileManager) {
|
||||
myProject = project;
|
||||
myModel = new ArtifactManagerModel();
|
||||
myResolvingContext = new DefaultPackagingElementResolvingContext(myProject);
|
||||
virtualFileManager.addVirtualFileListener(new ArtifactVirtualFileListener(myProject, this), myProject);
|
||||
}
|
||||
@@ -85,6 +86,11 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
return myModel.getArtifactByOriginal(artifact);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Artifact getOriginalArtifact(@NotNull Artifact artifact) {
|
||||
return myModel.getOriginalArtifact(artifact);
|
||||
}
|
||||
|
||||
public Collection<? extends Artifact> getArtifactsByType(@NotNull ArtifactType type) {
|
||||
return myModel.getArtifactsByType(type);
|
||||
}
|
||||
@@ -183,8 +189,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
}
|
||||
|
||||
if (myLoaded) {
|
||||
final ArtifactModelImpl model = new ArtifactModelImpl(this);
|
||||
model.addArtifacts(artifacts);
|
||||
final ArtifactModelImpl model = new ArtifactModelImpl(this, artifacts);
|
||||
doCommit(model);
|
||||
}
|
||||
else {
|
||||
@@ -258,10 +263,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
|
||||
@Override
|
||||
public ModifiableArtifactModel createModifiableModel() {
|
||||
((ArtifactPointerManagerImpl)ArtifactPointerManager.getInstance(myProject)).updateAllPointers();
|
||||
final ArtifactModelImpl model = new ArtifactModelImpl(this);
|
||||
model.addArtifacts(getArtifactsList());
|
||||
return model;
|
||||
return new ArtifactModelImpl(this, getArtifactsList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,6 +55,11 @@ public abstract class ArtifactModelBase implements ArtifactModel {
|
||||
return artifact;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Artifact getOriginalArtifact(@NotNull Artifact artifact) {
|
||||
return artifact;
|
||||
}
|
||||
|
||||
public Collection<? extends Artifact> getArtifactsByType(@NotNull ArtifactType type) {
|
||||
final List<Artifact> result = new ArrayList<Artifact>();
|
||||
for (Artifact artifact : getArtifacts()) {
|
||||
|
||||
+23
-12
@@ -36,16 +36,15 @@ public class ArtifactModelImpl extends ArtifactModelBase implements ModifiableAr
|
||||
private final Map<ArtifactImpl, ArtifactImpl> myModifiable2Original = new HashMap<ArtifactImpl, ArtifactImpl>();
|
||||
private final EventDispatcher<ArtifactListener> myDispatcher = EventDispatcher.create(ArtifactListener.class);
|
||||
|
||||
public ArtifactModelImpl(ArtifactManagerImpl artifactManager) {
|
||||
public ArtifactModelImpl(ArtifactManagerImpl artifactManager, List<ArtifactImpl> originalArtifacts) {
|
||||
myArtifactManager = artifactManager;
|
||||
myOriginalArtifacts = new ArrayList<ArtifactImpl>();
|
||||
}
|
||||
|
||||
public void addArtifacts(List<ArtifactImpl> artifacts) {
|
||||
for (ArtifactImpl artifact : artifacts) {
|
||||
myOriginalArtifacts.add(artifact);
|
||||
}
|
||||
artifactsChanged();
|
||||
myOriginalArtifacts = new ArrayList<ArtifactImpl>(originalArtifacts);
|
||||
addListener(new ArtifactAdapter() {
|
||||
@Override
|
||||
public void artifactChanged(@NotNull Artifact artifact, @NotNull String oldName) {
|
||||
artifactsChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected List<? extends Artifact> getArtifactsList() {
|
||||
@@ -70,7 +69,7 @@ public class ArtifactModelImpl extends ArtifactModelBase implements ModifiableAr
|
||||
@NotNull
|
||||
public ModifiableArtifact addArtifact(@NotNull String name, @NotNull ArtifactType artifactType, CompositePackagingElement<?> rootElement) {
|
||||
final String outputPath = ArtifactUtil.getDefaultArtifactOutputPath(name, myArtifactManager.getProject());
|
||||
final ArtifactImpl artifact = new ArtifactImpl(generateUniqueName(name), artifactType, false, rootElement, outputPath);
|
||||
final ArtifactImpl artifact = new ArtifactImpl(generateUniqueName(name), artifactType, false, rootElement, outputPath, myDispatcher);
|
||||
myOriginalArtifacts.add(artifact);
|
||||
myArtifact2ModifiableCopy.put(artifact, artifact);
|
||||
myModifiable2Original.put(artifact, artifact);
|
||||
@@ -123,7 +122,8 @@ public class ArtifactModelImpl extends ArtifactModelBase implements ModifiableAr
|
||||
|
||||
ArtifactImpl modifiableCopy = myArtifact2ModifiableCopy.get(artifactImpl);
|
||||
if (modifiableCopy == null) {
|
||||
modifiableCopy = artifactImpl.createCopy();
|
||||
modifiableCopy = artifactImpl.createCopy(myDispatcher);
|
||||
myDispatcher.getMulticaster().artifactChanged(modifiableCopy, artifact.getName());
|
||||
myArtifact2ModifiableCopy.put(artifactImpl, modifiableCopy);
|
||||
myModifiable2Original.put(modifiableCopy, artifactImpl);
|
||||
artifactsChanged();
|
||||
@@ -131,7 +131,8 @@ public class ArtifactModelImpl extends ArtifactModelBase implements ModifiableAr
|
||||
return modifiableCopy;
|
||||
}
|
||||
|
||||
public Artifact getOriginalArtifact(Artifact artifact) {
|
||||
@NotNull
|
||||
public Artifact getOriginalArtifact(@NotNull Artifact artifact) {
|
||||
final ArtifactImpl original = myModifiable2Original.get(artifact);
|
||||
return original != null ? original : artifact;
|
||||
}
|
||||
@@ -151,6 +152,16 @@ public class ArtifactModelImpl extends ArtifactModelBase implements ModifiableAr
|
||||
myArtifactManager.commit(this);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
List<Artifact> artifacts = new ArrayList<Artifact>();
|
||||
for (ArtifactImpl artifact : myModifiable2Original.keySet()) {
|
||||
if (myModifiable2Original.get(artifact).equals(artifact)) {
|
||||
artifacts.add(artifact);
|
||||
}
|
||||
}
|
||||
((ArtifactPointerManagerImpl)ArtifactPointerManager.getInstance(myArtifactManager.getProject())).disposePointers(artifacts);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ArtifactImpl getModifiableCopy(Artifact artifact) {
|
||||
//noinspection SuspiciousMethodCalls
|
||||
|
||||
+21
-16
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package com.intellij.packaging.impl.artifacts;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.artifacts.ArtifactModel;
|
||||
import com.intellij.packaging.artifacts.ArtifactPointer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -26,35 +24,42 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author nik
|
||||
*/
|
||||
public class ArtifactPointerImpl implements ArtifactPointer {
|
||||
private final Project myProject;
|
||||
private String myName;
|
||||
private Artifact myArtifact;
|
||||
|
||||
public ArtifactPointerImpl(@NotNull Project project, @NotNull String name) {
|
||||
myProject = project;
|
||||
public ArtifactPointerImpl(@NotNull String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
public ArtifactPointerImpl(@NotNull Artifact artifact) {
|
||||
myArtifact = artifact;
|
||||
myName = artifact.getName();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
public String getArtifactName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public Artifact getArtifact() {
|
||||
if (myArtifact == null) {
|
||||
myArtifact = findArtifact(ArtifactManager.getInstance(myProject));
|
||||
}
|
||||
return myArtifact;
|
||||
}
|
||||
|
||||
public Artifact findArtifact(@NotNull ArtifactModel artifactModel) {
|
||||
if (myArtifact != null) {
|
||||
final Artifact artifact = artifactModel.getArtifactByOriginal(myArtifact);
|
||||
if (!artifact.equals(myArtifact)) {
|
||||
return artifact;
|
||||
}
|
||||
@NotNull
|
||||
public String getArtifactName(@NotNull ArtifactModel artifactModel) {
|
||||
final Artifact artifact = getArtifact();
|
||||
if (artifact != null) {
|
||||
return artifactModel.getArtifactByOriginal(artifact).getName();
|
||||
}
|
||||
return artifactModel.findArtifact(myName);
|
||||
return myName;
|
||||
}
|
||||
|
||||
public Artifact findArtifact(@NotNull ArtifactModel artifactModel) {
|
||||
final Artifact artifact = getArtifact();
|
||||
if (artifact != null) {
|
||||
return artifactModel.getArtifactByOriginal(artifact);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void setArtifact(Artifact artifact) {
|
||||
|
||||
+54
-28
@@ -20,72 +20,98 @@ import com.intellij.packaging.artifacts.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ArtifactPointerManagerImpl extends ArtifactPointerManager {
|
||||
private final Map<String, ArtifactPointerImpl> myUnresolvedPointers = new HashMap<String, ArtifactPointerImpl>();
|
||||
private final Map<Artifact, ArtifactPointerImpl> myPointers = new HashMap<Artifact, ArtifactPointerImpl>();
|
||||
private final Project myProject;
|
||||
private final Map<String, ArtifactPointerImpl> myPointers = new HashMap<String, ArtifactPointerImpl>();
|
||||
|
||||
public ArtifactPointerManagerImpl(Project project) {
|
||||
myProject = project;
|
||||
myProject.getMessageBus().connect().subscribe(ArtifactManager.TOPIC, new ArtifactAdapter() {
|
||||
project.getMessageBus().connect().subscribe(ArtifactManager.TOPIC, new ArtifactAdapter() {
|
||||
@Override
|
||||
public void artifactRemoved(@NotNull Artifact artifact) {
|
||||
final ArtifactPointerImpl pointer = myPointers.get(artifact.getName());
|
||||
if (pointer != null) {
|
||||
pointer.setArtifact(null);
|
||||
}
|
||||
disposePointer(artifact);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void artifactAdded(@NotNull Artifact artifact) {
|
||||
final ArtifactPointerImpl artifactPointer = myPointers.get(artifact.getName());
|
||||
if (artifactPointer != null) {
|
||||
artifactPointer.setArtifact(artifact);
|
||||
final ArtifactPointerImpl pointer = myPointers.get(artifact);
|
||||
if (pointer != null) {
|
||||
pointer.setName(artifact.getName());
|
||||
}
|
||||
|
||||
final ArtifactPointerImpl unresolved = myUnresolvedPointers.remove(artifact.getName());
|
||||
if (unresolved != null) {
|
||||
unresolved.setArtifact(artifact);
|
||||
if (pointer == null) {
|
||||
myPointers.put(artifact, unresolved);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void artifactChanged(@NotNull Artifact artifact, @NotNull String oldName) {
|
||||
final ArtifactPointerImpl pointer = myPointers.get(oldName);
|
||||
final ArtifactPointerImpl pointer = myPointers.get(artifact);
|
||||
if (pointer != null) {
|
||||
pointer.setArtifact(artifact);
|
||||
final String newName = artifact.getName();
|
||||
if (!newName.equals(oldName)) {
|
||||
pointer.setName(newName);
|
||||
myPointers.remove(oldName);
|
||||
myPointers.put(newName, pointer);
|
||||
pointer.setName(artifact.getName());
|
||||
}
|
||||
|
||||
final ArtifactPointerImpl unresolved = myUnresolvedPointers.remove(artifact.getName());
|
||||
if (unresolved != null) {
|
||||
unresolved.setArtifact(artifact);
|
||||
if (pointer == null) {
|
||||
myPointers.put(artifact, unresolved);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateAllPointers() {
|
||||
for (ArtifactPointerImpl pointer : myPointers.values()) {
|
||||
pointer.getArtifact();
|
||||
private void disposePointer(Artifact artifact) {
|
||||
final ArtifactPointerImpl pointer = myPointers.remove(artifact);
|
||||
if (pointer != null) {
|
||||
pointer.setArtifact(null);
|
||||
myUnresolvedPointers.put(pointer.getArtifactName(), pointer);
|
||||
}
|
||||
}
|
||||
|
||||
public ArtifactPointer create(@NotNull String name) {
|
||||
ArtifactPointerImpl pointer = myPointers.get(name);
|
||||
public ArtifactPointer createPointer(@NotNull String name) {
|
||||
final Artifact artifact = ArtifactManager.getInstance(myProject).findArtifact(name);
|
||||
if (artifact != null) {
|
||||
return createPointer(artifact);
|
||||
}
|
||||
|
||||
ArtifactPointerImpl pointer = myUnresolvedPointers.get(name);
|
||||
if (pointer == null) {
|
||||
pointer = new ArtifactPointerImpl(myProject, name);
|
||||
myPointers.put(name, pointer);
|
||||
pointer = new ArtifactPointerImpl(name);
|
||||
myUnresolvedPointers.put(name, pointer);
|
||||
}
|
||||
return pointer;
|
||||
}
|
||||
|
||||
public ArtifactPointer create(@NotNull Artifact artifact) {
|
||||
final String name = artifact.getName();
|
||||
ArtifactPointerImpl pointer = myPointers.get(name);
|
||||
public ArtifactPointer createPointer(@NotNull Artifact artifact) {
|
||||
ArtifactPointerImpl pointer = myPointers.get(artifact);
|
||||
if (pointer == null) {
|
||||
pointer = new ArtifactPointerImpl(myProject, name);
|
||||
myPointers.put(artifact.getName(), pointer);
|
||||
pointer = new ArtifactPointerImpl(artifact);
|
||||
myPointers.put(artifact, pointer);
|
||||
}
|
||||
return pointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArtifactPointer createPointer(@NotNull Artifact artifact, @NotNull ArtifactModel artifactModel) {
|
||||
return createPointer(artifactModel.getOriginalArtifact(artifact));
|
||||
}
|
||||
|
||||
public void disposePointers(List<Artifact> artifacts) {
|
||||
for (Artifact artifact : artifacts) {
|
||||
disposePointer(artifact);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class ArtifactElementType extends ComplexPackagingElementType<ArtifactPac
|
||||
List<Artifact> artifacts = context.chooseArtifacts(getAvailableArtifacts(context, artifact), CompilerBundle.message("dialog.title.choose.artifacts"));
|
||||
final List<ArtifactPackagingElement> elements = new ArrayList<ArtifactPackagingElement>();
|
||||
for (Artifact selected : artifacts) {
|
||||
elements.add(new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).create(selected.getName())));
|
||||
elements.add(new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).createPointer(selected, context.getArtifactModel())));
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
+6
-9
@@ -18,19 +18,16 @@ package com.intellij.packaging.impl.elements;
|
||||
import com.intellij.compiler.ant.BuildProperties;
|
||||
import com.intellij.compiler.ant.Generator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactType;
|
||||
import com.intellij.packaging.artifacts.ArtifactPointer;
|
||||
import com.intellij.packaging.artifacts.ArtifactPointerManager;
|
||||
import com.intellij.packaging.artifacts.*;
|
||||
import com.intellij.packaging.elements.*;
|
||||
import com.intellij.packaging.impl.ui.ArtifactElementPresentation;
|
||||
import com.intellij.packaging.impl.ui.DelegatedPackagingElementPresentation;
|
||||
import com.intellij.packaging.ui.PackagingElementPresentation;
|
||||
import com.intellij.packaging.ui.ArtifactEditorContext;
|
||||
import com.intellij.packaging.ui.PackagingElementPresentation;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -107,14 +104,14 @@ public class ArtifactPackagingElement extends ComplexPackagingElement<ArtifactPa
|
||||
public ArtifactPackagingElementState getState() {
|
||||
final ArtifactPackagingElementState state = new ArtifactPackagingElementState();
|
||||
if (myArtifactPointer != null) {
|
||||
state.setArtifactName(myArtifactPointer.getName());
|
||||
state.setArtifactName(myArtifactPointer.getArtifactName());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public void loadState(ArtifactPackagingElementState state) {
|
||||
final String name = state.getArtifactName();
|
||||
myArtifactPointer = name != null ? ArtifactPointerManager.getInstance(myProject).create(name) : null;
|
||||
myArtifactPointer = name != null ? ArtifactPointerManager.getInstance(myProject).createPointer(name) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,7 +132,7 @@ public class ArtifactPackagingElement extends ComplexPackagingElement<ArtifactPa
|
||||
|
||||
@Nullable
|
||||
public String getArtifactName() {
|
||||
return myArtifactPointer != null ? myArtifactPointer.getName() : null;
|
||||
return myArtifactPointer != null ? myArtifactPointer.getArtifactName() : null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+8
-1
@@ -27,6 +27,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactPointer;
|
||||
import com.intellij.packaging.artifacts.ArtifactPointerManager;
|
||||
import com.intellij.packaging.elements.*;
|
||||
import com.intellij.packaging.ui.ArtifactEditorContext;
|
||||
@@ -114,7 +115,7 @@ public class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createArtifactElement(@NotNull Artifact artifact, @NotNull Project project) {
|
||||
return new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).create(artifact));
|
||||
return new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).createPointer(artifact));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -204,6 +205,12 @@ public class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
return elements;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createArtifactElement(@NotNull ArtifactPointer artifactPointer, @NotNull Project project) {
|
||||
return new ArtifactPackagingElement(project, artifactPointer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createLibraryFiles(@NotNull String libraryName, @NotNull String level, String moduleName) {
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
public class ArtifactChooser extends ElementsChooser<ArtifactPointer> {
|
||||
private static final Comparator<ArtifactPointer> ARTIFACT_COMPARATOR = new Comparator<ArtifactPointer>() {
|
||||
public int compare(ArtifactPointer o1, ArtifactPointer o2) {
|
||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
||||
return o1.getArtifactName().compareToIgnoreCase(o2.getArtifactName());
|
||||
}
|
||||
};
|
||||
private static final ElementProperties INVALID_ARTIFACT_PROPERTIES = new ElementProperties() {
|
||||
@@ -57,7 +57,7 @@ public class ArtifactChooser extends ElementsChooser<ArtifactPointer> {
|
||||
|
||||
@Override
|
||||
protected String getItemText(@NotNull ArtifactPointer value) {
|
||||
return value.getName();
|
||||
return value.getArtifactName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -72,7 +72,7 @@ public class BuildArtifactsBeforeRun implements BeforeRunTaskProvider<BuildArtif
|
||||
return "Build Artifacts";
|
||||
}
|
||||
if (pointers.size() == 1) {
|
||||
return "Build '" + pointers.get(0).getName() + "' artifact";
|
||||
return "Build '" + pointers.get(0).getArtifactName() + "' artifact";
|
||||
}
|
||||
return "Build " + pointers.size() + " artifacts";
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class BuildArtifactsBeforeRun implements BeforeRunTaskProvider<BuildArtif
|
||||
final Artifact[] artifacts = ArtifactManager.getInstance(myProject).getArtifacts();
|
||||
Set<ArtifactPointer> pointers = new THashSet<ArtifactPointer>();
|
||||
for (Artifact artifact : artifacts) {
|
||||
pointers.add(ArtifactPointerManager.getInstance(myProject).create(artifact));
|
||||
pointers.add(ArtifactPointerManager.getInstance(myProject).createPointer(artifact));
|
||||
}
|
||||
pointers.addAll(task.getArtifactPointers());
|
||||
ArtifactChooser chooser = new ArtifactChooser(new ArrayList<ArtifactPointer>(pointers));
|
||||
|
||||
+4
-4
@@ -46,7 +46,7 @@ public class BuildArtifactsBeforeRunTask extends BeforeRunTask {
|
||||
final List<Element> children = element.getChildren(ARTIFACT_ELEMENT);
|
||||
final ArtifactPointerManager pointerManager = ArtifactPointerManager.getInstance(myProject);
|
||||
for (Element child : children) {
|
||||
myArtifactPointers.add(pointerManager.create(child.getAttributeValue(NAME_ATTRIBUTE)));
|
||||
myArtifactPointers.add(pointerManager.createPointer(child.getAttributeValue(NAME_ATTRIBUTE)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class BuildArtifactsBeforeRunTask extends BeforeRunTask {
|
||||
public void writeExternal(Element element) {
|
||||
super.writeExternal(element);
|
||||
for (ArtifactPointer pointer : myArtifactPointers) {
|
||||
element.addContent(new Element(ARTIFACT_ELEMENT).setAttribute(NAME_ATTRIBUTE, pointer.getName()));
|
||||
element.addContent(new Element(ARTIFACT_ELEMENT).setAttribute(NAME_ATTRIBUTE, pointer.getArtifactName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,14 +74,14 @@ public class BuildArtifactsBeforeRunTask extends BeforeRunTask {
|
||||
}
|
||||
|
||||
public void addArtifact(Artifact artifact) {
|
||||
final ArtifactPointer pointer = ArtifactPointerManager.getInstance(myProject).create(artifact);
|
||||
final ArtifactPointer pointer = ArtifactPointerManager.getInstance(myProject).createPointer(artifact);
|
||||
if (!myArtifactPointers.contains(pointer)) {
|
||||
myArtifactPointers.add(pointer);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeArtifact(Artifact artifact) {
|
||||
myArtifactPointers.remove(ArtifactPointerManager.getInstance(myProject).create(artifact));
|
||||
myArtifactPointers.remove(ArtifactPointerManager.getInstance(myProject).createPointer(artifact));
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
|
||||
+18
-10
@@ -24,43 +24,51 @@ import com.intellij.packaging.ui.PackagingElementWeights;
|
||||
import com.intellij.packaging.ui.TreeNodePresentation;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ArtifactElementPresentation extends TreeNodePresentation {
|
||||
private final Artifact myArtifact;
|
||||
private final ArtifactPointer myArtifactPointer;
|
||||
private final ArtifactEditorContext myContext;
|
||||
private final String myName;
|
||||
|
||||
public ArtifactElementPresentation(ArtifactPointer artifactPointer, ArtifactEditorContext context) {
|
||||
myName = artifactPointer != null ? artifactPointer.getName() : "<unknown>";
|
||||
myArtifact = artifactPointer != null ? artifactPointer.findArtifact(context.getArtifactModel()) : null;
|
||||
myArtifactPointer = artifactPointer;
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
public String getPresentableName() {
|
||||
return myName;
|
||||
return myArtifactPointer != null ? myArtifactPointer.getArtifactName(myContext.getArtifactModel()) : "<unknown>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigateToSource() {
|
||||
return myArtifact != null;
|
||||
return findArtifact() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSourceObject() {
|
||||
return myArtifact;
|
||||
return myArtifactPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigateToSource() {
|
||||
myContext.selectArtifact(myArtifact);
|
||||
final Artifact artifact = findArtifact();
|
||||
if (artifact != null) {
|
||||
myContext.selectArtifact(artifact);
|
||||
}
|
||||
}
|
||||
|
||||
public void render(@NotNull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) {
|
||||
presentationData.setIcons(myArtifact != null ? myArtifact.getArtifactType().getIcon() : PlainArtifactType.ARTIFACT_ICON);
|
||||
presentationData.addText(myName, myArtifact != null ? mainAttributes : SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
final Artifact artifact = findArtifact();
|
||||
presentationData.setIcons(artifact != null ? artifact.getArtifactType().getIcon() : PlainArtifactType.ARTIFACT_ICON);
|
||||
presentationData.addText(getPresentableName(), artifact != null ? mainAttributes : SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Artifact findArtifact() {
|
||||
return myArtifactPointer != null ? myArtifactPointer.findArtifact(myContext.getArtifactModel()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,5 +33,8 @@ public interface ArtifactModel {
|
||||
@NotNull
|
||||
Artifact getArtifactByOriginal(@NotNull Artifact artifact);
|
||||
|
||||
@NotNull
|
||||
Artifact getOriginalArtifact(@NotNull Artifact artifact);
|
||||
|
||||
Collection<? extends Artifact> getArtifactsByType(@NotNull ArtifactType type);
|
||||
}
|
||||
|
||||
@@ -24,11 +24,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface ArtifactPointer {
|
||||
|
||||
@NotNull
|
||||
String getName();
|
||||
String getArtifactName();
|
||||
|
||||
@Nullable
|
||||
Artifact getArtifact();
|
||||
|
||||
@NotNull
|
||||
String getArtifactName(@NotNull ArtifactModel artifactModel);
|
||||
|
||||
@Nullable
|
||||
Artifact findArtifact(@NotNull ArtifactModel artifactModel);
|
||||
|
||||
|
||||
+4
-2
@@ -27,7 +27,9 @@ public abstract class ArtifactPointerManager {
|
||||
return ServiceManager.getService(project, ArtifactPointerManager.class);
|
||||
}
|
||||
|
||||
public abstract ArtifactPointer create(@NotNull String name);
|
||||
public abstract ArtifactPointer createPointer(@NotNull String name);
|
||||
|
||||
public abstract ArtifactPointer create(@NotNull Artifact artifact);
|
||||
public abstract ArtifactPointer createPointer(@NotNull Artifact artifact);
|
||||
|
||||
public abstract ArtifactPointer createPointer(@NotNull Artifact artifact, @NotNull ArtifactModel artifactModel);
|
||||
}
|
||||
|
||||
+9
-2
@@ -35,10 +35,17 @@ public interface ModifiableArtifactModel extends ArtifactModel {
|
||||
@NotNull
|
||||
ModifiableArtifact getOrCreateModifiableArtifact(@NotNull Artifact artifact);
|
||||
|
||||
@Nullable
|
||||
Artifact getModifiableCopy(Artifact artifact);
|
||||
|
||||
void addListener(@NotNull ArtifactListener listener);
|
||||
|
||||
void removeListener(@NotNull ArtifactListener listener);
|
||||
|
||||
|
||||
boolean isModified();
|
||||
|
||||
void commit();
|
||||
|
||||
@Nullable
|
||||
Artifact getModifiableCopy(Artifact artifact);
|
||||
void dispose();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactPointer;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -53,6 +54,9 @@ public abstract class PackagingElementFactory {
|
||||
@NotNull
|
||||
public abstract List<? extends PackagingElement<?>> createLibraryElements(@NotNull Library library);
|
||||
|
||||
@NotNull
|
||||
public abstract PackagingElement<?> createArtifactElement(@NotNull ArtifactPointer artifactPointer, @NotNull Project project);
|
||||
|
||||
@NotNull
|
||||
public abstract PackagingElement<?> createArtifactElement(@NotNull Artifact artifact, @NotNull Project project);
|
||||
|
||||
|
||||
+7
-5
@@ -22,7 +22,6 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigur
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.packaging.artifacts.*;
|
||||
import com.intellij.packaging.elements.CompositePackagingElement;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactModelImpl;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
|
||||
import com.intellij.packaging.ui.ManifestFileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -69,7 +68,7 @@ class ArtifactsStructureConfigurableContextImpl implements ArtifactsStructureCon
|
||||
@NotNull
|
||||
public Artifact getOriginalArtifact(@NotNull Artifact artifact) {
|
||||
if (myModifiableModel != null) {
|
||||
return ((ArtifactModelImpl)myModifiableModel).getOriginalArtifact(artifact);
|
||||
return myModifiableModel.getOriginalArtifact(artifact);
|
||||
}
|
||||
return artifact;
|
||||
}
|
||||
@@ -108,7 +107,7 @@ class ArtifactsStructureConfigurableContextImpl implements ArtifactsStructureCon
|
||||
artifact = getOriginalArtifact(artifact);
|
||||
ArtifactEditorImpl artifactEditor = myArtifactEditors.get(artifact);
|
||||
if (artifactEditor == null) {
|
||||
final ArtifactEditorSettings settings = myEditorSettings.get(ArtifactPointerManager.getInstance(myProject).create(artifact));
|
||||
final ArtifactEditorSettings settings = myEditorSettings.get(ArtifactPointerManager.getInstance(myProject).createPointer(artifact, getArtifactModel()));
|
||||
artifactEditor = new ArtifactEditorImpl(this, artifact, settings != null ? settings : myDefaultSettings);
|
||||
myArtifactEditors.put(artifact, artifactEditor);
|
||||
}
|
||||
@@ -124,7 +123,7 @@ class ArtifactsStructureConfigurableContextImpl implements ArtifactsStructureCon
|
||||
public ModifiableArtifactModel getModifiableArtifactModel() {
|
||||
if (myModifiableModel == null) {
|
||||
myModifiableModel = ArtifactManager.getInstance(myProject).createModifiableModel();
|
||||
((ArtifactModelImpl)myModifiableModel).addListener(myModifiableModelListener);
|
||||
myModifiableModel.addListener(myModifiableModelListener);
|
||||
}
|
||||
return myModifiableModel;
|
||||
}
|
||||
@@ -168,12 +167,15 @@ class ArtifactsStructureConfigurableContextImpl implements ArtifactsStructureCon
|
||||
Disposer.dispose(editor);
|
||||
}
|
||||
myArtifactEditors.clear();
|
||||
if (myModifiableModel != null) {
|
||||
myModifiableModel.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveEditorSettings() {
|
||||
myEditorSettings.clear();
|
||||
for (ArtifactEditorImpl artifactEditor : myArtifactEditors.values()) {
|
||||
final ArtifactPointer pointer = ArtifactPointerManager.getInstance(myProject).create(artifactEditor.getArtifact());
|
||||
final ArtifactPointer pointer = ArtifactPointerManager.getInstance(myProject).createPointer(artifactEditor.getArtifact(), getArtifactModel());
|
||||
myEditorSettings.put(pointer, artifactEditor.createSettings());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package com.intellij.openapi.roots.ui.configuration.artifacts.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactEditorEx;
|
||||
@@ -71,7 +70,7 @@ public class ExtractArtifactAction extends LayoutTreeActionBase {
|
||||
for (PackagingElement element : selectedElements) {
|
||||
parent.removeChild(element);
|
||||
}
|
||||
parent.addOrFindChild(new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).create(artifact)));
|
||||
parent.addOrFindChild(new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).createPointer(artifact, myArtifactEditor.getContext().getArtifactModel())));
|
||||
}
|
||||
});
|
||||
treeComponent.rebuildTree();
|
||||
|
||||
+10
-4
@@ -15,15 +15,19 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration.artifacts.sourceItems;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactPointerManager;
|
||||
import com.intellij.packaging.artifacts.ArtifactPointer;
|
||||
import com.intellij.packaging.artifacts.ArtifactPointerManager;
|
||||
import com.intellij.packaging.elements.PackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElementFactory;
|
||||
import com.intellij.packaging.elements.PackagingElementOutputKind;
|
||||
import com.intellij.packaging.impl.artifacts.JarArtifactType;
|
||||
import com.intellij.packaging.impl.ui.ArtifactElementPresentation;
|
||||
import com.intellij.packaging.ui.*;
|
||||
import com.intellij.packaging.ui.ArtifactEditorContext;
|
||||
import com.intellij.packaging.ui.PackagingSourceItem;
|
||||
import com.intellij.packaging.ui.SourceItemPresentation;
|
||||
import com.intellij.packaging.ui.SourceItemWeights;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -40,7 +44,7 @@ public class ArtifactSourceItem extends PackagingSourceItem {
|
||||
}
|
||||
|
||||
public SourceItemPresentation createPresentation(@NotNull ArtifactEditorContext context) {
|
||||
final ArtifactPointer pointer = ArtifactPointerManager.getInstance(context.getProject()).create(myArtifact);
|
||||
final ArtifactPointer pointer = ArtifactPointerManager.getInstance(context.getProject()).createPointer(myArtifact, context.getArtifactModel());
|
||||
return new DelegatedSourceItemPresentation(new ArtifactElementPresentation(pointer, context)) {
|
||||
@Override
|
||||
public int getWeight() {
|
||||
@@ -51,7 +55,9 @@ public class ArtifactSourceItem extends PackagingSourceItem {
|
||||
|
||||
@NotNull
|
||||
public List<? extends PackagingElement<?>> createElements(@NotNull ArtifactEditorContext context) {
|
||||
return Collections.singletonList(PackagingElementFactory.getInstance().createArtifactElement(myArtifact, context.getProject()));
|
||||
final Project project = context.getProject();
|
||||
final ArtifactPointer pointer = ArtifactPointerManager.getInstance(project).createPointer(myArtifact, context.getArtifactModel());
|
||||
return Collections.singletonList(PackagingElementFactory.getInstance().createArtifactElement(pointer, project));
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
+1
-1
@@ -687,7 +687,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
|
||||
@Override public void visitReferenceElement(PsiJavaCodeReferenceElement ref) {
|
||||
JavaResolveResult result = null;
|
||||
JavaResolveResult result;
|
||||
try {
|
||||
result = ref.advancedResolve(true);
|
||||
}
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ public class CreateLocalVarFromInstanceofAction extends BaseIntentionAction {
|
||||
|
||||
private static boolean atSameLine(final PsiExpression condition, final Editor editor) {
|
||||
int line = editor.getCaretModel().getLogicalPosition().line;
|
||||
return editor.offsetToLogicalPosition(condition.getTextOffset()).line == line;
|
||||
return editor.getDocument().getLineNumber(condition.getTextOffset()) == line;
|
||||
}
|
||||
|
||||
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) {
|
||||
|
||||
@@ -19,12 +19,14 @@ import com.intellij.codeInsight.daemon.impl.analysis.AnnotationsHighlightUtil;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.PatchedSoftReference;
|
||||
@@ -132,7 +134,7 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
|
||||
PsiType type = cached == null ? null : cached.get();
|
||||
if (type != null) return type;
|
||||
try {
|
||||
String combinedAnnos = StringUtil.join(getApplicableAnnotations(), ANNOTATION_TEXT, " ");
|
||||
String combinedAnnos = getCombinedAnnosText();
|
||||
String text = combinedAnnos.length() == 0 ? getText().trim() : combinedAnnos + " " + getText().trim();
|
||||
type = JavaPsiFacade.getInstance(getProject()).getElementFactory().createTypeFromText(text, context);
|
||||
myCachedDetachedType = new PatchedSoftReference<PsiType>(type);
|
||||
@@ -143,6 +145,13 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
|
||||
return type;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getCombinedAnnosText() {
|
||||
boolean typeAnnotationsSupported = PsiUtil.getLanguageLevel(this).isAtLeast(LanguageLevel.JDK_1_7);
|
||||
if (!typeAnnotationsSupported) return "";
|
||||
return StringUtil.join(getApplicableAnnotations(), ANNOTATION_TEXT, " ");
|
||||
}
|
||||
|
||||
private static final Function<PsiAnnotation, String> ANNOTATION_TEXT = new Function<PsiAnnotation, String>() {
|
||||
public String fun(PsiAnnotation psiAnnotation) {
|
||||
return psiAnnotation.getText();
|
||||
|
||||
@@ -102,7 +102,8 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi
|
||||
if ("java.lang".equals(packageName)) return true;
|
||||
|
||||
// class from my package imported implicitly
|
||||
PsiFile file = myPlace == null ? null : myPlace.getContainingFile();
|
||||
PsiFile file = myPlace == null ? null : FileContextUtil.getContextFile(myPlace);
|
||||
|
||||
return file instanceof PsiJavaFile && ((PsiJavaFile)file).getPackageName().equals(packageName);
|
||||
}
|
||||
|
||||
|
||||
@@ -106,8 +106,6 @@ public class CommonRefactoringUtil {
|
||||
boolean seenNonWritablePsiFilesWithoutVirtualFile = false;
|
||||
|
||||
for (PsiElement element : elements) {
|
||||
if (element.isWritable()) continue;
|
||||
|
||||
if (element instanceof PsiDirectory) {
|
||||
PsiDirectory dir = (PsiDirectory)element;
|
||||
final VirtualFile vFile = dir.getVirtualFile();
|
||||
@@ -140,13 +138,11 @@ public class CommonRefactoringUtil {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!directory.isWritable()) {
|
||||
if (virtualFile.getFileSystem() instanceof JarFileSystem) {
|
||||
failed.add(virtualFile);
|
||||
}
|
||||
else {
|
||||
readonly.add(virtualFile);
|
||||
}
|
||||
if (virtualFile.getFileSystem() instanceof JarFileSystem) {
|
||||
failed.add(virtualFile);
|
||||
}
|
||||
else {
|
||||
readonly.add(virtualFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,7 +158,7 @@ public class CommonRefactoringUtil {
|
||||
if (file == null) {
|
||||
seenNonWritablePsiFilesWithoutVirtualFile = true;
|
||||
}
|
||||
else if (!file.isWritable()) {
|
||||
else {
|
||||
final VirtualFile vFile = file.getVirtualFile();
|
||||
if (vFile != null) {
|
||||
readonly.add(vFile);
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.psi.*;
|
||||
|
||||
public class UnwrapAction extends BaseCodeInsightAction{
|
||||
public UnwrapAction() {
|
||||
super(true);
|
||||
setEnabledInModalContext(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -224,8 +224,8 @@ public class QuickFixAction extends AnAction {
|
||||
Set<VirtualFile> readOnlyFiles = new THashSet<VirtualFile>();
|
||||
for (RefElement refElement : refElements) {
|
||||
PsiElement psiElement = refElement.getElement();
|
||||
if (psiElement == null) continue;
|
||||
if (!psiElement.isWritable()) readOnlyFiles.add(psiElement.getContainingFile().getVirtualFile());
|
||||
if (psiElement == null || psiElement.getContainingFile() == null) continue;
|
||||
readOnlyFiles.add(psiElement.getContainingFile().getVirtualFile());
|
||||
}
|
||||
return readOnlyFiles;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ public class FileListPasteProvider implements PasteProvider {
|
||||
catch (IOException e) {
|
||||
return;
|
||||
}
|
||||
if (fileList == null) return;
|
||||
List<PsiElement> elements = new ArrayList<PsiElement>();
|
||||
for (File file : fileList) {
|
||||
final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
|
||||
|
||||
@@ -27,9 +27,9 @@ import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowEx;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -61,7 +61,7 @@ public abstract class ProjectViewSelectInTarget extends SelectInTargetPsiWrapper
|
||||
|
||||
final ProjectView projectView = ProjectView.getInstance(project);
|
||||
ToolWindowManager windowManager=ToolWindowManager.getInstance(project);
|
||||
final ToolWindowEx projectViewToolWindow = (ToolWindowEx) windowManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
|
||||
final ToolWindow projectViewToolWindow = windowManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
if (requestFocus) {
|
||||
|
||||
+7
-10
@@ -172,27 +172,24 @@ public class ProjectViewDirectoryHelper {
|
||||
return psiDirectory.getChildren();
|
||||
}
|
||||
|
||||
Set<VirtualFile> directoriesOnTheWayToContentRoots = new THashSet<VirtualFile>();
|
||||
PsiManager manager = psiDirectory.getManager();
|
||||
Set<PsiElement> directoriesOnTheWayToContentRoots = new THashSet<PsiElement>();
|
||||
for (VirtualFile root : getTopLevelRoots()) {
|
||||
VirtualFile current = root;
|
||||
while (current != null) {
|
||||
VirtualFile parent = current.getParent();
|
||||
|
||||
if (parent == dir) {
|
||||
directoriesOnTheWayToContentRoots.add(current);
|
||||
final PsiDirectory psi = manager.findDirectory(current);
|
||||
if (psi != null) {
|
||||
directoriesOnTheWayToContentRoots.add(psi);
|
||||
}
|
||||
}
|
||||
current = parent;
|
||||
}
|
||||
}
|
||||
|
||||
PsiManager manager = psiDirectory.getManager();
|
||||
PsiElement[] answer = new PsiElement[directoriesOnTheWayToContentRoots.size()];
|
||||
int i = 0;
|
||||
for (VirtualFile directory : directoriesOnTheWayToContentRoots) {
|
||||
answer[i++] = manager.findDirectory(directory);
|
||||
}
|
||||
|
||||
return answer;
|
||||
return directoriesOnTheWayToContentRoots.toArray(new PsiElement[directoriesOnTheWayToContentRoots.size()]);
|
||||
}
|
||||
|
||||
// used only for non-flatten packages mode
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FileContextUtil {
|
||||
public static final Key<SmartPsiElementPointer> INJECTED_IN_ELEMENT = Key.create("injectedIn");
|
||||
@@ -32,7 +33,7 @@ public class FileContextUtil {
|
||||
return pointer == null ? null : pointer.getElement();
|
||||
}
|
||||
|
||||
public static PsiFile getContextFile(PsiElement element){
|
||||
public static PsiFile getContextFile(@NotNull PsiElement element){
|
||||
if (!element.isValid()) return null;
|
||||
PsiFile file = element.getContainingFile();
|
||||
if (file == null) return null;
|
||||
|
||||
@@ -1540,7 +1540,7 @@ public class AbstractTreeUi {
|
||||
public List<Object> getLoadedChildrenFor(Object element) {
|
||||
List<Object> result = new ArrayList<Object>();
|
||||
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode)findNodeByElement(element);
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode)getNodeForElement(element, false);
|
||||
if (node != null) {
|
||||
for (int i = 0; i < node.getChildCount(); i++) {
|
||||
TreeNode each = node.getChildAt(i);
|
||||
@@ -1772,6 +1772,8 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
private void processNodeActionsIfReady(final DefaultMutableTreeNode node) {
|
||||
assertIsDispatchThread();
|
||||
|
||||
if (isNodeBeingBuilt(node)) return;
|
||||
|
||||
final Object o = node.getUserObject();
|
||||
|
||||
@@ -127,9 +127,8 @@ public class UpdaterTreeState {
|
||||
public void addAll(final UpdaterTreeState state) {
|
||||
myToExpand.putAll(state.myToExpand);
|
||||
|
||||
final Iterator<Object> toSelect = state.myToSelect.keySet().iterator();
|
||||
while (toSelect.hasNext()) {
|
||||
Object each = toSelect.next();
|
||||
Object[] toSelect = state.getToSelect();
|
||||
for (Object each : toSelect) {
|
||||
if (!myAdjustedSelection.containsKey(each)) {
|
||||
myToSelect.put(each, each);
|
||||
}
|
||||
|
||||
@@ -281,6 +281,7 @@ public class Tree extends JTree implements Autoscroll, TestableUi {
|
||||
}
|
||||
}
|
||||
|
||||
if (last == null) continue;
|
||||
Rectangle lastBounds = getPathBounds(getPath(last));
|
||||
|
||||
if (firstBounds == null || lastBounds == null) continue;
|
||||
|
||||
@@ -28,7 +28,7 @@ import gnu.trove.THashSet;
|
||||
import java.util.*;
|
||||
|
||||
public class CacheUpdateSession {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.startup.SyncSession");
|
||||
private static final Logger LOG = Logger.getInstance("#" + CacheUpdateSession.class.getName());
|
||||
private static final Key<Boolean> FILED_TO_INDEX = Key.create(CacheUpdateSession.class.getSimpleName() + ".FAILED_TO_INDEX");
|
||||
private final Collection<VirtualFile> myFilesToUpdate;
|
||||
private final List<Pair<CacheUpdater, Collection<VirtualFile>>> myUpdatersWithFiles =
|
||||
|
||||
@@ -39,8 +39,8 @@ public class DumbModeIndicator extends AbstractProjectComponent {
|
||||
myAlarm.addRequest(new Runnable() {
|
||||
public void run() {
|
||||
myHandler = DumbService.getInstance(myProject).showDumbModeNotification(
|
||||
"Updating indexes...<br>" +
|
||||
"Some of advanced features (refactorings, navigation, etc.) are not available.");
|
||||
"Updating indices...<br>" +
|
||||
"Some of advanced features (refactorings, usage search ) are temporarily unavailable");
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
@@ -17,21 +17,22 @@ package com.intellij.openapi.project;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.caches.CacheUpdater;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.*;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.BalloonHandler;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.StatusBarEx;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.containers.Queue;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
@@ -40,19 +41,18 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class DumbServiceImpl extends DumbService {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.project.DumbServiceImpl");
|
||||
private final AtomicBoolean myDumb = new AtomicBoolean();
|
||||
private volatile boolean myDumb = false;
|
||||
private final DumbModeListener myPublisher;
|
||||
private final LinkedBlockingQueue<CacheUpdateRunner> myUpdatesQueue = new LinkedBlockingQueue<CacheUpdateRunner>();
|
||||
private final Queue<IndexUpdateRunnable> myUpdatesQueue = new Queue<IndexUpdateRunnable>(5);
|
||||
private final Queue<Runnable> myRunWhenSmartQueue = new Queue<Runnable>(5);
|
||||
private final Project myProject;
|
||||
|
||||
|
||||
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass"})
|
||||
public static DumbServiceImpl getInstance(@NotNull Project project) {
|
||||
return (DumbServiceImpl)DumbService.getInstance(project);
|
||||
}
|
||||
@@ -60,8 +60,6 @@ public class DumbServiceImpl extends DumbService {
|
||||
public DumbServiceImpl(Project project, MessageBus bus) {
|
||||
myProject = project;
|
||||
myPublisher = bus.syncPublisher(DUMB_MODE);
|
||||
|
||||
new CacheUpdateProcessor().start();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,12 +68,11 @@ public class DumbServiceImpl extends DumbService {
|
||||
}
|
||||
|
||||
public boolean isDumb() {
|
||||
return myDumb.get();
|
||||
return myDumb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runWhenSmart(Runnable runnable) {
|
||||
// todo: run is swing thread
|
||||
if (!isDumb()) {
|
||||
runnable.run();
|
||||
}
|
||||
@@ -88,49 +85,56 @@ public class DumbServiceImpl extends DumbService {
|
||||
|
||||
public void queueCacheUpdate(Collection<CacheUpdater> updaters) {
|
||||
// prevent concurrent modifications
|
||||
final Collection<CacheUpdater> updatersCopy = new ArrayList<CacheUpdater>(updaters);
|
||||
CacheUpdateRunner runner = new CacheUpdateRunner(myProject, updatersCopy);
|
||||
final CacheUpdateRunner runner = new CacheUpdateRunner(myProject, new ArrayList<CacheUpdater>(updaters));
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() || ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
EmptyProgressIndicator i = new EmptyProgressIndicator();
|
||||
runner.queryNeededFiles(i);
|
||||
runner.processFiles(i, false);
|
||||
runner.updatingDone();
|
||||
return;
|
||||
}
|
||||
|
||||
ProgressIndicator indicator = new EmptyProgressIndicator();
|
||||
|
||||
if (ApplicationManager.getApplication().isDispatchThread() && !isDumb()) {
|
||||
int size = runner.queryNeededFiles(indicator);
|
||||
if (size < 10) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
if (application.isDispatchThread() && !myDumb && application.isWriteAccessAllowed()) {
|
||||
ProgressIndicator indicator = new EmptyProgressIndicator();
|
||||
final int size = runner.queryNeededFiles(indicator);
|
||||
if (size < 50) {
|
||||
// if not that many files found, process them on the spot, avoiding entering dumb mode
|
||||
if (size > 0) {
|
||||
runner.processFiles(indicator, false);
|
||||
}
|
||||
runner.updatingDone();
|
||||
return;
|
||||
}
|
||||
|
||||
updateStarted();
|
||||
}
|
||||
|
||||
try {
|
||||
myUpdatesQueue.put(runner);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
final IndexUpdateRunnable updateRunnable = new IndexUpdateRunnable(runner);
|
||||
|
||||
invokeOnEDT(new DumbAwareRunnable() {
|
||||
public void run() {
|
||||
if (myProject.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
// ok to test and set the flag like this, because the change is always done from dispatch thread
|
||||
final boolean wasDumb = myDumb;
|
||||
if (!wasDumb) {
|
||||
myDumb = true;
|
||||
myPublisher.enteredDumbMode();
|
||||
|
||||
updateRunnable.run();
|
||||
}
|
||||
else {
|
||||
myUpdatesQueue.addLast(updateRunnable);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateStarted() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
myDumb.set(true);
|
||||
myPublisher.enteredDumbMode();
|
||||
private static void invokeOnEDT(DumbAwareRunnable runnable) {
|
||||
if (ApplicationManager.getApplication().isDispatchThread()) {
|
||||
runnable.run();
|
||||
}
|
||||
else {
|
||||
SwingUtilities.invokeLater(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFinished() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
myDumb.set(false);
|
||||
myDumb = false;
|
||||
myPublisher.exitDumbMode();
|
||||
while (true) {
|
||||
final Runnable runnable;
|
||||
@@ -140,6 +144,9 @@ public class DumbServiceImpl extends DumbService {
|
||||
}
|
||||
runnable = myRunWhenSmartQueue.pullFirst();
|
||||
}
|
||||
if (myProject.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
@@ -163,151 +170,116 @@ public class DumbServiceImpl extends DumbService {
|
||||
return statusBar.notifyProgressByBalloon(MessageType.WARNING, message, null, listener);
|
||||
}
|
||||
|
||||
private class CacheUpdateProcessor implements Runnable {
|
||||
private int myProcessedItems;
|
||||
private int myTotalItems;
|
||||
private int myCurrentUpdateTotal;
|
||||
private static final Ref<CacheUpdateRunner> NULL_ACTION = new Ref<CacheUpdateRunner>(null);
|
||||
|
||||
private class IndexUpdateRunnable implements Runnable {
|
||||
private final CacheUpdateRunner myAction;
|
||||
private double myProcessedItems;
|
||||
private volatile int myTotalItems;
|
||||
private double myCurrentBaseTotal;
|
||||
|
||||
public void start() {
|
||||
new Thread(this).start();
|
||||
public IndexUpdateRunnable(CacheUpdateRunner action) {
|
||||
myAction = action;
|
||||
myTotalItems = 0;
|
||||
myCurrentBaseTotal = 0;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
CacheUpdateRunner runner = null;
|
||||
while (runner == null) {
|
||||
if (myProject.isDisposed()) return;
|
||||
try {
|
||||
runner = myUpdatesQueue.poll(500, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
LOG.info(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (myProject.isDisposed()) return;
|
||||
if (myProject.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Semaphore sema = new Semaphore();
|
||||
sema.down();
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(myProject, IdeBundle.message("progress.indexing"), false) {
|
||||
|
||||
final CacheUpdateRunner finalRunner = runner;
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new Task.Backgroundable(myProject, IdeBundle.message("progress.indexing"), false) {
|
||||
@Override
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
private final ArrayBlockingQueue<Ref<CacheUpdateRunner>> myActionQueue = new ArrayBlockingQueue<Ref<CacheUpdateRunner>>(1);
|
||||
|
||||
@Override
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
final ProgressIndicator proxy =
|
||||
(ProgressIndicator)Proxy.newProxyInstance(indicator.getClass().getClassLoader(), new Class[]{ProgressIndicator.class}, new InvocationHandler() {
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
if ("setFraction".equals(method.getName())) {
|
||||
final double fraction = (Double)args[0];
|
||||
args[0] = new Double((myProcessedItems + fraction * myCurrentBaseTotal) / myTotalItems);
|
||||
}
|
||||
try {
|
||||
notifyStartedIfNotInDumbMode();
|
||||
try {
|
||||
processPendingUpdates(finalRunner, createIndicatorProxy(indicator));
|
||||
}
|
||||
finally {
|
||||
notifyFinishedIfQueueEmpty();
|
||||
}
|
||||
return method.invoke(indicator, args);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
if (!(e instanceof ProcessCanceledException)) {
|
||||
LOG.error(e);
|
||||
catch (InvocationTargetException e) {
|
||||
final Throwable cause = e.getCause();
|
||||
if (cause instanceof ProcessCanceledException) {
|
||||
throw cause;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
sema.up();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}.queue();
|
||||
}
|
||||
});
|
||||
|
||||
sema.waitFor();
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyStartedIfNotInDumbMode() {
|
||||
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
if (myProject.isDisposed()) return;
|
||||
if (!isDumb()) {
|
||||
updateStarted();
|
||||
myProcessedItems = 0;
|
||||
myTotalItems = 0;
|
||||
myCurrentUpdateTotal = 0;
|
||||
}
|
||||
});
|
||||
runAction(proxy, myAction);
|
||||
}
|
||||
}, ModalityState.defaultModalityState());
|
||||
}
|
||||
|
||||
private void notifyFinishedIfQueueEmpty() {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (myProject.isDisposed()) return;
|
||||
if (myUpdatesQueue.isEmpty()) updateFinished();
|
||||
private void runAction(ProgressIndicator indicator, CacheUpdateRunner updateRunner) {
|
||||
do {
|
||||
int count = 0;
|
||||
try {
|
||||
indicator.setIndeterminate(true);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.scanning"));
|
||||
count = updateRunner.queryNeededFiles(indicator);
|
||||
|
||||
myCurrentBaseTotal = count;
|
||||
myTotalItems += count;
|
||||
|
||||
indicator.setIndeterminate(false);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.updaing"));
|
||||
updateRunner.processFiles(indicator, true);
|
||||
}
|
||||
finally {
|
||||
updateRunner.updatingDone();
|
||||
myProcessedItems += count;
|
||||
invokeOnEDT(new DumbAwareRunnable() {
|
||||
public void run() {
|
||||
if (myUpdatesQueue.isEmpty()) {
|
||||
// really terminate the tesk
|
||||
myActionQueue.offer(NULL_ACTION);
|
||||
updateFinished();
|
||||
}
|
||||
else {
|
||||
//run next dumb action
|
||||
final IndexUpdateRunnable nextUpdateRunnable = myUpdatesQueue.pullFirst();
|
||||
// run next action under already existing progress indicator
|
||||
if (!myActionQueue.offer(new Ref<CacheUpdateRunner>(nextUpdateRunnable.myAction))) {
|
||||
LOG.assertTrue(false, "Action queue rejected next updateRunnable!");
|
||||
nextUpdateRunnable.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// try to obtain the next action or terminate if no actions left
|
||||
try {
|
||||
Ref<CacheUpdateRunner> ref;
|
||||
do {
|
||||
ref = myActionQueue.poll(500, TimeUnit.MILLISECONDS);
|
||||
updateRunner = ref != null? ref.get() : null;
|
||||
if (myProject.isDisposed()) {
|
||||
// just terminate the progress task
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (ref == null);
|
||||
}
|
||||
catch (InterruptedException ignored) {
|
||||
LOG.info(ignored);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (updateRunner != null);
|
||||
// make it impossible to add actions to the queue anymore
|
||||
myActionQueue.offer(NULL_ACTION);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void processPendingUpdates(CacheUpdateRunner runner, ProgressIndicator indicator) {
|
||||
while (true) {
|
||||
if (myProject.isDisposed()) break;
|
||||
|
||||
queryNeededFiles(runner, indicator);
|
||||
processFiles(runner, indicator);
|
||||
updatingDone(runner);
|
||||
|
||||
try {
|
||||
if (myProject.isDisposed()) break;
|
||||
runner = myUpdatesQueue.poll(100, TimeUnit.MILLISECONDS);
|
||||
if (runner == null) return;
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
LOG.info(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void queryNeededFiles(CacheUpdateRunner runner, ProgressIndicator indicator) {
|
||||
indicator.setIndeterminate(true);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.scanning"));
|
||||
myCurrentUpdateTotal = runner.queryNeededFiles(indicator);
|
||||
myTotalItems += myCurrentUpdateTotal;
|
||||
}
|
||||
|
||||
private void processFiles(CacheUpdateRunner runner, ProgressIndicator indicator) {
|
||||
long before = System.currentTimeMillis();
|
||||
indicator.setIndeterminate(false);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.updaing"));
|
||||
runner.processFiles(indicator, true);
|
||||
|
||||
long after = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private void updatingDone(CacheUpdateRunner runner) {
|
||||
runner.updatingDone();
|
||||
myProcessedItems += myCurrentUpdateTotal;
|
||||
}
|
||||
|
||||
private ProgressIndicator createIndicatorProxy(final ProgressIndicator indicator) {
|
||||
return (ProgressIndicator)Proxy
|
||||
.newProxyInstance(indicator.getClass().getClassLoader(), new Class[]{ProgressIndicator.class}, new InvocationHandler() {
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
if ("setFraction".equals(method.getName())) {
|
||||
double fraction = (Double)args[0];
|
||||
args[0] = new Double((myProcessedItems + fraction * myCurrentUpdateTotal) / myTotalItems);
|
||||
}
|
||||
|
||||
try {
|
||||
return method.invoke(indicator, args);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
final Throwable cause = e.getCause();
|
||||
if (cause instanceof ProcessCanceledException) {
|
||||
throw cause;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.intellij.codeInsight.unwrap;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class UnwrapTestCase extends LightPlatformCodeInsightTestCase {
|
||||
protected void assertUnwrapped(String codeBefore, String expectedCodeAfter) throws Exception {
|
||||
assertUnwrapped(codeBefore, expectedCodeAfter, 0);
|
||||
}
|
||||
|
||||
protected void assertUnwrapped(String codeBefore, String expectedCodeAfter, final int option) throws Exception {
|
||||
configureCode(codeBefore);
|
||||
|
||||
UnwrapHandler h = new UnwrapHandler() {
|
||||
@Override
|
||||
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
|
||||
if (options.isEmpty()) return;
|
||||
options.get(option).actionPerformed(null);
|
||||
}
|
||||
};
|
||||
|
||||
h.invoke(getProject(), getEditor(), getFile());
|
||||
|
||||
checkResultByText(createCode(expectedCodeAfter));
|
||||
}
|
||||
|
||||
protected void assertOptions(String code, String... expectedOptions) throws IOException {
|
||||
configureCode(code);
|
||||
|
||||
final List<String> actualOptions = new ArrayList<String>();
|
||||
|
||||
UnwrapHandler h = new UnwrapHandler() {
|
||||
@Override
|
||||
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
|
||||
for (AnAction each : options) {
|
||||
actualOptions.add(each.getTemplatePresentation().getText());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
h.invoke(getProject(), getEditor(), getFile());
|
||||
|
||||
assertEquals(Arrays.asList(expectedOptions), actualOptions);
|
||||
}
|
||||
|
||||
protected void configureCode(final String codeBefore) throws IOException {
|
||||
configureFromFileText(getFileNameToCreate(), createCode(codeBefore));
|
||||
}
|
||||
|
||||
protected String getFileNameToCreate() {
|
||||
return "A.java";
|
||||
}
|
||||
|
||||
protected String createCode(String codeBefore) {
|
||||
return "public class A {\n" +
|
||||
" void foo() {\n" +
|
||||
indentTwice(codeBefore) +
|
||||
" }\n" +
|
||||
"}";
|
||||
}
|
||||
|
||||
protected String indentTwice(String code) {
|
||||
String result = "";
|
||||
for (String line : StringUtil.tokenize(code, "\n")) {
|
||||
result += " " + line + "\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1238,7 +1238,7 @@ public class StringUtil {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private static String replace(final String text, final String[] from, final String[] to) {
|
||||
public static String replace(final String text, final String[] from, final String[] to) {
|
||||
final StringBuilder result = new StringBuilder(text.length());
|
||||
replace:
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
|
||||
+30
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2008 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Query;
|
||||
import com.siyeh.HardcodedMethodConstants;
|
||||
@@ -67,10 +68,28 @@ public class UtilityClassWithoutPrivateConstructorInspection
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
final PsiClass aClass = (PsiClass)infos[0];
|
||||
if (hasNullArgConstructor(aClass)) {
|
||||
return new MakeConstructorPrivateFix();
|
||||
} else {
|
||||
final PsiMethod constructor = getNullArgConstructor(aClass);
|
||||
if (constructor == null) {
|
||||
final Query<PsiReference> query =
|
||||
ReferencesSearch.search(aClass, aClass.getUseScope());
|
||||
for (PsiReference reference : query) {
|
||||
final PsiElement element = reference.getElement();
|
||||
final PsiElement parent = element.getParent();
|
||||
if (parent instanceof PsiNewExpression) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new CreateEmptyPrivateConstructor();
|
||||
} else {
|
||||
final Query<PsiReference> query =
|
||||
ReferencesSearch.search(constructor,
|
||||
constructor.getUseScope());
|
||||
final PsiReference reference = query.findFirst();
|
||||
if (reference == null) {
|
||||
return new MakeConstructorPrivateFix();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,14 +110,14 @@ public class UtilityClassWithoutPrivateConstructorInspection
|
||||
if (aClass == null) {
|
||||
return;
|
||||
}
|
||||
final PsiManager psiManager = PsiManager.getInstance(project);
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory();
|
||||
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
|
||||
final PsiElementFactory factory = psiFacade.getElementFactory();
|
||||
final PsiMethod constructor = factory.createConstructor();
|
||||
final PsiModifierList modifierList = constructor.getModifierList();
|
||||
modifierList.setModifierProperty(PsiModifier.PRIVATE, true);
|
||||
aClass.add(constructor);
|
||||
final CodeStyleManager styleManager =
|
||||
psiManager.getCodeStyleManager();
|
||||
CodeStyleManager.getInstance(project);
|
||||
styleManager.reformat(constructor);
|
||||
}
|
||||
}
|
||||
@@ -220,14 +239,15 @@ public class UtilityClassWithoutPrivateConstructorInspection
|
||||
}
|
||||
}
|
||||
|
||||
static boolean hasNullArgConstructor(PsiClass aClass) {
|
||||
@Nullable
|
||||
static PsiMethod getNullArgConstructor(PsiClass aClass) {
|
||||
final PsiMethod[] constructors = aClass.getConstructors();
|
||||
for (final PsiMethod constructor : constructors) {
|
||||
final PsiParameterList params = constructor.getParameterList();
|
||||
if (params.getParametersCount() == 0) {
|
||||
return true;
|
||||
return constructor;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+19
-9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,6 +27,7 @@ import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.psiutils.ComparisonUtils;
|
||||
import com.siyeh.ig.psiutils.ExpressionUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ConstantOnLHSOfComparisonInspection extends BaseInspection {
|
||||
@@ -68,16 +69,20 @@ public class ConstantOnLHSOfComparisonInspection extends BaseInspection {
|
||||
final PsiBinaryExpression expression =
|
||||
(PsiBinaryExpression) descriptor.getPsiElement();
|
||||
final PsiExpression rhs = expression.getROperand();
|
||||
final PsiExpression lhs = expression.getLOperand();
|
||||
if (rhs == null) {
|
||||
return;
|
||||
}
|
||||
final PsiJavaToken sign = expression.getOperationSign();
|
||||
final String flippedSign =
|
||||
final String flippedComparison =
|
||||
ComparisonUtils.getFlippedComparison(sign);
|
||||
assert rhs != null;
|
||||
if (flippedComparison == null) {
|
||||
return;
|
||||
}
|
||||
final PsiExpression lhs = expression.getLOperand();
|
||||
final String rhsText = rhs.getText();
|
||||
final String lhsText = lhs.getText();
|
||||
replaceExpression(expression,
|
||||
rhsText + ' ' + flippedSign + ' ' + lhsText);
|
||||
|
||||
rhsText + ' ' + flippedComparison + ' ' + lhsText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +92,7 @@ public class ConstantOnLHSOfComparisonInspection extends BaseInspection {
|
||||
@Override public void visitBinaryExpression(
|
||||
@NotNull PsiBinaryExpression expression) {
|
||||
super.visitBinaryExpression(expression);
|
||||
if(!(expression.getROperand() != null)) {
|
||||
if (!(expression.getROperand() != null)) {
|
||||
return;
|
||||
}
|
||||
if (!ComparisonUtils.isComparison(expression)) {
|
||||
@@ -95,11 +100,16 @@ public class ConstantOnLHSOfComparisonInspection extends BaseInspection {
|
||||
}
|
||||
final PsiExpression lhs = expression.getLOperand();
|
||||
final PsiExpression rhs = expression.getROperand();
|
||||
if (!PsiUtil.isConstantExpression(lhs)
|
||||
|| PsiUtil.isConstantExpression(rhs)) {
|
||||
if (!isConstantExpression(lhs)
|
||||
|| isConstantExpression(rhs)) {
|
||||
return;
|
||||
}
|
||||
registerError(expression);
|
||||
}
|
||||
|
||||
private boolean isConstantExpression(PsiExpression expression) {
|
||||
return ExpressionUtils.isNullLiteral(expression) ||
|
||||
PsiUtil.isConstantExpression(expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-4
@@ -27,6 +27,7 @@ import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.psiutils.ComparisonUtils;
|
||||
import com.siyeh.ig.psiutils.ExpressionUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ConstantOnRHSOfComparisonInspection extends BaseInspection {
|
||||
@@ -71,14 +72,14 @@ public class ConstantOnRHSOfComparisonInspection extends BaseInspection {
|
||||
if (rhs == null) {
|
||||
return;
|
||||
}
|
||||
final PsiExpression lhs = expression.getLOperand();
|
||||
final PsiJavaToken sign = expression.getOperationSign();
|
||||
final String rhsText = rhs.getText();
|
||||
final String flippedComparison =
|
||||
ComparisonUtils.getFlippedComparison(sign);
|
||||
if (flippedComparison == null) {
|
||||
return;
|
||||
}
|
||||
final PsiExpression lhs = expression.getLOperand();
|
||||
final String rhsText = rhs.getText();
|
||||
final String lhsText = lhs.getText();
|
||||
replaceExpression(expression,
|
||||
rhsText + ' ' + flippedComparison + ' ' + lhsText);
|
||||
@@ -99,11 +100,15 @@ public class ConstantOnRHSOfComparisonInspection extends BaseInspection {
|
||||
}
|
||||
final PsiExpression lhs = expression.getLOperand();
|
||||
final PsiExpression rhs = expression.getROperand();
|
||||
if (!PsiUtil.isConstantExpression(rhs) ||
|
||||
PsiUtil.isConstantExpression(lhs)) {
|
||||
if (!isConstantExpression(rhs) || isConstantExpression(lhs)) {
|
||||
return;
|
||||
}
|
||||
registerError(expression);
|
||||
}
|
||||
|
||||
private boolean isConstantExpression(PsiExpression expression) {
|
||||
return ExpressionUtils.isNullLiteral(expression) ||
|
||||
PsiUtil.isConstantExpression(expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,7 +196,11 @@ public class GitRootTracker implements VcsListener {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void directoryMappingChanged() {
|
||||
scheduleRootsCheck(true);
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
scheduleRootsCheck(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void scheduleRootsCheck(final boolean rootsChanged) {
|
||||
|
||||
+64
-5
@@ -15,16 +15,75 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.dom.annotator;
|
||||
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.xml.DomElement;
|
||||
import com.intellij.util.xml.DomUtil;
|
||||
import com.intellij.util.xml.highlighting.DomElementAnnotationHolder;
|
||||
import com.intellij.util.xml.highlighting.DomElementsAnnotator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.dom.MavenDomBundle;
|
||||
import org.jetbrains.idea.maven.dom.MavenDomUtil;
|
||||
import org.jetbrains.idea.maven.dom.model.MavenDomParent;
|
||||
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectProblem;
|
||||
|
||||
public class MavenDomAnnotator implements DomElementsAnnotator {
|
||||
public void annotate(DomElement element, DomElementAnnotationHolder holder) {
|
||||
//Project project = element.getManager().getProject();
|
||||
//MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(project);
|
||||
//if (element instanceof MavenDomProjectModel) {
|
||||
// String groupId = ((MavenDomProjectModel)element).getGroupId().getValue();
|
||||
//}
|
||||
if (element instanceof MavenDomProjectModel) {
|
||||
addProblems(element, (MavenDomProjectModel)element, holder,
|
||||
MavenProjectProblem.ProblemType.STRUCTURE,
|
||||
MavenProjectProblem.ProblemType.SETTINGS_OR_PROFILES);
|
||||
}
|
||||
else if (element instanceof MavenDomParent) {
|
||||
addProblems(element, DomUtil.getParentOfType(element, MavenDomProjectModel.class, true), holder,
|
||||
MavenProjectProblem.ProblemType.PARENT);
|
||||
}
|
||||
}
|
||||
|
||||
private void addProblems(DomElement element, MavenDomProjectModel model, DomElementAnnotationHolder holder,
|
||||
MavenProjectProblem.ProblemType... types) {
|
||||
MavenProject mavenProject = MavenDomUtil.findProject(model);
|
||||
if (mavenProject != null) {
|
||||
for (MavenProjectProblem each : mavenProject.getProblems()) {
|
||||
MavenProjectProblem.ProblemType type = each.getType();
|
||||
if (!ArrayUtil.contains(type, types)) continue;
|
||||
VirtualFile problemFile = each.findFile();
|
||||
|
||||
LocalQuickFix[] fixes = LocalQuickFix.EMPTY_ARRAY;
|
||||
if (problemFile != null && mavenProject.getFile() != problemFile) {
|
||||
fixes = new LocalQuickFix[]{new OpenProblemFileFix(problemFile)};
|
||||
}
|
||||
holder.createProblem(element, HighlightSeverity.ERROR, each.getDescription(), fixes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class OpenProblemFileFix implements LocalQuickFix {
|
||||
private final VirtualFile myFile;
|
||||
|
||||
private OpenProblemFileFix(VirtualFile file) {
|
||||
myFile = file;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return MavenDomBundle.message("fix.open.file", myFile.getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return MavenDomBundle.message("inspection.group");
|
||||
}
|
||||
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
new OpenFileDescriptor(project, myFile).navigate(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -133,6 +133,9 @@ public class MavenDefaultModifiableModelsProvider extends MavenBaseModifiableMod
|
||||
each.dispose();
|
||||
}
|
||||
myModuleModel.dispose();
|
||||
if (myArtifactModel != null) {
|
||||
myArtifactModel.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+2
-13
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.indices;
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.application.Result;
|
||||
@@ -31,8 +30,6 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.ShutDownTracker;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.PsiModificationTrackerImpl;
|
||||
import gnu.trove.THashSet;
|
||||
import org.apache.maven.archetype.catalog.Archetype;
|
||||
import org.apache.maven.archetype.catalog.ArchetypeCatalog;
|
||||
@@ -43,6 +40,7 @@ import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.idea.maven.utils.MavenRehighlighter;
|
||||
import org.jetbrains.idea.maven.embedder.MavenEmbedderFactory;
|
||||
import org.jetbrains.idea.maven.embedder.MavenEmbedderWrapper;
|
||||
import org.jetbrains.idea.maven.project.MavenGeneralSettings;
|
||||
@@ -310,16 +308,7 @@ public class MavenIndicesManager implements ApplicationComponent {
|
||||
|
||||
private void scheduleRehighlightAllPoms(final Project projectOrNull) {
|
||||
if (projectOrNull == null) return;
|
||||
MavenUtil.invokeLater(projectOrNull, new Runnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
((PsiModificationTrackerImpl)PsiManager.getInstance(projectOrNull).getModificationTracker()).incCounter();
|
||||
DaemonCodeAnalyzer.getInstance(projectOrNull).restart();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
MavenRehighlighter.rehighlight(projectOrNull);
|
||||
}
|
||||
|
||||
public synchronized Set<ArchetypeInfo> getArchetypes() {
|
||||
|
||||
+10
-32
@@ -303,7 +303,7 @@ public class MavenProjectsStructure extends SimpleTreeStructure {
|
||||
}
|
||||
|
||||
public enum ErrorLevel {
|
||||
NONE, WARNING, ERROR
|
||||
NONE, ERROR
|
||||
}
|
||||
|
||||
public abstract class CustomNode extends SimpleNode {
|
||||
@@ -443,8 +443,7 @@ public class MavenProjectsStructure extends SimpleTreeStructure {
|
||||
|
||||
private SimpleTextAttributes prepareAttribs(SimpleTextAttributes from) {
|
||||
ErrorLevel level = getOverallErrorLevel();
|
||||
Color waveColor = level == ErrorLevel.NONE
|
||||
? null : (level == ErrorLevel.WARNING ? Color.GRAY : Color.RED);
|
||||
Color waveColor = level == ErrorLevel.NONE ? null : Color.RED;
|
||||
int style = from.getStyle();
|
||||
if (waveColor != null) style |= SimpleTextAttributes.STYLE_WAVED;
|
||||
return new SimpleTextAttributes(from.getBgColor(),
|
||||
@@ -629,19 +628,7 @@ public class MavenProjectsStructure extends SimpleTreeStructure {
|
||||
}
|
||||
|
||||
private void updateErrorLevel() {
|
||||
if (!myMavenProject.hasErrors()) {
|
||||
setNodeErrorLevel(ErrorLevel.NONE);
|
||||
return;
|
||||
}
|
||||
List<MavenProjectProblem> problems = myMavenProject.getProblems();
|
||||
boolean isError = false;
|
||||
for (MavenProjectProblem each : problems) {
|
||||
if (each.isCritical()) {
|
||||
isError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
setNodeErrorLevel(isError ? ErrorLevel.ERROR : ErrorLevel.WARNING);
|
||||
setNodeErrorLevel(myMavenProject.getProblems().isEmpty() ? ErrorLevel.NONE : ErrorLevel.ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -675,8 +662,7 @@ public class MavenProjectsStructure extends SimpleTreeStructure {
|
||||
desc.append(" </table>");
|
||||
desc.append("</td>");
|
||||
desc.append("</tr>");
|
||||
appendProblems(desc, true);
|
||||
appendProblems(desc, false);
|
||||
appendProblems(desc);
|
||||
|
||||
if (getModulesErrorLevel() != ErrorLevel.NONE) {
|
||||
desc.append("<tr>");
|
||||
@@ -698,8 +684,8 @@ public class MavenProjectsStructure extends SimpleTreeStructure {
|
||||
return result;
|
||||
}
|
||||
|
||||
private void appendProblems(StringBuilder desc, boolean critical) {
|
||||
List<MavenProjectProblem> problems = collectProblems(critical);
|
||||
private void appendProblems(StringBuilder desc) {
|
||||
List<MavenProjectProblem> problems = myMavenProject.getProblems();
|
||||
if (problems.isEmpty()) return;
|
||||
|
||||
desc.append("<tr>");
|
||||
@@ -709,8 +695,8 @@ public class MavenProjectsStructure extends SimpleTreeStructure {
|
||||
for (MavenProjectProblem each : problems) {
|
||||
desc.append("<tr>");
|
||||
if (first) {
|
||||
desc.append("<td valign=top>" + MavenUtil.formatHtmlImage(critical ? ERROR_ICON_URL : WARNING_ICON_URL) + "</td>");
|
||||
desc.append("<td valign=top>" + (critical ? "Errors" : "Warnings") + ":</td>");
|
||||
desc.append("<td valign=top>" + MavenUtil.formatHtmlImage(ERROR_ICON_URL) + "</td>");
|
||||
desc.append("<td valign=top>Problems:</td>");
|
||||
first = false;
|
||||
}
|
||||
else {
|
||||
@@ -725,7 +711,7 @@ public class MavenProjectsStructure extends SimpleTreeStructure {
|
||||
}
|
||||
|
||||
private String wrappedText(MavenProjectProblem each) {
|
||||
String text = each.getDescription();
|
||||
String text = StringUtil.replace(each.getDescription(), new String[]{"<", ">"}, new String[]{"<", ">"});
|
||||
StringBuffer result = new StringBuffer();
|
||||
int count = 0;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
@@ -742,14 +728,6 @@ public class MavenProjectsStructure extends SimpleTreeStructure {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private List<MavenProjectProblem> collectProblems(boolean critical) {
|
||||
List<MavenProjectProblem> result = new ArrayList<MavenProjectProblem>();
|
||||
for (MavenProjectProblem each : myMavenProject.getProblems()) {
|
||||
if (critical == each.isCritical()) result.add(each);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void updateGoals() {
|
||||
myLifecycleNode.updateGoals();
|
||||
myPluginsNode.updateGoals();
|
||||
@@ -1012,7 +990,7 @@ public class MavenProjectsStructure extends SimpleTreeStructure {
|
||||
else {
|
||||
setNameAndTooltip(myPluginInfo.getGoalPrefix(), null, myPlugin.getDisplayString());
|
||||
}
|
||||
setNodeErrorLevel(myPluginInfo == null ? ErrorLevel.WARNING : ErrorLevel.NONE);
|
||||
setNodeErrorLevel(myPluginInfo == null ? ErrorLevel.ERROR : ErrorLevel.NONE);
|
||||
|
||||
// there is no need to update goals since plugins do not change
|
||||
if (hadPluginInfo || myPluginInfo == null) return;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.idea.maven.project;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -32,6 +33,10 @@ public class MavenId implements Serializable {
|
||||
this.myVersion = version;
|
||||
}
|
||||
|
||||
public MavenId(Model model) {
|
||||
this(model.getGroupId(), model.getArtifactId(), model.getVersion());
|
||||
}
|
||||
|
||||
public MavenId(Artifact artifact) {
|
||||
this(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
|
||||
}
|
||||
|
||||
@@ -101,7 +101,6 @@ public class MavenProject {
|
||||
|
||||
if (updateLastReadStamp) newState.myLastReadStamp++;
|
||||
|
||||
newState.myValid = readerResult.isValid;
|
||||
newState.myActiveProfilesIds = readerResult.activeProfiles;
|
||||
newState.myReadingProblems = readerResult.readingProblems;
|
||||
newState.myLocalRepository = readerResult.localRepository;
|
||||
@@ -346,8 +345,8 @@ public class MavenProject {
|
||||
return MavenUtil.getProfilesXmlIoFile(myFile);
|
||||
}
|
||||
|
||||
public boolean hasErrors() {
|
||||
return !myState.myValid;
|
||||
public boolean hasReadingProblems() {
|
||||
return !myState.myReadingProblems.isEmpty();
|
||||
}
|
||||
|
||||
public List<String> getActiveProfilesIds() {
|
||||
@@ -441,7 +440,7 @@ public class MavenProject {
|
||||
getFile(),
|
||||
getActiveProfilesIds(),
|
||||
locator);
|
||||
MavenProjectChanges changes = set(result, false, result.isValid, false);
|
||||
MavenProjectChanges changes = set(result, false, result.readingProblems.isEmpty(), false);
|
||||
return Pair.create(changes, result.nativeMavenProject);
|
||||
}
|
||||
|
||||
@@ -454,7 +453,7 @@ public class MavenProject {
|
||||
getFile(),
|
||||
getActiveProfilesIds(),
|
||||
console);
|
||||
if (result == null || !result.isValid) return Pair.create(false, MavenProjectChanges.NONE);
|
||||
if (result == null || !result.readingProblems.isEmpty()) return Pair.create(false, MavenProjectChanges.NONE);
|
||||
MavenProjectChanges changes = setFolders(result);
|
||||
return Pair.create(true, changes);
|
||||
}
|
||||
@@ -468,58 +467,62 @@ public class MavenProject {
|
||||
if (state.myProblemsCache == null) {
|
||||
synchronized (state) {
|
||||
if (state.myProblemsCache == null) {
|
||||
state.myProblemsCache = collectProblems(state);
|
||||
state.myProblemsCache = collectProblems(myFile, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
return state.myProblemsCache;
|
||||
}
|
||||
|
||||
private static List<MavenProjectProblem> collectProblems(State state) {
|
||||
private static List<MavenProjectProblem> collectProblems(VirtualFile file, State state) {
|
||||
List<MavenProjectProblem> result = new ArrayList<MavenProjectProblem>();
|
||||
|
||||
validateParent(state, result);
|
||||
validateParent(file, state, result);
|
||||
result.addAll(state.myReadingProblems);
|
||||
|
||||
for (Map.Entry<String, String> each : state.myModulesPathsAndNames.entrySet()) {
|
||||
if (LocalFileSystem.getInstance().findFileByPath(each.getKey()) == null) {
|
||||
result.add(new MavenProjectProblem(ProjectBundle.message("maven.project.problem.missingModule", each.getValue()), false));
|
||||
result.add(createDependencyProblem(file, ProjectBundle.message("maven.project.problem.moduleNotFound", each.getValue())));
|
||||
}
|
||||
}
|
||||
|
||||
validateDependencies(state, result);
|
||||
validateExtensions(state, result);
|
||||
validatePlugins(state, result);
|
||||
validateDependencies(file, state, result);
|
||||
validateExtensions(file, state, result);
|
||||
validatePlugins(file, state, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void validateParent(State state, List<MavenProjectProblem> result) {
|
||||
private static void validateParent(VirtualFile file, State state, List<MavenProjectProblem> result) {
|
||||
if (!isParentResolved(state)) {
|
||||
result.add(new MavenProjectProblem(ProjectBundle.message("maven.project.problem.parentNotFound", state.myParentId), true));
|
||||
result.add(createDependencyProblem(file, ProjectBundle.message("maven.project.problem.parentNotFound", state.myParentId)));
|
||||
}
|
||||
}
|
||||
|
||||
private static void validateDependencies(State state, List<MavenProjectProblem> result) {
|
||||
private static void validateDependencies(VirtualFile file, State state, List<MavenProjectProblem> result) {
|
||||
for (MavenArtifact each : getUnresolvedDependencies(state)) {
|
||||
result.add(new MavenProjectProblem(
|
||||
ProjectBundle.message("maven.project.problem.unresolvedDependency", each.getDisplayStringWithType()), false));
|
||||
result.add(createDependencyProblem(file, ProjectBundle.message("maven.project.problem.unresolvedDependency",
|
||||
each.getDisplayStringWithType())));
|
||||
}
|
||||
}
|
||||
|
||||
private static void validateExtensions(State state, List<MavenProjectProblem> result) {
|
||||
private static void validateExtensions(VirtualFile file, State state, List<MavenProjectProblem> result) {
|
||||
for (MavenArtifact each : getUnresolvedExtensions(state)) {
|
||||
result.add(new MavenProjectProblem(
|
||||
ProjectBundle.message("maven.project.problem.unresolvedExtension", each.getDisplayStringSimple()), false));
|
||||
result.add(createDependencyProblem(file, ProjectBundle.message("maven.project.problem.unresolvedExtension",
|
||||
each.getDisplayStringSimple())));
|
||||
}
|
||||
}
|
||||
|
||||
private static void validatePlugins(State state, List<MavenProjectProblem> result) {
|
||||
private static void validatePlugins(VirtualFile file, State state, List<MavenProjectProblem> result) {
|
||||
for (MavenPlugin each : getUnresolvedPlugins(state)) {
|
||||
result.add(new MavenProjectProblem(ProjectBundle.message("maven.project.problem.unresolvedPlugin", each), false));
|
||||
result.add(createDependencyProblem(file, ProjectBundle.message("maven.project.problem.unresolvedPlugin", each)));
|
||||
}
|
||||
}
|
||||
|
||||
private static MavenProjectProblem createDependencyProblem(VirtualFile file, String description) {
|
||||
return new MavenProjectProblem(file, description, MavenProjectProblem.ProblemType.DEPENDENCY);
|
||||
}
|
||||
|
||||
private static boolean isParentResolved(State state) {
|
||||
return !state.myUnresolvedArtifactIds.contains(state.myParentId);
|
||||
}
|
||||
@@ -817,8 +820,6 @@ public class MavenProject {
|
||||
private static class State implements Cloneable, Serializable {
|
||||
long myLastReadStamp = 0;
|
||||
|
||||
boolean myValid;
|
||||
|
||||
MavenId myMavenId;
|
||||
MavenId myParentId;
|
||||
String myPackaging;
|
||||
@@ -851,7 +852,7 @@ public class MavenProject {
|
||||
List<MavenRemoteRepository> myRemoteRepositories;
|
||||
|
||||
List<String> myActiveProfilesIds;
|
||||
List<MavenProjectProblem> myReadingProblems;
|
||||
Collection<MavenProjectProblem> myReadingProblems;
|
||||
Set<MavenId> myUnresolvedArtifactIds;
|
||||
File myLocalRepository;
|
||||
|
||||
|
||||
+43
-6
@@ -15,30 +15,67 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.project;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MavenProjectProblem implements Serializable {
|
||||
public enum ProblemType {
|
||||
SYNTAX, STRUCTURE, DEPENDENCY, PARENT, SETTINGS_OR_PROFILES;
|
||||
}
|
||||
|
||||
private String myUrl;
|
||||
private String myDescription;
|
||||
private boolean isCritical;
|
||||
private ProblemType myType;
|
||||
|
||||
protected MavenProjectProblem() {
|
||||
}
|
||||
|
||||
public MavenProjectProblem(String description, boolean critical) {
|
||||
public MavenProjectProblem(VirtualFile file, String description, ProblemType type) {
|
||||
myUrl = file.getUrl();
|
||||
myDescription = description;
|
||||
isCritical = critical;
|
||||
myType = type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return myUrl;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return myDescription;
|
||||
}
|
||||
|
||||
public boolean isCritical() {
|
||||
return isCritical;
|
||||
public ProblemType getType() {
|
||||
return myType;
|
||||
}
|
||||
|
||||
public VirtualFile findFile() {
|
||||
return VirtualFileManager.getInstance().findFileByUrl(myUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return (isCritical ? "!!!" : "") + myDescription;
|
||||
return myType + ":" + myDescription + ":" + myUrl;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
MavenProjectProblem that = (MavenProjectProblem)o;
|
||||
|
||||
if (!myDescription.equals(that.myDescription)) return false;
|
||||
if (myType != that.myType) return false;
|
||||
if (!myUrl.equals(that.myUrl)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = myUrl.hashCode();
|
||||
result = 31 * result + myDescription.hashCode();
|
||||
result = 31 * result + myType.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+138
-167
@@ -17,7 +17,6 @@ package org.jetbrains.idea.maven.project;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -57,17 +56,14 @@ import static com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces;
|
||||
public class MavenProjectReader {
|
||||
private static final String UNKNOWN = MavenId.UNKNOWN_VALUE;
|
||||
|
||||
private final Map<VirtualFile, ModelWithValidity> myRawModelsAndValidityCache = new THashMap<VirtualFile, ModelWithValidity>();
|
||||
private final Map<VirtualFile, ModelWithProblems> myRawModelsAndProblemsCache = new THashMap<VirtualFile, ModelWithProblems>();
|
||||
|
||||
public MavenProjectReaderResult readProject(MavenGeneralSettings generalSettings,
|
||||
VirtualFile file,
|
||||
List<String> activeProfiles,
|
||||
MavenProjectReaderProjectLocator locator) {
|
||||
Pair<ModelWithValidity, List<Profile>> readResult = doReadProjectModel(generalSettings,
|
||||
file,
|
||||
activeProfiles,
|
||||
new THashSet<VirtualFile>(),
|
||||
locator);
|
||||
Pair<ModelWithProblems, List<Profile>> readResult =
|
||||
doReadProjectModel(generalSettings, file, activeProfiles, new THashSet<VirtualFile>(), locator);
|
||||
|
||||
File basedir = getBaseDir(file);
|
||||
Model model = expandProperties(readResult.first.model, basedir);
|
||||
@@ -76,63 +72,55 @@ public class MavenProjectReader {
|
||||
MavenProject mavenProject = new MavenProject(model);
|
||||
mavenProject.setFile(new File(file.getPath()));
|
||||
mavenProject.setActiveProfiles(readResult.second);
|
||||
JBMavenProjectHelper.setSourceRoots(mavenProject,
|
||||
Collections.singletonList(model.getBuild().getSourceDirectory()),
|
||||
JBMavenProjectHelper.setSourceRoots(mavenProject, Collections.singletonList(model.getBuild().getSourceDirectory()),
|
||||
Collections.singletonList(model.getBuild().getTestSourceDirectory()),
|
||||
Collections.singletonList(model.getBuild().getScriptSourceDirectory()));
|
||||
|
||||
boolean isValid = readResult.first.validity;
|
||||
List<MavenProjectProblem> problems = new ArrayList<MavenProjectProblem>();
|
||||
if (!isValid) {
|
||||
problems.add(new MavenProjectProblem(ProjectBundle.message("maven.project.problem.syntaxError"), true));
|
||||
}
|
||||
return new MavenProjectReaderResult(isValid,
|
||||
activeProfiles,
|
||||
problems,
|
||||
Collections.EMPTY_SET,
|
||||
generalSettings.getEffectiveLocalRepository(),
|
||||
mavenProject);
|
||||
return new MavenProjectReaderResult(activeProfiles, readResult.first.problems, Collections.EMPTY_SET,
|
||||
generalSettings.getEffectiveLocalRepository(), mavenProject);
|
||||
}
|
||||
|
||||
private File getBaseDir(VirtualFile file) {
|
||||
return new File(file.getParent().getPath());
|
||||
}
|
||||
|
||||
private Pair<ModelWithValidity, List<Profile>> doReadProjectModel(MavenGeneralSettings generalSettings,
|
||||
private Pair<ModelWithProblems, List<Profile>> doReadProjectModel(MavenGeneralSettings generalSettings,
|
||||
VirtualFile file,
|
||||
List<String> activeProfiles,
|
||||
Set<VirtualFile> recursionGuard,
|
||||
MavenProjectReaderProjectLocator locator) {
|
||||
ModelWithValidity modelWithValidity = myRawModelsAndValidityCache.get(file);
|
||||
ModelWithProblems modelWithValidity = myRawModelsAndProblemsCache.get(file);
|
||||
if (modelWithValidity == null) {
|
||||
modelWithValidity = doReadProjectModel(file, generalSettings);
|
||||
myRawModelsAndValidityCache.put(file, modelWithValidity);
|
||||
modelWithValidity = doReadProjectModel(file, generalSettings, false);
|
||||
myRawModelsAndProblemsCache.put(file, modelWithValidity);
|
||||
}
|
||||
|
||||
Model model = modelWithValidity.model;
|
||||
List<Profile> activatedProfiles = applyProfiles(model, getBaseDir(file), activeProfiles);
|
||||
repairModelHeader(model);
|
||||
if (!resolveInheritance(generalSettings, model, file, activeProfiles, recursionGuard, locator)) {
|
||||
modelWithValidity.validity = false; // todo ????????? changing cached value
|
||||
}
|
||||
resolveInheritance(generalSettings, model, file, activeProfiles,
|
||||
recursionGuard, locator, modelWithValidity.problems); // todo ????????? changing cached value
|
||||
repairModelBody(model);
|
||||
|
||||
return Pair.create(modelWithValidity, activatedProfiles);
|
||||
}
|
||||
|
||||
private ModelWithValidity doReadProjectModel(VirtualFile file, MavenGeneralSettings generalSettings) {
|
||||
private ModelWithProblems doReadProjectModel(VirtualFile file, MavenGeneralSettings generalSettings, boolean headerOnly) {
|
||||
Model result = new Model();
|
||||
LinkedHashSet<MavenProjectProblem> problems = createProblemsList();
|
||||
|
||||
Pair<Element, Boolean> readXmlResult = readXml(file);
|
||||
Element xmlProject = readXmlResult.first.getChild("project");
|
||||
Element xmlProject = readXml(file, problems, MavenProjectProblem.ProblemType.SYNTAX).getChild("project");
|
||||
if (xmlProject == null) {
|
||||
return new ModelWithValidity(result, false);
|
||||
return new ModelWithProblems(result, problems);
|
||||
}
|
||||
|
||||
result.setModelVersion(findChildValueByPath(xmlProject, "modelVersion"));
|
||||
result.setGroupId(findChildValueByPath(xmlProject, "groupId"));
|
||||
result.setArtifactId(findChildValueByPath(xmlProject, "artifactId"));
|
||||
result.setVersion(findChildValueByPath(xmlProject, "version"));
|
||||
|
||||
if (headerOnly) return new ModelWithProblems(result, problems);
|
||||
|
||||
result.setPackaging(findChildValueByPath(xmlProject, "packaging"));
|
||||
result.setName(findChildValueByPath(xmlProject, "name"));
|
||||
|
||||
@@ -150,18 +138,14 @@ public class MavenProjectReader {
|
||||
|
||||
result.setParent(parent);
|
||||
}
|
||||
|
||||
result.setBuild(new Build());
|
||||
readModelAndBuild(result, result.getBuild(), xmlProject);
|
||||
|
||||
Ref<Boolean> validity = new Ref<Boolean>(readXmlResult.second);
|
||||
result.setProfiles(collectProfiles(generalSettings, file, xmlProject, validity));
|
||||
return new ModelWithValidity(result, validity.get());
|
||||
result.setProfiles(collectProfiles(generalSettings, file, xmlProject, problems));
|
||||
return new ModelWithProblems(result, problems);
|
||||
}
|
||||
|
||||
private void readModelAndBuild(ModelBase mavenModelBase,
|
||||
BuildBase mavenBuildBase,
|
||||
Element xmlModel) {
|
||||
private void readModelAndBuild(ModelBase mavenModelBase, BuildBase mavenBuildBase, Element xmlModel) {
|
||||
mavenModelBase.setModules(findChildrenValuesByPath(xmlModel, "modules", "module"));
|
||||
collectProperties(findChildByPath(xmlModel, "properties"), mavenModelBase);
|
||||
|
||||
@@ -199,15 +183,16 @@ public class MavenProjectReader {
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<Profile> collectProfiles(MavenGeneralSettings generalSettings, VirtualFile file, Element xmlProject, Ref<Boolean> validity) {
|
||||
private List<Profile> collectProfiles(MavenGeneralSettings generalSettings,
|
||||
VirtualFile projectFile,
|
||||
Element xmlProject,
|
||||
Collection<MavenProjectProblem> problems) {
|
||||
List<Profile> result = new ArrayList<Profile>();
|
||||
collectProfiles(findChildrenByPath(xmlProject, "profiles", "profile"), result);
|
||||
|
||||
VirtualFile profilesFile = MavenUtil.findProfilesXmlFile(file);
|
||||
VirtualFile profilesFile = MavenUtil.findProfilesXmlFile(projectFile);
|
||||
if (profilesFile != null) {
|
||||
Pair<Element, Boolean> readResult = readXml(profilesFile);
|
||||
Element profilesFileElement = readResult.first;
|
||||
if (!readResult.second) validity.set(false);
|
||||
Element profilesFileElement = readXml(profilesFile, problems, MavenProjectProblem.ProblemType.SETTINGS_OR_PROFILES);
|
||||
|
||||
Element rootElement = findChildByPath(profilesFileElement, "profiles");
|
||||
if (rootElement == null) rootElement = findChildByPath(profilesFileElement, "profilesXml.profiles");
|
||||
@@ -216,18 +201,18 @@ public class MavenProjectReader {
|
||||
}
|
||||
|
||||
for (VirtualFile each : generalSettings.getEffectiveSettingsFiles()) {
|
||||
collectProfilesFromSettingsFile(each, result, validity);
|
||||
collectProfilesFromSettingsFile(each, result, problems);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void collectProfilesFromSettingsFile(VirtualFile settingsFile, List<Profile> result, Ref<Boolean> validity) {
|
||||
private void collectProfilesFromSettingsFile(VirtualFile settingsFile,
|
||||
List<Profile> result,
|
||||
Collection<MavenProjectProblem> problems) {
|
||||
if (settingsFile == null) return;
|
||||
Pair<Element, Boolean> readResult = readXml(settingsFile);
|
||||
if (!readResult.second) validity.set(false);
|
||||
|
||||
List<Element> xmlProfiles = findChildrenByPath(readResult.first, "settings.profiles", "profile");
|
||||
Element readResult = readXml(settingsFile, problems, MavenProjectProblem.ProblemType.SETTINGS_OR_PROFILES);
|
||||
List<Element> xmlProfiles = findChildrenByPath(readResult, "settings.profiles", "profile");
|
||||
collectProfiles(xmlProfiles, result);
|
||||
}
|
||||
|
||||
@@ -322,9 +307,9 @@ public class MavenProjectReader {
|
||||
Profile eachExpandedProfile = expandedProfiles.get(i);
|
||||
|
||||
// todo hook for IDEADEV-38717
|
||||
assert eachExpandedProfile != null : "expanded profile not found";
|
||||
assert Comparing.equal(eachExpandedProfile.getId(), eachRawProfile.getId()) :
|
||||
"expected id: " + eachRawProfile.getId() + " was : " + eachExpandedProfile.getId();
|
||||
MavenLog.LOG.assertTrue(eachExpandedProfile != null, "expanded profile not found");
|
||||
MavenLog.LOG.assertTrue(Comparing.equal(eachExpandedProfile.getId(), eachRawProfile.getId()),
|
||||
"expected id: " + eachRawProfile.getId() + " was : " + eachExpandedProfile.getId());
|
||||
|
||||
for (ProfileActivator eachActivator : getProfileActivators()) {
|
||||
try {
|
||||
@@ -360,12 +345,8 @@ public class MavenProjectReader {
|
||||
return new ProfileActivator[0];
|
||||
}
|
||||
|
||||
return new ProfileActivator[]{
|
||||
new FileProfileActivator(),
|
||||
sysPropertyActivator,
|
||||
new JdkPrefixProfileActivator(),
|
||||
new OperatingSystemProfileActivator()
|
||||
};
|
||||
return new ProfileActivator[]{new FileProfileActivator(), sysPropertyActivator, new JdkPrefixProfileActivator(),
|
||||
new OperatingSystemProfileActivator()};
|
||||
}
|
||||
|
||||
private void repairModelHeader(Model model) {
|
||||
@@ -410,26 +391,19 @@ public class MavenProjectReader {
|
||||
build.setFinalName("${project.artifactId}-${project.version}");
|
||||
}
|
||||
|
||||
build.setSourceDirectory(isEmptyOrSpaces(build.getSourceDirectory())
|
||||
? "src/main/java"
|
||||
: build.getSourceDirectory());
|
||||
build.setTestSourceDirectory(isEmptyOrSpaces(build.getTestSourceDirectory())
|
||||
? "src/test/java"
|
||||
: build.getTestSourceDirectory());
|
||||
build.setScriptSourceDirectory(isEmptyOrSpaces(build.getScriptSourceDirectory())
|
||||
? "src/main/scripts"
|
||||
: build.getScriptSourceDirectory());
|
||||
build.setSourceDirectory(isEmptyOrSpaces(build.getSourceDirectory()) ? "src/main/java" : build.getSourceDirectory());
|
||||
build.setTestSourceDirectory(isEmptyOrSpaces(build.getTestSourceDirectory()) ? "src/test/java" : build.getTestSourceDirectory());
|
||||
build
|
||||
.setScriptSourceDirectory(isEmptyOrSpaces(build.getScriptSourceDirectory()) ? "src/main/scripts" : build.getScriptSourceDirectory());
|
||||
|
||||
build.setResources(repairResources(build.getResources(), "src/main/resources"));
|
||||
build.setTestResources(repairResources(build.getTestResources(), "src/test/resources"));
|
||||
|
||||
build.setDirectory(isEmptyOrSpaces(build.getDirectory()) ? "target" : build.getDirectory());
|
||||
build.setOutputDirectory(isEmptyOrSpaces(build.getOutputDirectory())
|
||||
? "${project.build.directory}/classes"
|
||||
: build.getOutputDirectory());
|
||||
build.setTestOutputDirectory(isEmptyOrSpaces(build.getTestOutputDirectory())
|
||||
? "${project.build.directory}/test-classes"
|
||||
: build.getTestOutputDirectory());
|
||||
build
|
||||
.setOutputDirectory(isEmptyOrSpaces(build.getOutputDirectory()) ? "${project.build.directory}/classes" : build.getOutputDirectory());
|
||||
build.setTestOutputDirectory(
|
||||
isEmptyOrSpaces(build.getTestOutputDirectory()) ? "${project.build.directory}/test-classes" : build.getTestOutputDirectory());
|
||||
}
|
||||
|
||||
private List<Resource> repairResources(List<Resource> resources, String defaultDir) {
|
||||
@@ -453,68 +427,71 @@ public class MavenProjectReader {
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean resolveInheritance(final MavenGeneralSettings generalSettings,
|
||||
final Model model,
|
||||
final VirtualFile file,
|
||||
final List<String> activeProfiles,
|
||||
final Set<VirtualFile> recursionGuard,
|
||||
final MavenProjectReaderProjectLocator locator) {
|
||||
if (recursionGuard.contains(file)) return false;
|
||||
private void resolveInheritance(final MavenGeneralSettings generalSettings,
|
||||
final Model model,
|
||||
final VirtualFile file,
|
||||
final List<String> activeProfiles,
|
||||
final Set<VirtualFile> recursionGuard,
|
||||
final MavenProjectReaderProjectLocator locator,
|
||||
Collection<MavenProjectProblem> problems) {
|
||||
if (recursionGuard.contains(file)) {
|
||||
problems.add(createProblem(file, ProjectBundle.message("maven.project.problem.recursiveInheritance"),
|
||||
MavenProjectProblem.ProblemType.PARENT));
|
||||
return;
|
||||
}
|
||||
recursionGuard.add(file);
|
||||
|
||||
try {
|
||||
Parent parent = model.getParent();
|
||||
final MavenParentDesc[] parentDesc = new MavenParentDesc[1];
|
||||
if (parent != null) {
|
||||
MavenId parentId = new MavenId(parent.getGroupId(),
|
||||
parent.getArtifactId(),
|
||||
parent.getVersion());
|
||||
MavenId parentId = new MavenId(parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
|
||||
if (parentId.equals(model.getGroupId(), model.getArtifactId(), model.getVersion())) {
|
||||
// self-inheritance protection
|
||||
return false;
|
||||
problems.add(createProblem(file, ProjectBundle.message("maven.project.problem.selfInheritance"),
|
||||
MavenProjectProblem.ProblemType.PARENT));
|
||||
return;
|
||||
}
|
||||
parentDesc[0] = new MavenParentDesc(parentId, parent.getRelativePath());
|
||||
}
|
||||
|
||||
ModelWithValidity parentModelWithValidity = new MavenParentProjectFileProcessor<ModelWithValidity>() {
|
||||
@Nullable
|
||||
protected VirtualFile findManagedFile(@NotNull MavenId id) {
|
||||
return locator.findProjectFile(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected ModelWithValidity processRelativeParent(VirtualFile parentFile) {
|
||||
ModelWithValidity result = super.processRelativeParent(parentFile);
|
||||
if (result == null) return null;
|
||||
|
||||
MavenId parentId = parentDesc[0].getParentId();
|
||||
Model model = result.model;
|
||||
if (!(parentId.equals(model.getGroupId(), model.getArtifactId(), model.getVersion()))) {
|
||||
return null;
|
||||
Pair<VirtualFile, ModelWithProblems> parentModelWithProblems =
|
||||
new MavenParentProjectFileProcessor<Pair<VirtualFile, ModelWithProblems>>() {
|
||||
@Nullable
|
||||
protected VirtualFile findManagedFile(@NotNull MavenId id) {
|
||||
return locator.findProjectFile(id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModelWithValidity processSuperParent(VirtualFile parentFile) {
|
||||
return null; // do not process superPom
|
||||
}
|
||||
@Override
|
||||
@Nullable
|
||||
protected Pair<VirtualFile, ModelWithProblems> processRelativeParent(VirtualFile parentFile) {
|
||||
Model parentModel = doReadProjectModel(parentFile, generalSettings, true).model;
|
||||
MavenId parentId = parentDesc[0].getParentId();
|
||||
if (!parentId.equals(new MavenId(parentModel))) return null;
|
||||
|
||||
@Override
|
||||
protected ModelWithValidity doProcessParent(VirtualFile parentFile) {
|
||||
return doReadProjectModel(generalSettings,
|
||||
parentFile,
|
||||
activeProfiles,
|
||||
recursionGuard,
|
||||
locator).first;
|
||||
}
|
||||
}.process(generalSettings, file, parentDesc[0]);
|
||||
return super.processRelativeParent(parentFile);
|
||||
}
|
||||
|
||||
if (parentModelWithValidity == null) return true; // no parent or parent not found;
|
||||
@Override
|
||||
protected Pair<VirtualFile, ModelWithProblems> processSuperParent(VirtualFile parentFile) {
|
||||
return null; // do not process superPom
|
||||
}
|
||||
|
||||
new DefaultModelInheritanceAssembler().assembleModelInheritance(model, parentModelWithValidity.model);
|
||||
return parentModelWithValidity.validity;
|
||||
@Override
|
||||
protected Pair<VirtualFile, ModelWithProblems> doProcessParent(VirtualFile parentFile) {
|
||||
ModelWithProblems result = doReadProjectModel(generalSettings, parentFile, activeProfiles, recursionGuard, locator).first;
|
||||
return Pair.create(parentFile, result);
|
||||
}
|
||||
}.process(generalSettings, file, parentDesc[0]);
|
||||
|
||||
if (parentModelWithProblems == null) return; // no parent or parent not found;
|
||||
if (!parentModelWithProblems.second.problems.isEmpty()) {
|
||||
problems.add(createProblem(parentModelWithProblems.first,
|
||||
ProjectBundle.message("maven.project.problem.parentHasProblems",
|
||||
new MavenId(parentModelWithProblems.second.model)),
|
||||
MavenProjectProblem.ProblemType.PARENT));
|
||||
}
|
||||
|
||||
new DefaultModelInheritanceAssembler().assembleModelInheritance(model, parentModelWithProblems.second.model);
|
||||
}
|
||||
finally {
|
||||
recursionGuard.remove(file);
|
||||
@@ -548,14 +525,29 @@ public class MavenProjectReader {
|
||||
build.setScriptSourceDirectory(pathTranslator.alignToBaseDirectory(build.getScriptSourceDirectory(), basedir));
|
||||
}
|
||||
|
||||
private MavenProjectProblem createStructureProblem(VirtualFile file, String description) {
|
||||
return createProblem(file, description, MavenProjectProblem.ProblemType.STRUCTURE);
|
||||
}
|
||||
|
||||
private MavenProjectProblem createSyntaxProblem(VirtualFile file, MavenProjectProblem.ProblemType type) {
|
||||
return createProblem(file, ProjectBundle.message("maven.project.problem.syntaxError", file.getName()), type);
|
||||
}
|
||||
|
||||
private MavenProjectProblem createProblem(VirtualFile file, String description, MavenProjectProblem.ProblemType type) {
|
||||
return new MavenProjectProblem(file, description, type);
|
||||
}
|
||||
|
||||
private LinkedHashSet<MavenProjectProblem> createProblemsList() {
|
||||
return new LinkedHashSet<MavenProjectProblem>();
|
||||
}
|
||||
|
||||
public MavenProjectReaderResult resolveProject(MavenGeneralSettings generalSettings,
|
||||
MavenEmbedderWrapper embedder,
|
||||
VirtualFile file,
|
||||
List<String> activeProfiles,
|
||||
MavenProjectReaderProjectLocator locator) throws MavenProcessCanceledException {
|
||||
MavenProject mavenProject = null;
|
||||
boolean isValid = true;
|
||||
List<MavenProjectProblem> problems = new ArrayList<MavenProjectProblem>();
|
||||
Collection<MavenProjectProblem> problems = createProblemsList();
|
||||
Set<MavenId> unresolvedArtifactsIds = new THashSet<MavenId>();
|
||||
|
||||
try {
|
||||
@@ -574,39 +566,32 @@ public class MavenProjectReader {
|
||||
}
|
||||
|
||||
if (message != null) {
|
||||
problems.add(new MavenProjectProblem(message, true));
|
||||
problems.add(createStructureProblem(file, message));
|
||||
}
|
||||
MavenLog.LOG.info(e);
|
||||
MavenLog.printInTests(e); // print exception since we need to know if something wrong with our logic
|
||||
}
|
||||
|
||||
if (mavenProject == null) {
|
||||
isValid = false;
|
||||
|
||||
if (problems.isEmpty()) {
|
||||
problems.add(new MavenProjectProblem(ProjectBundle.message("maven.project.problem.syntaxError"), true));
|
||||
problems.add(createSyntaxProblem(file, MavenProjectProblem.ProblemType.SYNTAX));
|
||||
}
|
||||
mavenProject = readProject(generalSettings, file, activeProfiles, locator).nativeMavenProject;
|
||||
}
|
||||
|
||||
return new MavenProjectReaderResult(isValid,
|
||||
activeProfiles,
|
||||
problems,
|
||||
unresolvedArtifactsIds,
|
||||
embedder.getLocalRepositoryFile(),
|
||||
mavenProject);
|
||||
return new MavenProjectReaderResult(activeProfiles, problems, unresolvedArtifactsIds, embedder.getLocalRepositoryFile(), mavenProject);
|
||||
}
|
||||
|
||||
private Pair<MavenProject, Set<MavenId>> doResolveProject(MavenEmbedderWrapper embedder,
|
||||
VirtualFile file,
|
||||
List<String> profiles,
|
||||
List<MavenProjectProblem> problems) throws MavenProcessCanceledException {
|
||||
Collection<MavenProjectProblem> problems) throws MavenProcessCanceledException {
|
||||
MavenExecutionResult result = embedder.resolveProject(file, profiles);
|
||||
validate(result, problems);
|
||||
validate(file, result, problems);
|
||||
return Pair.create(result.getMavenProject(), result.getUnresolvedArtifactIds());
|
||||
}
|
||||
|
||||
private boolean validate(MavenExecutionResult r, List<MavenProjectProblem> problems) {
|
||||
private boolean validate(VirtualFile file, MavenExecutionResult r, Collection<MavenProjectProblem> problems) {
|
||||
for (Exception each : r.getExceptions()) {
|
||||
MavenLog.LOG.info(each);
|
||||
|
||||
@@ -614,21 +599,19 @@ public class MavenProjectReader {
|
||||
ModelValidationResult modelValidationResult = ((InvalidProjectModelException)each).getValidationResult();
|
||||
if (modelValidationResult != null) {
|
||||
for (Object eachValidationProblem : modelValidationResult.getMessages()) {
|
||||
problems.add(new MavenProjectProblem((String)eachValidationProblem, true));
|
||||
problems.add(createStructureProblem(file, (String)eachValidationProblem));
|
||||
}
|
||||
}
|
||||
else {
|
||||
problems.add(new MavenProjectProblem(each.getCause().getMessage(), true));
|
||||
problems.add(createStructureProblem(file, each.getCause().getMessage()));
|
||||
}
|
||||
}
|
||||
else if (each instanceof ProjectBuildingException) {
|
||||
String causeMessage = each.getCause() != null
|
||||
? each.getCause().getMessage()
|
||||
: each.getMessage();
|
||||
problems.add(new MavenProjectProblem(causeMessage, true));
|
||||
String causeMessage = each.getCause() != null ? each.getCause().getMessage() : each.getMessage();
|
||||
problems.add(createStructureProblem(file, causeMessage));
|
||||
}
|
||||
else {
|
||||
problems.add(new MavenProjectProblem(each.getMessage(), true));
|
||||
problems.add(createStructureProblem(file, each.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -647,17 +630,13 @@ public class MavenProjectReader {
|
||||
MavenConsoleHelper.printExecutionExceptions(console, result);
|
||||
}
|
||||
|
||||
List<MavenProjectProblem> problems = new ArrayList<MavenProjectProblem>();
|
||||
if (!validate(result, problems)) return null;
|
||||
Collection<MavenProjectProblem> problems = createProblemsList();
|
||||
if (!validate(file, result, problems)) return null;
|
||||
|
||||
MavenProject project = result.getMavenProject();
|
||||
if (project == null) return null;
|
||||
|
||||
return new MavenProjectReaderResult(true,
|
||||
profiles,
|
||||
problems,
|
||||
result.getUnresolvedArtifactIds(),
|
||||
embedder.getLocalRepositoryFile(),
|
||||
return new MavenProjectReaderResult(profiles, problems, result.getUnresolvedArtifactIds(), embedder.getLocalRepositoryFile(),
|
||||
project);
|
||||
}
|
||||
catch (MavenProcessCanceledException e) {
|
||||
@@ -670,7 +649,7 @@ public class MavenProjectReader {
|
||||
}
|
||||
}
|
||||
|
||||
private Pair<Element, Boolean> readXml(VirtualFile file) {
|
||||
private Element readXml(final VirtualFile file, final Collection<MavenProjectProblem> problems, final MavenProjectProblem.ProblemType type) {
|
||||
final LinkedList<Element> stack = new LinkedList<Element>();
|
||||
final Element root = new Element("root");
|
||||
|
||||
@@ -680,24 +659,16 @@ public class MavenProjectReader {
|
||||
}
|
||||
catch (IOException e) {
|
||||
MavenLog.LOG.warn("Cannot read the pom file: " + e);
|
||||
return Pair.create(root, false);
|
||||
problems.add(createProblem(file, e.getMessage(), type));
|
||||
return root;
|
||||
}
|
||||
|
||||
final boolean[] validity = new boolean[]{true};
|
||||
|
||||
XmlBuilderDriver driver = new XmlBuilderDriver(text);
|
||||
XmlBuilder builder = new XmlBuilder() {
|
||||
public void doctype(@Nullable CharSequence publicId,
|
||||
@Nullable CharSequence systemId,
|
||||
int startOffset,
|
||||
int endOffset) {
|
||||
public void doctype(@Nullable CharSequence publicId, @Nullable CharSequence systemId, int startOffset, int endOffset) {
|
||||
}
|
||||
|
||||
public ProcessingOrder startTag(CharSequence localName,
|
||||
String namespace,
|
||||
int startoffset,
|
||||
int endoffset,
|
||||
int headerEndOffset) {
|
||||
public ProcessingOrder startTag(CharSequence localName, String namespace, int startoffset, int endoffset, int headerEndOffset) {
|
||||
String name = localName.toString();
|
||||
if (StringUtil.isEmptyOrSpaces(name)) return ProcessingOrder.TAGS;
|
||||
|
||||
@@ -738,12 +709,12 @@ public class MavenProjectReader {
|
||||
}
|
||||
|
||||
public void error(String message, int startOffset, int endOffset) {
|
||||
validity[0] = false;
|
||||
problems.add(createSyntaxProblem(file, type));
|
||||
}
|
||||
};
|
||||
|
||||
driver.build(builder);
|
||||
return Pair.create(root, validity[0]);
|
||||
return root;
|
||||
}
|
||||
|
||||
private Element findChildByPath(Element element, String path) {
|
||||
@@ -790,13 +761,13 @@ public class MavenProjectReader {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static class ModelWithValidity {
|
||||
private static class ModelWithProblems {
|
||||
public Model model;
|
||||
public boolean validity;
|
||||
public Collection<MavenProjectProblem> problems;
|
||||
|
||||
private ModelWithValidity(Model model, boolean validity) {
|
||||
private ModelWithProblems(Model model, Collection<MavenProjectProblem> problems) {
|
||||
this.model = model;
|
||||
this.validity = validity;
|
||||
this.problems = problems;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-7
@@ -16,27 +16,24 @@
|
||||
package org.jetbrains.idea.maven.project;
|
||||
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenId;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class MavenProjectReaderResult {
|
||||
public boolean isValid;
|
||||
public List<String> activeProfiles;
|
||||
public List<MavenProjectProblem> readingProblems;
|
||||
public Collection<MavenProjectProblem> readingProblems;
|
||||
public Set<MavenId> unresolvedArtifactIds;
|
||||
public File localRepository;
|
||||
public MavenProject nativeMavenProject;
|
||||
|
||||
public MavenProjectReaderResult(boolean valid,
|
||||
List<String> activeProfiles,
|
||||
List<MavenProjectProblem> readingProblems,
|
||||
public MavenProjectReaderResult(List<String> activeProfiles,
|
||||
Collection<MavenProjectProblem> readingProblems,
|
||||
Set<MavenId> unresolvedArtifactIds,
|
||||
File localRepository,
|
||||
MavenProject nativeMavenProject) {
|
||||
isValid = valid;
|
||||
this.activeProfiles = activeProfiles;
|
||||
this.readingProblems = readingProblems;
|
||||
this.unresolvedArtifactIds = unresolvedArtifactIds;
|
||||
|
||||
+3
-2
@@ -36,6 +36,7 @@ import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.problems.WolfTheProblemSolver;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
@@ -324,7 +325,7 @@ public class MavenProjectsManager extends SimpleProjectComponent implements Pers
|
||||
Iterator<MavenProject> it = toResolve.iterator();
|
||||
while (it.hasNext()) {
|
||||
MavenProject each = it.next();
|
||||
if (each.hasErrors()) it.remove();
|
||||
if (each.hasReadingProblems()) it.remove();
|
||||
}
|
||||
|
||||
if (haveChanges(toImport) || !deleted.isEmpty()) {
|
||||
@@ -362,7 +363,7 @@ public class MavenProjectsManager extends SimpleProjectComponent implements Pers
|
||||
}
|
||||
|
||||
private boolean shouldScheduleProject(Pair<MavenProject, MavenProjectChanges> projectWithChanges) {
|
||||
return !projectWithChanges.first.hasErrors() && projectWithChanges.second.hasChanges();
|
||||
return !projectWithChanges.first.hasReadingProblems() && projectWithChanges.second.hasChanges();
|
||||
}
|
||||
|
||||
private void processMessage(Object message) {
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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 org.jetbrains.idea.maven.utils;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import org.jetbrains.idea.maven.dom.MavenDomUtil;
|
||||
|
||||
public class MavenProblemFileHighlighter implements Condition<VirtualFile> {
|
||||
private final Project myProject;
|
||||
|
||||
public MavenProblemFileHighlighter(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public boolean value(VirtualFile file) {
|
||||
PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
|
||||
return psiFile != null && MavenDomUtil.isMavenFile(psiFile);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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 org.jetbrains.idea.maven.utils;
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.PsiModificationTrackerImpl;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectChanges;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsTree;
|
||||
import org.jetbrains.idea.maven.utils.MavenUtil;
|
||||
import org.jetbrains.idea.maven.utils.SimpleProjectComponent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MavenRehighlighter extends SimpleProjectComponent {
|
||||
protected MavenRehighlighter(Project project) {
|
||||
super(project);
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
MavenProjectsManager m = MavenProjectsManager.getInstance(myProject);
|
||||
m.addManagerListener(new MavenProjectsManager.Listener() {
|
||||
public void activated() {
|
||||
rehighlight(myProject);
|
||||
}
|
||||
|
||||
public void scheduledImportsChanged() {
|
||||
}
|
||||
});
|
||||
m.addProjectsTreeListener(new MavenProjectsTree.ListenerAdapter() {
|
||||
public void projectsUpdated(List<Pair<MavenProject, MavenProjectChanges>> updated, List<MavenProject> deleted, Object message) {
|
||||
rehighlight(myProject);
|
||||
}
|
||||
|
||||
public void projectResolved(Pair<MavenProject, MavenProjectChanges> projectWithChanges,
|
||||
org.apache.maven.project.MavenProject nativeMavenProject,
|
||||
Object message) {
|
||||
rehighlight(myProject);
|
||||
}
|
||||
|
||||
public void pluginsResolved(MavenProject project) {
|
||||
rehighlight(myProject);
|
||||
}
|
||||
|
||||
public void foldersResolved(Pair<MavenProject, MavenProjectChanges> projectWithChanges, Object message) {
|
||||
rehighlight(myProject);
|
||||
}
|
||||
|
||||
public void artifactsDownloaded(MavenProject project) {
|
||||
rehighlight(myProject);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void rehighlight(final Project project) {
|
||||
MavenUtil.invokeLater(project, new Runnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
((PsiModificationTrackerImpl)PsiManager.getInstance(project).getModificationTracker()).incCounter();
|
||||
DaemonCodeAnalyzer.getInstance(project).restart();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,5 @@ fix.create.module=Create Module
|
||||
fix.create.module.with.parent=Create Module with Parent
|
||||
fix.update.indices=Update Maven Indices
|
||||
fix.parent.path=Fix relative path
|
||||
fix.open.file=Open ''{0}''
|
||||
intention.choose.file=Choose File
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
<iconProvider implementation="org.jetbrains.idea.maven.utils.MavenIconProvider"/>
|
||||
<editorTabTitleProvider implementation="org.jetbrains.idea.maven.utils.MavenEditorTabTitleProvider"/>
|
||||
|
||||
<problemFileHighlightFilter implementation="org.jetbrains.idea.maven.utils.MavenProblemFileHighlighter"/>
|
||||
|
||||
<xml.elementDescriptorProvider implementation="org.jetbrains.idea.maven.dom.MavenDomElementDescriptorProvider"/>
|
||||
<dom.fileDescription implementation="org.jetbrains.idea.maven.dom.MavenDomProjectModelDescription"/>
|
||||
<dom.fileDescription implementation="org.jetbrains.idea.maven.dom.MavenDomProfilesModelDescription"/>
|
||||
@@ -120,6 +122,9 @@
|
||||
<component>
|
||||
<implementation-class>org.jetbrains.idea.maven.utils.MavenImportNotifier</implementation-class>
|
||||
</component>
|
||||
<component>
|
||||
<implementation-class>org.jetbrains.idea.maven.utils.MavenRehighlighter</implementation-class>
|
||||
</component>
|
||||
</project-components>
|
||||
|
||||
<actions>
|
||||
|
||||
@@ -65,12 +65,15 @@ maven.ignore.edit=Edit Ignored Files...
|
||||
maven.profile.activate=Activate
|
||||
maven.profile.deactivate=Deactivate
|
||||
|
||||
maven.project.problem.syntaxError=Pom file has syntax errors.
|
||||
maven.project.problem.parentNotFound=Parent ''{0}'' not found.
|
||||
maven.project.problem.missingModule=Missing module: ''{0}''.
|
||||
maven.project.problem.unresolvedDependency=Unresolved dependency: ''{0}''.
|
||||
maven.project.problem.unresolvedExtension=Unresolved build extension: ''{0}''.
|
||||
maven.project.problem.unresolvedPlugin=Unresolved plugin: ''{0}''.
|
||||
maven.project.problem.syntaxError=''{0}'' has syntax errors
|
||||
maven.project.problem.recursiveInheritance=Recursive inheritance found
|
||||
maven.project.problem.selfInheritance=Self-inheritance found
|
||||
maven.project.problem.parentHasProblems=Parent ''{0}'' has problems
|
||||
maven.project.problem.parentNotFound=Parent ''{0}'' not found
|
||||
maven.project.problem.moduleNotFound=Module ''{0}'' not found
|
||||
maven.project.problem.unresolvedDependency=Unresolved dependency: ''{0}''
|
||||
maven.project.problem.unresolvedExtension=Unresolved build extension: ''{0}''
|
||||
maven.project.problem.unresolvedPlugin=Unresolved plugin: ''{0}''
|
||||
|
||||
|
||||
maven.tab.general=General
|
||||
|
||||
@@ -348,7 +348,7 @@ public abstract class MavenImportingTestCase extends MavenTestCase {
|
||||
myProjectsManager.importProjects();
|
||||
|
||||
for (MavenProject each : myProjectsTree.getProjects()) {
|
||||
if (each.hasErrors()) {
|
||||
if (each.hasReadingProblems()) {
|
||||
System.out.println(each + " has problems: " + each.getProblems());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,12 +92,17 @@ public abstract class MavenDomTestCase extends MavenImportingTestCase {
|
||||
return PsiManager.getInstance(myProject).findFile(f);
|
||||
}
|
||||
|
||||
private void configTest(VirtualFile f) throws IOException {
|
||||
protected void configTest(VirtualFile f) throws IOException {
|
||||
if (Comparing.equal(myConfigTimestamps.get(f), f.getModificationStamp())) return;
|
||||
myCodeInsightFixture.configureFromExistingVirtualFile(f);
|
||||
myConfigTimestamps.put(f, f.getModificationStamp());
|
||||
}
|
||||
|
||||
protected void type(VirtualFile f, char c) throws IOException {
|
||||
configTest(f);
|
||||
myCodeInsightFixture.type(c);
|
||||
}
|
||||
|
||||
protected PsiReference getReferenceAtCaret(VirtualFile f) throws IOException {
|
||||
configTest(f);
|
||||
return findPsiFile(f).findReferenceAt(getEditorOffset(f));
|
||||
|
||||
+180
@@ -91,4 +91,184 @@ public class MavenModelValidationTest extends MavenDomWithIndicesTestCase {
|
||||
"<<error>version</error>></version>");
|
||||
checkHighlighting();
|
||||
}
|
||||
|
||||
public void testAddingSettingsXmlReadingProblemsToProjectTag() throws Exception {
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<project>" +
|
||||
" <modelVersion>4.0.0</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</project>");
|
||||
updateSettingsXml("<<<");
|
||||
|
||||
myProjectsManager.forceUpdateAllProjectsOrFindAllAvailablePomFiles();
|
||||
waitForReadingCompletion();
|
||||
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<<error descr=\"'settings.xml' has syntax errors\">project</error>>" +
|
||||
" <modelVersion>4.0.0</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</project>");
|
||||
checkHighlighting();
|
||||
}
|
||||
|
||||
public void testAddingProfilesXmlReadingProblemsToProjectTag() throws Exception {
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<project>" +
|
||||
" <modelVersion>4.0.0</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</project>");
|
||||
createProfilesXml("<<<");
|
||||
|
||||
myProjectsManager.forceUpdateAllProjectsOrFindAllAvailablePomFiles();
|
||||
waitForReadingCompletion();
|
||||
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<<error descr=\"'profiles.xml' has syntax errors\">project</error>>" +
|
||||
" <modelVersion>4.0.0</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</project>");
|
||||
checkHighlighting();
|
||||
}
|
||||
|
||||
public void testAddingStructureReadingProblemsToParentTag() throws Exception {
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<project>" +
|
||||
" <modelVersion>4.0.0</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <parent>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" </parent>" +
|
||||
"</project>");
|
||||
myProjectsManager.forceUpdateAllProjectsOrFindAllAvailablePomFiles();
|
||||
waitForReadingCompletion();
|
||||
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<project>" +
|
||||
" <modelVersion>4.0.0</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <<error descr=\"Self-inheritance found\">parent</error>>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" </parent>" +
|
||||
"</project>");
|
||||
checkHighlighting();
|
||||
}
|
||||
|
||||
public void testAddingParentReadingProblemsToParentTag() throws Exception {
|
||||
createModulePom("parent",
|
||||
"<groupId>test</groupId>" +
|
||||
"<artifactId>parent</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<<<");
|
||||
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<project>" +
|
||||
" <modelVersion>4.0.0</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <parent>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>parent</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <relativePath>parent/pom.xml</relativePath>" +
|
||||
" </parent>" +
|
||||
"</project>");
|
||||
myProjectsManager.forceUpdateAllProjectsOrFindAllAvailablePomFiles();
|
||||
waitForReadingCompletion();
|
||||
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<project>" +
|
||||
" <modelVersion>4.0.0</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <<error descr=\"Parent 'test:parent:1' has problems\">parent</error>>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>parent</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <relativePath>parent/pom.xml</relativePath>" +
|
||||
" </parent>" +
|
||||
"</project>");
|
||||
checkHighlighting();
|
||||
}
|
||||
|
||||
public void testDoNotAddReadingSyntaxProblemsToProjectTag() throws Exception {
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<project>" +
|
||||
" <modelVersion>4.0.0</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <" +
|
||||
"</project>");
|
||||
myProjectsManager.forceUpdateAllProjectsOrFindAllAvailablePomFiles();
|
||||
waitForReadingCompletion();
|
||||
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<project>" +
|
||||
" <modelVersion>4.0.0</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <" +
|
||||
"<error><</error>/project>");
|
||||
checkHighlighting();
|
||||
}
|
||||
|
||||
public void testDoNotAddDependencyAndModuleProblemsToProjectTag() throws Exception {
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<project>" +
|
||||
" <modelVersion>4.0.0</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <modules>" +
|
||||
" <module>foo</module>" +
|
||||
" </modules>" +
|
||||
" <dependencies>" +
|
||||
" <dependency>" +
|
||||
" <groupId>xxx</groupId>" +
|
||||
" <artifactId>yyy</artifactId>" +
|
||||
" <version>xxx</version>" +
|
||||
" </dependency>" +
|
||||
" </dependencies>" +
|
||||
"</project>");
|
||||
myProjectsManager.forceUpdateAllProjectsOrFindAllAvailablePomFiles();
|
||||
waitForReadingCompletion();
|
||||
|
||||
VfsUtil.saveText(myProjectPom,
|
||||
"<project>" +
|
||||
" <modelVersion>4.0.0</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <modules>" +
|
||||
" <module><error>foo</error></module>" +
|
||||
" </modules>" +
|
||||
" <dependencies>" +
|
||||
" <dependency>" +
|
||||
" <groupId><error>xxx</error></groupId>" +
|
||||
" <artifactId><error>yyy</error></artifactId>" +
|
||||
" <version><error>xxx</error></version>" +
|
||||
" </dependency>" +
|
||||
" </dependencies>" +
|
||||
"</project>");
|
||||
checkHighlighting();
|
||||
}
|
||||
}
|
||||
|
||||
+21
-13
@@ -260,13 +260,17 @@ public class MavenParentCompletionAndResolutionTest extends MavenDomWithIndicesT
|
||||
public void testHighlightingUnknownValues() throws Throwable {
|
||||
importProject("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<version>1</version>");
|
||||
|
||||
"<parent>" +
|
||||
" <groupId><error>xxx</error></groupId>" +
|
||||
" <artifactId><error>xxx</error></artifactId>" +
|
||||
" <version><error>xxx</error></version>" +
|
||||
"</parent>");
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
|
||||
"<parent>" +
|
||||
" <groupId><error>xxx</error></groupId>" +
|
||||
" <artifactId><error>xxx</error></artifactId>" +
|
||||
" <version><error>xxx</error></version>" +
|
||||
"</parent>");
|
||||
|
||||
checkHighlighting();
|
||||
}
|
||||
@@ -310,14 +314,18 @@ public class MavenParentCompletionAndResolutionTest extends MavenDomWithIndicesT
|
||||
public void testHighlightingInvalidRelativePath() throws Throwable {
|
||||
importProject("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
"<version>1</version>");
|
||||
|
||||
"<parent>" +
|
||||
" <groupId>junit</groupId>" +
|
||||
" <artifactId>junit</artifactId>" +
|
||||
" <version>4.0</version>" +
|
||||
" <relativePath><error>parent/pom.xml</error></relativePath>" +
|
||||
"</parent>");
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
|
||||
"<parent>" +
|
||||
" <groupId>junit</groupId>" +
|
||||
" <artifactId>junit</artifactId>" +
|
||||
" <version>4.0</version>" +
|
||||
" <relativePath><error>parent/pom.xml</error></relativePath>" +
|
||||
"</parent>");
|
||||
|
||||
checkHighlighting();
|
||||
}
|
||||
|
||||
@@ -241,9 +241,7 @@ public class MavenTypingTest extends MavenDomTestCase {
|
||||
}
|
||||
|
||||
private void assertTypeResultInRegularFile(VirtualFile f, char c, String expected) throws IOException {
|
||||
myCodeInsightFixture.configureFromExistingVirtualFile(f);
|
||||
myCodeInsightFixture.type(c);
|
||||
|
||||
type(f, c);
|
||||
myCodeInsightFixture.checkResult(expected);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -13,9 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.util.io.ReadOnlyAttributeUtil;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.indices.MavenCustomRepositoryHelper;
|
||||
import org.jetbrains.idea.maven.project.MavenArtifact;
|
||||
import org.jetbrains.idea.maven.project.MavenId;
|
||||
+2
-1
@@ -13,10 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.idea.maven.MavenTestCase;
|
||||
import org.jetbrains.idea.maven.execution.MavenExecutor;
|
||||
import org.jetbrains.idea.maven.execution.MavenExternalExecutor;
|
||||
import org.jetbrains.idea.maven.execution.MavenRunnerParameters;
|
||||
+2
-1
@@ -13,8 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.indices.MavenCustomRepositoryHelper;
|
||||
|
||||
import java.io.File;
|
||||
+2
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.*;
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.indices.MavenCustomRepositoryHelper;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
|
||||
+3
-2
@@ -13,9 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -128,7 +129,7 @@ public class DependenciesManagementTest extends MavenImportingTestCase {
|
||||
|
||||
// maven doesn't expect imported pom to be in the reactor,
|
||||
// when it is fixed, let us know
|
||||
assertTrue(myProjectsManager.findProject(project).hasErrors());
|
||||
assertTrue(myProjectsManager.findProject(project).hasReadingProblems());
|
||||
assertModuleLibDeps("project");
|
||||
|
||||
// actually should be
|
||||
+2
-1
@@ -13,11 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.openapi.roots.CompilerModuleExtension;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.importing.MavenDefaultModifiableModelsProvider;
|
||||
import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
|
||||
import org.jetbrains.idea.maven.indices.MavenCustomRepositoryHelper;
|
||||
+2
-1
@@ -2,10 +2,11 @@
|
||||
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.importing.MavenDefaultModifiableModelsProvider;
|
||||
import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
|
||||
import org.jetbrains.plugins.groovy.config.GroovyConfigUtils;
|
||||
+2
-1
@@ -13,9 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
+43
-19
@@ -13,8 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.indices.MavenCustomRepositoryHelper;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectProblem;
|
||||
@@ -28,7 +29,7 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
assertModules("project");
|
||||
|
||||
MavenProject root = getRootProjects().get(0);
|
||||
assertProblems(root, "Pom file has syntax errors.");
|
||||
assertProblems(root, "'pom.xml' has syntax errors");
|
||||
}
|
||||
|
||||
public void testUndefinedPropertyInHeader() throws Exception {
|
||||
@@ -55,7 +56,7 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
assertModules("project");
|
||||
|
||||
MavenProject root = getRootProjects().get(0);
|
||||
assertProblems(root, "Parent 'test:parent:1' not found.");
|
||||
assertProblems(root, "Parent 'test:parent:1' not found");
|
||||
}
|
||||
|
||||
public void testUnresolvedParentForInvalidProject() throws Exception {
|
||||
@@ -76,9 +77,9 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
|
||||
MavenProject root = getRootProjects().get(0);
|
||||
assertProblems(root,
|
||||
"Parent 'test:parent:1' not found.",
|
||||
"Parent 'test:parent:1' not found",
|
||||
"Packaging 'jar' is invalid. Aggregator projects require 'pom' as packaging.",
|
||||
"Missing module: 'foo'.");
|
||||
"Module 'foo' not found");
|
||||
}
|
||||
|
||||
public void testMissingModules() throws Exception {
|
||||
@@ -94,7 +95,7 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
assertModules("project");
|
||||
|
||||
MavenProject root = getRootProjects().get(0);
|
||||
assertProblems(root, "Missing module: 'foo'.");
|
||||
assertProblems(root, "Module 'foo' not found");
|
||||
}
|
||||
|
||||
public void testInvalidProjectModel() throws Exception {
|
||||
@@ -137,8 +138,7 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
MavenProject root = getRootProjects().get(0);
|
||||
assertProblems(root);
|
||||
|
||||
assertProblems(getModules(root).get(0),
|
||||
"Pom file has syntax errors.");
|
||||
assertProblems(getModules(root).get(0), "'pom.xml' has syntax errors");
|
||||
}
|
||||
|
||||
public void testSeveratInvalidModulesAndWithSameName() throws Exception {
|
||||
@@ -316,10 +316,10 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
|
||||
assertProblems(root);
|
||||
assertProblems(getModules(root).get(0),
|
||||
"Unresolved dependency: 'xxx:xxx:jar:1'.",
|
||||
"Unresolved dependency: 'yyy:yyy:jar:2'.");
|
||||
"Unresolved dependency: 'xxx:xxx:jar:1'",
|
||||
"Unresolved dependency: 'yyy:yyy:jar:2'");
|
||||
assertProblems(getModules(root).get(1),
|
||||
"Unresolved dependency: 'zzz:zzz:jar:3'.");
|
||||
"Unresolved dependency: 'zzz:zzz:jar:3'");
|
||||
}
|
||||
|
||||
public void testUnresolvedPomTypeDependency() throws Exception {
|
||||
@@ -341,7 +341,7 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
assertModuleLibDeps("project");
|
||||
|
||||
MavenProject root = getRootProjects().get(0);
|
||||
assertProblems(root, "Unresolved dependency: 'xxx:yyy:pom:4.0'.");
|
||||
assertProblems(root, "Unresolved dependency: 'xxx:yyy:pom:4.0'");
|
||||
}
|
||||
|
||||
public void testDoesNotReportInterModuleDependenciesAsUnresolved() throws Exception {
|
||||
@@ -454,7 +454,7 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
"</build>");
|
||||
|
||||
MavenProject root = getRootProjects().get(0);
|
||||
assertProblems(root, "Unresolved build extension: 'xxx:yyy:1'.");
|
||||
assertProblems(root, "Unresolved build extension: 'xxx:yyy:1'");
|
||||
}
|
||||
|
||||
public void testUnresolvedExtensionsAfterResolve() throws Exception {
|
||||
@@ -474,7 +474,7 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
|
||||
resolveDependenciesAndImport();
|
||||
MavenProject root = getRootProjects().get(0);
|
||||
assertProblems(root, "Unresolved build extension: 'xxx:yyy:1'.");
|
||||
assertProblems(root, "Unresolved build extension: 'xxx:yyy:1'");
|
||||
}
|
||||
|
||||
public void testDoesNotReportExtensionsThatWereNotTriedToBeResolved() throws Exception {
|
||||
@@ -575,10 +575,10 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
|
||||
assertProblems(root);
|
||||
assertProblems(getModules(root).get(0),
|
||||
"Unresolved build extension: 'xxx:xxx:1'.");
|
||||
"Unresolved build extension: 'xxx:xxx:1'");
|
||||
assertProblems(getModules(root).get(1),
|
||||
"Unresolved build extension: 'yyy:yyy:1'.",
|
||||
"Unresolved build extension: 'zzz:zzz:1'.");
|
||||
"Unresolved build extension: 'yyy:yyy:1'",
|
||||
"Unresolved build extension: 'zzz:zzz:1'");
|
||||
}
|
||||
|
||||
public void testUnresolvedPlugins() throws Exception {
|
||||
@@ -597,7 +597,7 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
"</build>");
|
||||
|
||||
MavenProject root = getRootProjects().get(0);
|
||||
assertProblems(root, "Unresolved plugin: 'xxx:yyy:1'.");
|
||||
assertProblems(root, "Unresolved plugin: 'xxx:yyy:1'");
|
||||
}
|
||||
|
||||
public void testDoNotReportResolvedPlugins() throws Exception {
|
||||
@@ -641,7 +641,31 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
assertModules("project");
|
||||
|
||||
MavenProject root = getRootProjects().get(0);
|
||||
assertProblems(root, "Unresolved plugin: 'xxx:yyy:1'.");
|
||||
assertProblems(root, "Unresolved plugin: 'xxx:yyy:1'");
|
||||
}
|
||||
|
||||
public void testInvalidSettingsXml() throws Exception {
|
||||
updateSettingsXml("<localRepo<<");
|
||||
|
||||
importProject("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>");
|
||||
assertModules("project");
|
||||
|
||||
MavenProject root = getRootProjects().get(0);
|
||||
assertProblems(root, "'settings.xml' has syntax errors");
|
||||
}
|
||||
|
||||
public void testInvalidProfilesXml() throws Exception {
|
||||
createProfilesXml("<prof<<");
|
||||
|
||||
importProject("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>");
|
||||
assertModules("project");
|
||||
|
||||
MavenProject root = getRootProjects().get(0);
|
||||
assertProblems(root, "'profiles.xml' has syntax errors");
|
||||
}
|
||||
|
||||
private void assertProblems(MavenProject project, String... expectedProblems) {
|
||||
+2
-1
@@ -13,11 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.idea.Bombed;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
|
||||
import java.util.Collections;
|
||||
+2
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
import com.intellij.openapi.roots.ModuleRootListener;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.importing.MavenDefaultModifiableModelsProvider;
|
||||
import org.jetbrains.idea.maven.indices.MavenCustomRepositoryHelper;
|
||||
|
||||
+2
-1
@@ -13,11 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
+2
-1
@@ -13,10 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
+2
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.compiler.impl.javaCompiler.javac.JavacSettings;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.roots.LanguageLevelModuleExtension;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
|
||||
import java.io.File;
|
||||
+2
-1
@@ -13,13 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven;
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
+49
-13
@@ -26,6 +26,7 @@ import org.jetbrains.idea.maven.embedder.MavenEmbedderFactory;
|
||||
import org.jetbrains.idea.maven.utils.MavenUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -51,7 +52,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>");
|
||||
|
||||
assertTrue(readProject(myProjectPom, new NullProjectLocator()).isValid);
|
||||
assertProblems(readProject(myProjectPom, new NullProjectLocator()));
|
||||
|
||||
createProjectPom("<foo>" +
|
||||
"</bar>" +
|
||||
@@ -61,7 +62,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
"<version>1</version>");
|
||||
|
||||
MavenProjectReaderResult result = readProject(myProjectPom, new NullProjectLocator());
|
||||
assertFalse(result.isValid);
|
||||
assertProblems(result, "'pom.xml' has syntax errors");
|
||||
org.apache.maven.project.MavenProject p = result.nativeMavenProject;
|
||||
|
||||
assertEquals(new File(myProjectPom.getPath()), p.getFile());
|
||||
@@ -85,7 +86,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
" <version>1</version>" +
|
||||
"</parent>");
|
||||
|
||||
assertFalse(readProject(module, new NullProjectLocator()).isValid);
|
||||
assertProblems(readProject(module, new NullProjectLocator()), "Parent 'test:parent:1' has problems");
|
||||
}
|
||||
|
||||
public void testProjectWithAbsentParentXmlIsValid() throws Exception {
|
||||
@@ -94,7 +95,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
" <artifactId>parent</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</parent>");
|
||||
assertTrue(readProject(myProjectPom, new NullProjectLocator()).isValid);
|
||||
assertProblems(readProject(myProjectPom, new NullProjectLocator()));
|
||||
}
|
||||
|
||||
public void testProjectWithSelfParentIsInvalid() throws Exception {
|
||||
@@ -106,7 +107,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<packaging>pom</packaging>");
|
||||
assertFalse(readProject(myProjectPom, new NullProjectLocator()).isValid);
|
||||
assertProblems(readProject(myProjectPom, new NullProjectLocator()), "Self-inheritance found");
|
||||
}
|
||||
|
||||
public void testInvalidProfilesXml() throws Exception {
|
||||
@@ -116,7 +117,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
|
||||
createProfilesXml("<profiles");
|
||||
|
||||
assertFalse(readProject(myProjectPom, new NullProjectLocator()).isValid);
|
||||
assertProblems(readProject(myProjectPom, new NullProjectLocator()), "'profiles.xml' has syntax errors");
|
||||
}
|
||||
|
||||
public void testInvalidSettingsXml() throws Exception {
|
||||
@@ -126,7 +127,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
|
||||
updateSettingsXml("<settings");
|
||||
|
||||
assertFalse(readProject(myProjectPom, new NullProjectLocator()).isValid);
|
||||
assertProblems(readProject(myProjectPom, new NullProjectLocator()), "'settings.xml' has syntax errors");
|
||||
}
|
||||
|
||||
public void testInvalidXmlWithNotClosedTag() throws Exception {
|
||||
@@ -136,7 +137,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
"<name>foo</name>");
|
||||
|
||||
MavenProjectReaderResult readResult = readProject(myProjectPom, new NullProjectLocator());
|
||||
assertFalse(readResult.isValid);
|
||||
assertProblems(readResult, "'pom.xml' has syntax errors");
|
||||
org.apache.maven.project.MavenProject p = readResult.nativeMavenProject;
|
||||
|
||||
assertEquals(new File(myProjectPom.getPath()), p.getFile());
|
||||
@@ -157,7 +158,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
"<name>foo</name>");
|
||||
|
||||
MavenProjectReaderResult readResult = readProject(myProjectPom, new NullProjectLocator());
|
||||
assertFalse(readResult.isValid);
|
||||
assertProblems(readResult, "'pom.xml' has syntax errors");
|
||||
org.apache.maven.project.MavenProject p = readResult.nativeMavenProject;
|
||||
|
||||
assertEquals(new File(myProjectPom.getPath()), p.getFile());
|
||||
@@ -431,7 +432,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
assertEquals("value12", p.getPackaging());
|
||||
}
|
||||
|
||||
public void testHandlingRecursionProprietly() throws Exception {
|
||||
public void testHandlingRecursiveProperties() throws Exception {
|
||||
createProjectPom("<properties>" +
|
||||
" <prop1>${prop2}</prop1>" +
|
||||
" <prop2>${prop1}</prop2>" +
|
||||
@@ -445,7 +446,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
assertEquals("${prop2}", p.getPackaging());
|
||||
}
|
||||
|
||||
public void testHandlingRecursionProprietlyAndDoNotForgetCoClearRecursionGuard() throws Exception {
|
||||
public void testHandlingRecursionProprielyAndDoNotForgetCoClearRecursionGuard() throws Exception {
|
||||
File repositoryPath = new File(myDir, "repository");
|
||||
setRepositoryPath(repositoryPath.getPath());
|
||||
|
||||
@@ -477,7 +478,34 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
"</parent>");
|
||||
|
||||
MavenProjectReaderResult readResult = readProject(child, new NullProjectLocator());
|
||||
assertTrue(readResult.isValid);
|
||||
assertProblems(readResult);
|
||||
}
|
||||
|
||||
public void testDoNotGoIntoRecursionWhenTryingToResolveParentInDefaultPath() throws Exception {
|
||||
VirtualFile child = createModulePom("child",
|
||||
"<groupId>test</groupId>" +
|
||||
"<artifactId>child</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
|
||||
"<parent>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>parent</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</parent>");
|
||||
|
||||
createProjectPom("<groupId>test</groupId>" +
|
||||
"<artifactId>subChild</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
|
||||
"<parent>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>child</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <relativePath>child/pom.xml</relativePath>" +
|
||||
"</parent>");
|
||||
|
||||
MavenProjectReaderResult readResult = readProject(child, new NullProjectLocator());
|
||||
assertProblems(readResult);
|
||||
}
|
||||
|
||||
public void testExpandingSystemAndEnvProperties() throws Exception {
|
||||
@@ -1098,7 +1126,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
|
||||
private org.apache.maven.project.MavenProject readProject(VirtualFile file, String... profiles) {
|
||||
MavenProjectReaderResult readResult = readProject(file, new NullProjectLocator(), profiles);
|
||||
assertTrue(readResult.isValid);
|
||||
assertProblems(readResult);
|
||||
return readResult.nativeMavenProject;
|
||||
}
|
||||
|
||||
@@ -1138,6 +1166,14 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
assertOrderedElementsAreEqual(resource.getExcludes(), excludes);
|
||||
}
|
||||
|
||||
private void assertProblems(MavenProjectReaderResult readerResult, String... expectedProblems) {
|
||||
List<String> actualProblems = new ArrayList<String>();
|
||||
for (MavenProjectProblem each : readerResult.readingProblems) {
|
||||
actualProblems.add(each.getDescription());
|
||||
}
|
||||
assertOrderedElementsAreEqual(actualProblems, expectedProblems);
|
||||
}
|
||||
|
||||
private static class NullProjectLocator implements MavenProjectReaderProjectLocator {
|
||||
public VirtualFile findProjectFile(MavenId coordinates) {
|
||||
return null;
|
||||
|
||||
+1
-1
@@ -605,7 +605,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase {
|
||||
|
||||
assertEquals("resolved: project ", listener.log);
|
||||
assertNotNull(nativeProject[0]);
|
||||
assertTrue(project.hasErrors());
|
||||
assertTrue(project.hasReadingProblems());
|
||||
}
|
||||
|
||||
public void testDoNotUpdateChildAfterParentWasResolved() throws Exception {
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
@@ -32,13 +33,17 @@ import com.intellij.spellchecker.state.StateLoader;
|
||||
import com.intellij.spellchecker.util.SPFileUtil;
|
||||
import com.intellij.spellchecker.util.Strings;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.sun.net.ssl.internal.ssl.SSLEngineImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
public class SpellCheckerManager {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.spellchecker.SpellCheckerManager");
|
||||
|
||||
private static final int MAX_SUGGESTIONS_THRESHOLD = 5;
|
||||
private static final int MAX_METRICS = 1;
|
||||
|
||||
@@ -87,7 +92,13 @@ public class SpellCheckerManager {
|
||||
for (BundledDictionaryProvider provider : Extensions.getExtensions(BundledDictionaryProvider.EP_NAME)) {
|
||||
for (String dictionary : provider.getBundledDictionaries()) {
|
||||
if (this.settings == null || !this.settings.getBundledDisabledDictionariesPaths().contains(dictionary)) {
|
||||
loaders.add(new StreamLoader(provider.getClass().getResourceAsStream(dictionary)));
|
||||
final Class<? extends BundledDictionaryProvider> loaderClass = provider.getClass();
|
||||
final InputStream stream = loaderClass.getResourceAsStream(dictionary);
|
||||
if (stream != null){
|
||||
loaders.add(new StreamLoader(stream));
|
||||
} else {
|
||||
LOG.warn("Couldn't load dictionary '" + dictionary + "' for loader '" + loaderClass + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user