diff --git a/java/compiler/openapi/src/com/intellij/compiler/CompilerWorkspaceConfiguration.java b/java/compiler/openapi/src/com/intellij/compiler/CompilerWorkspaceConfiguration.java index 22fd6c6527ef..74ad7cfae9b1 100644 --- a/java/compiler/openapi/src/com/intellij/compiler/CompilerWorkspaceConfiguration.java +++ b/java/compiler/openapi/src/com/intellij/compiler/CompilerWorkspaceConfiguration.java @@ -22,6 +22,7 @@ package com.intellij.compiler; import com.intellij.openapi.components.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.registry.Registry; import com.intellij.util.xmlb.XmlSerializerUtil; @State( @@ -60,6 +61,6 @@ public class CompilerWorkspaceConfiguration implements PersistentStateComponent< } public boolean allowAutoMakeWhileRunningApplication() { - return false;/*ALLOW_AUTOMAKE_WHILE_RUNNING_APPLICATION*/ + return Registry.is("compiler.automake.allow.when.app.running", false);/*ALLOW_AUTOMAKE_WHILE_RUNNING_APPLICATION*/ } } diff --git a/java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java b/java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java index 827fd3f2dfd7..a43e62da7138 100644 --- a/java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java +++ b/java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java @@ -109,7 +109,6 @@ public abstract class JavaTestFrameworkRunnableState 1) { - final String message = JavaErrorMessages.message("too.many.characters.in.character.literal"); - final HighlightInfo info = - HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); + String message = JavaErrorMessages.message("too.many.characters.in.character.literal"); + HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createConvertToStringLiteralAction()); return info; } else if (length == 0) { - final String message = JavaErrorMessages.message("empty.character.literal"); - return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); + String message = JavaErrorMessages.message("empty.character.literal"); + return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } } else if (type == JavaTokenType.STRING_LITERAL) { if (value == null) { - for (final PsiElement element : expression.getChildren()) { + for (PsiElement element : expression.getChildren()) { if (element instanceof OuterLanguageElement) { return null; } @@ -1110,44 +1111,45 @@ public class HighlightUtil extends HighlightUtilBase { if (!StringUtil.startsWithChar(text, '\"')) return null; if (StringUtil.endsWithChar(text, '\"')) { if (text.length() == 1) { - final String message = JavaErrorMessages.message("illegal.line.end.in.string.literal"); - return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); + String message = JavaErrorMessages.message("illegal.line.end.in.string.literal"); + return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } text = text.substring(1, text.length() - 1); } else { - final String message = JavaErrorMessages.message("illegal.line.end.in.string.literal"); - return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); + String message = JavaErrorMessages.message("illegal.line.end.in.string.literal"); + return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } + StringBuilder chars = new StringBuilder(); boolean success = PsiLiteralExpressionImpl.parseStringCharacters(text, chars, null); if (!success) { - final String message = JavaErrorMessages.message("illegal.escape.character.in.string.literal"); - return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); + String message = JavaErrorMessages.message("illegal.escape.character.in.string.literal"); + return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } } if (value instanceof Float) { - final Float number = (Float)value; + Float number = (Float)value; if (number.isInfinite()) { - final String message = JavaErrorMessages.message("floating.point.number.too.large"); - return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); + String message = JavaErrorMessages.message("floating.point.number.too.large"); + return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } if (number.floatValue() == 0 && !TypeConversionUtil.isFPZero(text)) { - final String message = JavaErrorMessages.message("floating.point.number.too.small"); - return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); + String message = JavaErrorMessages.message("floating.point.number.too.small"); + return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } else if (value instanceof Double) { - final Double number = (Double)value; + Double number = (Double)value; if (number.isInfinite()) { - final String message = JavaErrorMessages.message("floating.point.number.too.large"); - return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); + String message = JavaErrorMessages.message("floating.point.number.too.large"); + return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } if (number.doubleValue() == 0 && !TypeConversionUtil.isFPZero(text)) { - final String message = JavaErrorMessages.message("floating.point.number.too.small"); - return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); + String message = JavaErrorMessages.message("floating.point.number.too.small"); + return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } @@ -1749,23 +1751,22 @@ public class HighlightUtil extends HighlightUtilBase { } @Nullable - static HighlightInfo checkExpressionRequired(@NotNull PsiReferenceExpression expression, - @NotNull JavaResolveResult resultForIncompleteCode) { + static HighlightInfo checkExpressionRequired(@NotNull PsiReferenceExpression expression, @NotNull JavaResolveResult resultForIncompleteCode) { if (expression.getNextSibling() instanceof PsiErrorElement) return null; + PsiElement resolved = resultForIncompleteCode.getElement(); - if (resolved == null) return null; + if (resolved == null || resolved instanceof PsiVariable) return null; + PsiElement parent = expression.getParent(); // String.class or String() are both correct if (parent instanceof PsiReferenceExpression || parent instanceof PsiMethodCallExpression) return null; - if (resolved instanceof PsiVariable) return null; + String description = JavaErrorMessages.message("expression.expected"); - final HighlightInfo info = - HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); + HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); UnresolvedReferenceQuickFixProvider.registerReferenceFixes(expression, new QuickFixActionRegistrarImpl(info)); return info; } - @Nullable static HighlightInfo checkArrayInitializerApplicable(@NotNull PsiArrayInitializerExpression expression) { /* @@ -1782,8 +1783,7 @@ public class HighlightUtil extends HighlightUtilBase { } String description = JavaErrorMessages.message("array.initializer.not.allowed"); - HighlightInfo info = - HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); + HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createAddNewArrayExpressionFix(expression)); return info; } diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java index 9ebe8673af22..dc919245f5c9 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java @@ -315,11 +315,10 @@ public class ExpressionParser { return operand; } - private enum BreakPoint {P1, P2, P3, P4} + private enum BreakPoint {P1, P2, P4} - // todo[r.sh] make 'this', 'super' and 'class' reference expressions @Nullable - private PsiBuilder.Marker parsePrimary(final PsiBuilder builder, @Nullable final BreakPoint breakPoint, final int breakOffset) { + private PsiBuilder.Marker parsePrimary(PsiBuilder builder, @Nullable BreakPoint breakPoint, int breakOffset) { PsiBuilder.Marker startMarker = builder.mark(); PsiBuilder.Marker expr = parsePrimaryExpressionStart(builder); @@ -365,6 +364,14 @@ public class ExpressionParser { dotPos.drop(); expr = parseNew(builder, expr); } + else if (dotTokenType == JavaTokenType.SUPER_KEYWORD && builder.lookAhead(1) == JavaTokenType.LPARENTH) { + dotPos.drop(); + PsiBuilder.Marker refExpr = expr.precede(); + builder.mark().done(JavaElementType.REFERENCE_PARAMETER_LIST); + builder.advanceLexer(); + refExpr.done(JavaElementType.REFERENCE_EXPRESSION); + expr = refExpr; + } else if (THIS_OR_SUPER.contains(dotTokenType) && exprType(expr) == JavaElementType.REFERENCE_EXPRESSION) { if (breakPoint == BreakPoint.P2 && builder.getCurrentOffset() == breakOffset) { dotPos.rollbackTo(); @@ -372,11 +379,11 @@ public class ExpressionParser { return expr; } - final PsiBuilder.Marker copy = startMarker.precede(); - final int offset = builder.getCurrentOffset(); + PsiBuilder.Marker copy = startMarker.precede(); + int offset = builder.getCurrentOffset(); startMarker.rollbackTo(); - final PsiBuilder.Marker ref = myParser.getReferenceParser().parseJavaCodeReference(builder, false, true, false, false); + PsiBuilder.Marker ref = myParser.getReferenceParser().parseJavaCodeReference(builder, false, true, false, false); if (ref == null || builder.getTokenType() != JavaTokenType.DOT || builder.getCurrentOffset() != dotOffset) { copy.rollbackTo(); return parsePrimary(builder, BreakPoint.P2, offset); @@ -393,17 +400,10 @@ public class ExpressionParser { expr = ref.precede(); expr.done(dotTokenType == JavaTokenType.THIS_KEYWORD ? JavaElementType.THIS_EXPRESSION : JavaElementType.SUPER_EXPRESSION); } - else if (dotTokenType == JavaTokenType.SUPER_KEYWORD) { - dotPos.drop(); - final PsiBuilder.Marker refExpr = expr.precede(); - builder.mark().done(JavaElementType.REFERENCE_PARAMETER_LIST); - builder.advanceLexer(); - refExpr.done(JavaElementType.REFERENCE_EXPRESSION); - expr = refExpr; - } else { dotPos.drop(); - final PsiBuilder.Marker refExpr = expr.precede(); + PsiBuilder.Marker refExpr = expr.precede(); + myParser.getReferenceParser().parseReferenceParameterList(builder, false, false); if (!expectOrError(builder, ID_OR_SUPER, "expected.identifier")) { @@ -418,40 +418,11 @@ public class ExpressionParser { } else if (tokenType == JavaTokenType.LPARENTH) { if (exprType(expr) != JavaElementType.REFERENCE_EXPRESSION) { - if (exprType(expr) == JavaElementType.SUPER_EXPRESSION) { - if (breakPoint == BreakPoint.P3) { - startMarker.drop(); - return expr; - } - - final PsiBuilder.Marker copy = startMarker.precede(); - startMarker.rollbackTo(); - - final PsiBuilder.Marker qualifier = parsePrimaryExpressionStart(builder); - if (qualifier != null) { - final PsiBuilder.Marker refExpr = qualifier.precede(); - if (builder.getTokenType() == JavaTokenType.DOT) { - builder.advanceLexer(); - if (builder.getTokenType() == JavaTokenType.SUPER_KEYWORD) { - builder.advanceLexer(); - refExpr.done(JavaElementType.REFERENCE_EXPRESSION); - expr = refExpr; - startMarker = copy; - continue; - } - } - } - - copy.rollbackTo(); - return parsePrimary(builder, BreakPoint.P3, -1); - } - else { - startMarker.drop(); - return expr; - } + startMarker.drop(); + return expr; } - final PsiBuilder.Marker callExpr = expr.precede(); + PsiBuilder.Marker callExpr = expr.precede(); parseArgumentList(builder); callExpr.done(JavaElementType.METHOD_CALL_EXPRESSION); expr = callExpr; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java index dba1d05fd1d0..cba5c8d9db02 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -357,7 +357,6 @@ public class PsiImplUtil { return TargetType.UNKNOWN; } - // todo[r.sh] cache? @Nullable public static Set getAnnotationTargets(@NotNull PsiClass annotationType) { if (!annotationType.isAnnotationType()) return null; @@ -393,38 +392,38 @@ public class PsiImplUtil { PsiUtilCore.ensureValid(expression); PsiUtil.ensureValidType(type); - PsiExpression toplevel = expression; - while (toplevel.getParent() instanceof PsiArrayAccessExpression && - ((PsiArrayAccessExpression)toplevel.getParent()).getArrayExpression() == toplevel) { - toplevel = (PsiExpression)toplevel.getParent(); + PsiExpression topLevel = expression; + while (topLevel.getParent() instanceof PsiArrayAccessExpression && + ((PsiArrayAccessExpression)topLevel.getParent()).getArrayExpression() == topLevel) { + topLevel = (PsiExpression)topLevel.getParent(); } - if (toplevel instanceof PsiArrayAccessExpression && !PsiUtil.isAccessedForWriting(toplevel)) { + if (topLevel instanceof PsiArrayAccessExpression && !PsiUtil.isAccessedForWriting(topLevel)) { return PsiUtil.captureToplevelWildcards(type, expression); } - final PsiType normalized = doNormalizeWildcardByPosition(type, expression, toplevel); + final PsiType normalized = doNormalizeWildcardByPosition(type, expression, topLevel); LOG.assertTrue(normalized.isValid(), type); - if (normalized instanceof PsiClassType && !PsiUtil.isAccessedForWriting(toplevel)) { + if (normalized instanceof PsiClassType && !PsiUtil.isAccessedForWriting(topLevel)) { return PsiUtil.captureToplevelWildcards(normalized, expression); } return normalized; } - private static PsiType doNormalizeWildcardByPosition(final PsiType type, @NotNull PsiExpression expression, final PsiExpression toplevel) { + private static PsiType doNormalizeWildcardByPosition(PsiType type, @NotNull PsiExpression expression, PsiExpression topLevel) { if (type instanceof PsiCapturedWildcardType) { final PsiWildcardType wildcardType = ((PsiCapturedWildcardType)type).getWildcard(); if (expression instanceof PsiReferenceExpression && LambdaUtil.isLambdaReturnExpression(expression)) { return type; } - if (PsiUtil.isAccessedForWriting(toplevel)) { + if (PsiUtil.isAccessedForWriting(topLevel)) { return wildcardType.isSuper() ? wildcardType.getBound() : PsiCapturedWildcardType.create(wildcardType, expression); } else { final PsiType upperBound = ((PsiCapturedWildcardType)type).getUpperBound(); - return upperBound instanceof PsiWildcardType ? doNormalizeWildcardByPosition(upperBound, expression, toplevel) : upperBound; + return upperBound instanceof PsiWildcardType ? doNormalizeWildcardByPosition(upperBound, expression, topLevel) : upperBound; } } @@ -432,7 +431,7 @@ public class PsiImplUtil { if (type instanceof PsiWildcardType) { final PsiWildcardType wildcardType = (PsiWildcardType)type; - if (PsiUtil.isAccessedForWriting(toplevel)) { + if (PsiUtil.isAccessedForWriting(topLevel)) { return wildcardType.isSuper() ? wildcardType.getBound() : PsiCapturedWildcardType.create(wildcardType, expression); } else { @@ -446,7 +445,7 @@ public class PsiImplUtil { } else if (type instanceof PsiArrayType) { final PsiType componentType = ((PsiArrayType)type).getComponentType(); - final PsiType normalizedComponentType = doNormalizeWildcardByPosition(componentType, expression, toplevel); + final PsiType normalizedComponentType = doNormalizeWildcardByPosition(componentType, expression, topLevel); if (normalizedComponentType != componentType) { return normalizedComponentType.createArrayType(); } @@ -521,26 +520,34 @@ public class PsiImplUtil { @Nullable String attributeName, @Nullable PsiAnnotationMemberValue value, @NotNull PairFunction annotationCreator) { - final PsiAnnotationMemberValue existing = psiAnnotation.findDeclaredAttributeValue(attributeName); + PsiAnnotationMemberValue existing = psiAnnotation.findDeclaredAttributeValue(attributeName); if (value == null) { if (existing == null) { return null; } existing.getParent().delete(); - } else { + } + else { if (existing != null) { ((PsiNameValuePair)existing.getParent()).setValue(value); - } else { - final PsiNameValuePair[] attributes = psiAnnotation.getParameterList().getAttributes(); - if (attributes.length == 1 && attributes[0].getName() == null) { - attributes[0].replace(createNameValuePair(attributes[0].getValue(), PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME + "=", annotationCreator)); + } + else { + PsiNameValuePair[] attributes = psiAnnotation.getParameterList().getAttributes(); + if (attributes.length == 1) { + PsiNameValuePair attribute = attributes[0]; + if (attribute.getName() == null) { + PsiAnnotationMemberValue defValue = attribute.getValue(); + assert defValue != null : attribute; + attribute.replace(createNameValuePair(defValue, PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME + "=", annotationCreator)); + } } boolean allowNoName = attributes.length == 0 && ("value".equals(attributeName) || null == attributeName); final String namePrefix; if (allowNoName) { namePrefix = ""; - } else { + } + else { namePrefix = attributeName + "="; } psiAnnotation.getParameterList().addBefore(createNameValuePair(value, namePrefix, annotationCreator), null); @@ -709,7 +716,8 @@ public class PsiImplUtil { if (typeName.indexOf('<') != -1 || typeName.indexOf('[') != -1 || typeName.indexOf('.') == -1) { try { return JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createTypeFromText(typeName, context); - } catch(Exception ex) {} // invalid syntax will produce unresolved class type + } + catch(Exception ignored) { } // invalid syntax will produce unresolved class type } PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(typeName, context.getResolveScope()); diff --git a/java/java-tests/testData/psi/parser-full/expressionParsing/QualifiedSuperMethodCall1.txt b/java/java-tests/testData/psi/parser-full/expressionParsing/QualifiedSuperMethodCall1.txt index faac0de388c1..f8e41ac609c1 100644 --- a/java/java-tests/testData/psi/parser-full/expressionParsing/QualifiedSuperMethodCall1.txt +++ b/java/java-tests/testData/psi/parser-full/expressionParsing/QualifiedSuperMethodCall1.txt @@ -60,6 +60,8 @@ PsiJavaFile:QualifiedSuperMethodCall1.java PsiIdentifier:d('d') PsiJavaToken:DOT('.') + PsiReferenceParameterList + PsiKeyword:super('super') PsiExpressionList PsiJavaToken:LPARENTH('(') diff --git a/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall1.txt b/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall1.txt index c08eb71cc220..a5ef807409eb 100644 --- a/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall1.txt +++ b/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall1.txt @@ -6,9 +6,11 @@ PsiJavaFile:QualifiedSuperMethodCall1.java PsiIdentifier:d('d') PsiJavaToken:DOT('.') + PsiReferenceParameterList + PsiKeyword:super('super') PsiExpressionList PsiJavaToken:LPARENTH('(') PsiLiteralExpression:0 PsiJavaToken:INTEGER_LITERAL('0') - PsiJavaToken:RPARENTH(')') + PsiJavaToken:RPARENTH(')') \ No newline at end of file diff --git a/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall3.txt b/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall3.txt new file mode 100644 index 000000000000..e885d4b2e3c9 --- /dev/null +++ b/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall3.txt @@ -0,0 +1,19 @@ +PsiJavaFile:QualifiedSuperMethodCall3.java + PsiMethodCallExpression:C.A.super() + PsiReferenceExpression:C.A.super + PsiReferenceExpression:C.A + PsiReferenceExpression:C + PsiReferenceParameterList + + PsiIdentifier:C('C') + PsiJavaToken:DOT('.') + PsiReferenceParameterList + + PsiIdentifier:A('A') + PsiJavaToken:DOT('.') + PsiReferenceParameterList + + PsiKeyword:super('super') + PsiExpressionList + PsiJavaToken:LPARENTH('(') + PsiJavaToken:RPARENTH(')') \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java index 3290863f153f..920894619570 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package com.intellij.lang.java.parser.partial; import com.intellij.lang.PsiBuilder; import com.intellij.lang.java.parser.JavaParser; import com.intellij.lang.java.parser.JavaParsingTestCase; -import org.jetbrains.annotations.NonNls; public class ExpressionParserTest extends JavaParsingTestCase { public ExpressionParserTest() { @@ -112,6 +111,7 @@ public class ExpressionParserTest extends JavaParsingTestCase { public void testQualifiedSuperMethodCall0() { doParserTest("new D().super(0)"); } public void testQualifiedSuperMethodCall1() { doParserTest("d.super(0)"); } public void testQualifiedSuperMethodCall2() { doParserTest("(new O()).super()"); } + public void testQualifiedSuperMethodCall3() { doParserTest("C.A.super()"); } public void testSuperMethodCallTypeParameterList() { doParserTest("super()"); } public void testPrimitiveClassObjectAccess() { doParserTest("int.class"); } public void testPrimitiveFieldAccess() { doParserTest("int.x"); } @@ -149,9 +149,10 @@ public class ExpressionParserTest extends JavaParsingTestCase { public void testLambdaExpression19() { doParserTest("(@A T t) -> (null)"); } public void testAmbiguousLambdaExpression() { doParserTest("f( (x) < y , z > (w) -> v )"); } - private void doParserTest(@NonNls final String text) { + private void doParserTest(String text) { doParserTest(text, new MyTestParser()); } + private static class MyTestParser implements TestParser { @Override public void parse(final PsiBuilder builder) { diff --git a/java/java-tests/testSrc/com/intellij/psi/autodetect/AbstractNewLineBlocksIteratorTest.java b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/AbstractNewLineBlocksIteratorTest.java similarity index 98% rename from java/java-tests/testSrc/com/intellij/psi/autodetect/AbstractNewLineBlocksIteratorTest.java rename to java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/AbstractNewLineBlocksIteratorTest.java index 2b6350e05e1a..7e7e7a35ef2c 100644 --- a/java/java-tests/testSrc/com/intellij/psi/autodetect/AbstractNewLineBlocksIteratorTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/AbstractNewLineBlocksIteratorTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.psi.autodetect; +package com.intellij.psi.codeStyle.autodetect; import com.intellij.formatting.Block; import com.intellij.formatting.FormattingModel; diff --git a/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/DetectIndentAndTypeTest.java b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/DetectIndentAndTypeTest.java index adbf48df086b..0a13972a6be4 100644 --- a/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/DetectIndentAndTypeTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/DetectIndentAndTypeTest.java @@ -71,4 +71,29 @@ public class DetectIndentAndTypeTest extends LightPlatformCodeInsightFixtureTest "\t}\n" + "}\n"); } + + public void testWhenTabsDetected_SetContinuationIndentSizeToDoubleTabSize() { + CommonCodeStyleSettings common = mySettings.getCommonSettings(JavaLanguage.INSTANCE); + CommonCodeStyleSettings.IndentOptions indentOptions = common.getIndentOptions(); + + assert indentOptions != null; + + indentOptions.INDENT_SIZE = 1; + indentOptions.TAB_SIZE = 2; + indentOptions.CONTINUATION_INDENT_SIZE = 8; + + myFixture.configureByText(JavaFileType.INSTANCE, + "public class T {\n" + + "\tvoid run() {\n" + + "\t\tint a = 2 + 2;\n" + + "\t}\n" + + "}\n"); + myFixture.type('\n'); + myFixture.checkResult("public class T {\n" + + "\tvoid run() {\n" + + "\t\tint a = 2 \n" + + "\t\t\t\t+ 2;\n" + + "\t}\n" + + "}\n"); + } } diff --git a/java/java-tests/testSrc/com/intellij/psi/autodetect/JavaAutoDetectIndentTest.java b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/JavaAutoDetectIndentTest.java similarity index 97% rename from java/java-tests/testSrc/com/intellij/psi/autodetect/JavaAutoDetectIndentTest.java rename to java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/JavaAutoDetectIndentTest.java index f1b90dced63d..70bca2a7fd66 100644 --- a/java/java-tests/testSrc/com/intellij/psi/autodetect/JavaAutoDetectIndentTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/JavaAutoDetectIndentTest.java @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.psi.autodetect; +package com.intellij.psi.codeStyle.autodetect; import com.intellij.JavaTestUtil; import com.intellij.openapi.fileTypes.PlainTextLanguage; +import com.intellij.psi.autodetect.AbstractIndentAutoDetectionTest; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.codeStyle.autodetect.LineIndentInfo; import com.intellij.psi.codeStyle.autodetect.LineIndentInfoBuilder; diff --git a/java/java-tests/testSrc/com/intellij/psi/autodetect/NewLineBlocksIteratorTest.java b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/NewLineBlocksIteratorTest.java similarity index 96% rename from java/java-tests/testSrc/com/intellij/psi/autodetect/NewLineBlocksIteratorTest.java rename to java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/NewLineBlocksIteratorTest.java index 25c4416ad73a..2e3269ff02b9 100644 --- a/java/java-tests/testSrc/com/intellij/psi/autodetect/NewLineBlocksIteratorTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/NewLineBlocksIteratorTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.psi.autodetect; +package com.intellij.psi.codeStyle.autodetect; import com.intellij.JavaTestUtil; import org.jetbrains.annotations.NotNull; diff --git a/java/java-tests/testSrc/com/intellij/JavaTestUtil.java b/java/testFramework/src/com/intellij/JavaTestUtil.java similarity index 83% rename from java/java-tests/testSrc/com/intellij/JavaTestUtil.java rename to java/testFramework/src/com/intellij/JavaTestUtil.java index 4dfce7cc9438..6e75f5193329 100644 --- a/java/java-tests/testSrc/com/intellij/JavaTestUtil.java +++ b/java/testFramework/src/com/intellij/JavaTestUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import com.intellij.openapi.util.text.StringUtil; * @author Konstantin Bulenkov */ public class JavaTestUtil { + private static final String TEST_JDK_NAME = "JDK"; public static String getJavaTestDataPath() { return PathManagerEx.getTestDataPath(); @@ -43,12 +44,14 @@ public class JavaTestUtil { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { - Sdk jdk = ProjectJdkTable.getInstance().findJdk("JDK"); + ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); + + Sdk jdk = jdkTable.findJdk(TEST_JDK_NAME); if (jdk != null) { - ProjectJdkTable.getInstance().removeJdk(jdk); + jdkTable.removeJdk(jdk); } - ProjectJdkTable.getInstance().addJdk(getTestJdk()); + jdkTable.addJdk(getTestJdk()); } }); } @@ -56,14 +59,11 @@ public class JavaTestUtil { public static Sdk getTestJdk() { try { ProjectJdkImpl jdk = (ProjectJdkImpl)JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk().clone(); - jdk.setName("JDK"); + jdk.setName(TEST_JDK_NAME); return jdk; } catch (CloneNotSupportedException e) { - //LOG.error(e); - return null; + throw new RuntimeException(e); } } - - -} +} \ No newline at end of file diff --git a/java/testFramework/src/com/intellij/debugger/DebuggerTestCase.java b/java/testFramework/src/com/intellij/debugger/DebuggerTestCase.java index c94b71966ad3..b05fd4bfbb51 100644 --- a/java/testFramework/src/com/intellij/debugger/DebuggerTestCase.java +++ b/java/testFramework/src/com/intellij/debugger/DebuggerTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package com.intellij.debugger; +import com.intellij.JavaTestUtil; import com.intellij.debugger.engine.DebugProcessImpl; import com.intellij.debugger.engine.JavaDebugProcess; import com.intellij.debugger.engine.RemoteStateState; @@ -69,17 +70,11 @@ import java.util.StringTokenizer; public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCase { protected DebuggerSession myDebuggerSession; - private StringBuffer myConsoleBuffer; - - @Override - protected void setUp() throws Exception { - super.setUp(); - } @Override protected void initApplication() throws Exception { super.initApplication(); - setTestJDK(); + JavaTestUtil.setupTestJDK(); DebuggerSettings.getInstance().DEBUGGER_TRANSPORT = DebuggerSettings.SOCKET_TRANSPORT; DebuggerSettings.getInstance().SKIP_CONSTRUCTORS = false; DebuggerSettings.getInstance().SKIP_GETTERS = false; @@ -97,11 +92,6 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas assertNull(DebuggerManagerEx.getInstanceEx(myProject).getDebugProcess(getDebugProcess().getProcessHandler())); myDebuggerSession = null; } - if(myConsoleBuffer != null) { - //println("", b); - //println("Console output:", b); - //println(myConsoleBuffer.toString(), b); - } checkTestOutput(); } @@ -121,7 +111,6 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas @Override protected void tearDown() throws Exception { FileEditorManagerEx.getInstanceEx(getProject()).closeAllFiles(); - myConsoleBuffer = null; super.tearDown(); } @@ -180,12 +169,9 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas }, ModalityState.defaultModalityState()); myDebugProcess = myDebuggerSession.getProcess(); - //myConsoleBuffer = new StringBuffer(); - myDebugProcess.addProcessListener(new ProcessAdapter() { @Override public void onTextAvailable(ProcessEvent event, Key outputType) { - //myConsoleBuffer.append(event.getText()); print(event.getText(), outputType); } }); @@ -330,6 +316,7 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas @Override public PsiFile compute() { PsiClass psiClass = JavaPsiFacade.getInstance(myProject).findClass(className, GlobalSearchScope.allScope(myProject)); + assertNotNull(psiClass); return psiClass.getContainingFile(); } }); @@ -339,10 +326,9 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas protected EvaluationContextImpl createEvaluationContext(final SuspendContextImpl suspendContext) { try { - return new EvaluationContextImpl( - suspendContext, - suspendContext.getFrameProxy(), - suspendContext.getFrameProxy().thisObject()); + StackFrameProxyImpl proxy = suspendContext.getFrameProxy(); + assertNotNull(proxy); + return new EvaluationContextImpl(suspendContext, proxy, proxy.thisObject()); } catch (EvaluateException e) { error(e); @@ -440,6 +426,7 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas public void run() { BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager(); PsiClass psiClass = JavaPsiFacade.getInstance(myProject).findClass("HelloWorld", GlobalSearchScope.allScope(myProject)); + assertNotNull(psiClass); Document document = PsiDocumentManager.getInstance(myProject).getDocument(psiClass.getContainingFile()); breakpointManager.addLineBreakpoint(document, 3); } @@ -481,33 +468,31 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas @Override @NotNull public Module[] getModules() { - return Module.EMPTY_ARRAY; //To change body of implemented methods use File | Settings | File Templates. + return Module.EMPTY_ARRAY; } @Override public Icon getIcon() { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } @Override public ConfigurationFactory getFactory() { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } @Override - public void setName(final String name) { - //To change body of implemented methods use File | Settings | File Templates. - } + public void setName(String name) { } @NotNull @Override public SettingsEditor getConfigurationEditor() { - return null; //To change body of implemented methods use File | Settings | File Templates. + throw new UnsupportedOperationException(); } @Override public Project getProject() { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } @Override @@ -517,18 +502,18 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas } @Override - public ConfigurationPerRunnerSettings createRunnerSettings(final ConfigurationInfoProvider provider) { - return null; //To change body of implemented methods use File | Settings | File Templates. + public ConfigurationPerRunnerSettings createRunnerSettings(ConfigurationInfoProvider provider) { + return null; } @Override - public SettingsEditor getRunnerSettingsEditor(final ProgramRunner runner) { - return null; //To change body of implemented methods use File | Settings | File Templates. + public SettingsEditor getRunnerSettingsEditor(ProgramRunner runner) { + return null; } @Override public RunConfiguration clone() { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } @Override @@ -537,28 +522,22 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas } @Override - public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException { - return null; //To change body of implemented methods use File | Settings | File Templates. + public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException { + return null; } @Override public String getName() { - return ""; //To change body of implemented methods use File | Settings | File Templates. + return ""; } @Override - public void checkConfiguration() throws RuntimeConfigurationException { - //To change body of implemented methods use File | Settings | File Templates. - } + public void checkConfiguration() throws RuntimeConfigurationException { } @Override - public void readExternal(final Element element) throws InvalidDataException { - //To change body of implemented methods use File | Settings | File Templates. - } + public void readExternal(Element element) throws InvalidDataException { } @Override - public void writeExternal(final Element element) throws WriteExternalException { - //To change body of implemented methods use File | Settings | File Templates. - } + public void writeExternal(Element element) throws WriteExternalException { } } } diff --git a/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java b/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java index e1ab9ff4e3cf..653a11879d00 100644 --- a/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java +++ b/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java @@ -36,10 +36,6 @@ import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.editor.Document; -import com.intellij.openapi.projectRoots.ProjectJdkTable; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl; -import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; @@ -400,33 +396,7 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa } } - private Sdk getTestJdk() { - try { - ProjectJdkImpl jdk = (ProjectJdkImpl)JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk().clone(); - jdk.setName("JDK"); - return jdk; - } - catch (CloneNotSupportedException e) { - LOG.error(e); - return null; - } - } - - protected void setTestJDK() { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - Sdk jdk = ProjectJdkTable.getInstance().findJdk("JDK"); - if (jdk != null) { - ProjectJdkTable.getInstance().removeJdk(jdk); - } - - ProjectJdkTable.getInstance().addJdk(getTestJdk()); - } - }); - } - - private class DelayedEventsProcessListener implements DebugProcessListener { + private static class DelayedEventsProcessListener implements DebugProcessListener { private final DebugProcessAdapterImpl myTarget; public DelayedEventsProcessListener(DebugProcessAdapterImpl target) { @@ -473,7 +443,7 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa myTarget.attachException(state, exception, remoteConnection); } - private void pauseExecution() { + private static void pauseExecution() { TimeoutUtil.sleep(10); } } diff --git a/platform/core-api/src/com/intellij/openapi/options/ExternalInfo.java b/platform/core-api/src/com/intellij/openapi/options/ExternalInfo.java index 8156da085fd5..ba95d8e1c97f 100644 --- a/platform/core-api/src/com/intellij/openapi/options/ExternalInfo.java +++ b/platform/core-api/src/com/intellij/openapi/options/ExternalInfo.java @@ -68,4 +68,4 @@ public final class ExternalInfo { public String toString() { return "file: " + myCurrentFileName + (myRemote ? ", remote" : ""); } -} +} \ No newline at end of file diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/search/CachesBasedRefSearcher.java b/platform/indexing-impl/src/com/intellij/psi/impl/search/CachesBasedRefSearcher.java index 56a2229e9fac..c09e67ccf6b9 100644 --- a/platform/indexing-impl/src/com/intellij/psi/impl/search/CachesBasedRefSearcher.java +++ b/platform/indexing-impl/src/com/intellij/psi/impl/search/CachesBasedRefSearcher.java @@ -26,6 +26,7 @@ public class CachesBasedRefSearcher extends QueryExecutorBase consumer) { final PsiElement refElement = p.getElementToSearch(); + boolean caseSensitive = refElement.getLanguage().isCaseSensitive(); String text = null; if (refElement instanceof PsiFileSystemItem && !(refElement instanceof SyntheticFileSystemItem)) { @@ -33,6 +34,10 @@ public class CachesBasedRefSearcher extends QueryExecutorBase modifiedUserTypes = myOriginalToEditedMap.keySet(); for (UserFileType oldType : modifiedUserTypes) { - UserFileType newType = myOriginalToEditedMap.get(oldType); - oldType.copyFrom(newType); + oldType.copyFrom(myOriginalToEditedMap.get(oldType)); } myOriginalToEditedMap.clear(); diff --git a/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/IndentOptionsDetectorImpl.java b/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/IndentOptionsDetectorImpl.java index 4c425a8e4d24..3fa3b3bd785e 100644 --- a/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/IndentOptionsDetectorImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/IndentOptionsDetectorImpl.java @@ -82,6 +82,7 @@ public class IndentOptionsDetectorImpl implements IndentOptionsDetector { if (linesWithTabs > linesWithWhiteSpaceIndent) { setUseTabs(indentOptions, true); indentOptions.INDENT_SIZE = indentOptions.TAB_SIZE; + indentOptions.CONTINUATION_INDENT_SIZE = indentOptions.TAB_SIZE * 2; } else if (linesWithWhiteSpaceIndent > linesWithTabs) { setUseTabs(indentOptions, false); diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/UserFileType.java b/platform/platform-api/src/com/intellij/openapi/fileTypes/UserFileType.java index aa6ef4e276ec..4c0a27555726 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileTypes/UserFileType.java +++ b/platform/platform-api/src/com/intellij/openapi/fileTypes/UserFileType.java @@ -80,7 +80,7 @@ public abstract class UserFileType implements FileType, return null; } - public void copyFrom(UserFileType newType) { + public void copyFrom(@NotNull UserFileType newType) { myName = newType.getName(); myDescription = newType.getDescription(); } diff --git a/platform/platform-api/src/com/intellij/ui/CollectionListModel.java b/platform/platform-api/src/com/intellij/ui/CollectionListModel.java index e87ca745465b..dc8a52f62293 100644 --- a/platform/platform-api/src/com/intellij/ui/CollectionListModel.java +++ b/platform/platform-api/src/com/intellij/ui/CollectionListModel.java @@ -42,6 +42,10 @@ public class CollectionListModel extends AbstractListModel implements Editabl myItems = ContainerUtilRt.newArrayList(items); } + public CollectionListModel() { + myItems = new ArrayList(); + } + @Override public int getSize() { return myItems.size(); @@ -148,4 +152,8 @@ public class CollectionListModel extends AbstractListModel implements Editabl public int getElementIndex(T item) { return myItems.indexOf(item); } + + public boolean isEmpty() { + return myItems.isEmpty(); + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ChangeEditorFontSizeAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ChangeEditorFontSizeAction.java index e129e5d33041..9213f1a63a44 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ChangeEditorFontSizeAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ChangeEditorFontSizeAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,12 +22,13 @@ import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorBundle; import com.intellij.openapi.editor.impl.EditorImpl; +import com.intellij.openapi.project.DumbAware; import org.jetbrains.annotations.Nullable; /** * @author Konstantin Bulenkov */ -public abstract class ChangeEditorFontSizeAction extends AnAction { +public abstract class ChangeEditorFontSizeAction extends AnAction implements DumbAware { private final int myStep; protected ChangeEditorFontSizeAction(@Nullable String text, int increaseStep) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java index feb01fb0db79..48e8de5f769b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java @@ -166,7 +166,8 @@ public class ComplementaryFontsRegistry { boolean tryDefaultFont = true; List fontFamilies = preferences.getEffectiveFontFamilies(); FontInfo result; - for (int i = 0, len = fontFamilies.size(); i < len; ++i) { + //noinspection ForLoopReplaceableByForEach + for (int i = 0, len = fontFamilies.size(); i < len; ++i) { // avoid foreach, it instantiates ArrayList$Itr, this traversal happens very often final String fontFamily = fontFamilies.get(i); result = doGetFontAbleToDisplay(c, preferences.getSize(fontFamily), style, fontFamily); if (result != null) { diff --git a/platform/platform-resources-en/src/messages/ToolsBundle.properties b/platform/platform-resources-en/src/messages/ToolsBundle.properties index cfb7e2dfe191..a8d06a5a9f35 100644 --- a/platform/platform-resources-en/src/messages/ToolsBundle.properties +++ b/platform/platform-resources-en/src/messages/ToolsBundle.properties @@ -60,4 +60,4 @@ tools.before.run.provider.name=Run External tool tools.after.commit.description=Run tool: tools.unnamed.group=[unnamed group] tools.list.item.none=(none) -tools.dialog.title=External tools \ No newline at end of file +tools.dialog.title=External Tools \ No newline at end of file diff --git a/platform/platform-resources/src/idea/Keymap_Xcode.xml b/platform/platform-resources/src/idea/Keymap_Xcode.xml index c814b66d3f87..717ec356eb7e 100644 --- a/platform/platform-resources/src/idea/Keymap_Xcode.xml +++ b/platform/platform-resources/src/idea/Keymap_Xcode.xml @@ -323,7 +323,9 @@ - + + + diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 7ee1c8d66648..394c7e775d0f 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -221,6 +221,9 @@ compiler.process.debug.port=-1 compiler.automake.trigger.delay=300 compiler.automake.trigger.delay.description=Delay in milliseconds before triggering auto-make in response to file system events +compiler.automake.allow.when.app.running=false +compiler.automake.allow.when.app.running.description=Allow auto-make to start even if developed application is currently running. Note that automatically started make may eventually delete some classes that are required by the application. + compiler.document.save.trigger.delay=1500 compiler.document.save.trigger.delay.description=Delay in milliseconds before triggering save in response to document changes diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java index 4172471be0de..2b65a17cf598 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java @@ -339,7 +339,9 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { if (patchReader == null) return; List filePatches = ContainerUtil.newArrayList(patchReader.getPatches()); - filePatches.addAll(myBinaryShelvedPatches); + if (!ContainerUtil.isEmpty(myBinaryShelvedPatches)) { + filePatches.addAll(myBinaryShelvedPatches); + } final List matchedPatches = new MatchPatchPaths(myProject).execute(filePatches); ApplicationManager.getApplication().invokeLater(new Runnable() { diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/XLineBreakpointType.java b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/XLineBreakpointType.java index 32e35eded48e..09b4a7b550e0 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/XLineBreakpointType.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/XLineBreakpointType.java @@ -137,10 +137,13 @@ public abstract class XLineBreakpointType

exten public abstract class XLineBreakpointVariant { public abstract String getText(); + @Nullable public abstract Icon getIcon(); + @Nullable public abstract TextRange getHighlightRange(); + @Nullable public abstract P createProperties(); } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java index 6f4a761df82d..f55e80100183 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java @@ -189,6 +189,21 @@ public class XDebuggerUtilImpl extends XDebuggerUtil { } } } + + // calculate default item + int caretOffset = editor.getCaretModel().getOffset(); + XLineBreakpointType

.XLineBreakpointVariant defaultVariant = null; + for (XLineBreakpointType

.XLineBreakpointVariant variant : variants) { + TextRange range = variant.getHighlightRange(); + if (range != null && range.contains(caretOffset)) { + //noinspection ConstantConditions + if (defaultVariant == null || defaultVariant.getHighlightRange().getLength() > range.getLength()) { + defaultVariant = variant; + } + } + } + final int defaultIndex = defaultVariant != null ? variants.indexOf(defaultVariant) : 0; + final MySelectionListener selectionListener = new MySelectionListener(); ListPopup popup = JBPopupFactory.getInstance().createListPopup( new BaseListPopupStep("Create breakpoint for", variants) { @@ -220,6 +235,11 @@ public class XDebuggerUtilImpl extends XDebuggerUtil { }); return FINAL_CHOICE; } + + @Override + public int getDefaultOptionIndex() { + return defaultIndex; + } }); popup.addListSelectionListener(selectionListener); popup.show(relativePoint); diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/serialization/serialVersionUID/ClassAccess.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/serialization/serialVersionUID/ClassAccess.after.java index f84120dbf9fe..3c56f734be2a 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igfixes/serialization/serialVersionUID/ClassAccess.after.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/serialization/serialVersionUID/ClassAccess.after.java @@ -9,6 +9,7 @@ public class ClassAccess implements Serializable { enum TestEnum {} + // at one point javac generated a synthetic field for .class accesses with a name starting with the string "class$" Map> testField = new EnumMap>(TestEnum.class); // Map> testField = new HashMap<>(); diff --git a/plugins/junit_rt/junit_rt.iml b/plugins/junit_rt/junit_rt.iml index 37653b53cb5a..28dc623b5f2d 100644 --- a/plugins/junit_rt/junit_rt.iml +++ b/plugins/junit_rt/junit_rt.iml @@ -9,7 +9,5 @@ - - - + \ No newline at end of file diff --git a/plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java b/plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java index 27ada8d3b4b9..e7bd2692b04b 100644 --- a/plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java +++ b/plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java @@ -18,8 +18,6 @@ package com.intellij.junit3; import com.intellij.rt.execution.junit.*; import com.intellij.rt.execution.junit.segments.OutputObjectRegistry; import com.intellij.rt.execution.junit.segments.PacketProcessor; -import jetbrains.buildServer.messages.serviceMessages.ServiceMessage; -import jetbrains.buildServer.messages.serviceMessages.ServiceMessageTypes; import junit.framework.*; import junit.textui.ResultPrinter; import junit.textui.TestRunner; @@ -179,7 +177,7 @@ public class JUnit3IdeaTestRunner extends TestRunner implements IdeaTestRunner { final Map attrs = new HashMap(); attrs.put("name", getMethodName(test)); attrs.put("message", failureMessage != null ? failureMessage : ""); - System.out.println(ServiceMessage.asString(ServiceMessageTypes.TEST_FAILED, attrs)); + System.out.println(MapSerializerUtil.asString(MapSerializerUtil.TEST_FAILED, attrs)); } private static String getMethodName(Test test) { diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java index 9b21ca5fe63f..7d9ceb6a2ec2 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java +++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestListener.java @@ -21,9 +21,7 @@ package com.intellij.junit4; import com.intellij.rt.execution.junit.ComparisonFailureData; -import jetbrains.buildServer.messages.serviceMessages.MapSerializerUtil; -import jetbrains.buildServer.messages.serviceMessages.ServiceMessage; -import jetbrains.buildServer.messages.serviceMessages.ServiceMessageTypes; +import com.intellij.rt.execution.junit.MapSerializerUtil; import junit.framework.ComparisonFailure; import org.junit.Ignore; import org.junit.runner.Description; @@ -140,11 +138,11 @@ public class JUnit4TestListener extends RunListener { //class setUp failed if (methodName == null) { for (Iterator iterator = description.getChildren().iterator(); iterator.hasNext(); ) { - testFailure(failure, ServiceMessageTypes.TEST_FAILED, getFullMethodName((Description)iterator.next())); + testFailure(failure, MapSerializerUtil.TEST_FAILED, getFullMethodName((Description)iterator.next())); } } else { - testFailure(failure, ServiceMessageTypes.TEST_FAILED, methodName); + testFailure(failure, MapSerializerUtil.TEST_FAILED, methodName); } } @@ -168,7 +166,7 @@ public class JUnit4TestListener extends RunListener { ComparisonFailureData.registerSMAttributes(null, stringWriter.toString(), e.getMessage(), attrs, e); } finally { - myPrintStream.println(ServiceMessage.asString(messageName, attrs)); + myPrintStream.println(MapSerializerUtil.asString(messageName, attrs)); } } @@ -204,7 +202,7 @@ public class JUnit4TestListener extends RunListener { private void testAssumptionFailure(Failure failure, Description testDescription, String name) throws Exception { testStarted(testDescription); - testFailure(failure, ServiceMessageTypes.TEST_IGNORED, name); + testFailure(failure, MapSerializerUtil.TEST_IGNORED, name); testFinished(testDescription); } @@ -224,7 +222,7 @@ public class JUnit4TestListener extends RunListener { //junit < 4.4 } attrs.put("name", getFullMethodName(description)); - myPrintStream.println(ServiceMessage.asString(ServiceMessageTypes.TEST_IGNORED, attrs)); + myPrintStream.println(MapSerializerUtil.asString(MapSerializerUtil.TEST_IGNORED, attrs)); testFinished(description); } diff --git a/plugins/junit_rt/src/com/intellij/rt/execution/junit/MapSerializerUtil.java b/plugins/junit_rt/src/com/intellij/rt/execution/junit/MapSerializerUtil.java new file mode 100644 index 000000000000..dbe9bd597737 --- /dev/null +++ b/plugins/junit_rt/src/com/intellij/rt/execution/junit/MapSerializerUtil.java @@ -0,0 +1,123 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.rt.execution.junit; + + +import java.util.Iterator; +import java.util.Map; + +public class MapSerializerUtil { + public static final String TEST_FAILED = "testFailed"; + public static final String TEST_IGNORED = "testIgnored"; + + + /** + * String escaping info provider. + */ + public interface EscapeInfoProvider { + /** + * Converts character to its representation in the final string + * @param c character to convert + * @return character representation or 0 if conversion is not applicable to that character + */ + char escape(char c); + + /** + * Escape character to use before escaped characters (before character representations generated by {@link #escape(char)} method) + * @return see above + */ + char escapeCharacter(); + } + + public static final EscapeInfoProvider STD_ESCAPER = new EscapeInfoProvider() { + public char escape(final char c) { + switch (c) { + case '\n': return 'n'; + case '\r': return 'r'; + case '\u0085': return 'x'; // next-line character + case '\u2028': return 'l'; // line-separator character + case '\u2029': return 'p'; // paragraph-separator character + case '|': return '|'; + case '\'': return '\''; + case '[': return '['; + case ']': return ']'; + default:return 0; + } + } + + public char escapeCharacter() { + return '|'; + } + }; + + /** + * Escapes characters specified by provider with '\' and specified character. + * @param str initial string + * @param p escape info provider. + * @return escaped string. + */ + public static String escapeStr(final String str, EscapeInfoProvider p) { + if (str == null) return null; + int finalCount = calcFinalEscapedStringCount(str, p); + + if (str.length() == finalCount) return str; + + char[] resultChars = new char[finalCount]; + int resultPos = 0; + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + final char escaped = p.escape(c); + if (escaped != 0) { + resultChars[resultPos++] = p.escapeCharacter(); + resultChars[resultPos++] = escaped; + } + else { + resultChars[resultPos++] = c; + } + } + + if (resultPos != finalCount) { + throw new RuntimeException("Incorrect escaping for '" + str + "'"); + } + return new String(resultChars); + } + + private static int calcFinalEscapedStringCount(final String name, final EscapeInfoProvider p) { + int result = 0; + for (int i = 0; i < name.length(); i++) { + char c = name.charAt(i); + if (p.escape(c) != 0) { + result += 2; + } + else { + result += 1; + } + } + + return result; + } + + public static String asString(final String messageName, final Map attributes) { + String text = "##teamcity[" + messageName; + for (Iterator iterator = attributes.keySet().iterator(); iterator.hasNext(); ) { + final Object attrName = iterator.next(); + text += " " + attrName + "='" + escapeStr((String)attributes.get(attrName), STD_ESCAPER) + "'"; + } + text += "]"; + return text; + } + +} diff --git a/plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java b/plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java index 08fe21a74286..6ce51491d450 100644 --- a/plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java +++ b/plugins/testng_rt/src/org/testng/IDEATestNGRemoteListener.java @@ -1,9 +1,6 @@ package org.testng; import com.intellij.rt.execution.junit.ComparisonFailureData; -import jetbrains.buildServer.messages.serviceMessages.MapSerializerUtil; -import jetbrains.buildServer.messages.serviceMessages.ServiceMessage; -import jetbrains.buildServer.messages.serviceMessages.ServiceMessageTypes; import org.testng.internal.IResultListener; import org.testng.xml.XmlTest; @@ -166,7 +163,7 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener notification = null; } ComparisonFailureData.registerSMAttributes(notification, getTrace(ex), failureMessage, attrs, ex); - myPrintStream.println(ServiceMessage.asString(ServiceMessageTypes.TEST_FAILED, attrs)); + myPrintStream.println(MapSerializerUtil.asString("testFailed", attrs)); onTestFinished(result); } diff --git a/plugins/testng_rt/src/org/testng/MapSerializerUtil.java b/plugins/testng_rt/src/org/testng/MapSerializerUtil.java new file mode 100644 index 000000000000..0d28976e66e0 --- /dev/null +++ b/plugins/testng_rt/src/org/testng/MapSerializerUtil.java @@ -0,0 +1,122 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.testng; + + +import java.util.Iterator; +import java.util.Map; + +public class MapSerializerUtil { + private static final String STD_EX_SUFFIX = + "Valid property list format is (name( )*=( )*\'escaped_value\'( )*)* where escape simbol is \"|\""; + + + /** + * String escaping info provider. + */ + public interface EscapeInfoProvider { + /** + * Converts character to its representation in the final string + * @param c character to convert + * @return character representation or 0 if conversion is not applicable to that character + */ + char escape(char c); + + /** + * Escape character to use before escaped characters (before character representations generated by {@link #escape(char)} method) + * @return see above + */ + char escapeCharacter(); + } + + public static final EscapeInfoProvider STD_ESCAPER = new EscapeInfoProvider() { + public char escape(final char c) { + switch (c) { + case '\n': return 'n'; + case '\r': return 'r'; + case '\u0085': return 'x'; // next-line character + case '\u2028': return 'l'; // line-separator character + case '\u2029': return 'p'; // paragraph-separator character + case '|': return '|'; + case '\'': return '\''; + case '[': return '['; + case ']': return ']'; + default:return 0; + } + } + + public char escapeCharacter() { + return '|'; + } + }; + + /** + * Escapes characters specified by provider with '\' and specified character. + * @param str initial string + * @param p escape info provider. + * @return escaped string. + */ + public static String escapeStr(final String str, EscapeInfoProvider p) { + if (str == null) return null; + int finalCount = calcFinalEscapedStringCount(str, p); + + if (str.length() == finalCount) return str; + + char[] resultChars = new char[finalCount]; + int resultPos = 0; + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + final char escaped = p.escape(c); + if (escaped != 0) { + resultChars[resultPos++] = p.escapeCharacter(); + resultChars[resultPos++] = escaped; + } + else { + resultChars[resultPos++] = c; + } + } + + if (resultPos != finalCount) { + throw new RuntimeException("Incorrect escaping for '" + str + "'"); + } + return new String(resultChars); + } + + private static int calcFinalEscapedStringCount(final String name, final EscapeInfoProvider p) { + int result = 0; + for (int i = 0; i < name.length(); i++) { + char c = name.charAt(i); + if (p.escape(c) != 0) { + result += 2; + } + else { + result += 1; + } + } + + return result; + } + + public static String asString(final String messageName, final Map attributes) { + String text = "##teamcity[" + messageName; + for (final String attrName : attributes.keySet()) { + text += " " + attrName + "='" + escapeStr(attributes.get(attrName), STD_ESCAPER) + "'"; + } + text += "]"; + return text; + } + +} diff --git a/plugins/testng_rt/testng_rt.iml b/plugins/testng_rt/testng_rt.iml index 3921608b92b4..f347fc89bc27 100644 --- a/plugins/testng_rt/testng_rt.iml +++ b/plugins/testng_rt/testng_rt.iml @@ -8,7 +8,6 @@ - \ No newline at end of file