diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java index 6de8c43e0f79..733de352a6aa 100644 --- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java @@ -736,7 +736,8 @@ public class DfaMemoryStateImpl implements DfaMemoryState { } public void flushVariable(@NotNull DfaVariableValue variable) { - if (variable.getPsiVariable().hasModifierProperty(PsiModifier.FINAL)) { + PsiVariable psiVariable = variable.getPsiVariable(); + if (psiVariable instanceof PsiField && psiVariable.hasModifierProperty(PsiModifier.FINAL)) { return; } diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/FinalLoopVariableInstanceof.java b/java/java-tests/testData/inspection/dataFlow/fixture/FinalLoopVariableInstanceof.java new file mode 100644 index 000000000000..f60cad9974f8 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/FinalLoopVariableInstanceof.java @@ -0,0 +1,16 @@ +public class Test { + + public static void main(Object[] args) throws Exception { + boolean elvisLives = false; + for (final Object o : args) { + if (o instanceof Integer) { + elvisLives = true; + } else { + if (elvisLives) { + System.err.println("Elvis is alive!"); + } + } + } + } + +} diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java index 57ca43e790bb..0f0f2430cb5e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java @@ -75,5 +75,6 @@ public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCas public void testNotEqualsDoesntImplyNotNullity() throws Throwable { doTest(); } public void testEqualsEnumConstant() throws Throwable { doTest(); } public void testEqualsConstant() throws Throwable { doTest(); } + public void testFinalLoopVariableInstanceof() throws Throwable { doTest(); } } diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java index 9a7202125242..f9ac675c2a50 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java @@ -82,11 +82,11 @@ public class JBEditorTabs extends JBTabsImpl { int _y = effectiveBounds.y + insets.top; int _width = effectiveBounds.width - insets.left - insets.right + (getTabsPosition() == JBTabsPosition.right ? 1 : 0); int _height = effectiveBounds.height - insets.top - insets.bottom; - - + + if ((!isSingleRow() /* for multiline */) || (isSingleRow() && isHorizontalTabs())) { if (isSingleRow() && getPosition() == JBTabsPosition.bottom) { - _y += TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; + _y += TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; } else { if (isSingleRow()) { _height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; @@ -98,7 +98,7 @@ public class JBEditorTabs extends JBTabsImpl { } } } - + Color tabColor = label.getInfo().getTabColor(); if (tabColor != null) { //g2d.setPaint(new LinearGradientPaint(_x, _y, _x, _y + effectiveBounds.height, new float[] {.3f, .6f, 1f}, new Color[] {new SameColor(170), new SameColor(150), new SameColor(90)})); @@ -192,7 +192,7 @@ public class JBEditorTabs extends JBTabsImpl { Rectangle r = label.getBounds(); ShapeInfo selectedShape = _computeSelectedLabelShape(); - + Insets insets = getTabsBorder().getEffectiveBorder(); Insets i = selectedShape.path.transformInsets(insets); @@ -218,23 +218,23 @@ public class JBEditorTabs extends JBTabsImpl { if (tabColor != null) { g2d.setColor(multiplyColor(tabColor)); g2d.fill(selectedShape.fillPath.getShape()); - + g2d.setPaint(new GradientPaint(_x, _y, new Color(255, 255, 255, 150), _x, _y + _height, new Color(255, 255, 255, 0))); } else { g2d.setPaint(new GradientPaint(_x, _y, new SameColor(255), _x, _y + _height, new SameColor(230))); } g2d.fill(selectedShape.fillPath.getShape()); - + g2d.setColor(new Color(255, 255, 255, 180)); g2d.draw(selectedShape.fillPath.getShape()); - + // fix right side due to swing stupidity (fill & draw will occupy different shapes) g2d.draw(selectedShape.labelPath .transformLine(selectedShape.labelPath.getMaxX() - selectedShape.labelPath.deltaX(1), selectedShape.labelPath.getY() + selectedShape.labelPath.deltaY(1), - selectedShape.labelPath.getMaxX() - selectedShape.labelPath.deltaX(1), selectedShape.labelPath.getMaxY() - - selectedShape.labelPath.deltaY(4))); + selectedShape.labelPath.getMaxX() - selectedShape.labelPath.deltaX(1), selectedShape.labelPath.getMaxY() - + selectedShape.labelPath.deltaY(4))); if (!isHorizontalTabs()) { // side shadow @@ -258,7 +258,7 @@ public class JBEditorTabs extends JBTabsImpl { g2d.setColor(new Color(0, 0, 0, 50)); g2d.draw(selectedShape.labelPath.transformLine(i.left, selectedShape.labelPath.getMaxY(), - selectedShape.path.getMaxX(), + selectedShape.path.getMaxX(), selectedShape.labelPath.getMaxY())); } @@ -266,14 +266,14 @@ public class JBEditorTabs extends JBTabsImpl { public Color getBackground() { return new SameColor(142); } - + protected ShapeInfo _computeSelectedLabelShape() { final ShapeInfo shape = new ShapeInfo(); shape.path = getEffectiveLayout().createShapeTransform(getSize()); shape.insets = shape.path.transformInsets(getLayoutInsets()); shape.labelPath = shape.path.createTransform(getSelectedLabel().getBounds()); - + shape.labelBottomY = shape.labelPath.getMaxY() - shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1); shape.labelTopY = shape.labelPath.getY() + (getPosition() == JBTabsPosition.top || getPosition() == JBTabsPosition.bottom ? shape.labelPath.deltaY(1) : 0) ; @@ -282,7 +282,7 @@ public class JBEditorTabs extends JBTabsImpl { shape.labelRightX = shape.labelPath.getMaxX() - shape.labelPath.deltaX(1); int leftX = shape.insets.left + (getPosition() == JBTabsPosition.top || getPosition() == JBTabsPosition.bottom ? 0 : shape.labelPath.deltaX(1)); - + shape.path.moveTo(leftX, shape.labelBottomY); shape.path.lineTo(shape.labelLeftX, shape.labelBottomY); shape.path.lineTo(shape.labelLeftX, shape.labelTopY); @@ -294,10 +294,10 @@ public class JBEditorTabs extends JBTabsImpl { shape.path.lineTo(lastX, shape.labelBottomY); shape.path.lineTo(lastX, shape.labelBottomY + shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1)); shape.path.lineTo(leftX, shape.labelBottomY + shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1)); - + shape.path.closePath(); shape.fillPath = shape.path.copy(); - + return shape; } } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/borders/DarculaCheckBoxUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/borders/DarculaCheckBoxUI.java index c9d5870bd627..483773477bc0 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/borders/DarculaCheckBoxUI.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/borders/DarculaCheckBoxUI.java @@ -109,10 +109,13 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { if (b.getModel().isSelected()) { g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); - g.setPaint(Gray._200); g.setStroke(new BasicStroke(2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); - g.drawLine(iconRect.x + 4, iconRect.y + 6, iconRect.x + 7, iconRect.y + 10); - g.drawLine(iconRect.x + 7, iconRect.y + 10, iconRect.x + iconRect.width + 1, iconRect.y -1); + g.setPaint(Gray._30); + g.drawLine(iconRect.x + 4, iconRect.y + 8, iconRect.x + 9, iconRect.y + 14); + g.drawLine(iconRect.x + 9, iconRect.y + 14, iconRect.x + iconRect.width, iconRect.y+2); + g.setPaint(Gray._200); + g.drawLine(iconRect.x + 4, iconRect.y + 6, iconRect.x + 9, iconRect.y + 12); + g.drawLine(iconRect.x + 9, iconRect.y + 12, iconRect.x + iconRect.width, iconRect.y); } config.restore(); //icon.paintIcon(c, g, iconRect.x, iconRect.y); diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula.properties b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula.properties index ecbb31754e3d..5954c3433607 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula.properties +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula.properties @@ -51,8 +51,6 @@ TextPane.caretForeground=cccccc CheckBox.background=333333 CheckBox.foreground=cccccc -CheckBox.icon=AllIcons.Darcula.Checkbox -CheckBox.selectedIcon=AllIcons.Darcula.CheckboxSelected CheckBoxUI=com.intellij.ide.ui.laf.borders.DarculaCheckBoxUI RadioButton.foreground=cccccc diff --git a/plugins/groovy/resources/standardDsls/defaultMethods.gdsl b/plugins/groovy/resources/standardDsls/defaultMethods.gdsl index e269d2230dfa..b93896995b56 100644 --- a/plugins/groovy/resources/standardDsls/defaultMethods.gdsl +++ b/plugins/groovy/resources/standardDsls/defaultMethods.gdsl @@ -18,14 +18,12 @@ package standardDsls import com.intellij.psi.PsiType import com.intellij.psi.util.PsiUtil -import static standardDsls.Constants.NUMBER import static standardDsls.Constants.STRING /** * @author Maxim.Medvedev */ private interface Constants { - String NUMBER = "java.lang.Number" String STRING = "java.lang.String" String WILDCARD_PREFIX = "? extends " } @@ -61,22 +59,25 @@ contributor(ctype:"groovy.lang.GString") { delegatesTo(findClass("java.lang.String")) } -contributor(ctype:NUMBER) { - method name: "plus", type: NUMBER, params:[arg:NUMBER] - method name: "minus", type: NUMBER, params:[arg:NUMBER] - method name: "multiply", type: NUMBER, params:[arg:NUMBER] - method name: "power", type: NUMBER, params:[arg:NUMBER] - method name: "div", type: NUMBER, params:[arg:NUMBER] - method name: "mod", type: NUMBER, params:[arg:NUMBER] - method name: "or", type: NUMBER, params:[arg:NUMBER] - method name: "and", type: NUMBER, params:[arg:NUMBER] - method name: "xor", type: NUMBER, params:[arg:NUMBER] - method name: "next", type: removeWildcard(psiType.canonicalText) - method name: "previous", type: removeWildcard(psiType.canonicalText) - method name: "negative", type: removeWildcard(psiType.canonicalText) - method name: "positive", type: removeWildcard(psiType.canonicalText) +[Integer, Double, Float, Byte, Long, Short, Number].each { + def className = it.canonicalName + contributor(ctype: className) { + method name: "plus", type: className, params: [arg: className] + method name: "minus", type: className, params: [arg: className] + method name: "multiply", type: className, params: [arg: className] + method name: "power", type: className, params: [arg: className] + method name: "div", type: className, params: [arg: className] + method name: "mod", type: className, params: [arg: className] + method name: "or", type: className, params: [arg: className] + method name: "and", type: className, params: [arg: className] + method name: "xor", type: className, params: [arg: className] + method name: "next", type: className + method name: "previous", type: className + method name: "negative", type: className + method name: "positive", type: className - method name: "plus", type: STRING, params:[arg:STRING] + method name: "plus", type: STRING, params: [arg: STRING] + } } contributor(ctype: 'groovy.lang.MetaClass') { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GrKeywordAndDeclarationHighlighter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GrKeywordAndDeclarationHighlighter.java index 041c9f1ddd1a..c5e723129b59 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GrKeywordAndDeclarationHighlighter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GrKeywordAndDeclarationHighlighter.java @@ -23,6 +23,7 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiErrorElement; import com.intellij.psi.PsiRecursiveElementVisitor; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; @@ -66,7 +67,7 @@ public class GrKeywordAndDeclarationHighlighter extends TextEditorHighlightingPa result.add(HighlightInfo.createHighlightInfo(HighlightInfoType.INFORMATION, element, null, DefaultHighlighter.KEYWORD)); } } - else if (!(element instanceof GroovyPsiElement)) { + else if (!(element instanceof GroovyPsiElement || element instanceof PsiErrorElement)) { final TextAttributesKey attribute = getDeclarationAttribute(element); if (attribute != null) { result.add(HighlightInfo.createHighlightInfo(HighlightInfoType.INFORMATION, element, null, attribute)); diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/methodParamInClosureImplicitReturn.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/methodParamInClosureImplicitReturn.java index 94756942eaa3..f99657794bc8 100644 --- a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/methodParamInClosureImplicitReturn.java +++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/methodParamInClosureImplicitReturn.java @@ -10,13 +10,13 @@ return null; public void foo(int x) { final groovy.lang.Reference i = new groovy.lang.Reference(x); -org.codehaus.groovy.runtime.DefaultGroovyMethods.each(new java.util.ArrayList(java.util.Arrays.asList(1, 2, 3)), new groovy.lang.Closure(this, this) { -public java.lang.Number doCall(java.lang.Object it) { +org.codehaus.groovy.runtime.DefaultGroovyMethods.each(new java.util.ArrayList(java.util.Arrays.asList(1, 2, 3)), new groovy.lang.Closure(this, this) { +public java.lang.Integer doCall(java.lang.Object it) { org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, i.get()); return setGroovyRef(i, i.get() + 1); } -public java.lang.Number doCall() { +public java.lang.Integer doCall() { return doCall(null); }