Merge remote-tracking branch 'origin/pr/435'
Conflicts: idea/src/META-INF/plugin.xml idea/tests/org/jetbrains/jet/plugin/codeInsight/JetInspectionTestGenerated.java
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
This inspection reports any if-then expressions that can be folded into safe-access (?.) expressions
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -673,6 +673,13 @@
|
|||||||
level="WARNING"
|
level="WARNING"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<localInspection implementationClass="org.jetbrains.jet.plugin.inspections.IfThenToSafeAccessInspection"
|
||||||
|
displayName="If-Then foldable to '?.'"
|
||||||
|
groupName="Kotlin"
|
||||||
|
enabledByDefault="true"
|
||||||
|
level="WARNING"
|
||||||
|
/>
|
||||||
|
|
||||||
<project.converterProvider implementation="org.jetbrains.jet.plugin.converters.JetRunConfigurationSettingsFormatConverterProvider"/>
|
<project.converterProvider implementation="org.jetbrains.jet.plugin.converters.JetRunConfigurationSettingsFormatConverterProvider"/>
|
||||||
|
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.jet.plugin.inspections
|
||||||
|
|
||||||
|
import org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.IfThenToSafeAccessIntention
|
||||||
|
import org.jetbrains.jet.lang.psi.JetIfExpression
|
||||||
|
|
||||||
|
public class IfThenToSafeAccessInspection : IntentionBasedInspection<JetIfExpression>(IfThenToSafeAccessIntention())
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
<problems>
|
||||||
|
<problem>
|
||||||
|
<file>rhsNotEqualsNull.kt</file>
|
||||||
|
<line>7</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/rhsNotEqualsNull.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>rhsEqualsNull.kt</file>
|
||||||
|
<line>7</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/rhsEqualsNull.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>noThenBlock.kt</file>
|
||||||
|
<line>7</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/noThenBlock.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>noElseBlock.kt</file>
|
||||||
|
<line>7</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/noElseBlock.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>lhsNotEqualsNull.kt</file>
|
||||||
|
<line>7</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/lhsNotEqualsNull.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>lhsEqualsNull.kt</file>
|
||||||
|
<line>7</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/lhsEqualsNull.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>ifAsExpression.kt</file>
|
||||||
|
<line>7</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/ifAsExpression.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>ifAndElseNotInBlocks.kt</file>
|
||||||
|
<line>7</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/ifAndElseNotInBlocks.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>ifAndElseBothInBlocks.kt</file>
|
||||||
|
<line>7</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/ifAndElseBothInBlocks.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>emptyThenBlock.kt</file>
|
||||||
|
<line>7</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/emptyThenBlock.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>emptyElseBlock.kt</file>
|
||||||
|
<line>7</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/emptyElseBlock.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>doesNotinlineValueOutsideOfScope.kt</file>
|
||||||
|
<line>8</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/doesNotInlineValueOutsideOfScope.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>doesNotinlineValueIfUsedMoreThanOnce.kt</file>
|
||||||
|
<line>10</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/doesNotInlineValueIfUsedMoreThanOnce.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
<problem>
|
||||||
|
<file>willNotInlineClassProperty.kt</file>
|
||||||
|
<line>3</line>
|
||||||
|
<module>light_idea_test_case</module>
|
||||||
|
<entry_point TYPE="file" FQNAME="temp:///src/src/willNotInlineClassProperty.kt" />
|
||||||
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
||||||
|
<description>Replace 'if' expression with safe access expression</description>
|
||||||
|
</problem>
|
||||||
|
</problems>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
// INSPECTION_CLASS: org.jetbrains.jet.plugin.inspections.IfThenToSafeAccessInspection
|
||||||
@@ -46,4 +46,9 @@ public class JetInspectionTestGenerated extends AbstractJetInspectionTest {
|
|||||||
doTest("idea/testData/intentions/branched/ifThenToElvis/inspectionData/inspections.test");
|
doTest("idea/testData/intentions/branched/ifThenToElvis/inspectionData/inspections.test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("branched/ifThenToSafeAccess/inspectionData/inspections.test")
|
||||||
|
public void testBranched_ifThenToSafeAccess_inspectionData_Inspections_test() throws Exception {
|
||||||
|
doTest("idea/testData/intentions/branched/ifThenToSafeAccess/inspectionData/inspections.test");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -363,6 +363,7 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
|||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/intentions/branched/ifThenToSafeAccess")
|
@TestMetadata("idea/testData/intentions/branched/ifThenToSafeAccess")
|
||||||
|
@InnerTestClasses({})
|
||||||
public static class IfThenToSafeAccess extends AbstractCodeTransformationTest {
|
public static class IfThenToSafeAccess extends AbstractCodeTransformationTest {
|
||||||
public void testAllFilesPresentInIfThenToSafeAccess() throws Exception {
|
public void testAllFilesPresentInIfThenToSafeAccess() throws Exception {
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/branched/ifThenToSafeAccess"), Pattern.compile("^(.+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/branched/ifThenToSafeAccess"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
@@ -538,6 +539,11 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
|||||||
doTestIfThenToSafeAccess("idea/testData/intentions/branched/ifThenToSafeAccess/willNotInlineClassProperty.kt");
|
doTestIfThenToSafeAccess("idea/testData/intentions/branched/ifThenToSafeAccess/willNotInlineClassProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Test innerSuite() {
|
||||||
|
TestSuite suite = new TestSuite("IfThenToSafeAccess");
|
||||||
|
suite.addTestSuite(IfThenToSafeAccess.class);
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/intentions/branched/folding/ifToAssignment")
|
@TestMetadata("idea/testData/intentions/branched/folding/ifToAssignment")
|
||||||
@@ -3426,7 +3432,7 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
|||||||
suite.addTestSuite(ElvisToIfThen.class);
|
suite.addTestSuite(ElvisToIfThen.class);
|
||||||
suite.addTest(IfThenToElvis.innerSuite());
|
suite.addTest(IfThenToElvis.innerSuite());
|
||||||
suite.addTestSuite(SafeAccessToIfThen.class);
|
suite.addTestSuite(SafeAccessToIfThen.class);
|
||||||
suite.addTestSuite(IfThenToSafeAccess.class);
|
suite.addTest(IfThenToSafeAccess.innerSuite());
|
||||||
suite.addTestSuite(IfToAssignment.class);
|
suite.addTestSuite(IfToAssignment.class);
|
||||||
suite.addTestSuite(IfToReturn.class);
|
suite.addTestSuite(IfToReturn.class);
|
||||||
suite.addTestSuite(IfToReturnAsymmetrically.class);
|
suite.addTestSuite(IfToReturnAsymmetrically.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user