Merge remote-tracking branch 'origin/master'

This commit is contained in:
Yann Cébron
2016-08-12 15:41:27 +02:00
7 changed files with 26 additions and 22 deletions
@@ -2519,10 +2519,10 @@
key="expand.one.line.lambda2.code.block.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.code.style.issues" enabledByDefault="true" level="INFORMATION"
implementationClass="com.siyeh.ig.style.ExpandOneLineLambda2CodeBlockInspection"/>
<localInspection groupPath="Java" language="JAVA" shortName="InferLambdaParameterType" bundle="com.siyeh.InspectionGadgetsBundle"
key="infer.lambda.parameter.type.name" groupBundle="messages.InspectionsBundle"
<localInspection groupPath="Java" language="JAVA" shortName="LambdaParameterTypeCanBeSpecified" bundle="com.siyeh.InspectionGadgetsBundle"
key="lambda.parameter.type.can.be.specified.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.code.style.issues" enabledByDefault="true" level="INFORMATION"
implementationClass="com.siyeh.ig.style.InferLambdaParameterTypeInspection"/>
implementationClass="com.siyeh.ig.style.LambdaParameterTypeCanBeSpecifiedInspection"/>
<localInspection groupPath="Java" language="JAVA" shortName="DiamondCanBeReplacedWithExplicitTypeArguments" bundle="com.siyeh.InspectionGadgetsBundle"
key="diamond.can.be.replaced.with.explicit.type.arguments.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.code.style.issues" enabledByDefault="true" level="INFORMATION"
@@ -2159,8 +2159,10 @@ object.instantiation.inside.equals.or.hashcode.problem.descriptor=Object instant
expand.one.line.lambda2.code.block.name=Expand lambda expression body to code block
expand.one.line.lambda2.code.block.descriptor=Expand lambda expression body to {...}
expand.one.line.lambda2.code.block.quickfix=Expand lambda expression body to {...}
infer.lambda.parameter.type.name=Infer lambda parameter type
infer.lambda.parameter.type.descriptor=Expand lambda to {0} -> '{'...'}'
lambda.parameter.type.can.be.specified.name=Lambda parameter type can be specified
lambda.parameter.type.can.be.specified.descriptor=Lambda can be expanded to {0} -> '{'...'}'
lambda.parameter.type.can.be.specified.quickfix=Expand lambda to {0} -> '{'...'}'
lambda.parameter.type.can.be.specified.family.quickfix=Specify lambda parameter type
diamond.can.be.replaced.with.explicit.type.arguments.name=Diamond can be replaced with explicit type arguments
diamond.can.be.replaced.with.explicit.type.arguments.quickfix=Replace '<>' with explicit type arguments
lambda.can.be.replaced.with.anonymous.name=Lambda can be replaced with anonymous class
@@ -30,20 +30,20 @@ import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class InferLambdaParameterTypeInspection extends BaseInspection {
private static final Logger LOG = Logger.getInstance("#" + InferLambdaParameterTypeInspection.class.getName());
public class LambdaParameterTypeCanBeSpecifiedInspection extends BaseInspection {
private static final Logger LOG = Logger.getInstance("#" + LambdaParameterTypeCanBeSpecifiedInspection.class.getName());
@Nls
@NotNull
@Override
public String getDisplayName() {
return InspectionGadgetsBundle.message("infer.lambda.parameter.type.name");
return InspectionGadgetsBundle.message("lambda.parameter.type.can.be.specified.name");
}
@NotNull
@Override
protected String buildErrorString(Object... infos) {
return InspectionGadgetsBundle.message("infer.lambda.parameter.type.descriptor", infos);
return InspectionGadgetsBundle.message("lambda.parameter.type.can.be.specified.descriptor", infos);
}
@Override
@@ -126,21 +126,21 @@ public class InferLambdaParameterTypeInspection extends BaseInspection {
@NotNull
@Override
public String getName() {
return InspectionGadgetsBundle.message("infer.lambda.parameter.type.descriptor", myInfos);
return InspectionGadgetsBundle.message("lambda.parameter.type.can.be.specified.quickfix", myInfos);
}
@Nls
@NotNull
@Override
public String getFamilyName() {
return InspectionGadgetsBundle.message("infer.lambda.parameter.type.name");
return InspectionGadgetsBundle.message("lambda.parameter.type.can.be.specified.family.quickfix");
}
@Override
protected void doFix(Project project, ProblemDescriptor descriptor) {
final PsiElement element = descriptor.getPsiElement();
if (element instanceof PsiLambdaExpression) {
InferLambdaParameterTypeInspection.doFix(project, (PsiLambdaExpression)element);
LambdaParameterTypeCanBeSpecifiedInspection.doFix(project, (PsiLambdaExpression)element);
}
}
}
@@ -3,8 +3,8 @@
This inspection reports instantiation of generic classes where <b>&lt;&gt;</b> (diamond) is used instead of type parameters.
<p>The quick fix replaces the <b>&lt;&gt;</b> (diamond) with the explicit type parameters.
<p>Example of use of the diamond:
<pre><code>List String&gt; list = new ArrayList&lt;&gt;()</code></pre>
<pre><code>List &lt;String&gt; list = new ArrayList&lt;&gt;()</code></pre>
<p>The statement above is replaced with the following:
<pre><code>List String&gt; list = new ArrayList&lt;String&gt;()</code></pre>
<pre><code>List &lt;String&gt; list = new ArrayList&lt;String&gt;()</code></pre>
</body>
</html>
@@ -1,5 +0,0 @@
<html>
<body>
This inspection extends lambda parameters to contain formal types
</body>
</html>
@@ -0,0 +1,7 @@
<html>
<body>
This inspection reports lambda parameters which don't have their type specified, e.g. <code>a&nbsp;->&nbsp;a&nbsp;+&nbsp;1</code>
<p>The quick fix adds type declaration to the lambda parameters, the result looks like this:
<code>(int&nbsp;a)&nbsp;->&nbsp;a&nbsp;+&nbsp;1</code>
</body>
</html>
@@ -16,13 +16,13 @@
package com.siyeh.ig.fixes.style;
import com.siyeh.ig.IGQuickFixesTestCase;
import com.siyeh.ig.style.InferLambdaParameterTypeInspection;
import com.siyeh.ig.style.LambdaParameterTypeCanBeSpecifiedInspection;
public class InferLambdaParameterTypeFixTest extends IGQuickFixesTestCase {
public class LambdaParameterTypeCanBeSpecifiedFixTest extends IGQuickFixesTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
myFixture.enableInspections(new InferLambdaParameterTypeInspection());
myFixture.enableInspections(new LambdaParameterTypeCanBeSpecifiedInspection());
}
public void testSimple() {