From aecfafc8fc8e20d58c895d79a6c9fff9b7fdf5e6 Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Tue, 12 Aug 2014 15:01:35 +0400 Subject: [PATCH 01/32] minor --- .../com/intellij/ide/actions/CreateLauncherScriptAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java b/platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java index 0d333a4be636..411f2d9d93bb 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java @@ -45,7 +45,7 @@ import static java.util.Arrays.asList; */ public class CreateLauncherScriptAction extends DumbAwareAction { private static final Logger LOG = Logger.getInstance("#com.intellij.ide.actions.CreateLauncherScriptAction"); - public static final String CONTENTS = "/Contents"; + private static final String CONTENTS = "/Contents"; public static boolean isAvailable() { return SystemInfo.isUnix; From 60139e325b5e1416290dff75cb8e5a734b7e3e3f Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Tue, 12 Aug 2014 15:59:25 +0400 Subject: [PATCH 02/32] PY-12801 Correctly infer type of result for tuple concatenation --- .../stdlib/PyStdlibTypeProvider.java | 19 +++++++++++++++++++ .../PyStringFormatInspection/expected.xml | 16 ++++++++++++++++ .../src/string-format.py | 8 +++++++- .../com/jetbrains/python/PyTypeTest.java | 6 ++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java index 346d40f3273e..c28bc29455c9 100644 --- a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java +++ b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java @@ -36,6 +36,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import static com.jetbrains.python.psi.PyUtil.as; + /** * @author yole */ @@ -132,6 +134,23 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase { } } } + else if ("__builtin__.tuple.__add__".equals(qname) && callSite instanceof PyBinaryExpression) { + final PyBinaryExpression expression = (PyBinaryExpression)callSite; + final PyTupleType leftTupleType = as(context.getType(expression.getLeftExpression()), PyTupleType.class); + if (expression.getRightExpression() != null) { + final PyTupleType rightTupleType = as(context.getType(expression.getRightExpression()), PyTupleType.class); + if (leftTupleType != null && rightTupleType != null) { + final PyType[] elementTypes = new PyType[leftTupleType.getElementCount() + rightTupleType.getElementCount()]; + for (int i = 0; i < leftTupleType.getElementCount(); i++) { + elementTypes[i] = leftTupleType.getElementType(i); + } + for (int i = 0; i < rightTupleType.getElementCount(); i++) { + elementTypes[i + leftTupleType.getElementCount()] = rightTupleType.getElementType(i); + } + return PyTupleType.create(function, elementTypes); + } + } + } } return null; } diff --git a/python/testData/inspections/PyStringFormatInspection/expected.xml b/python/testData/inspections/PyStringFormatInspection/expected.xml index 62301ce56510..25e70285bd8d 100644 --- a/python/testData/inspections/PyStringFormatInspection/expected.xml +++ b/python/testData/inspections/PyStringFormatInspection/expected.xml @@ -160,4 +160,20 @@ 99 Too few arguments for format string + + string-format.py + 103 + Unexpected type + + + string-format.py + 104 + Too few arguments for format string + + + string-format.py + 105 + Too many arguments for format string + + diff --git a/python/testData/inspections/PyStringFormatInspection/src/string-format.py b/python/testData/inspections/PyStringFormatInspection/src/string-format.py index e60e4bb90911..b82ebcf4eb5c 100644 --- a/python/testData/inspections/PyStringFormatInspection/src/string-format.py +++ b/python/testData/inspections/PyStringFormatInspection/src/string-format.py @@ -96,4 +96,10 @@ print '%d' % string[:2] my_tuple = (1,2,3,4,5,6,7,8) print '%d, %d' % my_tuple[:7:3] print '%d, %d, %d' % my_tuple[:7:3] -print '%d, %d, %d, %d' % my_tuple[:7:3] \ No newline at end of file +print '%d, %d, %d, %d' % my_tuple[:7:3] + +# PY-12801 +print '%d %s' % ((42,) + ('spam',)) +print '%d %s' % (('ham',) + ('spam',)) +print '%d %s' % ((42,) + ()) +print '%d' % ((42,) + ('spam',)) \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java index 88243f065a3b..b0e41bcffddc 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java @@ -829,6 +829,12 @@ public class PyTypeTest extends PyTestCase { " pass\n"); } + // PY-12801 + public void testTupleConcatenation() { + doTest("(int, bool, str)", + "expr = (1,) + (True, 'spam') + ()"); + } + private static TypeEvalContext getTypeEvalContext(@NotNull PyExpression element) { return TypeEvalContext.userInitiated(element.getContainingFile()).withTracing(); } From a218280be4727b496ca819f292646ed03bb68053 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 12 Aug 2014 15:51:42 +0400 Subject: [PATCH 03/32] new inference: take into account backward variable dependencies (IDEA-123951) --- .../resolve/graphInference/InferenceSession.java | 16 ++++++++++++++-- .../graphInference/InferenceVariable.java | 10 ++++++++++ .../daemon/lambda/NewLambdaHighlightingTest.java | 1 - 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java index 782df40b80b4..c04daa826daa 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java @@ -27,6 +27,7 @@ import com.intellij.psi.util.*; import com.intellij.util.ArrayUtilRt; import com.intellij.util.Function; import com.intellij.util.Processor; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -221,7 +222,7 @@ public class InferenceSession { } if (parameters != null && args != null && !MethodCandidateInfo.isOverloadCheck()) { - final Set additionalConstraints = new HashSet(); + final Set additionalConstraints = new LinkedHashSet(); if (parameters.length > 0) { collectAdditionalConstraints(parameters, args, properties.getMethod(), PsiSubstitutor.EMPTY, additionalConstraints, properties.isVarargs(), true); } @@ -881,7 +882,7 @@ public class InferenceSession { private Set buildSubset(final Set additionalConstraints) { - final Set subset = new HashSet(); + final Set subset = new LinkedHashSet(); final Set outputVariables = new HashSet(); for (ConstraintFormula constraint : additionalConstraints) { if (constraint instanceof InputOutputConstraintFormula) { @@ -899,8 +900,19 @@ public class InferenceSession { if (inputVariables != null) { boolean dependsOnOutput = false; for (InferenceVariable inputVariable : inputVariables) { + if (dependsOnOutput) break; + if (inputVariable.hasInstantiation(this)) continue; final Set dependencies = inputVariable.getDependencies(this); dependencies.add(inputVariable); + if (!hasCapture(inputVariable)) { + for (InferenceVariable outputVariable : outputVariables) { + if (ContainerUtil.intersects(outputVariable.getDependencies(this), dependencies)) { + dependsOnOutput = true; + break; + } + } + } + dependencies.retainAll(outputVariables); if (!dependencies.isEmpty()) { dependsOnOutput = true; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java index a19961f4c3a9..6bc9e0b89871 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java @@ -115,6 +115,16 @@ public class InferenceVariable extends LightTypeParameter { return dependencies; } + public boolean hasInstantiation(InferenceSession session) { + List bounds = getBounds(InferenceBound.EQ); + if (bounds != null) { + for (PsiType bound : bounds) { + if (session.isProperType(bound)) return true; + } + } + return false; + } + public boolean isThrownBound() { return myThrownBound; } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java index 2daed089d5c2..807ce9881c22 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java @@ -102,7 +102,6 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } - @Bombed(day = 20, month = Calendar.AUGUST) public void testIDEA123951() throws Exception { doTest(); } From 68248573dd0982ab0f84904d6d6e5d5f4402faa4 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 12 Aug 2014 16:00:23 +0400 Subject: [PATCH 04/32] testdata for IDEA-127124 comment --- .../lambda/newLambda/IDEA127124comment.java | 30 +++++++++++++++++++ .../lambda/NewLambdaHighlightingTest.java | 3 ++ 2 files changed, 33 insertions(+) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA127124comment.java diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA127124comment.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA127124comment.java new file mode 100644 index 000000000000..cb8442e59d12 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA127124comment.java @@ -0,0 +1,30 @@ +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; + +class Test { + private static class Thing { + final String val; + public Thing(String val) { + this.val = val; + } + } + + public static Optional> highlights() { + return Optional.of(Collections.singletonList(new Thing("Hello"))) + .map(l -> l + .stream() + .map(t -> t.val + " world!") + .collect(Collectors.toList())); + } + + public static Optional> works() { + return Optional.of(Collections.singletonList(new Thing("Hello"))) + .map(l -> l + .stream() + .map(t -> t.val + " world!") + .collect(Collectors.toList())); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java index 807ce9881c22..92eb0daa09f9 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java @@ -109,6 +109,9 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIDEA124190() throws Exception { doTest(); } + public void testIDEA127124comment() throws Exception { + doTest(); + } private void doTest() { doTest(false); From 7a01205e53dd59c3ed79b1ba800111c2c15a72a3 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Tue, 12 Aug 2014 16:14:33 +0400 Subject: [PATCH 05/32] highlight colors reverted --- colorSchemes/src/colorSchemes/Darcula.xml | 12 ++++++------ .../HighlightDisplayLevel.java | 2 +- platform/icons/src/general/errorMask.png | Bin 1034 -> 273 bytes platform/icons/src/general/errorMask@2x.png | Bin 1053 -> 0 bytes platform/icons/src/general/errorMask_dark.png | Bin 0 -> 147 bytes .../MultiScopeSeverityIcon.java | 2 +- .../src/DefaultColorSchemesManager.xml | 12 ++++++------ 7 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 platform/icons/src/general/errorMask@2x.png create mode 100644 platform/icons/src/general/errorMask_dark.png diff --git a/colorSchemes/src/colorSchemes/Darcula.xml b/colorSchemes/src/colorSchemes/Darcula.xml index 2665674ca240..9691e1db6a5e 100644 --- a/colorSchemes/src/colorSchemes/Darcula.xml +++ b/colorSchemes/src/colorSchemes/Darcula.xml @@ -553,9 +553,9 @@