New J2K: add ReplaceGuardClause inspection to post-processing

#KT-22412 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-08-08 23:54:01 +09:00
committed by Ilya Kirillov
parent 51e007116f
commit 154cf46f7c
4 changed files with 19 additions and 1 deletions
@@ -221,7 +221,8 @@ private val inspectionLikePostProcessingGroup =
intentionBasedProcessing(RemoveEmptyPrimaryConstructorIntention()),
generalInspectionBasedProcessing(MayBeConstantInspection()),
RemoveForExpressionLoopParameterTypeProcessing(),
intentionBasedProcessing(ReplaceMapGetOrDefaultIntention())
intentionBasedProcessing(ReplaceMapGetOrDefaultIntention()),
inspectionBasedProcessing(ReplaceGuardClauseWithFunctionCallInspection())
)
+7
View File
@@ -0,0 +1,7 @@
public class Test {
void test(String s) {
if (s == null) {
throw new IllegalArgumentException("s should not be null");
}
}
}
+5
View File
@@ -0,0 +1,5 @@
class Test {
internal fun test(s: String?) {
requireNotNull(s) { "s should not be null" }
}
}
@@ -4082,6 +4082,11 @@ public class NewJavaToKotlinConverterSingleFileTestGenerated extends AbstractNew
runTest("nj2k/testData/newJ2k/postProcessing/GetOperator.java");
}
@TestMetadata("GuardClause.java")
public void testGuardClause() throws Exception {
runTest("nj2k/testData/newJ2k/postProcessing/GuardClause.java");
}
@TestMetadata("IfNullReturnToElvis.java")
public void testIfNullReturnToElvis() throws Exception {
runTest("nj2k/testData/newJ2k/postProcessing/IfNullReturnToElvis.java");