Don't suggest 'Redundant semicolon' before lambda extension call
So #KT-23152 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
5d06c2c584
commit
7328f75103
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiComment
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import org.jetbrains.kotlin.kdoc.psi.api.KDoc
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
@@ -74,7 +75,10 @@ class RedundantSemicolonInspection : AbstractKotlinInspection(), CleanupLocalIns
|
||||
return false
|
||||
}
|
||||
|
||||
if (nextLeaf?.nextLeaf { it !is PsiWhiteSpace && it !is PsiComment }?.node?.elementType == KtTokens.LBRACE) {
|
||||
if (nextLeaf?.nextLeaf {
|
||||
it !is PsiWhiteSpace && it !is PsiComment && it.getStrictParentOfType<KDoc>() == null &&
|
||||
it.getStrictParentOfType<KtAnnotationEntry>() == null
|
||||
}?.node?.elementType == KtTokens.LBRACE) {
|
||||
return false // case with statement starting with '{' and call on the previous line
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// PROBLEM: none
|
||||
fun test() {
|
||||
foo()<caret>;
|
||||
@Ann("")
|
||||
{ i: Int -> }.doIt()
|
||||
}
|
||||
fun foo() {}
|
||||
fun ((Int) -> Unit).doIt() {}
|
||||
|
||||
@Target(AnnotationTarget.EXPRESSION)
|
||||
annotation class Ann(val bar: String)
|
||||
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
fun test() {
|
||||
foo()<caret>;
|
||||
/**
|
||||
* kdoc
|
||||
*/
|
||||
{ i: Int -> }.doIt()
|
||||
}
|
||||
fun foo() {}
|
||||
fun ((Int) -> Unit).doIt() {}
|
||||
+12
@@ -2913,12 +2913,24 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/redundantSemicolon"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeAnnotationAndLambda.kt")
|
||||
public void testBeforeAnnotationAndLambda() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/redundantSemicolon/beforeAnnotationAndLambda.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeCommentAndLambda.kt")
|
||||
public void testBeforeCommentAndLambda() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/redundantSemicolon/beforeCommentAndLambda.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeKDocAndLambda.kt")
|
||||
public void testBeforeKDocAndLambda() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/redundantSemicolon/beforeKDocAndLambda.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("companionBeforeFun.kt")
|
||||
public void testCompanionBeforeFun() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/redundantSemicolon/companionBeforeFun.kt");
|
||||
|
||||
Reference in New Issue
Block a user