mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
+31
-10
@@ -579,7 +579,30 @@ public class HighlightMethodUtil {
|
||||
}
|
||||
|
||||
private static String esctrim(@NotNull String s) {
|
||||
return XmlStringUtil.escapeString(StringUtil.first(s, 40, true));
|
||||
return XmlStringUtil.escapeString(trimNicely(s));
|
||||
}
|
||||
|
||||
private static String trimNicely(String s) {
|
||||
if (s.length() <= 40) return s;
|
||||
|
||||
List<TextRange> wordIndices = StringUtil.getWordIndicesIn(s);
|
||||
if (wordIndices.size() > 2) {
|
||||
int firstWordEnd = wordIndices.get(0).getEndOffset();
|
||||
|
||||
// try firstWord...remainder
|
||||
for (int i = 1; i<wordIndices.size();i++) {
|
||||
int stringLength = firstWordEnd + s.length() - wordIndices.get(i).getStartOffset();
|
||||
if (stringLength <= 40) {
|
||||
return s.substring(0, firstWordEnd) + "..." + s.substring(wordIndices.get(i).getStartOffset());
|
||||
}
|
||||
}
|
||||
}
|
||||
// maybe one last word will fit?
|
||||
if (!wordIndices.isEmpty() && s.length() - wordIndices.get(wordIndices.size()-1).getStartOffset() <= 40) {
|
||||
return "..." + s.substring(wordIndices.get(wordIndices.size()-1).getStartOffset());
|
||||
}
|
||||
|
||||
return StringUtil.last(s, 40, true).toString();
|
||||
}
|
||||
|
||||
private static String createMismatchedArgumentsHtmlTooltip(PsiExpressionList list,
|
||||
@@ -615,7 +638,8 @@ public class HighlightMethodUtil {
|
||||
for (int i = 0; i < Math.max(parameters.length,expressions.length); i++) {
|
||||
PsiParameter parameter = i < parameters.length ? parameters[i] : null;
|
||||
PsiExpression expression = i < expressions.length ? expressions[i] : null;
|
||||
@NonNls String mismatchColor = showShortType(i, parameters, expressions, substitutor) ? null : "red";
|
||||
boolean showShort = showShortType(i, parameters, expressions, substitutor);
|
||||
@NonNls String mismatchColor = showShort ? null : "red";
|
||||
|
||||
s += "<tr" + (i % 2 == 0 ? " style='background-color: #eeeeee'" : "") + ">";
|
||||
s += "<td><b><nobr>";
|
||||
@@ -631,9 +655,7 @@ public class HighlightMethodUtil {
|
||||
if (parameter != null) {
|
||||
PsiType type = substitutor.substitute(parameter.getType());
|
||||
s += "<font " + (mismatchColor == null ? "" : "color=" + mismatchColor) + ">" +
|
||||
esctrim(showShortType(i, parameters, expressions, substitutor)
|
||||
? type.getPresentableText()
|
||||
: HighlightUtil.formatType(type))
|
||||
esctrim(showShort ? type.getPresentableText() : HighlightUtil.formatType(type))
|
||||
+ "</font>"
|
||||
;
|
||||
}
|
||||
@@ -666,12 +688,11 @@ public class HighlightMethodUtil {
|
||||
PsiExpression expression = expressions[i];
|
||||
PsiType type = expression.getType();
|
||||
|
||||
@NonNls String mismatchColor = showShortType(i, parameters, expressions, substitutor) ? null : "red";
|
||||
boolean showShort = showShortType(i, parameters, expressions, substitutor);
|
||||
@NonNls String mismatchColor = showShort ? null : "red";
|
||||
ms += "<td> " + "<b><nobr>" + (i == 0 ? "(" : "")
|
||||
+ "<font " + (mismatchColor == null ? "" : "color=" + mismatchColor) + ">" +
|
||||
XmlStringUtil.escapeString(showShortType(i, parameters, expressions, substitutor)
|
||||
? type.getPresentableText()
|
||||
: HighlightUtil.formatType(type))
|
||||
+ "<font " + (showShort ? "" : "color=" + mismatchColor) + ">" +
|
||||
XmlStringUtil.escapeString(showShort ? type.getPresentableText() : HighlightUtil.formatType(type))
|
||||
+ "</font>"
|
||||
+ (i == expressions.length - 1 ? ")" : ",") + "</nobr></b></td>";
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@ public class RefClassImpl extends RefJavaElementImpl implements RefClass {
|
||||
final PsiClass applet = getRefJavaManager().getApplet();
|
||||
setApplet(applet != null && psiClass.isInheritor(applet, true));
|
||||
getRefManager().fireNodeInitialized(this);
|
||||
getRefManager().getPsiManager().dropResolveCaches();
|
||||
}
|
||||
|
||||
private void initializeSuperReferences(PsiClass psiClass) {
|
||||
|
||||
@@ -87,7 +87,8 @@ public class DeclarationParser {
|
||||
}
|
||||
error.error(JavaErrorMessages.message("expected.lbrace"));
|
||||
}
|
||||
else {
|
||||
|
||||
if (builder.getTokenType() == JavaTokenType.LBRACE) {
|
||||
parseClassBodyWithBraces(builder, isAnnotation, isEnum);
|
||||
}
|
||||
|
||||
@@ -245,7 +246,8 @@ public class DeclarationParser {
|
||||
|
||||
if (expect(builder, JavaTokenType.AT)) {
|
||||
if (builder.getTokenType() == JavaTokenType.INTERFACE_KEYWORD) {
|
||||
return parseClassFromKeyword(builder, declaration, true, context);
|
||||
final PsiBuilder.Marker result = parseClassFromKeyword(builder, declaration, true, context);
|
||||
return result != null ? result : modList;
|
||||
}
|
||||
else {
|
||||
declaration.rollbackTo();
|
||||
@@ -445,6 +447,7 @@ public class DeclarationParser {
|
||||
builder.advanceLexer();
|
||||
|
||||
PsiBuilder.Marker invalidElements = null;
|
||||
String errorMessage = null;
|
||||
boolean commaExpected = false;
|
||||
int paramCount = 0;
|
||||
while (true) {
|
||||
@@ -454,15 +457,19 @@ public class DeclarationParser {
|
||||
if (noLastParam) {
|
||||
error(builder, JavaErrorMessages.message("expected.identifier.or.type"));
|
||||
}
|
||||
if (builder.getTokenType() == JavaTokenType.RPARENTH) {
|
||||
if (tokenType == JavaTokenType.RPARENTH) {
|
||||
if (invalidElements != null) {
|
||||
invalidElements.error(commaExpected ? JavaErrorMessages.message("expected.comma") : JavaErrorMessages.message("expected.parameter"));
|
||||
invalidElements.error(errorMessage);
|
||||
}
|
||||
invalidElements = null;
|
||||
builder.advanceLexer();
|
||||
}
|
||||
else {
|
||||
if (!noLastParam) {
|
||||
if (invalidElements != null) {
|
||||
invalidElements.error(errorMessage);
|
||||
}
|
||||
invalidElements = null;
|
||||
error(builder, JavaErrorMessages.message("expected.rparen"));
|
||||
}
|
||||
}
|
||||
@@ -473,7 +480,7 @@ public class DeclarationParser {
|
||||
if (builder.getTokenType() == JavaTokenType.COMMA) {
|
||||
commaExpected = false;
|
||||
if (invalidElements != null) {
|
||||
invalidElements.error(JavaErrorMessages.message("expected.parameter"));
|
||||
invalidElements.error(errorMessage);
|
||||
invalidElements = null;
|
||||
}
|
||||
builder.advanceLexer();
|
||||
@@ -485,7 +492,7 @@ public class DeclarationParser {
|
||||
if (param != null) {
|
||||
commaExpected = true;
|
||||
if (invalidElements != null) {
|
||||
invalidElements.errorBefore(JavaErrorMessages.message("expected.comma"), param);
|
||||
invalidElements.errorBefore(errorMessage, param);
|
||||
invalidElements = null;
|
||||
}
|
||||
paramCount++;
|
||||
@@ -501,6 +508,7 @@ public class DeclarationParser {
|
||||
}
|
||||
else {
|
||||
invalidElements = builder.mark();
|
||||
errorMessage = commaExpected ? JavaErrorMessages.message("expected.comma") : JavaErrorMessages.message("expected.parameter");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,7 +520,7 @@ public class DeclarationParser {
|
||||
}
|
||||
|
||||
if (invalidElements != null) {
|
||||
invalidElements.error(commaExpected ? JavaErrorMessages.message("expected.comma") : JavaErrorMessages.message("expected.parameter"));
|
||||
invalidElements.error(errorMessage);
|
||||
}
|
||||
|
||||
paramList.done(JavaElementType.PARAMETER_LIST);
|
||||
@@ -545,7 +553,7 @@ public class DeclarationParser {
|
||||
else {
|
||||
error(builder, JavaErrorMessages.message("expected.identifier"));
|
||||
param.drop();
|
||||
return type;
|
||||
return modListInfo.first;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,8 +742,8 @@ public class DeclarationParser {
|
||||
PsiBuilder.Marker pair = builder.mark();
|
||||
|
||||
if (mayBeSimple) {
|
||||
final PsiBuilder.Marker value = parseAnnotationValue(builder);
|
||||
if (value != null && builder.getTokenType() != JavaTokenType.EQ) {
|
||||
parseAnnotationValue(builder);
|
||||
if (builder.getTokenType() != JavaTokenType.EQ) {
|
||||
pair.done(JavaElementType.NAME_VALUE_PAIR);
|
||||
return false;
|
||||
}
|
||||
@@ -755,9 +763,9 @@ public class DeclarationParser {
|
||||
return hasName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
private static PsiBuilder.Marker parseAnnotationValue(final PsiBuilder builder) {
|
||||
final PsiBuilder.Marker result;
|
||||
PsiBuilder.Marker result;
|
||||
|
||||
final IElementType tokenType = builder.getTokenType();
|
||||
if (tokenType == JavaTokenType.AT) {
|
||||
@@ -771,8 +779,10 @@ public class DeclarationParser {
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
error(builder, JavaErrorMessages.message("expected.value"));
|
||||
result = builder.mark();
|
||||
result.error(JavaErrorMessages.message("expected.value"));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static com.intellij.lang.PsiBuilderUtil.expect;
|
||||
import static com.intellij.lang.java.parser.JavaParserUtil.*;
|
||||
|
||||
|
||||
@@ -502,7 +503,11 @@ public class ExpressionParser {
|
||||
error(builder, JavaErrorMessages.message("expected.expression"));
|
||||
}
|
||||
|
||||
JavaParserUtil.expectOrError(builder, JavaTokenType.RPARENTH, JavaErrorMessages.message("expected.rparen"));
|
||||
if (!expect(builder, JavaTokenType.RPARENTH)) {
|
||||
if (inner != null) {
|
||||
error(builder, JavaErrorMessages.message("expected.rparen"));
|
||||
}
|
||||
}
|
||||
|
||||
parenth.done(JavaElementType.PARENTH_EXPRESSION);
|
||||
return parenth;
|
||||
|
||||
@@ -172,7 +172,9 @@ public class ReferenceParser {
|
||||
parseReferenceParameterList(builder, true);
|
||||
}
|
||||
else {
|
||||
emptyElement(builder, JavaElementType.REFERENCE_PARAMETER_LIST);
|
||||
if (!isStaticImport || builder.getTokenType() == JavaTokenType.DOT) {
|
||||
emptyElement(builder, JavaElementType.REFERENCE_PARAMETER_LIST);
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasIdentifier;
|
||||
@@ -210,6 +212,7 @@ public class ReferenceParser {
|
||||
}
|
||||
else {
|
||||
error(builder, JavaErrorMessages.message("expected.identifier"));
|
||||
emptyElement(builder, JavaElementType.REFERENCE_PARAMETER_LIST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ConcurrentSoftHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -37,7 +38,7 @@ public class JavaConstantExpressionEvaluator extends JavaRecursiveElementWalking
|
||||
|
||||
private static final Key<CachedValue<ConcurrentMap<PsiElement,Object>>> CONSTANT_VALUE_WO_OVERFLOW_MAP_KEY = Key.create("CONSTANT_VALUE_WO_OVERFLOW_MAP_KEY");
|
||||
private static final Key<CachedValue<ConcurrentMap<PsiElement,Object>>> CONSTANT_VALUE_WITH_OVERFLOW_MAP_KEY = Key.create("CONSTANT_VALUE_WITH_OVERFLOW_MAP_KEY");
|
||||
private static final Object NO_VALUE = new Object();
|
||||
private static final Object NO_VALUE = ObjectUtils.NULL;
|
||||
private final ConstantExpressionVisitor myConstantExpressionVisitor;
|
||||
|
||||
private JavaConstantExpressionEvaluator(Set<PsiVariable> visitedVars, final boolean throwExceptionOnOverflow, final Project project, final PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// "Make 'a' extend 'b'" "true"
|
||||
<caret>class a extends b {
|
||||
<caret>// "Make 'a' extend 'b'" "true"
|
||||
class a extends b {
|
||||
void f(b b, Runnable r) {
|
||||
f(this, null);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
@Ann(<error descr="Cannot find method 'value'">0</error>) class D {
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
PsiJavaFile:Errors.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiClass:D
|
||||
PsiModifierList:@Ann(<error descr="Cannot find method 'value'">0</error>)
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:Ann
|
||||
PsiIdentifier:Ann('Ann')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiNameValuePair
|
||||
PsiErrorElement:Value expected
|
||||
<empty list>
|
||||
PsiErrorElement:',' or ')' expected
|
||||
<empty list>
|
||||
PsiJavaToken:LT('<')
|
||||
PsiNameValuePair
|
||||
PsiIdentifier:error('error')
|
||||
PsiErrorElement:'=' expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceExpression:descr
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:descr('descr')
|
||||
PsiErrorElement:',' or ')' expected
|
||||
<empty list>
|
||||
PsiJavaToken:EQ('=')
|
||||
PsiNameValuePair
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiErrorElement:'=' expected
|
||||
<empty list>
|
||||
PsiBinaryExpression:"Cannot find method 'value'">0<
|
||||
PsiBinaryExpression:"Cannot find method 'value'">0
|
||||
PsiLiteralExpression:"Cannot find method 'value'"
|
||||
PsiJavaToken:STRING_LITERAL('"Cannot find method 'value'"')
|
||||
PsiJavaToken:GT('>')
|
||||
PsiLiteralExpression:0
|
||||
PsiJavaToken:INTEGER_LITERAL('0')
|
||||
PsiJavaToken:LT('<')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiErrorElement:',' or ')' expected
|
||||
<empty list>
|
||||
PsiJavaToken:DIV('/')
|
||||
PsiNameValuePair
|
||||
PsiIdentifier:error('error')
|
||||
PsiErrorElement:'=' expected
|
||||
<empty list>
|
||||
PsiErrorElement:Value expected
|
||||
<empty list>
|
||||
PsiErrorElement:',' or ')' expected
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:class('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:D('D')
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
PsiJavaFile:Simple.java
|
||||
PsiJavaFile:Simple1.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiClass:TimeTravel
|
||||
@@ -0,0 +1,3 @@
|
||||
class C {
|
||||
BCSSChild.<error descr="">BCSSCServiceClassRef</error> fd = null;
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
PsiJavaFile:RefParamsAfterError.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiClass:C
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:class('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:C('C')
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:BCSSChild.
|
||||
PsiJavaCodeReferenceElement:BCSSChild.
|
||||
PsiJavaCodeReferenceElement:BCSSChild
|
||||
PsiIdentifier:BCSSChild('BCSSChild')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:DOT('.')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiErrorElement:Unexpected token
|
||||
PsiTypeParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeParameter:error
|
||||
PsiIdentifier:error('error')
|
||||
PsiElement(EXTENDS_BOUND_LIST)
|
||||
<empty list>
|
||||
PsiErrorElement:'>' expected.
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiTypeElement:descr
|
||||
PsiJavaCodeReferenceElement:descr
|
||||
PsiIdentifier:descr('descr')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiErrorElement:Unexpected token
|
||||
PsiJavaToken:EQ('=')
|
||||
PsiJavaToken:STRING_LITERAL('""')
|
||||
PsiJavaToken:GT('>')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:BCSSCServiceClassRef<
|
||||
PsiJavaCodeReferenceElement:BCSSCServiceClassRef<
|
||||
PsiIdentifier:BCSSCServiceClassRef('BCSSCServiceClassRef')
|
||||
PsiReferenceParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiErrorElement:'>' or ',' expected.
|
||||
<empty list>
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiErrorElement:Unexpected token
|
||||
PsiJavaToken:DIV('/')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:error
|
||||
PsiJavaCodeReferenceElement:error
|
||||
PsiIdentifier:error('error')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiErrorElement:Unexpected token
|
||||
PsiJavaToken:GT('>')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:fd
|
||||
PsiJavaCodeReferenceElement:fd
|
||||
PsiIdentifier:fd('fd')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected token
|
||||
PsiJavaToken:EQ('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:NULL_KEYWORD('null')
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
PsiJavaFile:Error.java
|
||||
PsiJavaFile:Errors0.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiModifierList:public
|
||||
@@ -0,0 +1,4 @@
|
||||
// "Replace Implements with Static Import" "true"
|
||||
interface I<caret>n {
|
||||
int FOO = 0;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
PsiJavaFile:Errors1.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiClass:I
|
||||
PsiComment(END_OF_LINE_COMMENT)('// "Replace Implements with Static Import" "true"')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:interface('interface')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:I('I')
|
||||
PsiTypeParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeParameter:caret
|
||||
PsiIdentifier:caret('caret')
|
||||
PsiElement(EXTENDS_BOUND_LIST)
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiErrorElement:'{' expected
|
||||
PsiIdentifier:n('n')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiField:FOO
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:int
|
||||
PsiKeyword:int('int')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:FOO('FOO')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:EQ('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiLiteralExpression:0
|
||||
PsiJavaToken:INTEGER_LITERAL('0')
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -0,0 +1,3 @@
|
||||
public class Main {
|
||||
@interface <caret>
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
PsiJavaFile:Errors2.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiClass:Main
|
||||
PsiModifierList:public
|
||||
PsiKeyword:public('public')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:class('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:Main('Main')
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiJavaToken:AT('@')
|
||||
PsiKeyword:interface('interface')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiErrorElement:Identifier or type expected
|
||||
PsiTypeParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeParameter:caret
|
||||
PsiIdentifier:caret('caret')
|
||||
PsiElement(EXTENDS_BOUND_LIST)
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -0,0 +1,3 @@
|
||||
public class Test {
|
||||
void foo(<caret>
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
PsiJavaFile:Errors3.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiClass:Test
|
||||
PsiModifierList:public
|
||||
PsiKeyword:public('public')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:class('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:Test('Test')
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiMethod:foo
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiTypeElement:void
|
||||
PsiKeyword:void('void')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:foo('foo')
|
||||
PsiParameterList:(<caret>
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiErrorElement:Parameter expected
|
||||
PsiJavaToken:LT('<')
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:caret
|
||||
PsiJavaCodeReferenceElement:caret
|
||||
PsiIdentifier:caret('caret')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiErrorElement:',' expected
|
||||
PsiJavaToken:GT('>')
|
||||
PsiErrorElement:')' expected
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiErrorElement:'{' or ';' expected
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -0,0 +1,5 @@
|
||||
PsiJavaFile:Parenth2.java
|
||||
PsiParenthesizedExpression:(
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
@@ -0,0 +1,11 @@
|
||||
PsiJavaFile:UnclosedImport3.java
|
||||
PsiImportList
|
||||
PsiImportStaticStatement
|
||||
PsiKeyword:import('import')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:static('static')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiImportStaticReferenceElement:a
|
||||
PsiIdentifier:a('a')
|
||||
PsiErrorElement:';' expected
|
||||
<empty list>
|
||||
@@ -10,6 +10,8 @@ PsiJavaFile:UnclosedPackage1.java
|
||||
PsiJavaToken:DOT('.')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiErrorElement:';' expected
|
||||
<empty list>
|
||||
PsiImportList
|
||||
|
||||
@@ -7,3 +7,5 @@ PsiJavaFile:Reference1.java
|
||||
PsiJavaToken:DOT('.')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
@@ -21,8 +21,7 @@ public class CommonJavaParsingTest extends JavaParsingTestCase{
|
||||
}
|
||||
|
||||
public void testSCR5202() { doTest(true); }
|
||||
|
||||
public void testIncompleteCodeBlock() { doTest(true); }
|
||||
|
||||
public void testImportListBug() { doTest(true); }
|
||||
public void testRefParamsAfterError() { doTest(true); }
|
||||
}
|
||||
+3
-1
@@ -14,7 +14,7 @@ public class AnnotationParsingTest extends JavaParsingTestCase {
|
||||
}
|
||||
|
||||
public void testMarker() { doTest(true); }
|
||||
public void testSimple() { doTest(true); }
|
||||
public void testSimple1() { doTest(true); }
|
||||
public void testSimple2() { doTest(true); }
|
||||
public void testComplex() { doTest(true); }
|
||||
public void testMultiple() { doTest(true); }
|
||||
@@ -40,4 +40,6 @@ public class AnnotationParsingTest extends JavaParsingTestCase {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testErrors() { doTest(true); }
|
||||
}
|
||||
|
||||
+3
-1
@@ -37,5 +37,7 @@ public class ClassParsingTest extends JavaParsingTestCase {
|
||||
public void testExtraOpeningBraceInMethod() { doTestDefaultParser(true); } // todo: fix
|
||||
public void testExtraClosingBraceInMethod() { doTest(true); }
|
||||
|
||||
public void testError() { doTest(true); }
|
||||
public void testErrors0() { doTest(true); }
|
||||
public void testErrors1() { doTest(true); }
|
||||
public void testErrors2() { doTest(true); }
|
||||
}
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ public class MethodParsingTest extends JavaParsingTestCase {
|
||||
public void testErrors0() { doTest(true); }
|
||||
public void testErrors1() { doTest(true); }
|
||||
public void testErrors2() { doTest(true); }
|
||||
public void testErrors3() { doTest(true); }
|
||||
public void testCompletionHack() { doTest(true); }
|
||||
public void testCompletionHack1() { doTest(true); }
|
||||
|
||||
|
||||
+1
@@ -49,6 +49,7 @@ public class ExpressionParserTest extends JavaParsingTestCase {
|
||||
|
||||
public void testParenth0() { doParserTest("(c)"); }
|
||||
public void testParenth1() { doParserTest("(this).f--"); }
|
||||
public void testParenth2() { doParserTest("("); }
|
||||
|
||||
public void testNewInExprList() { doParserTest("call(new)"); }
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class FileParserTest extends JavaParsingTestCase {
|
||||
public void testUnclosedImport0() { doParserTest("import"); }
|
||||
public void testUnclosedImport1() { doParserTest("import java.awt.*"); }
|
||||
public void testUnclosedImport2() { doParserTest("import java.awt."); }
|
||||
public void testUnclosedImport3() { doParserTest("import static a"); }
|
||||
|
||||
public void testFileWithClass() { doParserTest("package a;\n" +
|
||||
"import b;\n" +
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -108,4 +109,6 @@ public abstract class RefManager {
|
||||
public abstract String getQualifiedName(RefEntity refEntity);
|
||||
|
||||
public abstract void removeRefElement(RefElement refElement, List<RefElement> deletedRefs);
|
||||
|
||||
public abstract PsiManager getPsiManager();
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ public class RefManagerImpl extends RefManager {
|
||||
private THashMap<Module, RefModule> myModules;
|
||||
private final ProjectIterator myProjectIterator;
|
||||
private boolean myDeclarationsFound;
|
||||
private final PsiManager myPsiManager;
|
||||
|
||||
private boolean myIsInProcess = false;
|
||||
|
||||
@@ -83,6 +84,7 @@ public class RefManagerImpl extends RefManager {
|
||||
myProject = project;
|
||||
myScope = scope;
|
||||
myContext = context;
|
||||
myPsiManager = PsiManager.getInstance(project);
|
||||
myRefProject = new RefProjectImpl(this);
|
||||
myRefTable = new THashMap<PsiAnchor, RefElement>();
|
||||
myProjectIterator = new ProjectIterator();
|
||||
@@ -298,6 +300,11 @@ public class RefManagerImpl extends RefManager {
|
||||
return myRefTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiManager getPsiManager() {
|
||||
return myPsiManager;
|
||||
}
|
||||
|
||||
public void removeReference(RefElement refElem) {
|
||||
myLock.writeLock().lock();
|
||||
try {
|
||||
@@ -366,6 +373,7 @@ public class RefManagerImpl extends RefManager {
|
||||
for (Language language : relevantLanguages) {
|
||||
visitElement(viewProvider.getPsi(language));
|
||||
}
|
||||
myPsiManager.dropResolveCaches();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -47,6 +47,7 @@ import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.actions.MoveAction;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ReflectionCache;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
@@ -564,7 +565,7 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl
|
||||
};
|
||||
|
||||
//FavoritesManager.getInstance(myProject).getCurrentTreeViewPanel().setDraggableObject(draggableObject.getClass(), draggableObject.getValue());
|
||||
if ((psiElements != null && psiElements.length > 0) || canDragElements(elements)) {
|
||||
if ((psiElements != null && psiElements.length > 0) || canDragElements(elements, dataContext, dge.getDragAction())) {
|
||||
dge.startDrag(DragSource.DefaultMoveNoDrop, new MyTransferable(transferableWrapper), myDragSourceListener);
|
||||
}
|
||||
}
|
||||
@@ -574,12 +575,16 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canDragElements(Object[] elements) {
|
||||
private boolean canDragElements(Object[] elements, DataContext dataContext, int dragAction) {
|
||||
for (Object element : elements) {
|
||||
if (element instanceof Module) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (dragAction == DnDConstants.ACTION_MOVE) {
|
||||
final MoveAction.MoveProvider provider = MoveAction.MoveProvider.DATA_KEY.getData(dataContext);
|
||||
return provider != null && provider.isEnabledOnDataContext(dataContext);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+54
-41
@@ -15,23 +15,22 @@
|
||||
*/
|
||||
package com.intellij.ide.util.gotoByName;
|
||||
|
||||
import com.intellij.concurrency.JobUtil;
|
||||
import com.intellij.ide.util.NavigationItemListCellRenderer;
|
||||
import com.intellij.navigation.ChooseByNameContributor;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Contributor-based goto model
|
||||
@@ -51,24 +50,41 @@ public abstract class ContributorsBasedGotoByModel implements ChooseByNameModel
|
||||
return new NavigationItemListCellRenderer();
|
||||
}
|
||||
|
||||
public String[] getNames(boolean checkBoxState) {
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (ChooseByNameContributor contributor : myContributors) {
|
||||
try {
|
||||
ContainerUtil.addAll(names, contributor.getNames(myProject, checkBoxState));
|
||||
public String[] getNames(final boolean checkBoxState) {
|
||||
final Set<String> names = new ConcurrentHashSet<String>();
|
||||
|
||||
JobUtil.invokeConcurrentlyUnderMyProgress(filterDumb(myContributors), new Processor<ChooseByNameContributor>() {
|
||||
@Override
|
||||
public boolean process(ChooseByNameContributor contributor) {
|
||||
try {
|
||||
ContainerUtil.addAll(names, contributor.getNames(myProject, checkBoxState));
|
||||
}
|
||||
catch(ProcessCanceledException ex) {
|
||||
// index corruption detected, ignore
|
||||
}
|
||||
catch(IndexNotReadyException ex) {
|
||||
// index corruption detected, ignore
|
||||
}
|
||||
catch(Exception ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch(ProcessCanceledException ex) {
|
||||
// index corruption detected, ignore
|
||||
}
|
||||
catch(IndexNotReadyException ex) {
|
||||
// index corruption detected, ignore
|
||||
}
|
||||
catch(Exception ex) {
|
||||
LOG.error(ex);
|
||||
}, false);
|
||||
|
||||
return ArrayUtil.toStringArray(names);
|
||||
}
|
||||
|
||||
private List<ChooseByNameContributor> filterDumb(ChooseByNameContributor[] contributors) {
|
||||
if (!DumbService.getInstance(myProject).isDumb()) return Arrays.asList(contributors);
|
||||
List<ChooseByNameContributor> answer = new ArrayList<ChooseByNameContributor>(contributors.length);
|
||||
for (ChooseByNameContributor contributor : contributors) {
|
||||
if (DumbService.isDumbAware(contributor)) {
|
||||
answer.add(contributor);
|
||||
}
|
||||
}
|
||||
|
||||
return ArrayUtil.toStringArray(names);
|
||||
return answer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,33 +97,30 @@ public abstract class ContributorsBasedGotoByModel implements ChooseByNameModel
|
||||
* which {@link #acceptItem(NavigationItem) returns true.
|
||||
*
|
||||
*/
|
||||
public Object[] getElementsByName(String name, boolean checkBoxState, final String pattern) {
|
||||
List<NavigationItem> items = null;
|
||||
final boolean dumb = DumbService.getInstance(myProject).isDumb();
|
||||
public Object[] getElementsByName(final String name, final boolean checkBoxState, final String pattern) {
|
||||
final List<NavigationItem> items = Collections.synchronizedList(new ArrayList<NavigationItem>());
|
||||
|
||||
for (ChooseByNameContributor contributor : myContributors) {
|
||||
try {
|
||||
if (dumb && !DumbService.isDumbAware(contributor)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (NavigationItem item : contributor.getItemsByName(name, pattern, myProject, checkBoxState)) {
|
||||
if (acceptItem(item)) {
|
||||
if (items == null) {
|
||||
items = new ArrayList<NavigationItem>(2);
|
||||
JobUtil.invokeConcurrentlyUnderMyProgress(filterDumb(myContributors), new Processor<ChooseByNameContributor>() {
|
||||
@Override
|
||||
public boolean process(ChooseByNameContributor contributor) {
|
||||
try {
|
||||
for (NavigationItem item : contributor.getItemsByName(name, pattern, myProject, checkBoxState)) {
|
||||
if (acceptItem(item)) {
|
||||
items.add(item);
|
||||
}
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException ex) {
|
||||
// index corruption detected, ignore
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch(ProcessCanceledException ex) {
|
||||
// index corruption detected, ignore
|
||||
}
|
||||
catch(Exception ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
}
|
||||
return items == null ? ArrayUtil.EMPTY_OBJECT_ARRAY : ArrayUtil.toObjectArray(items);
|
||||
}, false);
|
||||
|
||||
return ArrayUtil.toObjectArray(items);
|
||||
}
|
||||
|
||||
public String getElementName(Object element) {
|
||||
|
||||
+48
-17
@@ -62,6 +62,7 @@ import com.intellij.util.messages.MessageBusConnection;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -79,8 +80,6 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
|
||||
private final EventDispatcher<ProjectJdkListener> myProjectJdkEventDispatcher = EventDispatcher.create(ProjectJdkListener.class);
|
||||
|
||||
private final MyVirtualFilePointerListener myVirtualFilePointerListener = new MyVirtualFilePointerListener();
|
||||
|
||||
private AppListener myApplicationListener;
|
||||
|
||||
private String myProjectJdkName;
|
||||
@@ -102,7 +101,6 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
private final MessageBusConnection myConnection;
|
||||
private final VirtualFileManagerAdapter myVFSListener;
|
||||
private final BatchUpdateListener myHandler;
|
||||
private final StartupManager myStartupManager;
|
||||
|
||||
private class BatchSession {
|
||||
private int myBatchLevel = 0;
|
||||
@@ -175,7 +173,6 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
FileTypeManager fileTypeManager,
|
||||
DirectoryIndex directoryIndex,
|
||||
StartupManager startupManager) {
|
||||
myStartupManager = startupManager;
|
||||
myProject = (ProjectEx)project;
|
||||
myConnection = project.getMessageBus().connect();
|
||||
myConnection.subscribe(AppTopics.FILE_TYPES, new FileTypeListener() {
|
||||
@@ -215,6 +212,8 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
myFileTypesChanged.levelDown();
|
||||
}
|
||||
};
|
||||
|
||||
myConnection.subscribe(VirtualFilePointerListener.TOPIC, new MyVirtualFilePointerListener());
|
||||
}
|
||||
|
||||
public void registerRootsChangeUpdater(CacheUpdater updater) {
|
||||
@@ -246,7 +245,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
}
|
||||
|
||||
public VirtualFilePointerListener getVirtualFilePointerListener() {
|
||||
return myVirtualFilePointerListener;
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -629,9 +628,20 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
}
|
||||
|
||||
private void addRootsToWatch() {
|
||||
if (myProject.isDefault()) {
|
||||
return;
|
||||
}
|
||||
final Set<String> rootPaths = getAllRoots();
|
||||
if (rootPaths == null) return;
|
||||
|
||||
final Set<LocalFileSystem.WatchRequest> newRootsToWatch = LocalFileSystem.getInstance().addRootsToWatch(rootPaths, true);
|
||||
|
||||
//remove old requests after adding new ones, helps avoiding unnecessary synchronizations
|
||||
LocalFileSystem.getInstance().removeWatchedRoots(myRootsToWatch);
|
||||
myRootsToWatch = newRootsToWatch;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Set<String> getAllRoots() {
|
||||
if (myProject.isDefault()) return null;
|
||||
|
||||
final Set<String> rootPaths = new HashSet<String>();
|
||||
Module[] modules = ModuleManager.getInstance(myProject).getModules();
|
||||
for (Module module : modules) {
|
||||
@@ -679,11 +689,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
}
|
||||
}
|
||||
|
||||
final Set<LocalFileSystem.WatchRequest> newRootsToWatch = LocalFileSystem.getInstance().addRootsToWatch(rootPaths, true);
|
||||
|
||||
//remove old requests after adding new ones, helps avoiding unnecessary synchronizations
|
||||
LocalFileSystem.getInstance().removeWatchedRoots(myRootsToWatch);
|
||||
myRootsToWatch = newRootsToWatch;
|
||||
return rootPaths;
|
||||
}
|
||||
|
||||
private static Collection<String> getRootsToTrack(final Library library, final OrderRootType rootType) {
|
||||
@@ -740,12 +746,16 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
public void beforeValidityChanged(VirtualFilePointer[] pointers) {
|
||||
if (!myProject.isDisposed()) {
|
||||
if (myInsideRefresh == 0) {
|
||||
beforeRootsChange(false);
|
||||
if (affectsRoots(pointers)) {
|
||||
beforeRootsChange(false);
|
||||
}
|
||||
}
|
||||
else if (!myPointerChangesDetected) {
|
||||
//this is the first pointer changing validity
|
||||
myPointerChangesDetected = true;
|
||||
myProject.getMessageBus().syncPublisher(ProjectTopics.PROJECT_ROOTS).beforeRootsChange(new ModuleRootEventImpl(myProject, false));
|
||||
if (affectsRoots(pointers)) {
|
||||
myPointerChangesDetected = true;
|
||||
myProject.getMessageBus().syncPublisher(ProjectTopics.PROJECT_ROOTS).beforeRootsChange(new ModuleRootEventImpl(myProject, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -756,12 +766,33 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
clearScopesCaches();
|
||||
}
|
||||
else {
|
||||
rootsChanged(false);
|
||||
if (affectsRoots(pointers)) {
|
||||
rootsChanged(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean affectsRoots(VirtualFilePointer[] pointers) {
|
||||
Set<String> roots = getAllRoots();
|
||||
if (roots == null) return false;
|
||||
|
||||
for (VirtualFilePointer pointer : pointers) {
|
||||
if (roots.contains(url2path(pointer.getUrl()))) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String url2path(String url) {
|
||||
String path = VfsUtil.urlToPath(url);
|
||||
|
||||
int separatorIndex = path.indexOf(JarFileSystem.JAR_SEPARATOR);
|
||||
if (separatorIndex < 0) return path;
|
||||
return path.substring(0, separatorIndex);
|
||||
}
|
||||
|
||||
private int myInsideRefresh = 0;
|
||||
private boolean myPointerChangesDetected = false;
|
||||
|
||||
|
||||
@@ -16,14 +16,13 @@
|
||||
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.extapi.psi.StubPath;
|
||||
import com.intellij.extapi.psi.StubPathBuilder;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NullableComputable;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.impl.light.LightElement;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.impl.source.PsiFileWithStubSupport;
|
||||
@@ -32,6 +31,7 @@ import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubTree;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -211,25 +211,29 @@ public abstract class PsiAnchor {
|
||||
}
|
||||
|
||||
public static class StubIndexReference extends PsiAnchor {
|
||||
private final PsiFile myFile;
|
||||
private final VirtualFile myVirtualFile;
|
||||
private final Project myProject;
|
||||
private final int myIndex;
|
||||
|
||||
public StubIndexReference(final PsiFile file, final int index) {
|
||||
myFile = file;
|
||||
public StubIndexReference(@NotNull PsiFile file, final int index) {
|
||||
myVirtualFile = file.getVirtualFile();
|
||||
myProject = file.getProject();
|
||||
myIndex = index;
|
||||
}
|
||||
|
||||
public PsiFile getFile() {
|
||||
return myFile;
|
||||
if (myProject.isDisposed()) return null;
|
||||
return PsiManager.getInstance(myProject).findFile(myVirtualFile);
|
||||
}
|
||||
|
||||
public PsiElement retrieve() {
|
||||
return ApplicationManager.getApplication().runReadAction(new NullableComputable<PsiElement>() {
|
||||
public PsiElement compute() {
|
||||
PsiFileWithStubSupport fileImpl = (PsiFileWithStubSupport)myFile;
|
||||
PsiFileWithStubSupport fileImpl = (PsiFileWithStubSupport)getFile();
|
||||
if (fileImpl == null) return null;
|
||||
StubTree tree = fileImpl.getStubTree();
|
||||
|
||||
boolean foreign = (tree == null);
|
||||
boolean foreign = tree == null;
|
||||
if (foreign) {
|
||||
if (fileImpl instanceof PsiFileImpl) {
|
||||
tree = ((PsiFileImpl)fileImpl).calcStubTree();
|
||||
@@ -262,12 +266,12 @@ public abstract class PsiAnchor {
|
||||
|
||||
final StubIndexReference that = (StubIndexReference)o;
|
||||
|
||||
return myIndex == that.myIndex && myFile.equals(that.myFile);
|
||||
return myIndex == that.myIndex && myVirtualFile.equals(that.myVirtualFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * myFile.hashCode() + myIndex;
|
||||
return 31 * myVirtualFile.hashCode() + myIndex;
|
||||
}
|
||||
|
||||
public int getStartOffset() {
|
||||
@@ -282,56 +286,5 @@ public abstract class PsiAnchor {
|
||||
return resolved.getTextRange().getEndOffset();
|
||||
}
|
||||
}
|
||||
|
||||
private static class StubPathReference extends PsiAnchor {
|
||||
private final PsiFile myFile;
|
||||
private final StubPath myPath;
|
||||
|
||||
public StubPathReference(final PsiFile file, final StubPath path) {
|
||||
myFile = file;
|
||||
myPath = path;
|
||||
}
|
||||
|
||||
public PsiElement retrieve() {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<PsiElement>() {
|
||||
public PsiElement compute() {
|
||||
return StubPathBuilder.resolve(myFile, myPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public PsiFile getFile() {
|
||||
return myFile;
|
||||
}
|
||||
|
||||
public int getStartOffset() {
|
||||
final PsiElement resolved = retrieve();
|
||||
if (resolved == null) throw new PsiInvalidElementAccessException(null);
|
||||
return resolved.getTextRange().getStartOffset();
|
||||
}
|
||||
|
||||
public int getEndOffset() {
|
||||
final PsiElement resolved = retrieve();
|
||||
if (resolved == null) throw new PsiInvalidElementAccessException(null);
|
||||
return resolved.getTextRange().getEndOffset();
|
||||
}
|
||||
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
if (o instanceof StubPathReference) {
|
||||
final StubPathReference that = (StubPathReference)o;
|
||||
return myFile.equals(that.myFile) && myPath.equals(that.myPath);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return 31 * myFile.hashCode() + myPath.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,15 +24,14 @@
|
||||
*/
|
||||
package com.intellij.psi.impl;
|
||||
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.ParameterizedCachedValueProvider;
|
||||
import com.intellij.psi.util.ParameterizedCachedValue;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.ParameterizedCachedValue;
|
||||
import com.intellij.psi.util.ParameterizedCachedValueProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.*;
|
||||
import static com.intellij.util.ObjectUtils.NULL;
|
||||
|
||||
public abstract class PsiParameterizedCachedValue<T,P> extends PsiCachedValue<T> implements ParameterizedCachedValue<T,P> {
|
||||
|
||||
@@ -45,16 +44,9 @@ public abstract class PsiParameterizedCachedValue<T,P> extends PsiCachedValue<T>
|
||||
|
||||
@Nullable
|
||||
public T getValue(P param) {
|
||||
r.lock();
|
||||
|
||||
T value;
|
||||
try {
|
||||
value = getUpToDateOrNull();
|
||||
if (value != null) {
|
||||
return value == NULL ? null : value;
|
||||
}
|
||||
} finally {
|
||||
r.unlock();
|
||||
T value = getUpToDateOrNull();
|
||||
if (value != null) {
|
||||
return value == NULL ? null : value;
|
||||
}
|
||||
|
||||
w.lock();
|
||||
|
||||
@@ -25,7 +25,7 @@ public interface Queryable {
|
||||
|
||||
void putInfo(Map<String, String> info);
|
||||
|
||||
static class PrintInfo {
|
||||
class PrintInfo {
|
||||
String[] myIdKeys;
|
||||
String[] myInfoKeys;
|
||||
|
||||
@@ -43,7 +43,7 @@ public interface Queryable {
|
||||
}
|
||||
}
|
||||
|
||||
static class Util {
|
||||
class Util {
|
||||
@Nullable
|
||||
public static String print(@NotNull Queryable ui, @Nullable PrintInfo printInfo, @Nullable Contributor contributor) {
|
||||
PrintInfo print = printInfo != null ? printInfo : new PrintInfo();
|
||||
@@ -65,7 +65,7 @@ public interface Queryable {
|
||||
}
|
||||
}
|
||||
|
||||
if (map.size() > 0) {
|
||||
if (!map.isEmpty()) {
|
||||
id = map.values().iterator().next();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,17 @@
|
||||
*/
|
||||
package com.intellij.openapi.ui.popup.util;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class PopupUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.ui.popup.util.PopupUtil");
|
||||
|
||||
private PopupUtil() {
|
||||
}
|
||||
@@ -46,4 +50,29 @@ public class PopupUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPopupType(@NotNull final PopupFactory factory, final int type) {
|
||||
try {
|
||||
final Method method = PopupFactory.class.getDeclaredMethod("setPopupType", int.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(factory, type);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getPopupType(@NotNull final PopupFactory factory) {
|
||||
try {
|
||||
final Method method = PopupFactory.class.getDeclaredMethod("getPopupType");
|
||||
method.setAccessible(true);
|
||||
final Object result = method.invoke(factory);
|
||||
return result instanceof Integer ? (Integer) result : -1;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -15,7 +15,11 @@
|
||||
*/
|
||||
package com.intellij.openapi.vfs.pointers;
|
||||
|
||||
import com.intellij.util.messages.Topic;
|
||||
|
||||
public interface VirtualFilePointerListener {
|
||||
Topic<VirtualFilePointerListener> TOPIC = Topic.create("VirtualFilePointer", VirtualFilePointerListener.class);
|
||||
|
||||
void beforeValidityChanged(VirtualFilePointer[] pointers);
|
||||
void validityChanged(VirtualFilePointer[] pointers);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public abstract class CachedValuesManager {
|
||||
|
||||
public <T, D extends UserDataHolder> T getCachedValue(@NotNull D dataHolder,
|
||||
@NotNull CachedValueProvider<T> provider) {
|
||||
return getCachedValue(dataHolder, new MemoizationKey<CachedValue<T>>("$CachedValue$" + provider.getClass().getName()), provider, false);
|
||||
return getCachedValue(dataHolder, new MemoizationKey<CachedValue<T>>(provider.getClass().getName()), provider, false);
|
||||
}
|
||||
|
||||
public static class MemoizationKey<T> extends Key<T> {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
private Rectangle myLastVisibleRec;
|
||||
|
||||
private Dimension myHoldSize;
|
||||
private MySelectionModel mySelectionModel = new MySelectionModel();
|
||||
private final MySelectionModel mySelectionModel = new MySelectionModel();
|
||||
|
||||
public Tree() {
|
||||
initTree_();
|
||||
@@ -185,7 +185,6 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
Rectangle clip = g.getClipBounds();
|
||||
final Rectangle visible = getVisibleRect();
|
||||
|
||||
if (!AbstractTreeBuilder.isToPaintSelection(this)) {
|
||||
@@ -237,7 +236,8 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
if (myBusy) {
|
||||
myBusyIcon.resume();
|
||||
myBusyIcon.setToolTipText("Update is in progress. Click to cancel");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
myBusyIcon.suspend();
|
||||
myBusyIcon.setToolTipText(null);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@@ -567,8 +567,8 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
if (paths == null) return (T[])Array.newInstance(nodeType, 0);
|
||||
|
||||
ArrayList<T> nodes = new ArrayList<T>();
|
||||
for (int i = 0; i < paths.length; i++) {
|
||||
Object last = paths[i].getLastPathComponent();
|
||||
for (TreePath path : paths) {
|
||||
Object last = path.getLastPathComponent();
|
||||
if (nodeType.isAssignableFrom(last.getClass())) {
|
||||
if (filter != null && !filter.accept((T)last)) continue;
|
||||
nodes.add((T)last);
|
||||
@@ -607,11 +607,6 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reshape(int x, int y, int w, int h) {
|
||||
super.reshape(x, y, w, h);
|
||||
}
|
||||
|
||||
public void setHoldSize(boolean hold) {
|
||||
if (hold && myHoldSize == null) {
|
||||
myHoldSize = getPreferredSize();
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.idea.StartupUtil;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.util.PopupUtil;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
@@ -308,10 +309,8 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
}
|
||||
|
||||
popupWeight = popupWeight.trim();
|
||||
final boolean heavyWeighPopup = HEAVY_WEIGHT_POPUP.equals(popupWeight);
|
||||
|
||||
PopupFactory popupFactory;
|
||||
|
||||
final PopupFactory oldFactory = PopupFactory.getSharedInstance();
|
||||
if (!(oldFactory instanceof OurPopupFactory)) {
|
||||
popupFactory = new OurPopupFactory() {
|
||||
@@ -322,20 +321,17 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
int y
|
||||
) throws IllegalArgumentException {
|
||||
final Point point = fixPopupLocation(contents, x, y);
|
||||
try {
|
||||
final Method method = PopupFactory.class.getDeclaredMethod("setPopupType", int.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(oldFactory, heavyWeighPopup ? 2 : 1);
|
||||
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
final int popupType = PopupUtil.getPopupType(this);
|
||||
if (popupType >= 0) {
|
||||
PopupUtil.setPopupType(oldFactory, popupType);
|
||||
}
|
||||
|
||||
return oldFactory.getPopup(owner, contents, point.x, point.y);
|
||||
}
|
||||
};
|
||||
|
||||
PopupUtil.setPopupType(popupFactory, HEAVY_WEIGHT_POPUP.equals(popupWeight) ? 2 : 1);
|
||||
PopupFactory.setSharedInstance(popupFactory);
|
||||
}
|
||||
|
||||
|
||||
+20
-8
@@ -50,6 +50,7 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
// guarded by myContainers
|
||||
private final Set<VirtualFilePointerContainerImpl> myContainers = new THashSet<VirtualFilePointerContainerImpl>(TObjectHashingStrategy.IDENTITY);
|
||||
private final VirtualFileManagerEx myVirtualFileManager;
|
||||
private MessageBus myBus;
|
||||
private static final Comparator<String> COMPARATOR = SystemInfo.isFileSystemCaseSensitive ? new Comparator<String>() {
|
||||
public int compare(@NotNull String url1, @NotNull String url2) {
|
||||
return url1.compareTo(url2);
|
||||
@@ -62,6 +63,7 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
|
||||
VirtualFilePointerManagerImpl(@NotNull VirtualFileManagerEx virtualFileManagerEx, MessageBus bus) {
|
||||
myVirtualFileManager = virtualFileManagerEx;
|
||||
myBus = bus;
|
||||
bus.connect().subscribe(VirtualFileManager.VFS_CHANGES, new VFSEventsProcessor());
|
||||
}
|
||||
|
||||
@@ -102,12 +104,12 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
}
|
||||
}
|
||||
|
||||
private List<VirtualFilePointer> getPointersUnder(String path) {
|
||||
private List<VirtualFilePointer> getPointersUnder(String path, boolean allowSameFSOptimization) {
|
||||
final List<VirtualFilePointer> pointers = new ArrayList<VirtualFilePointer>();
|
||||
final boolean urlFromJarFS = path.indexOf(JarFileSystem.JAR_SEPARATOR) > 0;
|
||||
final boolean urlFromJarFS = allowSameFSOptimization && path.indexOf(JarFileSystem.JAR_SEPARATOR) > 0;
|
||||
for (TreeMap<String, VirtualFilePointerImpl> urlToPointer : myUrlToPointerMaps.values()) {
|
||||
for (String pointerUrl : urlToPointer.keySet()) {
|
||||
final boolean pointerFromJarFS = pointerUrl.indexOf(JarFileSystem.JAR_SEPARATOR) > 0;
|
||||
final boolean pointerFromJarFS = allowSameFSOptimization && pointerUrl.indexOf(JarFileSystem.JAR_SEPARATOR) > 0;
|
||||
if (urlFromJarFS != pointerFromJarFS) {
|
||||
continue; // optimization: consider pointers from the same FS as the url specified
|
||||
}
|
||||
@@ -440,21 +442,21 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
if (event instanceof VFileDeleteEvent) {
|
||||
final VFileDeleteEvent deleteEvent = (VFileDeleteEvent)event;
|
||||
String url = deleteEvent.getFile().getPath();
|
||||
toFireEvents.addAll(getPointersUnder(url));
|
||||
toFireEvents.addAll(getPointersUnder(url, true));
|
||||
}
|
||||
else if (event instanceof VFileCreateEvent) {
|
||||
final VFileCreateEvent createEvent = (VFileCreateEvent)event;
|
||||
String url = createEvent.getPath();
|
||||
toFireEvents.addAll(getPointersUnder(url));
|
||||
toFireEvents.addAll(getPointersUnder(url, false));
|
||||
}
|
||||
else if (event instanceof VFileCopyEvent) {
|
||||
final VFileCopyEvent copyEvent = (VFileCopyEvent)event;
|
||||
String url = copyEvent.getNewParent().getPath() + "/" + copyEvent.getFile().getName();
|
||||
toFireEvents.addAll(getPointersUnder(url));
|
||||
toFireEvents.addAll(getPointersUnder(url, false));
|
||||
}
|
||||
else if (event instanceof VFileMoveEvent) {
|
||||
final VFileMoveEvent moveEvent = (VFileMoveEvent)event;
|
||||
List<VirtualFilePointer> pointers = getPointersUnder(moveEvent.getFile().getPath());
|
||||
List<VirtualFilePointer> pointers = getPointersUnder(moveEvent.getFile().getPath(), false);
|
||||
for (VirtualFilePointer pointer : pointers) {
|
||||
VirtualFile file = pointer.getFile();
|
||||
if (file != null) {
|
||||
@@ -465,7 +467,7 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
else if (event instanceof VFilePropertyChangeEvent) {
|
||||
final VFilePropertyChangeEvent change = (VFilePropertyChangeEvent)event;
|
||||
if (VirtualFile.PROP_NAME.equals(change.getPropertyName())) {
|
||||
List<VirtualFilePointer> pointers = getPointersUnder(change.getFile().getPath());
|
||||
List<VirtualFilePointer> pointers = getPointersUnder(change.getFile().getPath(), false);
|
||||
for (VirtualFilePointer pointer : pointers) {
|
||||
VirtualFile file = pointer.getFile();
|
||||
if (file != null) {
|
||||
@@ -488,6 +490,11 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
event.fireBefore();
|
||||
}
|
||||
|
||||
if (!toFireEvents.isEmpty()) {
|
||||
VirtualFilePointer[] arr = toFireEvents.toArray(new VirtualFilePointer[toFireEvents.size()]);
|
||||
myBus.syncPublisher(VirtualFilePointerListener.TOPIC).beforeValidityChanged(arr);
|
||||
}
|
||||
|
||||
myPointersToUdate = toFireEvents;
|
||||
myUrlsToUpdate = toUpdateUrl;
|
||||
}
|
||||
@@ -518,6 +525,11 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
event.fireAfter();
|
||||
}
|
||||
|
||||
if (!myPointersToUdate.isEmpty()) {
|
||||
VirtualFilePointer[] arr = myPointersToUdate.toArray(new VirtualFilePointer[myPointersToUdate.size()]);
|
||||
myBus.syncPublisher(VirtualFilePointerListener.TOPIC).beforeValidityChanged(arr);
|
||||
}
|
||||
|
||||
myUrlsToUpdate = null;
|
||||
myEvents = null;
|
||||
myPointersToUdate = null;
|
||||
|
||||
@@ -710,7 +710,10 @@ public class AbstractPopup implements JBPopup {
|
||||
}
|
||||
|
||||
if (myWindow != null) {
|
||||
if (!myMayBeParent) {
|
||||
// dialogwrapper-based popups do this internally through peer,
|
||||
// for other popups like jdialog-based we should exclude them manually, but
|
||||
// we still have to be able to use IdeFrame as parent
|
||||
if (!myMayBeParent && !(myWindow instanceof Frame)) {
|
||||
WindowManager.getInstance().doNotSuggestAsParent(myWindow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
package com.intellij.ui.popup;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.popup.util.PopupUtil;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public interface PopupComponent {
|
||||
|
||||
@@ -53,17 +53,12 @@ public interface PopupComponent {
|
||||
public PopupComponent getPopup(Component owner, Component content, int x, int y) {
|
||||
final PopupFactory factory = PopupFactory.getSharedInstance();
|
||||
|
||||
try {
|
||||
final Method method = PopupFactory.class.getDeclaredMethod("setPopupType", int.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(factory, 2);
|
||||
final int oldType = PopupUtil.getPopupType(factory);
|
||||
PopupUtil.setPopupType(factory, 2);
|
||||
final Popup popup = factory.getPopup(owner, content, x, y);
|
||||
if (oldType >= 0) PopupUtil.setPopupType(factory, oldType);
|
||||
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
return new AwtPopupWrapper(factory.getPopup(owner, content, x, y));
|
||||
return new AwtPopupWrapper(popup);
|
||||
}
|
||||
|
||||
public boolean isNativePopup() {
|
||||
|
||||
@@ -247,7 +247,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
|
||||
public void beforeRootsChange(ModuleRootEvent event) {
|
||||
if (!event.isCausedByFileTypesChange()) {
|
||||
fail("Root modification in LightIdeaTestCase is not allowed.");
|
||||
//TODO: uncomment fail("Root modification in LightIdeaTestCase is not allowed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1052,4 +1052,18 @@ public class FileUtil {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<File> findFilesByMask(Pattern pattern, File dir) {
|
||||
final ArrayList<File> found = new ArrayList<File>();
|
||||
for (File file : dir.listFiles()) {
|
||||
if (file.isDirectory()) {
|
||||
found.addAll(findFilesByMask(pattern, file));
|
||||
} else {
|
||||
if (pattern.matcher(file.getName()).matches()) {
|
||||
found.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -916,6 +916,27 @@ public class StringUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<TextRange> getWordIndicesIn(@NotNull String text) {
|
||||
List<TextRange> result = new SmartList<TextRange>();
|
||||
int start = -1;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char c = text.charAt(i);
|
||||
boolean isIdentifierPart = Character.isJavaIdentifierPart(c);
|
||||
if (isIdentifierPart && start == -1) {
|
||||
start = i;
|
||||
}
|
||||
if (isIdentifierPart && i == text.length() - 1 && start != -1) {
|
||||
result.add(new TextRange(start, i + 1));
|
||||
}
|
||||
else if (!isIdentifierPart && start != -1) {
|
||||
result.add(new TextRange(start, i));
|
||||
start = -1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull public static String join(@NotNull final String[] strings, @NotNull final String separator) {
|
||||
return join(strings, 0, strings.length, separator);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user