Merge remote-tracking branch 'origin/master'

This commit is contained in:
Vladimir.Orlov
2015-05-19 12:21:06 +03:00
13 changed files with 113 additions and 8 deletions
@@ -76,7 +76,7 @@ public class JavaSafeDeleteDelegateImpl implements JavaSafeDeleteDelegate {
newText.append(StringUtil.join(parameters, new Function<PsiParameter, String>() {
@Override
public String fun(PsiParameter psiParameter) {
return parameter.getType().getCanonicalText();
return psiParameter.getType().getCanonicalText();
}
}, ","));
newText.append(")*/");
@@ -261,8 +261,7 @@ public class InferenceSession {
return prepareSubstitution();
}
if (parameters != null && args != null &&
!MethodCandidateInfo.ourOverloadGuard.currentStack().contains(PsiUtil.skipParenthesizedExprUp(parent.getParent()))) {
if (parameters != null && args != null) {
final Set<ConstraintFormula> additionalConstraints = new LinkedHashSet<ConstraintFormula>();
if (parameters.length > 0) {
collectAdditionalConstraints(parameters, args, properties.getMethod(), PsiSubstitutor.EMPTY, additionalConstraints, properties.isVarargs());
@@ -0,0 +1,22 @@
import java.util.TreeSet;
import java.util.function.Supplier;
import java.util.stream.Stream;
class Test {
void foo() {
log(get(TreeSet<String>::new));
}
private void <warning descr="Private method 'log(java.lang.String[])' is never used">log</warning>(String params[]) {
System.out.println(params);
}
private void log(Object params) {
System.out.println(params);
}
<C> C get(Supplier<C> s) {
return s.get();
}
}
@@ -0,0 +1,6 @@
class Test {
public void abc(Integer arg1, String ar<caret>g2, Integer arg3) {}
/** {@link #abc(Integer, String, Integer)} */
public void def() {}
}
@@ -0,0 +1,6 @@
class Test {
public void abc(Integer arg1, Integer arg3) {}
/** {@link #abc(Integer, Integer)} */
public void def() {}
}
@@ -114,6 +114,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testMethodReferenceWithTypeArgs() throws Exception {
doTest();
}
private void doTest() {
doTest(true);
}
@@ -112,6 +112,10 @@ public class SafeDeleteTest extends MultiFileTestCase {
doSingleFileTest();
}
public void testDeleteParameterAndUpdateJavadocRef() throws Exception {
doSingleFileTest();
}
public void testDeleteConstructorParameterWithAnonymousClassUsage() throws Exception {
doSingleFileTest();
}
@@ -115,22 +115,28 @@ public class AbstractMethodOverridesAbstractMethodInspection extends BaseInspect
if (!method.hasModifierProperty(PsiModifier.ABSTRACT) && !containingClass.isInterface()) {
return;
}
boolean overrideDefault = false;
boolean accept = false;
final PsiMethod[] superMethods = method.findSuperMethods();
for (final PsiMethod superMethod : superMethods) {
overrideDefault |= superMethod.hasModifierProperty(PsiModifier.DEFAULT);
if (!isAbstract(superMethod)) {
continue;
}
if (!methodsHaveSameReturnTypes(method, superMethod) || !haveSameExceptionSignatures(method, superMethod)) {
continue;
if (overrideDefault) {
return;
}
accept |= methodsHaveSameReturnTypes(method, superMethod) && haveSameExceptionSignatures(method, superMethod);
if (ignoreJavaDoc && !haveSameJavaDoc(method, superMethod)) {
return;
}
if (ignoreAnnotations && !methodsHaveSameAnnotations(method, superMethod)) {
return;
}
}
if (accept && !overrideDefault) {
registerMethodError(method);
return;
}
}
@@ -62,6 +62,23 @@ class SuperclassSubst {
}
class Java8DefaultMethods {
interface A {
String method();
}
interface B {
default String method() {
return null;
}
}
//without override would inherit abstract & default - red code
interface C extends A, B {
@Override
String method();
}
interface Super
{
default void method()
@@ -1,5 +1,9 @@
package com.siyeh.ig.inheritance;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.IdeaTestUtil;
import com.siyeh.ig.IGInspectionTestCase;
public class AbstractMethodOverridesAbstractMethodInspectionTest extends IGInspectionTestCase {
@@ -10,4 +14,11 @@ public class AbstractMethodOverridesAbstractMethodInspectionTest extends IGInspe
tool.ignoreJavaDoc = true;
doTest("com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method", tool);
}
@Override
protected Sdk getTestProjectSdk() {
Sdk sdk = IdeaTestUtil.getMockJdk17();
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST);
return sdk;
}
}
@@ -47,6 +47,10 @@ public class JavaFxCoercingTest extends AbstractJavaFXTestCase {
doTest();
}
public void testPrimitiveCoercing() throws Exception {
doTest();
}
private void doTest() throws Exception {
myFixture.testHighlighting(false, false, false, getTestName(true) + ".fxml");
}
@@ -3,6 +3,7 @@ package org.jetbrains.plugins.javaFX.fxml.descriptors;
import com.intellij.psi.*;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.psi.xml.*;
import com.intellij.util.ArrayUtil;
import com.intellij.xml.XmlAttributeDescriptor;
@@ -151,7 +152,14 @@ public class JavaFxPropertyAttributeDescriptor extends BasicXmlAttributeDescript
final XmlAttributeDescriptor attributeDescriptor = ((XmlAttribute)parent).getDescriptor();
if (attributeDescriptor != null) {
final PsiElement declaration = attributeDescriptor.getDeclaration();
final String boxedQName = getBoxedPropertyType(declaration);
final String boxedQName;
if (declaration != null) {
boxedQName = getBoxedPropertyType(declaration);
}
else {
final PsiClass tagClass = JavaFxPsiUtil.getTagClass((XmlAttributeValue)context);
boxedQName = tagClass != null ? tagClass.getQualifiedName() : null;
}
if (boxedQName != null) {
try {
final Class<?> aClass = Class.forName(boxedQName);
@@ -161,10 +169,20 @@ public class JavaFxPropertyAttributeDescriptor extends BasicXmlAttributeDescript
catch (InvocationTargetException e) {
final Throwable cause = e.getCause();
if (cause instanceof NumberFormatException) {
final PsiReference reference = context.getReference();
if (reference != null) {
final PsiElement resolve = reference.resolve();
if (resolve instanceof XmlAttributeValue) {
final PsiClass tagClass = JavaFxPsiUtil.getTagClass((XmlAttributeValue)resolve);
if (tagClass != null && boxedQName.equals(tagClass.getQualifiedName())) {
return null;
}
}
}
return "Invalid value: unable to coerce to " + boxedQName;
}
}
catch (Exception ignore) {
catch (Throwable ignore) {
}
}
}
@@ -0,0 +1,8 @@
<?import javafx.scene.layout.VBox?>
<?import java.lang.Double?>
<VBox xmlns:fx="http://javafx.com/fxml" alignment="center" spacing="20">
<fx:define>
<Double fx:id="CONTENT_SPACING" fx:value=<error descr="Invalid value: unable to coerce to java.lang.Double">"200p"</error>/>
</fx:define>
<VBox fx:id="content" spacing="$CONTENT_SPACING"/>
</VBox>