Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
irengrig
2010-02-23 22:02:07 +03:00
355 changed files with 3631 additions and 1604 deletions
@@ -28,6 +28,7 @@ public class RegExpBraceMatcher implements PairedBraceMatcher {
new BracePair(RegExpTT.SET_OPTIONS, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.NON_CAPT_GROUP, RegExpTT.GROUP_END, true),
new BracePair(RegExpTT.POS_LOOKAHEAD, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.NEG_LOOKAHEAD, RegExpTT.GROUP_END, true),
new BracePair(RegExpTT.POS_LOOKBEHIND, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.NEG_LOOKBEHIND, RegExpTT.GROUP_END, true),
new BracePair(RegExpTT.PYTHON_NAMED_GROUP, RegExpTT.GROUP_END, true),
new BracePair(RegExpTT.CLASS_BEGIN, RegExpTT.CLASS_END, false), new BracePair(RegExpTT.LBRACE, RegExpTT.RBRACE, false),
new BracePair(RegExpTT.QUOTE_BEGIN, RegExpTT.QUOTE_END, false),};
}
@@ -22,4 +22,5 @@ public interface RegExpLanguageHost {
boolean characterNeedsEscaping(char c);
boolean supportsPerl5EmbeddedComments();
boolean supportsPossessiveQuantifiers();
boolean supportsPythonNamedGroups();
}
@@ -97,6 +97,9 @@ public interface RegExpTT {
IElementType OPTIONS_ON = new RegExpElementType("OPTIONS_ON");
IElementType OPTIONS_OFF = new RegExpElementType("OPTIONS_OFF");
// (?P<name>...
IElementType PYTHON_NAMED_GROUP = new RegExpElementType("PYTHON_NAMED_GROUP");
TokenSet KEYWORDS = TokenSet.create(DOT, STAR, QUEST, PLUS);
TokenSet CHARACTERS = TokenSet.create(CHARACTER,
@@ -123,7 +126,8 @@ public interface RegExpTT {
POS_LOOKAHEAD,
NEG_LOOKAHEAD,
POS_LOOKBEHIND,
NEG_LOOKBEHIND);
NEG_LOOKBEHIND,
PYTHON_NAMED_GROUP);
TokenSet BOUNDARIES = TokenSet.create(BOUNDARY, CARET, DOLLAR);
}
@@ -1,21 +1,20 @@
/* The following code was generated by JFlex 1.4.1 on 18.12.09 20:27 */
/* The following code was generated by JFlex 1.4.3 on 21.02.10 20:59 */
/* It's an automatically generated code. Do not modify it. */
package org.intellij.lang.regexp;
import com.intellij.lexer.FlexLexer;
import com.intellij.psi.StringEscapesTokenTypes;
import com.intellij.psi.tree.IElementType;
import java.util.LinkedList;
import com.intellij.psi.StringEscapesTokenTypes;
// IDEADEV-11055
@SuppressWarnings({ "ALL", "SameParameterValue", "WeakerAccess", "SameReturnValue", "RedundantThrows", "UnusedDeclaration", "UnusedDeclaration" })
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.1
* on 18.12.09 20:27 from the specification file
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
* on 21.02.10 20:59 from the specification file
* <tt>C:/JetBrains/IDEA/tools/lexer/../../community/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex</tt>
*/
class _RegExLexer implements FlexLexer {
@@ -23,86 +22,96 @@ class _RegExLexer implements FlexLexer {
private static final int ZZ_BUFFERSIZE = 16384;
/** lexical states */
public static final int CLASS1 = 3;
public static final int PROP = 5;
public static final int EMBRACED = 2;
public static final int QUOTED = 1;
public static final int CLASS1 = 6;
public static final int PROP = 10;
public static final int EMBRACED = 4;
public static final int QUOTED = 2;
public static final int YYINITIAL = 0;
public static final int COMMENT = 7;
public static final int OPTIONS = 6;
public static final int CLASS2 = 4;
public static final int COMMENT = 14;
public static final int OPTIONS = 12;
public static final int CLASS2 = 8;
/**
* ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
* ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
* at the beginning of a line
* l is of the form l = 2*k, k a non negative integer
*/
private static final int ZZ_LEXSTATE[] = {
0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7
};
/**
* Translates characters to character classes
*/
private static final String ZZ_CMAP_PACKED =
"\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\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"+
"\27\43\1\0\37\43\1\0\u013f\43\31\0\162\43\4\0\14\43\16\0"+
"\5\43\11\0\1\43\213\0\1\43\13\0\1\43\1\0\3\43\1\0"+
"\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\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\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\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\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\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\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\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\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\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\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\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\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\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"+
"\1\43\3\0\3\43\1\0\7\43\3\0\4\43\2\0\6\43\4\0"+
"\15\43\5\0\3\43\1\0\7\43\164\0\1\43\15\0\1\43\202\0"+
"\1\43\4\0\1\43\2\0\12\43\1\0\1\43\3\0\5\43\6\0"+
"\1\43\1\0\1\43\1\0\1\43\1\0\4\43\1\0\3\43\1\0"+
"\7\43\3\0\3\43\5\0\5\43\u0ebb\0\2\43\52\0\5\43\5\0"+
"\2\43\4\0\126\43\6\0\3\43\1\0\132\43\1\0\4\43\5\0"+
"\50\43\4\0\136\43\21\0\30\43\70\0\20\43\u0200\0\u19b6\43\112\0"+
"\u51a6\43\132\0\u048d\43\u0773\0\u2ba4\43\u215c\0\u012e\43\2\0\73\43\225\0"+
"\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\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";
"\10\0\2\52\1\13\1\0\1\52\1\61\22\0\1\45\1\56\1\0"+
"\1\60\1\15\1\0\1\51\1\0\1\4\1\5\1\17\1\20\1\50"+
"\1\43\1\3\1\0\1\2\7\42\2\1\1\53\1\0\1\57\1\55"+
"\1\54\1\16\1\0\1\24\1\24\1\30\1\27\1\37\1\35\1\25"+
"\1\44\1\32\6\44\1\34\1\36\1\44\1\26\3\44\1\26\1\26"+
"\1\44\1\25\1\10\1\12\1\11\1\14\1\46\1\0\1\23\1\24"+
"\1\31\1\27\1\23\1\23\2\44\1\32\4\44\1\22\1\44\1\33"+
"\1\44\1\22\1\26\1\22\1\41\1\44\1\26\1\40\1\44\1\25"+
"\1\6\1\21\1\7\54\0\1\44\12\0\1\44\4\0\1\44\5\0"+
"\27\44\1\0\37\44\1\0\u013f\44\31\0\162\44\4\0\14\44\16\0"+
"\5\44\11\0\1\44\213\0\1\44\13\0\1\44\1\0\3\44\1\0"+
"\1\44\1\0\24\44\1\0\54\44\1\0\46\44\1\0\5\44\4\0"+
"\202\44\10\0\105\44\1\0\46\44\2\0\2\44\6\0\20\44\41\0"+
"\46\44\2\0\1\44\7\0\47\44\110\0\33\44\5\0\3\44\56\0"+
"\32\44\5\0\13\44\25\0\12\47\4\0\2\44\1\0\143\44\1\0"+
"\1\44\17\0\2\44\7\0\2\44\12\47\3\44\2\0\1\44\20\0"+
"\1\44\1\0\36\44\35\0\3\44\60\0\46\44\13\0\1\44\u0152\0"+
"\66\44\3\0\1\44\22\0\1\44\7\0\12\44\4\0\12\47\25\0"+
"\10\44\2\0\2\44\2\0\26\44\1\0\7\44\1\0\1\44\3\0"+
"\4\44\3\0\1\44\36\0\2\44\1\0\3\44\4\0\12\47\2\44"+
"\23\0\6\44\4\0\2\44\2\0\26\44\1\0\7\44\1\0\2\44"+
"\1\0\2\44\1\0\2\44\37\0\4\44\1\0\1\44\7\0\12\47"+
"\2\0\3\44\20\0\11\44\1\0\3\44\1\0\26\44\1\0\7\44"+
"\1\0\2\44\1\0\5\44\3\0\1\44\22\0\1\44\17\0\2\44"+
"\4\0\12\47\25\0\10\44\2\0\2\44\2\0\26\44\1\0\7\44"+
"\1\0\2\44\1\0\5\44\3\0\1\44\36\0\2\44\1\0\3\44"+
"\4\0\12\47\1\0\1\44\21\0\1\44\1\0\6\44\3\0\3\44"+
"\1\0\4\44\3\0\2\44\1\0\1\44\1\0\2\44\3\0\2\44"+
"\3\0\3\44\3\0\10\44\1\0\3\44\55\0\11\47\25\0\10\44"+
"\1\0\3\44\1\0\27\44\1\0\12\44\1\0\5\44\46\0\2\44"+
"\4\0\12\47\25\0\10\44\1\0\3\44\1\0\27\44\1\0\12\44"+
"\1\0\5\44\3\0\1\44\40\0\1\44\1\0\2\44\4\0\12\47"+
"\25\0\10\44\1\0\3\44\1\0\27\44\1\0\20\44\46\0\2\44"+
"\4\0\12\47\25\0\22\44\3\0\30\44\1\0\11\44\1\0\1\44"+
"\2\0\7\44\72\0\60\44\1\0\2\44\14\0\7\44\11\0\12\47"+
"\47\0\2\44\1\0\1\44\2\0\2\44\1\0\1\44\2\0\1\44"+
"\6\0\4\44\1\0\7\44\1\0\3\44\1\0\1\44\1\0\1\44"+
"\2\0\2\44\1\0\4\44\1\0\2\44\11\0\1\44\2\0\5\44"+
"\1\0\1\44\11\0\12\47\2\0\2\44\42\0\1\44\37\0\12\47"+
"\26\0\10\44\1\0\42\44\35\0\4\44\164\0\42\44\1\0\5\44"+
"\1\0\2\44\25\0\12\47\6\0\6\44\112\0\46\44\12\0\51\44"+
"\7\0\132\44\5\0\104\44\5\0\122\44\6\0\7\44\1\0\77\44"+
"\1\0\1\44\1\0\4\44\2\0\7\44\1\0\1\44\1\0\4\44"+
"\2\0\47\44\1\0\1\44\1\0\4\44\2\0\37\44\1\0\1\44"+
"\1\0\4\44\2\0\7\44\1\0\1\44\1\0\4\44\2\0\7\44"+
"\1\0\7\44\1\0\27\44\1\0\37\44\1\0\1\44\1\0\4\44"+
"\2\0\7\44\1\0\47\44\1\0\23\44\16\0\11\47\56\0\125\44"+
"\14\0\u026c\44\2\0\10\44\12\0\32\44\5\0\113\44\25\0\15\44"+
"\1\0\4\44\16\0\22\44\16\0\22\44\16\0\15\44\1\0\3\44"+
"\17\0\64\44\43\0\1\44\4\0\1\44\3\0\12\47\46\0\12\47"+
"\6\0\130\44\10\0\51\44\127\0\35\44\51\0\12\47\36\44\2\0"+
"\5\44\u038b\0\154\44\224\0\234\44\4\0\132\44\6\0\26\44\2\0"+
"\6\44\2\0\46\44\2\0\6\44\2\0\10\44\1\0\1\44\1\0"+
"\1\44\1\0\1\44\1\0\37\44\2\0\65\44\1\0\7\44\1\0"+
"\1\44\3\0\3\44\1\0\7\44\3\0\4\44\2\0\6\44\4\0"+
"\15\44\5\0\3\44\1\0\7\44\164\0\1\44\15\0\1\44\202\0"+
"\1\44\4\0\1\44\2\0\12\44\1\0\1\44\3\0\5\44\6\0"+
"\1\44\1\0\1\44\1\0\1\44\1\0\4\44\1\0\3\44\1\0"+
"\7\44\3\0\3\44\5\0\5\44\u0ebb\0\2\44\52\0\5\44\5\0"+
"\2\44\4\0\126\44\6\0\3\44\1\0\132\44\1\0\4\44\5\0"+
"\50\44\4\0\136\44\21\0\30\44\70\0\20\44\u0200\0\u19b6\44\112\0"+
"\u51a6\44\132\0\u048d\44\u0773\0\u2ba4\44\u215c\0\u012e\44\2\0\73\44\225\0"+
"\7\44\14\0\5\44\5\0\1\44\1\0\12\44\1\0\15\44\1\0"+
"\5\44\1\0\1\44\1\0\2\44\1\0\2\44\1\0\154\44\41\0"+
"\u016b\44\22\0\100\44\2\0\66\44\50\0\14\44\164\0\5\44\1\0"+
"\207\44\23\0\12\47\7\0\32\44\6\0\32\44\13\0\131\44\3\0"+
"\6\44\2\0\6\44\2\0\6\44\2\0\3\44\43\0";
/**
* Translates characters to character classes
@@ -122,12 +131,12 @@ class _RegExLexer implements FlexLexer {
"\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\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";
"\1\62\1\63\1\0\1\64\1\65\1\66\2\0\1\67"+
"\1\70\2\60\2\61\1\0\1\71\1\72\1\0\1\67"+
"\1\60\1\73\2\61\1\74\1\75\1\67\3\61\1\76";
private static int [] zzUnpackAction() {
int [] result = new int[89];
int [] result = new int[92];
int offset = 0;
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
return result;
@@ -152,21 +161,21 @@ class _RegExLexer implements FlexLexer {
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
private static final String ZZ_ROWMAP_PACKED_0 =
"\0\0\0\61\0\142\0\223\0\304\0\365\0\u0126\0\u0157"+
"\0\u0188\0\u0188\0\u01b9\0\u0188\0\u0188\0\u01ea\0\u021b\0\u0188"+
"\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188"+
"\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\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\0\0\62\0\144\0\226\0\310\0\372\0\u012c\0\u015e"+
"\0\u0190\0\u0190\0\u01c2\0\u0190\0\u0190\0\u01f4\0\u0226\0\u0190"+
"\0\u0190\0\u0190\0\u0190\0\u0190\0\u0190\0\u0190\0\u0190\0\u0190"+
"\0\u0190\0\u0258\0\u0190\0\u028a\0\u0190\0\u02bc\0\u0190\0\u0190"+
"\0\u0190\0\u0190\0\u0190\0\u02ee\0\u0190\0\u0190\0\u01f4\0\u0190"+
"\0\u0190\0\u0320\0\u0352\0\u0190\0\u0190\0\u0384\0\u0190\0\u0190"+
"\0\u03b6\0\u03e8\0\u0190\0\u0190\0\u0190\0\u0190\0\u0190\0\u0190"+
"\0\u041a\0\u0190\0\u0190\0\u0190\0\u044c\0\u047e\0\u0190\0\u0190"+
"\0\u04b0\0\u0190\0\u0190\0\u0190\0\u04e2\0\u0514\0\u0546\0\u0190"+
"\0\u0578\0\u05aa\0\u05dc\0\u060e\0\u0640\0\u0190\0\u0190\0\u0672"+
"\0\u06a4\0\u0190\0\u0190\0\u06d6\0\u0708\0\u0190\0\u0190\0\u0190"+
"\0\u073a\0\u076c\0\u0190\0\u0190";
private static int [] zzUnpackRowMap() {
int [] result = new int[89];
int [] result = new int[92];
int offset = 0;
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
return result;
@@ -191,40 +200,41 @@ 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\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"+
"\21\11\1\27\1\11\1\30\4\11\1\20\5\11\1\31"+
"\1\20\12\11\1\32\1\0\46\11\1\33\2\34\4\33"+
"\1\35\12\33\20\36\1\34\1\33\1\36\2\33\1\34"+
"\1\37\11\33\11\40\1\41\1\40\1\0\46\40\6\11"+
"\1\15\1\11\1\16\1\42\1\17\1\43\1\21\26\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\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\45\1\47\1\45\1\17\47\45\5\50\1\51\14\50"+
"\20\52\1\50\1\53\1\52\6\50\1\54\6\50\13\10"+
"\1\55\45\10\1\55\100\0\1\56\54\0\1\57\50\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";
"\2\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\37\0\1\77"+
"\23\0\2\34\37\0\1\34\4\0\1\34\13\0\2\36"+
"\17\0\21\36\1\0\1\36\1\0\2\36\63\0\1\100"+
"\32\0\20\52\2\0\1\52\37\0\20\53\2\0\1\53"+
"\51\0\1\101\16\0\2\102\1\103\1\104\1\105\1\106"+
"\2\0\2\61\37\0\1\61\21\0\1\107\37\0\1\107"+
"\17\0\62\110\1\111\2\112\20\111\2\112\2\111\3\112"+
"\3\111\1\112\1\111\1\112\2\111\1\112\17\111\1\113"+
"\2\114\20\113\2\114\2\113\3\114\3\113\1\114\1\113"+
"\1\114\2\113\1\114\17\113\57\0\1\115\57\0\1\116"+
"\1\117\3\0\5\120\1\0\54\120\2\0\1\121\37\0"+
"\1\121\17\0\63\122\2\123\20\122\2\123\2\122\3\123"+
"\3\122\1\123\1\122\1\123\2\122\1\123\17\122\63\124"+
"\2\125\20\124\2\125\2\124\3\125\3\124\1\125\1\124"+
"\1\125\2\124\1\125\17\124\22\0\20\115\2\0\1\115"+
"\7\0\1\126\5\0\5\120\1\127\54\120\2\0\1\130"+
"\37\0\1\130\17\0\63\131\2\132\20\131\2\132\2\131"+
"\3\132\3\131\1\132\1\131\1\132\2\131\1\132\17\131"+
"\63\133\2\134\20\133\2\134\2\133\3\134\3\133\1\134"+
"\1\133\1\134\2\133\1\134\17\133";
private static int [] zzUnpackTrans() {
int [] result = new int[1813];
int [] result = new int[1950];
int offset = 0;
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
return result;
@@ -265,15 +275,15 @@ class _RegExLexer implements FlexLexer {
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
private static final String ZZ_ATTRIBUTE_PACKED_0 =
"\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"+
"\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";
"\6\0\2\1\2\11\1\1\2\11\2\1\12\11\1\1"+
"\1\11\1\1\1\11\1\1\5\11\1\1\2\11\1\1"+
"\2\11\2\1\2\11\1\1\2\11\2\1\6\11\1\1"+
"\3\11\2\1\2\11\1\0\3\11\2\0\1\1\1\11"+
"\4\1\1\0\2\11\1\0\1\1\2\11\2\1\3\11"+
"\2\1\2\11";
private static int [] zzUnpackAttribute() {
int [] result = new int[89];
int [] result = new int[92];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;
@@ -570,8 +580,6 @@ class _RegExLexer implements FlexLexer {
int [] zzTransL = ZZ_TRANS;
int [] zzRowMapL = ZZ_ROWMAP;
int [] zzAttrL = ZZ_ATTRIBUTE;
int zzPushbackPosL = zzPushbackPos = -1;
boolean zzWasPushback;
while (true) {
zzMarkedPosL = zzMarkedPos;
@@ -580,9 +588,8 @@ class _RegExLexer implements FlexLexer {
zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
zzState = zzLexicalState;
zzState = ZZ_LEXSTATE[zzLexicalState];
zzWasPushback = false;
zzForAction: {
while (true) {
@@ -597,14 +604,12 @@ class _RegExLexer implements FlexLexer {
// store back cached positions
zzCurrentPos = zzCurrentPosL;
zzMarkedPos = zzMarkedPosL;
zzPushbackPos = zzPushbackPosL;
boolean eof = zzRefill();
// get translated positions and possibly new buffer
zzCurrentPosL = zzCurrentPos;
zzMarkedPosL = zzMarkedPos;
zzBufferL = zzBuffer;
zzEndReadL = zzEndRead;
zzPushbackPosL = zzPushbackPos;
if (eof) {
zzInput = YYEOF;
break zzForAction;
@@ -618,11 +623,7 @@ class _RegExLexer implements FlexLexer {
zzState = zzNext;
int zzAttributes = zzAttrL[zzState];
if ( (zzAttributes & 2) == 2 )
zzPushbackPosL = zzCurrentPosL;
if ( (zzAttributes & 1) == 1 ) {
zzWasPushback = (zzAttributes & 4) == 4;
zzAction = zzState;
zzMarkedPosL = zzCurrentPosL;
if ( (zzAttributes & 8) == 8 ) break zzForAction;
@@ -633,246 +634,250 @@ class _RegExLexer implements FlexLexer {
// store back cached position
zzMarkedPos = zzMarkedPosL;
if (zzWasPushback)
zzMarkedPos = zzPushbackPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
case 7:
{ if (yystate() != CLASS2) yypushstate(EMBRACED); return RegExpTT.LBRACE;
}
case 62: break;
case 63: break;
case 6:
{ return RegExpTT.GROUP_END;
}
case 63: break;
case 64: break;
case 36:
// lookahead expression with fixed base length
zzMarkedPos = zzStartRead + 1;
{ yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN;
}
case 64: break;
case 65: break;
case 14:
{ return RegExpTT.STAR;
}
case 65: break;
case 66: break;
case 40:
{ return RegExpTT.ESC_CHARACTER;
}
case 66: break;
case 67: break;
case 28:
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.ESC_CHARACTER;
}
case 67: break;
case 68: break;
case 41:
{ return commentMode ? RegExpTT.CHARACTER : RegExpTT.REDUNDANT_ESCAPE;
}
case 68: break;
case 69: break;
case 37:
{ return RegExpTT.REDUNDANT_ESCAPE;
}
case 69: break;
case 70: break;
case 24:
{ return RegExpTT.COMMA;
}
case 70: break;
case 71: break;
case 57:
{ return RegExpTT.POS_LOOKBEHIND;
}
case 71: break;
case 72: break;
case 39:
{ return RegExpTT.BAD_OCT_VALUE;
}
case 72: break;
case 73: break;
case 10:
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CTRL_CHARACTER;
}
case 73: break;
case 74: break;
case 30:
{ yypopstate(); yypushstate(EMBRACED); return RegExpTT.LBRACE;
}
case 74: break;
case 75: break;
case 49:
{ return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
}
case 75: break;
case 76: break;
case 58:
{ return RegExpTT.NEG_LOOKBEHIND;
}
case 76: break;
case 61:
case 77: break;
case 62:
{ return RegExpTT.UNICODE_CHAR;
}
case 77: break;
case 78: break;
case 56:
{ if (xmlSchemaMode) { yypushback(1); return RegExpTT.CHAR_CLASS; } else return RegExpTT.CTRL;
}
case 78: break;
case 79: break;
case 35:
{ yybegin(OPTIONS); return RegExpTT.SET_OPTIONS;
}
case 79: break;
case 80: break;
case 12:
{ return RegExpTT.DOLLAR;
}
case 80: break;
case 81: break;
case 50:
{ yypopstate(); return RegExpTT.QUOTE_END;
}
case 81: break;
case 82: break;
case 53:
{ return RegExpTT.POS_LOOKAHEAD;
}
case 82: break;
case 83: break;
case 22:
{ yypopstate(); return RegExpTT.RBRACE;
}
case 83: break;
case 84: break;
case 3:
{ return RegExpTT.CHARACTER;
}
case 84: break;
case 85: break;
case 54:
{ return RegExpTT.NEG_LOOKAHEAD;
}
case 85: break;
case 86: break;
case 42:
{ return RegExpTT.ESC_CTRL_CHARACTER;
}
case 86: break;
case 87: break;
case 23:
{ return RegExpTT.NAME;
}
case 87: break;
case 88: break;
case 51:
{ return RegExpTT.ANDAND;
}
case 88: break;
case 89: break;
case 13:
{ return RegExpTT.QUEST;
}
case 89: break;
case 90: break;
case 44:
{ return RegExpTT.CHAR_CLASS;
}
case 90: break;
case 91: break;
case 17:
{ return RegExpTT.MINUS;
}
case 91: break;
case 60:
case 92: break;
case 61:
{ return RegExpTT.COMMENT;
}
case 92: break;
case 93: break;
case 38:
{ return yystate() != CLASS2 ? RegExpTT.BACKREF : RegExpTT.ESC_CHARACTER;
}
case 93: break;
case 94: break;
case 16:
{ return RegExpTT.UNION;
}
case 94: break;
case 95: break;
case 60:
{ return RegExpTT.PYTHON_NAMED_GROUP;
}
case 96: break;
case 45:
{ if (xmlSchemaMode) return RegExpTT.CHAR_CLASS; else return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
}
case 95: break;
case 97: break;
case 55:
{ return RegExpTT.OCT_CHAR;
}
case 96: break;
case 98: break;
case 4:
{ return RegExpTT.DOT;
}
case 97: break;
case 99: break;
case 32:
{ yybegin(YYINITIAL); return RegExpTT.GROUP_END;
}
case 98: break;
case 100: break;
case 21:
{ return RegExpTT.NUMBER;
}
case 99: break;
case 101: break;
case 46:
{ yypushstate(PROP); return RegExpTT.PROPERTY;
}
case 100: break;
case 102: break;
case 18:
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER;
}
case 101: break;
case 103: break;
case 33:
{ handleOptions(); return RegExpTT.OPTIONS_OFF;
}
case 102: break;
case 104: break;
case 34:
{ yybegin(YYINITIAL); return RegExpTT.COLON;
}
case 103: break;
case 105: break;
case 25:
{ assert false : yytext();
}
case 104: break;
case 106: break;
case 27:
{ yypopstate(); return RegExpTT.CLASS_END;
}
case 105: break;
case 107: break;
case 11:
{ return RegExpTT.CARET;
}
case 106: break;
case 108: break;
case 1:
{ handleOptions(); return RegExpTT.OPTIONS_ON;
}
case 107: break;
case 109: break;
case 29:
{ yypopstate(); yypushback(1);
}
case 108: break;
case 110: break;
case 43:
{ return yystate() != CLASS2 ? RegExpTT.BOUNDARY : RegExpTT.ESC_CHARACTER;
}
case 109: break;
case 111: break;
case 19:
{ if (commentMode) { yypushstate(COMMENT); return RegExpTT.COMMENT; } else return RegExpTT.CHARACTER;
}
case 110: break;
case 112: break;
case 59:
{ return RegExpTT.HEX_CHAR;
}
case 111: break;
case 113: break;
case 5:
{ return RegExpTT.GROUP_BEGIN;
}
case 112: break;
case 114: break;
case 8:
{ yypushstate(CLASS2); return RegExpTT.CLASS_BEGIN;
}
case 113: break;
case 115: break;
case 52:
{ return RegExpTT.NON_CAPT_GROUP;
}
case 114: break;
case 116: break;
case 9:
{ return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
}
case 115: break;
case 117: break;
case 48:
{ return RegExpTT.BAD_HEX_VALUE;
}
case 116: break;
case 118: break;
case 2:
{ yypopstate(); return RegExpTT.COMMENT;
}
case 117: break;
case 119: break;
case 47:
{ yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN;
}
case 118: break;
case 120: break;
case 26:
{ yybegin(CLASS2); return RegExpTT.CHARACTER;
}
case 119: break;
case 121: break;
case 15:
{ return RegExpTT.PLUS;
}
case 120: break;
case 122: break;
case 20:
{ if (allowDanglingMetacharacters) {
yypopstate(); yypushback(1);
@@ -880,11 +885,11 @@ class _RegExLexer implements FlexLexer {
return RegExpTT.BAD_CHARACTER;
}
}
case 121: break;
case 123: break;
case 31:
{ yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER;
}
case 122: break;
case 124: break;
default:
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
zzAtEOF = true;
@@ -22,4 +22,6 @@ public interface RegExpGroup extends RegExpAtom {
@Nullable
RegExpPattern getPattern();
boolean isPythonNamedGroup();
}
@@ -41,4 +41,8 @@ public class RegExpGroupImpl extends RegExpElementImpl implements RegExpGroup {
final ASTNode node = getNode().findChildByType(RegExpElementTypes.PATTERN);
return node != null ? (RegExpPattern)node.getPsi() : null;
}
public boolean isPythonNamedGroup() {
return getNode().findChildByType(RegExpTT.PYTHON_NAMED_GROUP) != null;
}
}
@@ -205,6 +205,7 @@ HEX_CHAR=[0-9a-fA-F]
"(?<=" { return RegExpTT.POS_LOOKBEHIND; }
"(?<!" { return RegExpTT.NEG_LOOKBEHIND; }
"(?#" [^)]+ ")" { return RegExpTT.COMMENT; }
"(?P<" [:letter:]* ">" { return RegExpTT.PYTHON_NAMED_GROUP; }
"(?" { yybegin(OPTIONS); return RegExpTT.SET_OPTIONS; }
}
@@ -30,12 +30,13 @@ import org.intellij.lang.regexp.RegExpLanguageHost;
import org.intellij.lang.regexp.RegExpTT;
import org.intellij.lang.regexp.psi.*;
import org.intellij.lang.regexp.psi.impl.RegExpPropertyImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public final class RegExpAnnotator extends RegExpElementVisitor implements Annotator {
private AnnotationHolder myHolder;
public void annotate(PsiElement psiElement, AnnotationHolder holder) {
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) {
assert myHolder == null : "unsupported concurrent annotator invocation";
try {
myHolder = holder;
@@ -159,6 +160,12 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot
}
}
}
if (group.isPythonNamedGroup()) {
RegExpLanguageHost host = findRegExpHost(group);
if (host == null || !host.supportsPythonNamedGroups()) {
myHolder.createErrorAnnotation(group, "This named group syntax is not supported");
}
}
}
@Override
@@ -57,7 +57,7 @@ public class MemberInfoExternalizer {
else if (tag == FIELD_INFO_TAG) {
return new FieldInfo(in);
}
LOG.assertTrue(false, "Unknown member info");
LOG.error("Unknown member info");
return null;
}
@@ -69,7 +69,7 @@ public class MemberInfoExternalizer {
else if (tag == MEMBER_REFERENCE_INFO_TAG) {
return new MemberReferenceInfo(in);
}
LOG.assertTrue(false, "Unknown declaration info tag: " + tag);
LOG.error("Unknown declaration info tag: " + tag);
return null;
}
@@ -108,7 +108,7 @@ public class MemberInfoExternalizer {
else if (tag == ENUM_CONSTANT_VALUE_TAG) {
return new EnumConstantValue(in);
}
LOG.assertTrue(false, "Unknown constant value type " + tag);
LOG.error("Unknown constant value type " + tag);
return null;
}
@@ -120,7 +120,7 @@ public class MemberInfoExternalizer {
out.writeByte(FIELD_INFO_TAG);
}
else {
LOG.assertTrue(false, "Unknown member info");
LOG.error("Unknown member info");
}
info.save(out);
}
@@ -161,7 +161,7 @@ public class MethodInfo extends MemberInfo {
String descriptor = symbolTable.getSymbol(getDescriptor());
int endIndex = descriptor.indexOf(')');
if (endIndex <= 0) {
LOG.assertTrue(false, "Corrupted method descriptor: "+descriptor);
LOG.error("Corrupted method descriptor: " + descriptor);
}
myParameterDescriptors = parseParameterDescriptors(descriptor.substring(1, endIndex));
}
@@ -71,7 +71,7 @@ public class OneProjectItemCompileScope extends UserDataHolderBase implements Co
public Module[] getAffectedModules() {
final Module module = ModuleUtil.findModuleForFile(myFile, myProject);
if (module == null) {
LOG.assertTrue(false, "Module is null for file " + myFile.getPresentableUrl());
LOG.error("Module is null for file " + myFile.getPresentableUrl());
return Module.EMPTY_ARRAY;
}
return new Module[] {module};
@@ -47,7 +47,7 @@ public class CacheUtils {
String descriptor = symbolTable.getSymbol(methodDeclarationId.getDescriptor());
int endIndex = descriptor.indexOf(')');
if (endIndex <= 0) {
LOG.assertTrue(false, "Corrupted method descriptor: "+descriptor);
LOG.error("Corrupted method descriptor: " + descriptor);
}
return parseSignature(descriptor.substring(1, endIndex));
}
@@ -97,7 +97,7 @@ public class Dependency {
String descriptorStr = symbolTable.getSymbol(descriptor);
int endIndex = descriptorStr.indexOf(')');
if (endIndex <= 0) {
LOG.assertTrue(false, "Corrupted method descriptor: "+ descriptorStr);
LOG.error("Corrupted method descriptor: " + descriptorStr);
}
myParameterDescriptors = parseParameterDescriptors(descriptorStr.substring(1, endIndex));
}
@@ -39,7 +39,7 @@ public class DependencyCacheNavigator {
int superQName = myCache.getSuperQualifiedName(classQName);
if (classQName == superQName) {
LOG.assertTrue(false, "Superclass qualified name is the same as class' name: " + classQName);
LOG.error("Superclass qualified name is the same as class' name: " + classQName);
return;
}
@@ -70,7 +70,7 @@ public class DependencyCacheNavigator {
public void walkSubClasses(int fromClassQName, ClassInfoProcessor processor) throws CacheCorruptedException {
for (int subQName : myCache.getSubclasses(fromClassQName)) {
if (fromClassQName == subQName) {
LOG.assertTrue(false, "Subclass qualified name is the same as class' name: " + fromClassQName);
LOG.error("Subclass qualified name is the same as class' name: " + fromClassQName);
return;
}
if (subQName != Cache.UNKNOWN) {
@@ -245,7 +245,7 @@ public abstract class DebugProcessImpl implements DebugProcess {
@SuppressWarnings({"HardCodedStringLiteral"})
protected void commitVM(VirtualMachine vm) {
if (!isInInitialState()) {
LOG.assertTrue(false, "State is invalid " + myState.get());
LOG.error("State is invalid " + myState.get());
}
DebuggerManagerThreadImpl.assertIsManagerThread();
myPositionManager = createPositionManager();
@@ -95,7 +95,7 @@ public class JVMNameUtil {
buffer.append(getPrimitiveSignature(psiType.getCanonicalText()));
}
else {
LOG.assertTrue(false, "unknown type " + type.getCanonicalText());
LOG.error("unknown type " + type.getCanonicalText());
}
}
@@ -215,12 +215,12 @@ public class PositionManagerImpl implements PositionManager {
if(PsiUtil.isLocalOrAnonymousClass(psiClass)) {
final PsiClass parentNonLocal = JVMNameUtil.getTopLevelParentClass(psiClass);
if(parentNonLocal == null) {
LOG.assertTrue(false, "Local or anonymous class has no non-local parent");
LOG.error("Local or anonymous class has no non-local parent");
return Collections.emptyList();
}
final String parentClassName = JVMNameUtil.getNonAnonymousClassName(parentNonLocal);
if(parentClassName == null) {
LOG.assertTrue(false, "The name of a parent of a local (anonymous) class is null");
LOG.error("The name of a parent of a local (anonymous) class is null");
return Collections.emptyList();
}
final List<ReferenceType> outers = myDebugProcess.getVirtualMachineProxy().classesByName(parentClassName);
@@ -102,7 +102,7 @@ public abstract class SuspendContextImpl implements SuspendContext {
private void assertNotResumed() {
if (myIsResumed) {
if (myDebugProcess.isAttached()) {
LOG.assertTrue(false, "Cannot access SuspendContext. SuspendContext is resumed.");
LOG.error("Cannot access SuspendContext. SuspendContext is resumed.");
}
}
}
@@ -120,7 +120,7 @@ public class SuspendManagerImpl implements SuspendManager {
if (thread != null) { // check that thread is suspended at the moment
try {
if (!thread.isSuspended()) {
LOG.assertTrue(false, "Context thread must be suspended");
LOG.error("Context thread must be suspended");
}
}
catch (ObjectCollectedException ignored) {}
@@ -86,7 +86,7 @@ public class CodeFragmentEvaluator extends BlockStatementEvaluator{
return vm.mirrorOf((String)value);
}
else {
LOG.assertTrue(false, "unknown default initializer type " + value.getClass().getName());
LOG.error("unknown default initializer type " + value.getClass().getName());
return null;
}
}
@@ -1026,13 +1026,13 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
final PsiType castType = expression.getCastType().getType();
final PsiType operandType = operandExpr.getType();
if (!TypeConversionUtil.areTypesConvertible(operandType, castType)) {
if (castType != null && operandType != null && !TypeConversionUtil.areTypesConvertible(operandType, castType)) {
throw new EvaluateRuntimeException(
new EvaluateException(JavaErrorMessages.message("inconvertible.type.cast", HighlightUtil.formatType(operandType), HighlightUtil.formatType(castType)))
);
}
final boolean shouldPerformBoxingConversion = TypeConversionUtil.boxingConversionApplicable(castType, operandType);
final boolean shouldPerformBoxingConversion = castType != null && operandType != null && TypeConversionUtil.boxingConversionApplicable(castType, operandType);
final boolean castingToPrimitive = castType instanceof PsiPrimitiveType;
if (shouldPerformBoxingConversion && castingToPrimitive) {
operandEvaluator = new UnBoxingEvaluator(operandEvaluator);
@@ -17,6 +17,7 @@ package com.intellij.debugger.engine.requests;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.ArrayUtil;
import com.sun.jdi.Method;
import com.sun.jdi.ObjectCollectedException;
import com.sun.jdi.Value;
@@ -56,7 +57,7 @@ public class MethodReturnValueWatcher {
try {
if (myReturnValueMethod == null) {
//noinspection HardCodedStringLiteral
myReturnValueMethod = MethodExitEvent.class.getDeclaredMethod("returnValue", new Class[0]);
myReturnValueMethod = MethodExitEvent.class.getDeclaredMethod("returnValue", ArrayUtil.EMPTY_CLASS_ARRAY);
}
myLastMethodReturnValue = (Value)myReturnValueMethod.invoke(event);
}
@@ -129,7 +129,7 @@ public abstract class InvokeThread<E extends PrioritizedTask> {
}
if(getCurrentRequest() != current) {
LOG.assertTrue(false, "Expected " + current + " instead of " + getCurrentRequest());
LOG.error("Expected " + current + " instead of " + getCurrentRequest());
}
processEvent(myEvents.get());
@@ -18,6 +18,7 @@ import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.openapi.project.Project;
import com.intellij.ui.*;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Icons;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.tree.TreeUtil;
@@ -42,7 +43,7 @@ public class BreakpointTree extends CheckboxTree {
private boolean myGroupByClasses = true;
private boolean myFlattenPackages = true;
private final NodeAppender[] myAppenders = new NodeAppender[] {
private final NodeAppender[] myAppenders = {
new BreakpointToMethodAppender(),
new BreakpointToClassAppender(),
new BreakpointToPackageAppender(),
@@ -186,12 +187,13 @@ public class BreakpointTree extends CheckboxTree {
public BreakpointDescriptor(Breakpoint breakpoint) {
myBreakpoint = breakpoint;
}
public @NotNull Breakpoint getBreakpoint() {
@NotNull
public Breakpoint getBreakpoint() {
return myBreakpoint;
}
protected Icon getDisplayIcon() {
return (myBreakpoint instanceof BreakpointWithHighlighter)?
return myBreakpoint instanceof BreakpointWithHighlighter ?
myBreakpoint.ENABLED? ((BreakpointWithHighlighter)myBreakpoint).getSetIcon() : ((BreakpointWithHighlighter)myBreakpoint).getDisabledIcon() :
myBreakpoint.getIcon();
}
@@ -224,7 +226,7 @@ public class BreakpointTree extends CheckboxTree {
private static final class MethodDescriptor extends TreeDescriptor {
private final String myClassName;
private final String myMethodName;
private final @NotNull String myPackageName;
@NotNull private final String myPackageName;
public MethodDescriptor(String methodName, String className, @NotNull String packageName) {
myClassName = className;
@@ -232,7 +234,8 @@ public class BreakpointTree extends CheckboxTree {
myPackageName = packageName;
}
public @NotNull String getPackageName() {
@NotNull
public String getPackageName() {
return myPackageName;
}
@@ -267,26 +270,27 @@ public class BreakpointTree extends CheckboxTree {
}
public int hashCode() {
int result;
result = myClassName.hashCode();
int result = myClassName.hashCode();
result = 29 * result + myMethodName.hashCode();
return result;
}
}
private static final class ClassDescriptor extends TreeDescriptor {
private final @NotNull String myClassName;
private final @NotNull String myPackageName;
@NotNull private final String myClassName;
@NotNull private final String myPackageName;
public ClassDescriptor(@NotNull String className, @NotNull String packageName) {
myClassName = className;
myPackageName = packageName.length() == 0? DEFAULT_PACKAGE_NAME : packageName;
}
@NotNull
public String getPackageName() {
return myPackageName;
}
@NotNull
public String getClassName() {
return myClassName;
}
@@ -383,7 +387,7 @@ public class BreakpointTree extends CheckboxTree {
myBreakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
myNodeUpdateListener = new BreakpointManagerListener() {
public void breakpointsChanged() {
BreakpointTree.this.repaint();
repaint();
}
};
myBreakpointManager.addBreakpointManagerListener(myNodeUpdateListener);
@@ -554,7 +558,8 @@ public class BreakpointTree extends CheckboxTree {
}
}
private @NotNull CheckedTreeNode createNode(final TreeDescriptor descriptor) {
@NotNull
private CheckedTreeNode createNode(final TreeDescriptor descriptor) {
final CheckedTreeNode node = new CheckedTreeNode(descriptor);
myDescriptorToNodeMap.put(descriptor, node);
return node;
@@ -615,7 +620,7 @@ public class BreakpointTree extends CheckboxTree {
}
}
private static abstract class NodeAppender {
private abstract static class NodeAppender {
public abstract CheckedTreeNode append(CheckedTreeNode node);
}
@@ -676,10 +681,10 @@ public class BreakpointTree extends CheckboxTree {
final Breakpoint breakpoint = ((BreakpointDescriptor)descriptor).getBreakpoint();
final String packageName;
if (breakpoint instanceof ExceptionBreakpoint) {
packageName = ((ExceptionBreakpoint)breakpoint).getPackageName();
packageName = breakpoint.getPackageName();
}
else if (breakpoint instanceof BreakpointWithHighlighter) {
packageName = ((BreakpointWithHighlighter)breakpoint).getPackageName();
packageName = breakpoint.getPackageName();
}
else {
packageName = null;
@@ -768,7 +773,6 @@ public class BreakpointTree extends CheckboxTree {
private static class TreeStateSnapshot {
private final Object[] myExpandedUserObjects;
private final Object[] mySelectedUserObjects;
private static final Object[][] EMPTY = new Object[0][];
public TreeStateSnapshot(BreakpointTree tree) {
final List<TreePath> expandedPaths = TreeUtil.collectExpandedPaths(tree);
@@ -776,9 +780,9 @@ public class BreakpointTree extends CheckboxTree {
mySelectedUserObjects =getUserObjects(tree.getSelectionPaths());
}
private Object[] getUserObjects(final TreePath[] treePaths) {
private static Object[] getUserObjects(final TreePath[] treePaths) {
if (treePaths == null) {
return EMPTY;
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
Object[] userObjects = new Object[treePaths.length];
int index = 0;
@@ -790,18 +794,18 @@ public class BreakpointTree extends CheckboxTree {
public void restore(BreakpointTree tree) {
final List<TreePath> pathsToExpand = getPaths(tree, myExpandedUserObjects);
if (pathsToExpand.size() > 0) {
if (!pathsToExpand.isEmpty()) {
TreeUtil.restoreExpandedPaths(tree, pathsToExpand);
}
final List<TreePath> pathsToSelect = getPaths(tree, mySelectedUserObjects);
if (pathsToSelect.size() > 0) {
if (!pathsToSelect.isEmpty()) {
tree.getSelectionModel().clearSelection();
tree.setSelectionPaths(pathsToSelect.toArray(new TreePath[pathsToSelect.size()]));
}
}
private List<TreePath> getPaths(BreakpointTree tree, final Object[] userObjects) {
private static List<TreePath> getPaths(BreakpointTree tree, final Object[] userObjects) {
final List<TreePath> paths = new ArrayList<TreePath>(userObjects.length);
for (Object descriptor : userObjects) {
final CheckedTreeNode node = tree.myDescriptorToNodeMap.get(descriptor);
@@ -266,7 +266,7 @@ public class DebuggerTreeNodeExpression {
return ((ValueDescriptorImpl)node.getDescriptor()).getTreeEvaluation(node, context);
}
else {
LOG.assertTrue(false, node.getDescriptor() != null ? node.getDescriptor().getClass().getName() : "null");
LOG.error(node.getDescriptor() != null ? node.getDescriptor().getClass().getName() : "null");
return null;
}
}
@@ -138,7 +138,7 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
final DescriptorData<FieldDescriptorImpl> descriptorData;
if (objRef == null ) {
if (!field.isStatic()) {
LOG.assertTrue(false, "Object reference is null for non-static field: " + field);
LOG.error("Object reference is null for non-static field: " + field);
}
descriptorData = new StaticFieldData(field);
}
@@ -102,10 +102,8 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
if (modules.length > 0) {
for (Module module : modules) {
if (module == null) {
LOG.assertTrue(
false,
"RunConfiguration should not return null modules. Configuration=" + runConfiguration.getName() + "; class=" + runConfiguration.getClass().getName()
);
LOG.error("RunConfiguration should not return null modules. Configuration=" + runConfiguration.getName() + "; class=" +
runConfiguration.getClass().getName());
}
}
scope = compilerManager.createModulesCompileScope(modules, true);
@@ -19,6 +19,7 @@ import com.intellij.rt.execution.junit.segments.Packet;
import com.intellij.rt.execution.junit.segments.PacketProcessor;
import com.intellij.rt.execution.junit.segments.SegmentedStream;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.containers.HashMap;
import java.io.BufferedReader;
import java.io.IOException;
@@ -108,7 +109,9 @@ public class SegmentedInputStream extends InputStream {
}
public int available() throws IOException {
final HashMap<String, String> map = new HashMap<String, String>();
map.keySet();
while (mySourceStream.ready()) {
while(myStartupPassed < SegmentedStream.STARTUP_MESSAGE.length()) {
@@ -131,8 +134,8 @@ public class SegmentedInputStream extends InputStream {
final Integer packetRead = readControlSequence();
if (packetRead != null) {
// push back quoted slash
mySourceStream.pushBack(b);
mySourceStream.pushBack(packetRead);
mySourceStream.pushBack(b);
return 1;
}
}
@@ -32,6 +32,7 @@ import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.RawCommandLineEditor;
import com.intellij.util.ArrayUtil;
import javax.swing.*;
import java.awt.*;
@@ -152,7 +153,7 @@ public class CommonJavaParameters extends JPanel {
final List<String> macros = new ArrayList<String>(PathMacros.getInstance().getUserMacroNames());
macros.add("MODULE_DIR");
final JList list = new JList(macros.toArray(new String[macros.size()]));
final JList list = new JList(ArrayUtil.toStringArray(macros));
final JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list).setItemChoosenCallback(new Runnable() {
public void run() {
final Object value = list.getSelectedValue();
@@ -112,7 +112,7 @@ public class LibrariesConfigurationManager implements Disposable {
}
private static String[] getSplitted(@Nullable final String s) {
if (StringUtil.isEmptyOrSpaces(s)) return new String[0];
if (StringUtil.isEmptyOrSpaces(s)) return ArrayUtil.EMPTY_STRING_ARRAY;
return ArrayUtil.toStringArray(StringUtil.split(s, STRING_DELIMITER));
}
@@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.ex.FileChooserDialogImpl;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfo;
@@ -63,6 +64,7 @@ public class OpenProjectAction extends AnAction implements DumbAware {
}
}
descriptor.putUserData(FileChooserDialogImpl.PREFER_LAST_OVER_TO_SELECT, Boolean.TRUE);
final VirtualFile[] files = FileChooser.chooseFiles(project, descriptor, userHomeDir);
if (files.length == 0 || files[0] == null) return;
@@ -34,7 +34,6 @@ import com.intellij.openapi.projectRoots.JavaSdk;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.CompilerProjectExtension;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
import com.intellij.openapi.roots.ui.configuration.ModulesConfigurator;
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
@@ -132,11 +131,13 @@ public class NewProjectUtil {
// ensure the dialog is shown after all startup activities are done
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (newProject.isDisposed()) return;
if (need2OpenProjectStructure) {
ModulesConfigurator.showDialog(newProject, null, null, true);
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
if (newProject.isDisposed()) return;
final ToolWindow toolWindow = ToolWindowManager.getInstance(newProject).getToolWindow(ToolWindowId.PROJECT_VIEW);
if (toolWindow != null) {
toolWindow.activate(null);
@@ -18,8 +18,6 @@ package com.intellij.openapi.roots.ui.configuration;
import com.intellij.ide.DataManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.module.Module;
@@ -530,7 +528,7 @@ public class ClasspathPanel extends JPanel {
}
}
}
LOG.assertTrue(false, "Unknown library " + item);
LOG.error("Unknown library " + item);
return null;
}
@@ -549,7 +547,7 @@ public class ClasspathPanel extends JPanel {
}
}
}
LOG.assertTrue(false, "Unknown library " + item);
LOG.error("Unknown library " + item);
return null;
}
@@ -886,7 +884,7 @@ public class ClasspathPanel extends JPanel {
if (columnIndex == ITEM_COLUMN) {
return item;
}
LOG.assertTrue(false, "Incorrect column index: " + columnIndex);
LOG.error("Incorrect column index: " + columnIndex);
return null;
}
@@ -56,7 +56,7 @@ public class LibraryChooserElement {
myLibrary = library;
myOrderEntry = orderEntry;
if (myLibrary == null && myOrderEntry == null) {
LOG.assertTrue(false, "Both library and order entry are null");
LOG.error("Both library and order entry are null");
myName = ProjectBundle.message("module.libraries.unknown.item");
}
else {
@@ -44,6 +44,7 @@ import com.intellij.ui.treeStructure.SimpleNode;
import com.intellij.ui.treeStructure.SimpleTreeBuilder;
import com.intellij.ui.treeStructure.SimpleTreeStructure;
import com.intellij.ui.treeStructure.WeightBasedComparator;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NonNls;
@@ -288,7 +289,7 @@ public class LayoutTreeComponent implements DnDTarget, Disposable {
myBuilder.addSubtreeToUpdate(treeNode, new Runnable() {
public void run() {
List<PackagingElementNode<?>> nodes = myTree.findNodes(toSelect);
myBuilder.select(nodes.toArray(new Object[nodes.size()]), null);
myBuilder.select(ArrayUtil.toObjectArray(nodes), null);
}
});
}
@@ -27,6 +27,7 @@ import com.intellij.packaging.elements.PackagingElement;
import com.intellij.packaging.ui.ArtifactEditorContext;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.treeStructure.SimpleNode;
import com.intellij.util.ArrayUtil;
import com.intellij.util.SmartList;
import com.intellij.util.StringBuilderSpinAllocator;
import org.jetbrains.annotations.NotNull;
@@ -81,7 +82,7 @@ public class PackagingElementNode<E extends PackagingElement<?>> extends Artifac
@Override
public Object[] getEqualityObjects() {
return myPackagingElements.toArray(new Object[myPackagingElements.size()]);
return ArrayUtil.toObjectArray(myPackagingElements);
}
@Override
@@ -222,12 +222,11 @@ public class JavaCompletionContributor extends CompletionContributor {
final Object[] variants = reference.getVariants();
if (variants == null) {
LOG.assertTrue(false, "Reference=" + reference);
LOG.error("Reference=" + reference);
}
for (Object completion : variants) {
if (completion == null) {
LOG.assertTrue(false, "Position=" + insertedElement + "\n;Reference=" + reference + "\n;variants=" + Arrays.toString(
variants));
LOG.error("Position=" + insertedElement + "\n;Reference=" + reference + "\n;variants=" + Arrays.toString(variants));
}
if (completion instanceof LookupElement) {
result.addElement((LookupElement)completion);
@@ -26,6 +26,7 @@ import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.*;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.Nullable;
@@ -238,7 +239,7 @@ public class CopyPasteReferenceProcessor implements CopyPastePostProcessor {
}
if (array.isEmpty()) return;
Object[] selectedObjects = array.toArray(new Object[array.size()]);
Object[] selectedObjects = ArrayUtil.toObjectArray(array);
Arrays.sort(
selectedObjects,
new Comparator<Object>() {
@@ -516,15 +516,8 @@ public class JavaFoldingBuilder extends FoldingBuilderEx implements DumbAware {
final String baseClassName = quick ? anonymousClass.getBaseClassReference().getReferenceName() : anonymousClass.getBaseClassType().resolve().getName();
if (lastLineEnd >= seq.length() || firstLineStart >= seq.length() || firstLineStart < 0) {
LOG.assertTrue(false, "llE=" +
lastLineEnd +
"; fLS=" +
firstLineStart +
"; len=" +
seq.length() +
"rE=" +
rangeEnd +
"; class=" + baseClassName);
LOG.error("llE=" + lastLineEnd + "; fLS=" + firstLineStart + "; len=" + seq.length() + "rE=" + rangeEnd + "; class=" +
baseClassName);
}
final String params = StringUtil.join(method.getParameterList().getParameters(), new Function<PsiParameter, String>() {
@@ -117,7 +117,7 @@ public class HighlightSuppressedWarningsHandler extends HighlightUsagesHandlerBa
final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
tool.initialize(context);
((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted();
pass.doInspectInBatch(managerEx, new InspectionProfileEntry[]{tool}, false);
pass.doInspectInBatch(managerEx, Collections.<InspectionProfileEntry>singletonList(tool), false);
for (HighlightInfo info : pass.getInfos()) {
final PsiElement element = CollectHighlightsUtil.findCommonParent(myFile, info.startOffset, info.endOffset);
if (element != null) {
@@ -46,7 +46,7 @@ public class JavaImplementationTextSelectioner implements ImplementationTextSele
return element.getTextRange().getStartOffset();
}
else {
LOG.assertTrue(false, "Element should not be null: " + parent.getText());
LOG.error("Element should not be null: " + parent.getText());
return parent.getTextRange().getStartOffset();
}
}
@@ -236,9 +236,9 @@ public class JavaDocInfoGenerator {
if (file instanceof PsiJavaFile) {
String packageName = ((PsiJavaFile)file).getPackageName();
if (packageName.length() > 0) {
buffer.append("<font size=\"-1\"><b>");
buffer.append("<small><b>");
buffer.append(packageName);
buffer.append("</b></font>");
buffer.append("</b></small>");
//buffer.append("<br>");
}
}
@@ -359,8 +359,19 @@ public class JavaDocInfoGenerator {
return null;
}
@Nullable
private static PsiDocComment getDocComment(final PsiDocCommentOwner docOwner) {
return ((PsiDocCommentOwner)docOwner.getNavigationElement()).getDocComment();
PsiDocComment comment = ((PsiDocCommentOwner)docOwner.getNavigationElement()).getDocComment();
if (comment == null) { //check for non-normalized fields
final PsiModifierList modifierList = docOwner.getModifierList();
if (modifierList != null) {
final PsiElement parent = modifierList.getParent();
if (parent instanceof PsiDocCommentOwner) {
return ((PsiDocCommentOwner)parent.getNavigationElement()).getDocComment();
}
}
}
return comment;
}
private void generateFieldJavaDoc(@NonNls StringBuilder buffer, PsiField field) {
@@ -370,10 +381,10 @@ public class JavaDocInfoGenerator {
if (parentClass != null) {
String qName = parentClass.getQualifiedName();
if (qName != null) {
buffer.append("<font size=\"-1\"><b>");
buffer.append("<small><b>");
//buffer.append(qName);
generateLink(buffer, qName, qName, field, false);
buffer.append("</b></font>");
buffer.append("</b></small>");
//buffer.append("<br>");
}
}
@@ -550,7 +561,7 @@ public class JavaDocInfoGenerator {
}
buffer.append(")");
}
buffer.append("\n");
buffer.append("&nbsp;");
}
}
}
@@ -599,10 +610,10 @@ public class JavaDocInfoGenerator {
if (parentClass != null) {
String qName = parentClass.getQualifiedName();
if (qName != null) {
buffer.append("<font size=\"-1\"><b>");
buffer.append("<small><b>");
generateLink(buffer, qName, qName, method, false);
//buffer.append(qName);
buffer.append("</b></font>");
buffer.append("</b></small>");
//buffer.append("<br>");
}
}
@@ -137,7 +137,7 @@ public class LookupItemUtil{
}
if (s == null) {
LOG.assertTrue(false, "Null string for object: " + object + " of class " + (object != null ?object.getClass():null));
LOG.error("Null string for object: " + object + " of class " + (object != null ? object.getClass() : null));
}
if (object instanceof LookupValueWithTail) {
item.setAttribute(LookupItem.TAIL_TEXT_ATTR, " " + ((LookupValueWithTail)object).getTailText());
@@ -63,14 +63,14 @@ public class JavaFileIconPatcher implements FileIconPatcher {
// prefer icon of the class named after file
final String fileName = file.getNameWithoutExtension();
for (PsiClass aClass : classes) {
if (!(aClass instanceof SyntheticElement) && Comparing.strEqual(aClass.getName(), fileName)) {
if (aClass instanceof SyntheticElement) {
return baseIcon;
}
if (Comparing.strEqual(aClass.getName(), fileName)) {
return aClass.getIcon(flags);
}
}
final PsiClass lastClass = classes[classes.length - 1];
if (!(lastClass instanceof SyntheticElement)) {
return lastClass.getIcon(flags);
}
return classes[classes.length - 1].getIcon(flags);
}
}
return baseIcon;
@@ -36,7 +36,7 @@ import org.jetbrains.annotations.NotNull;
*/
public class CreateClassAction extends CreateTemplateInPackageAction<PsiClass> {
public CreateClassAction() {
super(IdeBundle.message("action.create.new.class"), IdeBundle.message("action.create.new.class"), Icons.CLASS_ICON);
super(IdeBundle.message("action.create.new.class"), IdeBundle.message("action.create.new.class"), Icons.CLASS_ICON, true);
}
@NotNull
@@ -34,8 +34,11 @@ import javax.swing.*;
* @author peter
*/
public abstract class CreateTemplateInPackageAction<T extends PsiElement> extends AnAction {
protected CreateTemplateInPackageAction(String text, String description, Icon icon) {
private final boolean myinSourceOnly;
protected CreateTemplateInPackageAction(String text, String description, Icon icon, boolean inSourceOnly) {
super(text, description, icon);
myinSourceOnly = inSourceOnly;
}
public final void actionPerformed(final AnActionEvent e) {
@@ -93,6 +96,10 @@ public abstract class CreateTemplateInPackageAction<T extends PsiElement> extend
return false;
}
if (!myinSourceOnly) {
return true;
}
ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
for (PsiDirectory dir : view.getDirectories()) {
if (projectFileIndex.isInSourceContent(dir.getVirtualFile()) && JavaDirectoryService.getInstance().getPackage(dir) != null) {
@@ -129,12 +129,12 @@ public class ClassesScopeTreeStructureExpander implements ScopeTreeStructureExpa
final TreeNode childNode = node.getChildAt(i);
if (childNode instanceof ClassNode) {
final ClassNode classNode = (ClassNode)childNode;
final PsiElement psiElement = classNode.getPsiElement();
if (psiElement != null && psiElement.isValid()) {
final PsiFile containingFile = classNode.getContainingFile();
if (containingFile != null && containingFile.isValid()) {
if (fileNodes == null) {
fileNodes = new HashSet<FileNode>();
}
fileNodes.add(new FileNode(psiElement.getContainingFile(), true));
fileNodes.add(new FileNode(containingFile, true));
}
node.remove(classNode);
}
@@ -136,7 +136,7 @@ public class DefaultSymbolNavigationContributor implements ChooseByNameContribut
return 3;
}
else{
LOG.error(element.toString());
LOG.error(element);
return 0;
}
}
@@ -77,7 +77,6 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx implements Disposable {
private final ConcurrentMap<String, PsiPackage> myPackageCache = new ConcurrentHashMap<String, PsiPackage>();
private final Project myProject;
private final JavaFileManager myFileManager;
private final ProgressManager myProgressManager;
private final PackagePrefixIndex myPackagePrefixIndex;
@@ -114,7 +113,6 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx implements Disposable {
}
myFileManager = new JavaFileManagerImpl(psiManager, projectRootManagerEx, psiManager.getFileManager(), bus);
myProgressManager = ProgressManager.getInstance();
final PsiModificationTrackerImpl modificationTracker = (PsiModificationTrackerImpl) psiManager.getModificationTracker();
psiManager.addTreeChangePreprocessor(new JavaCodeBlockModificationListener(modificationTracker));
@@ -308,13 +306,15 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx implements Disposable {
}
public PsiClass[] getClasses(PsiPackageImpl psiPackage, GlobalSearchScope scope) {
List<PsiClass> result = new ArrayList<PsiClass>();
List<PsiClass> result = null;
for (PsiElementFinder finder : myElementFinders) {
PsiClass[] classes = finder.getClasses(psiPackage, scope);
if (classes.length == 0) continue;
if (result == null) result = new ArrayList<PsiClass>();
result.addAll(Arrays.asList(classes));
}
return result.toArray(new PsiClass[result.size()]);
return result == null ? PsiClass.EMPTY_ARRAY : result.toArray(new PsiClass[result.size()]);
}
public PsiPackage[] getSubPackages(PsiPackageImpl psiPackage, GlobalSearchScope scope) {
@@ -414,13 +414,21 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx implements Disposable {
@NotNull
public PsiClass[] getClasses(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
List<PsiClass> list = new ArrayList<PsiClass>();
List<PsiClass> list = null;
final PsiDirectory[] dirs = psiPackage.getDirectories(scope);
String packageName = psiPackage.getQualifiedName();
for (PsiDirectory dir : dirs) {
PsiClass[] classes = JavaDirectoryService.getInstance().getClasses(dir);
list.addAll(Arrays.asList(classes));
if (classes.length == 0) continue;
if (list == null) list = new ArrayList<PsiClass>();
for (PsiClass aClass : classes) {
// class file can be located in wrong place inside file system
if (Comparing.strEqual(((PsiClassOwner)aClass.getContainingFile()).getPackageName(), packageName)) {
list.add(aClass);
}
}
}
return list.toArray(new PsiClass[list.size()]);
return list == null ? PsiClass.EMPTY_ARRAY : list.toArray(new PsiClass[list.size()]);
}
}
@@ -28,11 +28,21 @@ import com.intellij.util.cls.ClsFormatException;
public class ClassFileStubBuilder implements BinaryFileStubBuilder {
public boolean acceptsFile(final VirtualFile file) {
return !isInner(file.getNameWithoutExtension());
return !isInner(file.getNameWithoutExtension(), new ParentDirectory(file));
}
private static boolean isInner(final String name) {
return name.indexOf('$') >= 0;
static boolean isInner(final String name, final Directory directory) {
return isInner(name, 0, directory);
}
private static boolean isInner(final String name, final int from, final Directory directory) {
final int index = name.indexOf('$', from);
return index == -1 ? false
: containsPart(directory, name, index) ? true : isInner(name, index + 1, directory);
}
private static boolean containsPart(Directory directory, String name, int endIndex) {
return endIndex > 0 && directory.contains(name.substring(0, endIndex));
}
public StubElement buildStubTree(final VirtualFile file, final byte[] content, final Project project) {
@@ -47,4 +57,24 @@ public class ClassFileStubBuilder implements BinaryFileStubBuilder {
public int getStubVersion() {
return JavaFileElementType.STUB_VERSION;
}
interface Directory {
boolean contains(String name);
}
private static class ParentDirectory implements Directory {
private final VirtualFile myDirectory;
private final String myExtension;
private ParentDirectory(final VirtualFile file) {
myDirectory = file.getParent();
myExtension = file.getExtension();
}
public boolean contains(final String name) {
final String fullName = myExtension == null ? name : name + "." + myExtension;
return myDirectory == null ? false : myDirectory.findChild(fullName) != null;
}
}
}
@@ -63,7 +63,7 @@ public class ClsParsingUtil {
return new ClsLiteralExpressionImpl(parent, exprText, expr.getType(), value); //it seems ok to make literal expression with non-literal text
}
}
LOG.error(expr.toString());
LOG.error(expr);
return null;
}
}
@@ -42,6 +42,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
public class JavaDirectoryServiceImpl extends JavaDirectoryService {
@@ -58,13 +59,16 @@ public class JavaDirectoryServiceImpl extends JavaDirectoryService {
public PsiClass[] getClasses(@NotNull PsiDirectory dir) {
LOG.assertTrue(dir.isValid());
ArrayList<PsiClass> classes = new ArrayList<PsiClass>();
List<PsiClass> classes = null;
for (PsiFile file : dir.getFiles()) {
if (file instanceof PsiClassOwner) {
classes.addAll(Arrays.asList(((PsiClassOwner)file).getClasses()));
PsiClass[] psiClasses = ((PsiClassOwner)file).getClasses();
if (psiClasses.length == 0) continue;
if (classes == null) classes = new ArrayList<PsiClass>();
classes.addAll(Arrays.asList(psiClasses));
}
}
return classes.toArray(new PsiClass[classes.size()]);
return classes == null ? PsiClass.EMPTY_ARRAY : classes.toArray(new PsiClass[classes.size()]);
}
@NotNull
@@ -116,14 +116,15 @@ public class PsiPackageImpl extends PsiElementBase implements PsiPackage {
@NotNull
public PsiDirectory[] getDirectories(@NotNull GlobalSearchScope scope) {
final List<PsiDirectory> result = new ArrayList<PsiDirectory>();
List<PsiDirectory> result = null;
final Collection<PsiDirectory> directories = getAllDirectories();
for (final PsiDirectory directory : directories) {
if (scope.contains(directory.getVirtualFile())) {
if (result == null) result = new ArrayList<PsiDirectory>();
result.add(directory);
}
}
return result.toArray(new PsiDirectory[result.size()]);
return result == null ? PsiDirectory.EMPTY_ARRAY : result.toArray(new PsiDirectory[result.size()]);
}
public RowIcon getElementIcon(final int elementFlags) {
@@ -79,7 +79,7 @@ public class AnnotatedElementsSearcher implements QueryExecutor<PsiModifierListO
if (found instanceof PsiAnnotation) return false;
VirtualFile faultyContainer = PsiUtil.getVirtualFile(found);
LOG.error("Non annotation in annotations list: " + faultyContainer);
LOG.error("Non annotation in annotations list: " + faultyContainer+"; element:"+found);
if (faultyContainer != null && faultyContainer.isValid()) {
FileBasedIndex.getInstance().requestReindex(faultyContainer);
}
@@ -354,7 +354,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
public JavaResolveResult[] multiResolve(final boolean incompleteCode) {
final PsiManagerEx manager = getManager();
if (manager == null) {
LOG.assertTrue(false, "getManager() == null!");
LOG.error("getManager() == null!");
return JavaResolveResult.EMPTY_ARRAY;
}
@@ -400,7 +400,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme
return JavaResolveResult.EMPTY_ARRAY;
}
else {
LOG.assertTrue(false, "Invalid java reference!");
LOG.error("Invalid java reference!");
return JavaResolveResult.EMPTY_ARRAY;
}
@@ -331,7 +331,7 @@ public class JavadocParsing extends Parsing {
LeafElement tokenElement = myParsing.createTokenElement(lexer);
IElementType type = lexer.getTokenType();
if (!TOKEN_FILTER.contains(type)) {
LOG.assertTrue(false, "Missed token should be space or asterisks:" + tokenElement);
LOG.error("Missed token should be space or asterisks:" + tokenElement);
throw new RuntimeException();
}
if (last != null) {
@@ -48,7 +48,7 @@ public class ClassCollectingProcessor extends BaseScopeProcessor implements Elem
public boolean execute(PsiElement element, ResolveState state) {
if (element instanceof PsiNamedElement) {
PsiNamedElement named = ((PsiNamedElement)element);
PsiNamedElement named = (PsiNamedElement)element;
String name = named.getName();
if (name != null) {
myResult.add(name, new ResultWithContext(named, myCurrentFileContext));
@@ -56,7 +56,7 @@ public class JavaResolveCache {
private final Map<PsiVariable,Object> myVarToConstValueMap2;
private static final Object NULL = Key.create("NULL");
private static final PsiType NULL_TYPE = new PsiEllipsisType(PsiType.NULL){
public static final PsiType NULL_TYPE = new PsiEllipsisType(PsiType.NULL){
public boolean isValid() {
return true;
}
@@ -436,7 +436,7 @@ public class JavaChangeUtilSupport implements TreeGenerator, TreeCopyHandler {
}
}
else {
LOG.assertTrue(false, "Wrong element type: " + original.getElementType());
LOG.error("Wrong element type: " + original.getElementType());
}
}
@@ -150,6 +150,7 @@ public class JavaConcatenationInjectorManager implements ProjectComponent, Modif
}
private static final Key<ParameterizedCachedValue<Places, PsiElement>> INJECTED_PSI_IN_CONCATENATION = Key.create("INJECTED_PSI_IN_CONCATENATION");
private final Concatenation2InjectorAdapter myConcatenation2InjectorAdapter = new Concatenation2InjectorAdapter();
private class Concatenation2InjectorAdapter implements MultiHostInjector {
public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) {
if (myConcatenationInjectors.isEmpty()) return;
@@ -206,9 +207,8 @@ public class JavaConcatenationInjectorManager implements ProjectComponent, Modif
}
}
else {
MultiHostInjector adapter = new Concatenation2InjectorAdapter();
if (myRegisteredConcatenationAdapter.compareAndSet(null, adapter)) {
myInjectedLanguageManager.registerMultiHostInjector(adapter);
if (myRegisteredConcatenationAdapter.compareAndSet(null, myConcatenation2InjectorAdapter)) {
myInjectedLanguageManager.registerMultiHostInjector(myConcatenation2InjectorAdapter);
}
}
}
@@ -61,6 +61,11 @@ public class PsiBinaryExpressionImpl extends ExpressionPsiElement implements Psi
PsiExpression lOperand = param.getLOperand();
PsiExpression rOperand = param.getROperand();
if (rOperand == null) return null;
PsiType rType = rOperand.getType();
IElementType sign = param.getOperationSign().getNode().getElementType();
// optimization: if we can calculate type based on right type only
PsiType type = calcTypeForBinaryExpression(null, rType, sign, false);
if (type != JavaResolveCache.NULL_TYPE) return type;
if (lOperand instanceof PsiBinaryExpressionImpl && !JavaResolveCache.getInstance(param.getProject()).isTypeCached(lOperand)) {
// cache all intermediate expression types from bottom up
@@ -80,9 +85,8 @@ public class PsiBinaryExpressionImpl extends ExpressionPsiElement implements Psi
}
});
}
PsiType rType = rOperand.getType();
PsiType lType = lOperand.getType();
return calcTypeForBinaryExpression(lType, rType, param.getOperationSign().getNode().getElementType());
return calcTypeForBinaryExpression(lType, rType, sign, true);
}
private static final Function<PsiBinaryExpressionImpl,PsiType> MY_TYPE_EVALUATOR = new Function<PsiBinaryExpressionImpl, PsiType>() {
@@ -144,13 +148,14 @@ public class PsiBinaryExpressionImpl extends ExpressionPsiElement implements Psi
}
@Nullable
public static PsiType calcTypeForBinaryExpression(PsiType lType, PsiType rType, IElementType sign) {
public static PsiType calcTypeForBinaryExpression(PsiType lType, PsiType rType, IElementType sign, boolean accessLType) {
if (sign == JavaTokenType.PLUS) {
// evaluate right argument first, since '+-/*%' is left associative and left operand tends to be bigger
if (rType == null) return null;
if (rType.equalsToText("java.lang.String")) {
return rType;
}
if (!accessLType) return JavaResolveCache.NULL_TYPE;
if (lType == null) return null;
if (lType.equalsToText("java.lang.String")) {
return lType;
@@ -158,10 +163,13 @@ public class PsiBinaryExpressionImpl extends ExpressionPsiElement implements Psi
return TypeConversionUtil.unboxAndBalanceTypes(lType, rType);
}
if (sign == JavaTokenType.MINUS || sign == JavaTokenType.ASTERISK || sign == JavaTokenType.DIV || sign == JavaTokenType.PERC) {
if (lType == null && rType == null) return null;
if (rType == null) return null;
if (!accessLType) return JavaResolveCache.NULL_TYPE;
if (lType == null) return null;
return TypeConversionUtil.unboxAndBalanceTypes(lType, rType);
}
if (sign == JavaTokenType.LTLT || sign == JavaTokenType.GTGT || sign == JavaTokenType.GTGTGT) {
if (!accessLType) return JavaResolveCache.NULL_TYPE;
if (PsiType.BYTE.equals(lType) || PsiType.CHAR.equals(lType) || PsiType.SHORT.equals(lType)) {
return PsiType.INT;
}
@@ -178,11 +186,15 @@ public class PsiBinaryExpressionImpl extends ExpressionPsiElement implements Psi
return PsiType.BOOLEAN;
}
if (sign == JavaTokenType.OR || sign == JavaTokenType.XOR || sign == JavaTokenType.AND) {
if (lType instanceof PsiClassType) lType = PsiPrimitiveType.getUnboxedType(lType);
if (rType instanceof PsiClassType) rType = PsiPrimitiveType.getUnboxedType(rType);
if (lType == null && rType == null) return null;
if (PsiType.BOOLEAN.equals(lType) || PsiType.BOOLEAN.equals(rType)) return PsiType.BOOLEAN;
if (lType instanceof PsiClassType) lType = PsiPrimitiveType.getUnboxedType(lType);
if (rType == null) return null;
if (PsiType.BOOLEAN.equals(rType)) return PsiType.BOOLEAN;
if (!accessLType) return JavaResolveCache.NULL_TYPE;
if (lType == null) return null;
if (PsiType.BOOLEAN.equals(lType)) return PsiType.BOOLEAN;
if (PsiType.LONG.equals(lType) || PsiType.LONG.equals(rType)) return PsiType.LONG;
return PsiType.INT;
}
@@ -39,14 +39,8 @@ import org.jetbrains.annotations.NotNull;
public class PsiInlineDocTagImpl extends CompositePsiElement implements PsiInlineDocTag, Constants {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.java.PsiInlineDocTagImpl");
private static final TokenSet VALUE_BIT_SET = TokenSet.create(new IElementType[]{
JAVA_CODE_REFERENCE,
DOC_TAG_VALUE_TOKEN,
DOC_METHOD_OR_FIELD_REF,
DOC_COMMENT_DATA,
DOC_INLINE_TAG,
DOC_REFERENCE_HOLDER
});
private static final TokenSet VALUE_BIT_SET = TokenSet.create(JAVA_CODE_REFERENCE, DOC_TAG_VALUE_TOKEN, DOC_METHOD_OR_FIELD_REF,
DOC_COMMENT_DATA, DOC_INLINE_TAG, DOC_REFERENCE_HOLDER, WHITE_SPACE, DOC_COMMENT_BAD_CHARACTER);
public PsiInlineDocTagImpl() {
super(DOC_INLINE_TAG);
@@ -284,7 +284,7 @@ public class PsiReferenceExpressionImpl extends ExpressionPsiElement implements
public JavaResolveResult[] multiResolve(boolean incompleteCode) {
final PsiManagerEx manager = getManager();
if (manager == null) {
LOG.assertTrue(false, "getManager() == null!");
LOG.error("getManager() == null!");
return null;
}
ResolveResult[] results = manager.getResolveCache().resolveWithCaching(this, OurGenericsResolver.INSTANCE, true, incompleteCode);
@@ -619,7 +619,7 @@ public class PsiReferenceExpressionImpl extends ExpressionPsiElement implements
if (nameChild == null) {
final TreeElement dot = (TreeElement)findChildByRole(ChildRole.DOT);
if (dot == null) {
LOG.assertTrue(false, this);
LOG.error(toString());
}
return new TextRange(dot.getStartOffsetInParent() + dot.getTextLength(), getTextLength());
}
@@ -154,7 +154,7 @@ public class ReplaceExpressionUtil implements Constants {
return 14;
}
else {
LOG.assertTrue(false, "Unknown element type:"+i);
LOG.error("Unknown element type:" + i);
return -1;
}
}
@@ -233,7 +233,7 @@ public class PsiScopesUtil {
}
}
else{
LOG.assertTrue(false, "Unknown name element " + referenceNameElement + " in reference " + ref.getText() + "(" + ref + ")");
LOG.error("Unknown name element " + referenceNameElement + " in reference " + ref.getText() + "(" + ref + ")");
}
}
else if (referenceNameElement instanceof PsiIdentifier){
@@ -243,7 +243,7 @@ public class PsiScopesUtil {
resolveAndWalk(processor, ref, null);
}
else{
LOG.assertTrue(false, "Unknown name element " + referenceNameElement + " in reference " + ref.getText() + "(" + ref + ")");
LOG.error("Unknown name element " + referenceNameElement + " in reference " + ref.getText() + "(" + ref + ")");
}
}
else{
@@ -54,7 +54,7 @@ public abstract class IntroduceHandlerBase {
invokeImpl(project, (PsiLocalVariable)tempExpr, editor);
}
else {
LOG.assertTrue(false, "elements[0] should be PsiExpression or PsiLocalVariable");
LOG.error("elements[0] should be PsiExpression or PsiLocalVariable");
}
}
@@ -238,7 +238,7 @@ public class ChangeSignatureDialog extends RefactoringDialog {
final PsiElementFactory factory = JavaPsiFacade.getInstance(myMethod.getProject()).getElementFactory();
final PsiTypeElement typeElement = myMethod.getReturnTypeElement();
if (typeElement == null) {
LOG.assertTrue(false, myMethod.getClass().getName());
LOG.error(myMethod.getClass().getName());
return panel;
}
myReturnTypeCodeFragment = factory.createTypeCodeFragment(typeElement.getText(), myMethod.getParameterList(), true, true);
@@ -52,7 +52,7 @@ public class MethodCallUsageInfo extends UsageInfo {
else if (parent instanceof PsiAnonymousClass) {
return ((PsiNewExpression)parent.getParent()).resolveConstructor();
}
LOG.assertTrue(false, "Unknown reference");
LOG.error("Unknown reference");
return null;
}
@@ -281,7 +281,7 @@ public class ControlFlowWrapper {
if (myFlowStart <= startOffset && endOffset <= myFlowEnd) continue;
}
else {
LOG.assertTrue(false, exitStatement);
LOG.error(String.valueOf(exitStatement));
continue;
}
@@ -81,7 +81,9 @@ public class InlineParameterHandler extends JavaInlineActionHandler {
final PsiCallExpression methodCall = (PsiCallExpression)parent;
occurrences.add(psiReference);
containingFiles.add(element.getContainingFile());
PsiExpression argument = methodCall.getArgumentList().getExpressions()[index];
final PsiExpression[] expressions = methodCall.getArgumentList().getExpressions();
if (expressions.length <= index) return false;
PsiExpression argument = expressions[index];
if (!refInitializer.isNull()) {
return argument != null
&& PsiEquivalenceUtil.areElementsEquivalent(refInitializer.get(), argument)
@@ -59,6 +59,7 @@ import com.intellij.refactoring.util.EnumConstantsUtil;
import com.intellij.refactoring.util.RefactoringUtil;
import com.intellij.refactoring.util.occurences.OccurenceManager;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.VisibilityUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -194,21 +195,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
ChangeContextUtil.encodeContextInfo(initializer, true);
PsiField field = settings.isIntroduceEnumConstant() ? EnumConstantsUtil.createEnumConstant(destClass, fieldName, initializer) : createField(fieldName, type, initializer, initializerPlace == InitializationPlace.IN_FIELD_DECLARATION && initializer != null);
if (!settings.isIntroduceEnumConstant()) {
PsiUtil.setModifierProperty(field, settings.getFieldVisibility(), true);
if (settings.isDeclareFinal()) {
PsiUtil.setModifierProperty(field, PsiModifier.FINAL, true);
}
if (settings.isDeclareStatic()) {
PsiUtil.setModifierProperty(field, PsiModifier.STATIC, true);
}
if (settings.isAnnotateAsNonNls()) {
PsiAnnotation annotation = JavaPsiFacade.getInstance(myParentClass.getProject()).getElementFactory()
.createAnnotationFromText("@" + AnnotationUtil.NON_NLS, myParentClass);
field.getModifierList().addAfter(annotation, null);
JavaCodeStyleManager.getInstance(myParentClass.getProject()).shortenClassReferences(field.getModifierList());
}
}
PsiElement finalAnchorElement = null;
if (destClass == myParentClass) {
for (finalAnchorElement = anchorElement;
@@ -230,6 +217,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
else {
field = (PsiField)destClass.add(field);
}
setModifiers(field, settings, settings.isDeclareStatic(), occurrences);
PsiStatement assignStatement = null;
PsiElement anchorElementHere = null;
if (initializerPlace == InitializationPlace.IN_CURRENT_METHOD && initializer != null ||
@@ -326,6 +314,26 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase
return true;
}
public static void setModifiers(PsiField field, Settings settings, final boolean declareStatic, PsiExpression[] occurrences) {
if (!settings.isIntroduceEnumConstant()) {
VisibilityUtil.fixVisibility(occurrences, field, settings.getFieldVisibility());
if (declareStatic) {
PsiUtil.setModifierProperty(field, PsiModifier.STATIC, true);
}
if (settings.isDeclareFinal()) {
PsiUtil.setModifierProperty(field, PsiModifier.FINAL, true);
}
if (settings.isAnnotateAsNonNls()) {
PsiAnnotation annotation = JavaPsiFacade.getInstance(field.getProject()).getElementFactory()
.createAnnotationFromText("@" + AnnotationUtil.NON_NLS, field);
final PsiModifierList modifierList = field.getModifierList();
LOG.assertTrue(modifierList != null);
modifierList.addAfter(annotation, null);
}
}
JavaCodeStyleManager.getInstance(field.getProject()).shortenClassReferences(field);
}
private static PsiElement getPhysicalElement(final PsiExpression selectedExpr) {
PsiElement element = selectedExpr.getUserData(ElementToWorkOn.PARENT);
if (element == null) element = selectedExpr;
@@ -79,52 +79,6 @@
<border type="none"/>
<children/>
</xy>
<grid id="7fca1" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none" title-resource-bundle="messages/RefactoringBundle" title-key="visibility.border.title"/>
<children>
<component id="c87a2" class="javax.swing.JRadioButton" binding="myRbPrivate">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<focusable value="false"/>
<text resource-bundle="messages/RefactoringBundle" key="visibility.private"/>
</properties>
</component>
<component id="68fc" class="javax.swing.JRadioButton" binding="myRbpackageLocal">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<focusable value="false"/>
<text resource-bundle="messages/RefactoringBundle" key="visibility.package.local"/>
</properties>
</component>
<component id="abc2a" class="javax.swing.JRadioButton" binding="myRbProtected">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<focusable value="false"/>
<text resource-bundle="messages/RefactoringBundle" key="visibility.protected"/>
</properties>
</component>
<component id="1f00d" class="javax.swing.JRadioButton" binding="myRbPublic">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<focusable value="false"/>
<text resource-bundle="messages/RefactoringBundle" key="visibility.public"/>
</properties>
</component>
</children>
</grid>
<component id="1b064" class="javax.swing.JCheckBox" binding="myCbReplaceAll">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
@@ -152,6 +106,14 @@
<text resource-bundle="messages/RefactoringBundle" key="annotate.field.as.nonnls.checkbox"/>
</properties>
</component>
<grid id="46a1d" binding="myVisibilityPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</form>
@@ -46,6 +46,7 @@ import com.intellij.ui.RecentsManager;
import com.intellij.ui.ReferenceEditorComboWithBrowseButton;
import com.intellij.ui.StateRestoringCheckBox;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.ui.UIUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NonNls;
@@ -77,11 +78,6 @@ class IntroduceConstantDialog extends DialogWrapper {
private NameSuggestionsField myNameField;
private JCheckBox myCbReplaceAll;
private JRadioButton myRbPrivate;
private JRadioButton myRbProtected;
private JRadioButton myRbpackageLocal;
private JRadioButton myRbPublic;
private TypeSelector myTypeSelector;
private StateRestoringCheckBox myCbDeleteVariable;
private final JavaCodeStyleManager myCodeStyleManager;
@@ -95,6 +91,8 @@ class IntroduceConstantDialog extends DialogWrapper {
private JLabel myNameSuggestionLabel;
private JLabel myTargetClassNameLabel;
private JCheckBox myCbNonNls;
private JPanel myVisibilityPanel;
private VisibilityPanel myVPanel;
private final JCheckBox myIntroduceEnumConstantCb = new JCheckBox(RefactoringBundle.message("introduce.constant.enum.cb"), true);
IntroduceConstantDialog(Project project,
@@ -119,20 +117,11 @@ class IntroduceConstantDialog extends DialogWrapper {
setTitle(IntroduceConstantHandler.REFACTORING_NAME);
myCodeStyleManager = JavaCodeStyleManager.getInstance(myProject);
myVPanel = new VisibilityPanel(false, true);
myVisibilityPanel.add(myVPanel, BorderLayout.CENTER);
init();
final String ourLastVisibility = JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_VISIBILITY;
if (PsiModifier.PUBLIC.equals(ourLastVisibility)) {
myRbPublic.setSelected(true);
} else if (PsiModifier.PROTECTED.equals(ourLastVisibility)) {
myRbProtected.setSelected(true);
} else if (PsiModifier.PACKAGE_LOCAL.equals(ourLastVisibility)) {
myRbpackageLocal.setSelected(true);
} else if (PsiModifier.PRIVATE.equals(ourLastVisibility)) {
myRbPrivate.setSelected(true);
} else {
myRbPrivate.setSelected(true);
}
myVPanel.setVisibility(JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_VISIBILITY);
myIntroduceEnumConstantCb.setEnabled(EnumConstantsUtil.isSuitableForEnumConstant(getSelectedType(), myTargetClass));
updateVisibilityPanel();
}
@@ -155,20 +144,7 @@ class IntroduceConstantDialog extends DialogWrapper {
@Modifier
public String getFieldVisibility() {
if (myRbPublic.isSelected()) {
return PsiModifier.PUBLIC;
}
if (myRbpackageLocal.isSelected()) {
return PsiModifier.PACKAGE_LOCAL;
}
if (myRbProtected.isSelected()) {
return PsiModifier.PROTECTED;
}
if (myRbPrivate.isSelected()) {
return PsiModifier.PRIVATE;
}
LOG.assertTrue(false);
return null;
return myVPanel.getVisibility();
}
public boolean isReplaceAllOccurrences() {
@@ -301,11 +277,6 @@ class IntroduceConstantDialog extends DialogWrapper {
updateTypeSelector();
ButtonGroup bg = new ButtonGroup();
bg.add(myRbPrivate);
bg.add(myRbpackageLocal);
bg.add(myRbProtected);
bg.add(myRbPublic);
enableEnumDependant(introduceEnumConstant());
return myPanel;
}
@@ -319,11 +290,7 @@ class IntroduceConstantDialog extends DialogWrapper {
private void enableEnumDependant(boolean enable) {
if (enable) {
myRbPrivate.setEnabled(false);
myRbProtected.setEnabled(false);
myRbpackageLocal.setEnabled(false);
myRbPublic.setEnabled(true);
myRbPublic.setSelected(true);
myVPanel.disableAllButPublic();
} else {
updateVisibilityPanel();
}
@@ -361,19 +328,11 @@ class IntroduceConstantDialog extends DialogWrapper {
}
private void updateVisibilityPanel() {
if (myTargetClass == null) return;
if (myTargetClass.isInterface()) {
myRbPrivate.setEnabled(false);
myRbProtected.setEnabled(false);
myRbpackageLocal.setEnabled(false);
myRbPublic.setEnabled(true);
myRbPublic.setSelected(true);
if (myTargetClass != null && myTargetClass.isInterface()) {
myVPanel.disableAllButPublic();
}
else {
myRbPrivate.setEnabled(true);
myRbProtected.setEnabled(true);
myRbpackageLocal.setEnabled(true);
myRbPublic.setEnabled(true);
UIUtil.setEnabled(myVisibilityPanel, true, true);
// exclude all modifiers not visible from all occurences
final Set<String> visible = new THashSet<String>();
visible.add(PsiModifier.PRIVATE);
@@ -397,10 +356,12 @@ class IntroduceConstantDialog extends DialogWrapper {
}
}
}
if (visible.contains(PsiModifier.PUBLIC)) myRbPublic.setSelected(true);
if (visible.contains(PsiModifier.PACKAGE_LOCAL)) myRbpackageLocal.setSelected(true);
if (visible.contains(PsiModifier.PROTECTED)) myRbProtected.setSelected(true);
if (visible.contains(PsiModifier.PRIVATE)) myRbPrivate.setSelected(true);
if (!visible.contains(getFieldVisibility())) {
if (visible.contains(PsiModifier.PUBLIC)) myVPanel.setVisibility(PsiModifier.PUBLIC);
if (visible.contains(PsiModifier.PACKAGE_LOCAL)) myVPanel.setVisibility(PsiModifier.PACKAGE_LOCAL);
if (visible.contains(PsiModifier.PROTECTED)) myVPanel.setVisibility(PsiModifier.PROTECTED);
if (visible.contains(PsiModifier.PRIVATE)) myVPanel.setVisibility(PsiModifier.PRIVATE);
}
}
}
@@ -15,7 +15,6 @@
*/
package com.intellij.refactoring.introduceField;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInsight.CodeInsightUtil;
import com.intellij.codeInsight.TestUtil;
import com.intellij.openapi.application.ApplicationManager;
@@ -25,15 +24,11 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.refactoring.HelpID;
import com.intellij.refactoring.RefactoringBundle;
import static com.intellij.refactoring.introduceField.BaseExpressionToFieldHandler.InitializationPlace.IN_CONSTRUCTOR;
import static com.intellij.refactoring.introduceField.BaseExpressionToFieldHandler.InitializationPlace.IN_FIELD_DECLARATION;
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.refactoring.util.EnumConstantsUtil;
@@ -41,6 +36,9 @@ import com.intellij.refactoring.util.RefactoringUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls;
import static com.intellij.refactoring.introduceField.BaseExpressionToFieldHandler.InitializationPlace.IN_CONSTRUCTOR;
import static com.intellij.refactoring.introduceField.BaseExpressionToFieldHandler.InitializationPlace.IN_FIELD_DECLARATION;
public class LocalToFieldHandler {
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.introduceField.LocalToFieldHandler");
@@ -125,9 +123,7 @@ public class LocalToFieldHandler {
final boolean isStatic = tempIsStatic;
PsiExpression[] occurences = CodeInsightUtil.findReferenceExpressions(RefactoringUtil.getVariableScope(local),
local
);
final PsiExpression[] occurences = CodeInsightUtil.findReferenceExpressions(RefactoringUtil.getVariableScope(local), local);
if (editor != null) {
RefactoringUtil.highlightAllOccurences(myProject, occurences, editor);
}
@@ -138,7 +134,6 @@ public class LocalToFieldHandler {
final String variableName = local.getName();
final String fieldName = settings.getFieldName();
final BaseExpressionToFieldHandler.InitializationPlace initializerPlace = settings.getInitializerPlace();
final boolean declareFinal = settings.isDeclareFinal();
@Modifier final String fieldVisibility = settings.getFieldVisibility();
final PsiClass destinationClass = settings.getDestinationClass();
boolean rebindNeeded = false;
@@ -146,7 +141,6 @@ public class LocalToFieldHandler {
aClass = destinationClass;
rebindNeeded = true;
}
final boolean annotateAsNonNls = settings.isAnnotateAsNonNls();
final PsiClass aaClass = aClass;
final boolean rebindNeeded1 = rebindNeeded;
@@ -165,22 +159,8 @@ public class LocalToFieldHandler {
final PsiMethod enclosingConstructor = BaseExpressionToFieldHandler.getEnclosingConstructor(aaClass, local);
PsiField field = settings.isIntroduceEnumConstant() ? EnumConstantsUtil.createEnumConstant(aaClass, local, fieldName)
: createField(local, fieldName, initializerPlace == IN_FIELD_DECLARATION);
if (!settings.isIntroduceEnumConstant()) {
if (isStatic) {
PsiUtil.setModifierProperty(field, PsiModifier.STATIC, true);
}
if (declareFinal) {
PsiUtil.setModifierProperty(field, PsiModifier.FINAL, true);
}
if (annotateAsNonNls) {
PsiAnnotation annotation = JavaPsiFacade.getInstance(local.getProject()).getElementFactory().createAnnotationFromText("@" + AnnotationUtil.NON_NLS, field);
field.getModifierList().addAfter(annotation, null);
}
PsiUtil.setModifierProperty(field, fieldVisibility, true);
}
field = (PsiField)aaClass.add(field);
JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(field);
BaseExpressionToFieldHandler.setModifiers(field, settings, isStatic, occurences);
local.normalizeDeclaration();
PsiDeclarationStatement declarationStatement = (PsiDeclarationStatement)local.getParent();
@@ -511,7 +511,7 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor implem
removeParametersFromCall(argList);
}
else {
LOG.error(element.getParent().toString());
LOG.error(element.getParent());
}
}
@@ -165,7 +165,7 @@ public class JavaNameSuggestionProvider implements NameSuggestionProvider {
result.add(suggestProperlyCasedName(prefix, NameUtil.splitNameIntoWords(name)));
}
result.add(suggestProperlyCasedName(prefix, NameUtil.splitNameIntoWords(name.toLowerCase())));
return result.toArray(new String[result.size()]);
return ArrayUtil.toStringArray(result);
}
}
@@ -45,13 +45,8 @@ public abstract class PsiNamedElementAutomaticRenamer<T extends PsiNamedElement>
String canonicalName = nameToCanonicalName(elementName, element);
final String newCanonicalName = suggester.suggestName(canonicalName);
if (newCanonicalName.length() == 0) {
LOG.assertTrue(false,
"oldName = " + getOldName() +
", newName = " + getNewName() +
", name = " + elementName +
", canonicalName = " + canonicalName +
", newCanonicalName = " + newCanonicalName
);
LOG.error("oldName = " + getOldName() + ", newName = " + getNewName() + ", name = " + elementName + ", canonicalName = " +
canonicalName + ", newCanonicalName = " + newCanonicalName);
}
return canonicalNameToName(newCanonicalName, element);
}
@@ -144,6 +144,20 @@ public class VisibilityPanel extends JPanel {
}
}
public void disableAllButPublic() {
myRbPrivate.setEnabled(false);
myRbProtected.setEnabled(false);
myRbPackageLocal.setEnabled(false);
if (myRbEscalate != null) {
myRbEscalate.setEnabled(false);
}
if (myRbAsIs != null) {
myRbAsIs.setEnabled(false);
}
myRbPublic.setEnabled(true);
myRbPublic.setSelected(true);
}
public static interface StateChanged extends EventListener {
void visibilityChanged();
}
@@ -186,7 +186,7 @@ public class ClassInstanceScanner extends DelegatingClassReferenceVisitor {
visitor.visitReadUsage(expression, null, referencedElement);
}
else {
LOG.assertTrue(false, "Unknown variation of class instance usage");
LOG.error("Unknown variation of class instance usage");
}
}
@@ -22,6 +22,7 @@ import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Iconable;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.TypeConversionUtil;
@@ -226,6 +227,16 @@ class WrapReturnValueDialog extends RefactoringDialog {
UIUtil.setEnabled(myExistingClassPanel, useExistingClassButton.isSelected(), true);
UIUtil.setEnabled(myNewClassPanel, createNewClassButton.isSelected(), true);
UIUtil.setEnabled(myCreateInnerPanel, myCreateInnerClassButton.isSelected(), true);
final IdeFocusManager focusManager = IdeFocusManager.getInstance(myProject);
if (useExistingClassButton.isSelected()) {
focusManager.requestFocus(existingClassField, true);
}
else if (myCreateInnerClassButton.isSelected()) {
focusManager.requestFocus(myInnerClassNameTextField, true);
}
else {
focusManager.requestFocus(classNameField, true);
}
validateButtons();
}
@@ -96,6 +96,7 @@
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<labelFor value="4d2b9"/>
<text value="Name"/>
</properties>
</component>
@@ -164,21 +164,22 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
}
else {
boolean foundConstructor = false;
final PsiCodeBlock methodBody = method.getBody();
assert methodBody != null;
final Set<PsiType> returnTypes = new HashSet<PsiType>();
returnTypes.add(method.getReturnType());
methodBody.accept(new JavaRecursiveElementWalkingVisitor() {
@Override
public void visitReturnStatement(final PsiReturnStatement statement) {
super.visitReturnStatement(statement);
if (PsiTreeUtil.getParentOfType(statement, PsiMethod.class) != method) return;
final PsiExpression returnValue = statement.getReturnValue();
if (returnValue != null) {
returnTypes.add(returnValue.getType());
final PsiCodeBlock methodBody = method.getBody();
if (methodBody != null) {
methodBody.accept(new JavaRecursiveElementWalkingVisitor() {
@Override
public void visitReturnStatement(final PsiReturnStatement statement) {
super.visitReturnStatement(statement);
if (PsiTreeUtil.getParentOfType(statement, PsiMethod.class) != method) return;
final PsiExpression returnValue = statement.getReturnValue();
if (returnValue != null) {
returnTypes.add(returnValue.getType());
}
}
}
});
});
}
final PsiMethod[] constructors = existingClass.getConstructors();
constr: for (PsiMethod constructor : constructors) {
@@ -54,7 +54,7 @@ public class CanItBeNullAction extends AnAction {
else {
type = null;
}
return type instanceof PsiClassType;
return type instanceof PsiClassType || type instanceof PsiArrayType;
}
@Override
@@ -8,4 +8,4 @@ class Test {
}
void bar(String s){}
}
}
@@ -0,0 +1,143 @@
package com.intellij.psi.impl.compiled;
import junit.framework.TestCase;
import java.util.*;
/**
* Pavel.Fatin, 18.02.2010
*/
public class ClassFileStubBuilderTest extends TestCase {
public void testOneFile() {
assertTopLevel("");
assertTopLevel("$");
assertTopLevel("$$");
assertTopLevel("$$$");
assertTopLevel("Foo");
assertTopLevel("Foo$");
assertTopLevel("$Foo");
assertTopLevel("$Foo$");
assertTopLevel("Foo$Bar");
assertTopLevel("$Foo$Bar");
assertTopLevel("Foo$Bar$");
assertTopLevel("$Foo$Bar$");
assertTopLevel("$$Foo$$Bar$$");
}
public void testWrongCase() {
assertTopLevel("Foo$Bar", "foo");
assertTopLevel("foo$Bar", "Foo");
}
public void testShortName() {
assertTopLevel("A");
assertInner("Foo$B", "Foo");
assertInner("A$Foo", "A");
assertInner("A$B", "A");
assertTopLevel("A$B", "A$");
assertTopLevel("A$B", "$B");
assertTopLevel("A$B", "B");
assertTopLevel("A$B", "$");
}
public void testShortNames() {
assertInner("A$B$C", "A");
assertInner("A$B$C", "A$B");
assertInner("A$B$C", "A", "A$B");
assertTopLevel("A$B$C", "A$");
assertTopLevel("A$B$C", "A$B$");
}
public void testEmptyFileName() {
assertTopLevel("$Foo", "");
}
public void testNoInnerName() {
//assertTopLevel("Foo$", "Foo");
//assertTopLevel("Foo$$", "Foo$");
// an exception to the rule (to hide Scala "objects")
assertInner("Foo$", "Foo");
assertInner("Foo$$", "Foo$");
}
public void testDollarsInName() {
assertInner("$Foo$Bar", "$Foo");
assertInner("Foo$$Bar", "Foo");
assertInner("Foo$$Bar", "Foo");
assertInner("$Foo$$Bar", "$Foo");
assertInner("$Foo$$Bar", "$Foo$");
}
public void testInner() {
assertInner("Foo$Bar", "Foo");
assertInner("Foo$bar", "Foo");
assertInner("foo$Bar", "foo");
assertInner("foo$bar", "foo");
}
public void testInnerAndNoise() {
assertInner("Foo$Bar", "Foo", "Foo$", "$Bar", "Bar");
}
public void testTopLevel() {
assertTopLevel("Foo$Bar");
assertTopLevel("Foo$Bar", "Foo$");
assertTopLevel("Foo$Bar", "$Bar");
assertTopLevel("Foo$Bar", "Bar");
assertTopLevel("Foo$Bar", "Foo$", "$Bar", "Bar");
}
public void testInners() {
assertInner("Foo$Bar$Moo", "Foo");
assertInner("Foo$Bar$Moo", "Foo$Bar");
assertInner("Foo$Bar$Moo", "Foo", "Foo$Bar");
}
public void testInnersAndNoise() {
assertInner("Foo$Bar$Moo", "Foo", "$Bar", "Bar", "$Moo", "Moo", "Bar$Moo", "$Bar$Moo");
assertInner("Foo$Bar$Moo", "Foo$Bar", "$Bar", "Bar", "$Moo", "Moo", "Bar$Moo", "$Bar$Moo");
assertInner("Foo$Bar$Moo", "Foo", "Foo$Bar", "$Bar", "Bar", "$Moo", "Moo", "Bar$Moo", "$Bar$Moo");
}
public void testTopLevels() {
assertTopLevel("Foo$Bar$Moo");
assertTopLevel("Foo$Bar$Moo", "$Bar");
assertTopLevel("Foo$Bar$Moo", "Bar");
assertTopLevel("Foo$Bar$Moo", "$Moo");
assertTopLevel("Foo$Bar$Moo", "Moo");
assertTopLevel("Foo$Bar$Moo", "Bar$Moo");
assertTopLevel("Foo$Bar$Moo", "$Bar$Moo");
assertTopLevel("Foo$Bar$Moo", "$Bar", "Bar", "$Moo", "Moo", "Bar$Moo", "$Bar$Moo");
}
private static void assertInner(String name, String... files) {
assertTrue("Class " + name + " must be identified as inner", isInner(name, files));
}
private static void assertTopLevel(String name, String... files) {
assertFalse("Class " + name + " must be identified as top-level", isInner(name, files));
}
private static boolean isInner(String name, String... files) {
Set<String> all = new HashSet<String>();
all.addAll(Arrays.asList(files));
all.add(name);
return ClassFileStubBuilder.isInner(name, new DirectoryMock(all));
}
private static class DirectoryMock implements ClassFileStubBuilder.Directory {
private Set<String> myFiles;
private DirectoryMock(Set<String> files) {
myFiles = files;
}
public boolean contains(String name) {
return myFiles.contains(name);
}
}
}
@@ -685,7 +685,7 @@ public class TypeConversionUtil {
IS_ASSIGNABLE_BIT_SET[rightTypeIndex][leftTypeIndex];
}
if (!(right instanceof PsiClassType)) {
LOG.error(right.toString());
LOG.error(right);
}
if (left instanceof PsiPrimitiveType) {
return isUnboxable((PsiPrimitiveType)left, (PsiClassType)right);
@@ -143,4 +143,16 @@ public class VisibilityUtil {
modifierList.setModifierProperty(PsiModifier.PROTECTED, false);
modifierList.setModifierProperty(newVisibility, true);
}
public static void fixVisibility(PsiExpression[] expressions, PsiMember member, String newVisibility) {
if (newVisibility == null) return;
if (ESCALATE_VISIBILITY.equals(newVisibility)) {
for (PsiExpression element : expressions) {
escalateVisibility(member, element);
}
}
else {
setVisibility(member.getModifierList(), newVisibility);
}
}
}
@@ -17,14 +17,16 @@
package com.intellij.codeInsight.daemon;
import com.intellij.lang.LanguageExtension;
import org.jetbrains.annotations.NonNls;
/**
* @author yole
*/
public class LineMarkerProviders extends LanguageExtension<LineMarkerProvider> {
public static LineMarkerProviders INSTANCE = new LineMarkerProviders();
@NonNls public static final String EP_NAME = "com.intellij.codeInsight.lineMarkerProvider";
private LineMarkerProviders() {
super("com.intellij.codeInsight.lineMarkerProvider");
super(EP_NAME);
}
}
@@ -38,7 +38,7 @@ public class MemberChooserObjectBase implements MemberChooserObject {
}
public void renderTreeNode(SimpleColoredComponent component, JTree tree) {
component.append(myText, getTextAttributes(tree));
component.append(getText(), getTextAttributes(tree));
component.setIcon(myIcon);
}
@@ -44,7 +44,7 @@ public class ProgramRunnerUtil {
String message = ExecutionBundle.message("error.running.configuration.with.error.error.message", runProfile != null? runProfile.getName() : "Run profile", e.getMessage());
if (ApplicationManager.getApplication().isUnitTestMode()) {
LOG.assertTrue(false, message);
LOG.error(message);
}
else {
if (message.contains("87") && e instanceof ProcessNotCreatedException) {
@@ -73,7 +73,7 @@ public class LanguageFolding extends LanguageExtension<FoldingBuilder> {
return ((FoldingBuilderEx)builder).buildFoldRegions(root, document, quick);
}
final ASTNode astNode = root.getNode();
if (astNode == null) {
if (astNode == null || builder == null) {
return FoldingDescriptor.EMPTY;
}
@@ -15,7 +15,6 @@
*/
package com.intellij.psi;
import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.search.PsiElementProcessor;
import org.jetbrains.annotations.NonNls;
@@ -27,7 +26,7 @@ import org.jetbrains.annotations.Nullable;
*
* @author ven
*/
public interface PsiFileSystemItem extends PsiCheckedRenameElement, NavigationItem {
public interface PsiFileSystemItem extends PsiCheckedRenameElement, NavigatablePsiElement {
boolean isDirectory();
@Nullable
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.DefaultJDOMExternalizer;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.ArrayUtil;
import com.intellij.util.xmlb.annotations.AbstractCollection;
import com.intellij.util.xmlb.annotations.Property;
import org.jdom.Element;
@@ -127,13 +128,11 @@ public class CodeInsightSettings implements PersistentStateComponent<Element>, C
public boolean OPTIMIZE_IMPORTS_ON_THE_FLY = false;
public boolean ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = false;
@Property(surroundWithTag = false)
@AbstractCollection(
@Property(surroundWithTag = false) @AbstractCollection(
surroundWithTag = false,
elementTag = "EXCLUDED_PACKAGE",
elementValueAttribute = "NAME"
)
public String[] EXCLUDED_PACKAGES = new String[0];
elementValueAttribute = "NAME")
public String[] EXCLUDED_PACKAGES = ArrayUtil.EMPTY_STRING_ARRAY;
public void loadState(final Element state) {
try {
@@ -396,7 +396,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
if (fileCopy == null) {
PsiElement elementAfterCommit = findElementAt(hostFile, hostStartOffset);
if (wasInjected) {
LOG.assertTrue(false, "No injected fragmnent found at offset " + hostStartOffset + " in the patched file copy, found: " + elementAfterCommit);
LOG.error("No injected fragmnent found at offset " + hostStartOffset + " in the patched file copy, found: " + elementAfterCommit);
}
fileCopy = elementAfterCommit == null ? oldFileCopy : elementAfterCommit.getContainingFile();
}
@@ -420,11 +420,8 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
final String allDoc = hostFile.getViewProvider().getDocument().getText();
String docText = allDoc.substring(Math.max(0, context.getStartOffset() - 10), Math.min(allDoc.length(), context.getStartOffset() + 10));
LOG.assertTrue(false, "offset " + newContext.getStartOffset() + " at:\n" +
"text=\"" + injectedFile.getText() + "\"\n" +
"instance=" + injectedFile + "\n" +
"patcher=" + patcher + "\n" +
"docText=" + docText);
LOG.error("offset " + newContext.getStartOffset() + " at:\n" + "text=\"" + injectedFile.getText() + "\"\n" + "instance=" +
injectedFile + "\n" + "patcher=" + patcher + "\n" + "docText=" + docText);
}
EditorFactory.getInstance().releaseEditor(editor);
return Pair.create(newContext, element);
@@ -433,7 +430,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
}
PsiElement element = findElementAt(fileCopy, context.getStartOffset());
if (element == null) {
LOG.assertTrue(false, "offset " + context.getStartOffset() + " at:\ntext=\"" + fileCopy.getText() + "\"\ninstance=" + fileCopy);
LOG.error("offset " + context.getStartOffset() + " at:\ntext=\"" + fileCopy.getText() + "\"\ninstance=" + fileCopy);
}
return Pair.create(context, element);
}
@@ -463,7 +460,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
Project project = context.project;
Editor editor = context.editor;
if (!ApplicationManager.getApplication().isUnitTestMode() && context.editor.getComponent().getRootPane() == null) {
LOG.assertTrue(false, "null root pane");
LOG.error("null root pane");
}
for (final CompletionContributor contributor : CompletionContributor.forParameters(parameters)) {
@@ -248,7 +248,7 @@ public class CompletionData {
s = ((PresentableLookupValue)object).getPresentation();
}
else {
LOG.assertTrue(false, "Null string for object: " + object + " of class " + (object != null ?object.getClass():null));
LOG.error("Null string for object: " + object + " of class " + (object != null ? object.getClass() : null));
}
LookupItem item = new LookupItem(object, s);
@@ -311,7 +311,7 @@ public class CompletionData {
for (Object completion : completions) {
if (completion == null) {
LOG.assertTrue(false, "Position=" + position + "\n;Reference=" + reference + "\n;variants=" + Arrays.toString(completions));
LOG.error("Position=" + position + "\n;Reference=" + reference + "\n;variants=" + Arrays.toString(completions));
}
if (completion instanceof PsiElement) {
final PsiElement psiElement = (PsiElement)completion;
@@ -31,9 +31,11 @@ import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.util.Processor;
@@ -78,13 +80,26 @@ public class IdentifierHighlighterPass extends TextEditorHighlightingPass {
return;
}
final PsiElement myTarget = TargetElementUtilBase.getInstance().findTargetElement(myEditor, TargetElementUtilBase.ELEMENT_NAME_ACCEPTED | TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED, myCaretOffset);
int flags = TargetElementUtilBase.ELEMENT_NAME_ACCEPTED | TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED;
PsiElement myTarget = TargetElementUtilBase.getInstance().findTargetElement(myEditor, flags, myCaretOffset);
if (myTarget == null) {
if (!PsiDocumentManager.getInstance(myProject).isUncommited(myEditor.getDocument())) {
// when document is committed, try to check injected stuff - it's fast
Editor injectedEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(myEditor, myFile, myCaretOffset);
if (injectedEditor != null) {
myTarget = TargetElementUtilBase.getInstance().findTargetElement(injectedEditor, flags, injectedEditor.getCaretModel().getOffset());
}
}
}
if (myTarget != null) {
final ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(myTarget);
final PsiElement finalMyTarget = myTarget;
ReferencesSearch.search(myTarget, new LocalSearchScope(myFile)).forEach(new Processor<PsiReference>() {
public boolean process(final PsiReference psiReference) {
final TextRange textRange = HighlightUsagesHandler.getRangeToHighlight(psiReference);
if (detector == null || detector.getReferenceAccess(myTarget, psiReference) == ReadWriteAccessDetector.Access.Read) {
if (detector == null || detector.getReferenceAccess(finalMyTarget, psiReference) == ReadWriteAccessDetector.Access.Read) {
myReadAccessRanges.add(textRange);
}
else {
@@ -118,12 +118,12 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
inspect(tools, iManager, true, true);
}
public void doInspectInBatch(final InspectionManagerEx iManager, InspectionProfileEntry[] toolWrappers, boolean ignoreSuppressed) {
public void doInspectInBatch(final InspectionManagerEx iManager, List<InspectionProfileEntry> toolWrappers, boolean ignoreSuppressed) {
myDescriptors = new ArrayList<ProblemDescriptor>();
myLevels = new ArrayList<HighlightInfoType>();
myTools = new ArrayList<LocalInspectionTool>();
Map<LocalInspectionTool, LocalInspectionToolWrapper> tool2Wrapper = new THashMap<LocalInspectionTool, LocalInspectionToolWrapper>(toolWrappers.length);
Map<LocalInspectionTool, LocalInspectionToolWrapper> tool2Wrapper = new THashMap<LocalInspectionTool, LocalInspectionToolWrapper>(toolWrappers.size());
for (InspectionProfileEntry toolWrapper : toolWrappers) {
tool2Wrapper.put(((LocalInspectionToolWrapper)toolWrapper).getTool(), (LocalInspectionToolWrapper)toolWrapper);
}
@@ -131,7 +131,7 @@ public class DocumentationComponent extends JPanel implements Disposable {
myText = "";
myEditorPane.setEditable(false);
myEditorPane.setBackground(HintUtil.INFORMATION_COLOR);
myEditorPane.setEditorKit(UIUtil.getHTMLEditorKit());
myScrollPane = new JScrollPane(myEditorPane);
myScrollPane.setBorder(null);
@@ -269,7 +269,7 @@ public class DocumentationComponent extends JPanel implements Disposable {
myForwardStack.clear();
}
updateControlState();
setData(element, text, !clean);
setData(element, text, clearHistory);
if (clean) {
myIsEmpty = false;
}
@@ -90,14 +90,13 @@ public class BackspaceHandler extends EditorWriteActionHandler {
myOriginalHandler.execute(editor, dataContext);
if (offset >= editor.getDocument().getTextLength()) return true;
for(BackspaceHandlerDelegate delegate: delegates) {
if (delegate.charDeleted(c, file, editor)) {
return true;
}
}
if (offset >= editor.getDocument().getTextLength()) return true;
chars = editor.getDocument().getCharsSequence();
if (c == '(' || c == '[' || c == '{'){

Some files were not shown because too many files have changed in this diff Show More