Merge remote-tracking branch 'origin/master'
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Thu, 6 Nov 2014 19:23:22 +0000 (20:23 +0100)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Thu, 6 Nov 2014 19:23:22 +0000 (20:23 +0100)
17 files changed:
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/PropertiesInsteadOfSiteSubstitutorIfAny.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/TypeParametersInitOrder.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java
platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/PersistableCodeStyleSchemes.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/AbstractUpdateDialog.java
platform/platform-impl/src/com/intellij/ui/popup/PopupComponent.java
platform/util/src/com/intellij/util/xmlb/SerializationFilter.java
platform/util/src/com/intellij/util/xmlb/SerializationFilterBase.java
platform/util/src/com/intellij/util/xmlb/XmlSerializer.java
platform/util/testSrc/com/intellij/util/xmlb/XmlSerializerTest.java
plugins/tasks/tasks-core/src/com/intellij/tasks/context/XDebuggerBreakpointsContextProvider.java
plugins/tasks/tasks-core/src/com/intellij/tasks/context/XDebuggerWatchesProvider.java

index 095912a200945e196a8c3fe0c0675c050fae2abd..936516efc083fdc40c2d3cf98ecd3d9320c4a49d 100644 (file)
@@ -617,9 +617,10 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
         myHolder.add(HighlightMethodUtil.checkConstructorName(method));
       }
       myHolder.add(HighlightNamesUtil.highlightMethodName(method, identifier, true, colorsScheme));
-      myHolder.add(GenericsHighlightUtil.checkDefaultMethodOverrideEquivalentToObjectNonPrivate(myLanguageLevel,
-                                                                                                method.getContainingClass(), method,
-                                                                                                identifier));
+      final PsiClass aClass = method.getContainingClass();
+      if (aClass != null) {
+        myHolder.add(GenericsHighlightUtil.checkDefaultMethodOverrideEquivalentToObjectNonPrivate(myLanguageLevel, aClass, method, identifier));
+      }
     }
 
     super.visitIdentifier(identifier);
index f7b73ba5eee2a5971ca5783e6e1448050b8b16b2..95baff29ef690d7616b8018186c32bf2cb1be3a6 100644 (file)
@@ -105,7 +105,7 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
 
         if (typeParams != null) {
           PsiSubstitutor siteSubstitutor =
-            resolveResult instanceof MethodCandidateInfo && method != null && !method.isConstructor() ? ((MethodCandidateInfo)resolveResult).getSiteSubstitutor() : PsiSubstitutor.EMPTY;
+            resolveResult instanceof MethodCandidateInfo && method != null && !method.isConstructor() ? ((MethodCandidateInfo)resolveResult).getSiteSubstitutor() : candidateProperties != null ? candidateProperties.getSubstitutor() : PsiSubstitutor.EMPTY;
           final InferenceSession callSession = new InferenceSession(typeParams, siteSubstitutor, myExpression.getManager(), myExpression);
           callSession.propagateVariables(session.getInferenceVariables());
           if (method != null) {
index b5e4188e1644babd0adf1e4100478acf8c904bb1..45018296d88800d01749bb45f20f34e7cfffc522 100644 (file)
@@ -169,13 +169,13 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
       }
       LOG.assertTrue(referencedMethodReturnType != null, method);
 
-      session.initBounds(myExpression, method.getTypeParameters());
-
-      if (!PsiTreeUtil.isContextAncestor(containingClass, myExpression, false) || 
+      if (!PsiTreeUtil.isContextAncestor(containingClass, myExpression, false) ||
           PsiUtil.getEnclosingStaticElement(myExpression, containingClass) != null) {
         session.initBounds(myExpression, containingClass.getTypeParameters());
       }
 
+      session.initBounds(myExpression, method.getTypeParameters());
+
       //if i) the method reference elides NonWildTypeArguments, 
       //  ii) the compile-time declaration is a generic method, and 
       // iii) the return type of the compile-time declaration mentions at least one of the method's type parameters;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/PropertiesInsteadOfSiteSubstitutorIfAny.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/PropertiesInsteadOfSiteSubstitutorIfAny.java
new file mode 100644 (file)
index 0000000..ddc4008
--- /dev/null
@@ -0,0 +1,51 @@
+
+import java.util.List;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
+
+class Test {
+  public static class Thing {
+    public Integer toPresenter() {
+      return 1;
+    }
+  }
+
+  public <U> void map1(Function<Object, U> mapper) {}
+
+  private  void getPresentersFailure( final Stream<Thing> stream) {
+    map1((roles) -> {
+      return stream.map(Thing::toPresenter);
+    });
+  }
+
+}
+
+class Test1 {
+  public interface Convertable {
+    ThingPresenter toPresenter();
+  }
+
+  public static class Thing implements Convertable {
+    @Override
+    public ThingPresenter toPresenter() {
+      return new ThingPresenter("thing");
+    }
+  }
+
+  public static class ThingPresenter {
+    public String value;
+    public ThingPresenter(String value) { this.value = value; }
+  }
+
+  private static Stream<ThingPresenter> getPresentersFailure(Supplier<Optional<List<Thing>>> thingSupplier) {
+    Optional<List<Thing>> personRoles = thingSupplier.get();
+    return personRoles.map(roles -> roles.stream().map(Thing::toPresenter)).get();
+  }
+
+  private static Stream<ThingPresenter> getPresentersWorking(Supplier<Optional<List<Thing>>> thingSupplier) {
+    Optional<List<Thing>> personRoles = thingSupplier.get();
+    return personRoles.map(roles -> roles.stream().map(t -> t.toPresenter())).get();
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/TypeParametersInitOrder.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/TypeParametersInitOrder.java
new file mode 100644 (file)
index 0000000..966b013
--- /dev/null
@@ -0,0 +1,21 @@
+import java.util.function.Function;
+
+interface Repository<T> {
+  <S extends T> S save(S s);
+}
+
+interface Builder<T> {
+
+  T build();
+
+  default <D> Builder<D> map(Function<T, D> fx) {
+    return () -> fx.apply(this.build());
+  }
+}
+
+class Usage {
+  void test(Repository<String> repository, Builder<String> sample) {
+    sample.map(repository::save).build();
+    sample.map((s) -> repository.save(s)).build();
+  }
+}
\ No newline at end of file
index 5f606082970e27a3d2f16f46e7242b4f1c6f4fe7..416f07e77b220e0e47aff6c8751650908f47b059 100644 (file)
@@ -156,6 +156,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
     doTest();
   }
 
+  public void testPropertiesInsteadOfSiteSubstitutorIfAny() throws Exception {
+    doTest();
+  }
+
   private void doTest() {
     doTest(false);
   }
index 281cefa641093df99f22154b0b9b8b23f899235f..57629d86b601ae954728e8d3850d2cb45034bfed 100644 (file)
@@ -318,6 +318,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
     doTest();
   }
 
+  public void testTypeParametersInitOrder() throws Exception {
+    doTest();
+  }
+
   private void doTest() {
     doTest(false);
   }
index 4a390bc1383b99616dca241f8c2f40d347a8cd39..a366c5bff330085a9c4ea325eb19491f8e38b73d 100644 (file)
@@ -186,7 +186,7 @@ public class UISettings extends SimpleModificationTracker implements PersistentS
 
   public static class FontFilter implements SerializationFilter {
     @Override
-    public boolean accepts(Accessor accessor, Object bean) {
+    public boolean accepts(@NotNull Accessor accessor, Object bean) {
       UISettings settings = (UISettings)bean;
       return !hasDefaultFontSetting(settings);
     }
index e3f4fb760fbfb500442c7b97fa793ebb8a2e4705..d04cc68967bcae255f5bb3de19c1e00889c2900e 100644 (file)
@@ -52,7 +52,7 @@ public class PersistableCodeStyleSchemes extends CodeStyleSchemesImpl implements
   public Element getState() {
     return XmlSerializer.serialize(this, new SerializationFilter() {
       @Override
-      public boolean accepts(Accessor accessor, Object bean) {
+      public boolean accepts(@NotNull Accessor accessor, Object bean) {
         return accessor.getValueClass().equals(String.class);
       }
     });
index 7d5456dd53b365d36b406344f0c0248711f516dc..fb3f69fc9c77c68d0e4bc7e83144304dcb6c0067 100644 (file)
@@ -102,7 +102,7 @@ public abstract class AbstractUpdateDialog extends DialogWrapper {
 
 
   protected void configureMessageArea(@NotNull JEditorPane area) {
-    configureMessageArea(area, IdeBundle.message("updates.configure.label", ShowSettingsUtil.getSettingsMenuName()), null, null);
+    configureMessageArea(area, myEnableLink ? IdeBundle.message("updates.configure.label", ShowSettingsUtil.getSettingsMenuName()) : "", null, null);
   }
 
   protected void configureMessageArea(final @NotNull JEditorPane area,
@@ -113,7 +113,7 @@ public abstract class AbstractUpdateDialog extends DialogWrapper {
                  UIUtil.getCssFontDeclaration(UIUtil.getLabelFont(), fontColor, null, null) +
                  "<style>body {background: #" + ColorUtil.toHex(UIUtil.getPanelBackground()) + ";}</style>" +
                  "</head><body>" +
-                 (myEnableLink ? messageBody : "") +
+                 messageBody +
                  "</body></html>";
 
     area.setBackground(UIUtil.getPanelBackground());
index 1670491b91bf81de26f95b11204ef0606767260c..aa2f1745b03bcc1af129fa013736704a784e9fa1 100644 (file)
@@ -140,23 +140,10 @@ public interface PopupComponent {
         myDialog.setFocusableWindowState(false);
       }
 
-      try {
-        if (UIUtil.isUnderDarcula()) {
-          AWTUtilities.setWindowOpaque(myDialog, false);
-        }
-      }
-      catch (Exception ignore) {
-      }
-
+      AwtPopupWrapper.fixFlickering(myDialog, false);
       myDialog.setVisible(true);
+      AwtPopupWrapper.fixFlickering(myDialog, true);
 
-      try {
-        if (UIUtil.isUnderDarcula()) {
-          AWTUtilities.setWindowOpaque(myDialog, true);
-        }
-      }
-      catch (Exception ignore) {
-      }
       SwingUtilities.invokeLater(new Runnable() {
         public void run() {
           myDialog.setFocusableWindowState(true);
index 4c0d2a81ff6291b2225274e319c3176e88fe41d3..01f6f68f4fd10e6df3795da02f0818afe5a8d42d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.intellij.util.xmlb;
 
+import org.jetbrains.annotations.NotNull;
+
 public interface SerializationFilter {
-  boolean accepts(Accessor accessor, Object bean);
+  boolean accepts(@NotNull Accessor accessor, Object bean);
 }
index 3fab01c85af69316c3075904836affec48ff1be2..7c1cb2b51795fa865eb11bd0f3f0655530cf1a8f 100644 (file)
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.Nullable;
 
 public abstract class SerializationFilterBase implements SerializationFilter {
   @Override
-  public final boolean accepts(Accessor accessor, Object bean) {
+  public final boolean accepts(@NotNull Accessor accessor, Object bean) {
     if (bean == null) {
       return true;
     }
index 76fa9d08c0e11e58279399e539884efed2983116..97e4a35276a5fe9d3bae94f90c002c5403ba52b3 100644 (file)
@@ -31,7 +31,7 @@ import java.util.Set;
 public class XmlSerializer {
   private static final SerializationFilter TRUE_FILTER = new SerializationFilter() {
     @Override
-    public boolean accepts(Accessor accessor, Object bean) {
+    public boolean accepts(@NotNull Accessor accessor, Object bean) {
       return true;
     }
   };
index a5b8edc491aa7624526f16c6d9f8e52b78d8d5c0..69cc37512462fc69ed069104896cc9bf823b4a8e 100644 (file)
@@ -537,7 +537,7 @@ public class XmlSerializerTest extends TestCase {
                      "</BeanWithPublicFields>",
                      new SerializationFilter() {
       @Override
-      public boolean accepts(Accessor accessor, Object bean) {
+      public boolean accepts(@NotNull Accessor accessor, Object bean) {
         return accessor.getName().startsWith("I");
       }
     });
@@ -850,7 +850,7 @@ public class XmlSerializerTest extends TestCase {
   }
   public static class PropertyFilterTest implements SerializationFilter {
     @Override
-    public boolean accepts(Accessor accessor, Object bean) {
+    public boolean accepts(@NotNull Accessor accessor, Object bean) {
       return !accessor.read(bean).equals("skip");
     }
   }
index 2e8d5df8c823a0e4caca274a2cd7000943e5220d..ec4d81f86d2ccb9f519f8d80009c1a8a8635c8aa 100644 (file)
@@ -56,7 +56,7 @@ public class XDebuggerBreakpointsContextProvider extends WorkingContextProvider
     XBreakpointManagerImpl.BreakpointManagerState state = myBreakpointManager.getState();
     Element serialize = XmlSerializer.serialize(state, new SerializationFilter() {
       @Override
-      public boolean accepts(Accessor accessor, Object bean) {
+      public boolean accepts(@NotNull Accessor accessor, Object bean) {
         return accessor.read(bean) != null;
       }
     });
index 62b26995daf23c5b0ed2dfbda64303d2161161aa..2b39f86d30b8ff3617a2688e3174fb933536d442 100644 (file)
@@ -54,7 +54,7 @@ public class XDebuggerWatchesProvider extends WorkingContextProvider {
     XDebuggerWatchesManager.WatchesManagerState state = myWatchesManager.getState();
     Element serialize = XmlSerializer.serialize(state, new SerializationFilter() {
       @Override
-      public boolean accepts(Accessor accessor, Object bean) {
+      public boolean accepts(@NotNull Accessor accessor, Object bean) {
         return accessor.read(bean) != null;
       }
     });