Fix false positive for if-else
This commit is contained in:
committed by
Mikhail Glukhikh
parent
0099b7b3b1
commit
e59427edab
@@ -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.KtNodeTypes
|
||||
import org.jetbrains.kotlin.kdoc.psi.api.KDoc
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -58,6 +59,8 @@ class RedundantSemicolonInspection : AbstractKotlinInspection(), CleanupLocalIns
|
||||
return false
|
||||
}
|
||||
|
||||
if (semicolon.prevLeaf()?.node?.elementType == KtNodeTypes.ELSE) return false
|
||||
|
||||
if (semicolon.parent is KtEnumEntry) return false
|
||||
|
||||
(semicolon.parent.parent as? KtClass)?.let {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test() {
|
||||
if (true) println("hello") else<caret>;
|
||||
println("hi")
|
||||
}
|
||||
+5
@@ -4181,6 +4181,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
public void testCompanionWithName() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSemicolon/companionWithName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifElse.kt")
|
||||
public void testIfElse() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSemicolon/ifElse.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/redundantSetter")
|
||||
|
||||
Reference in New Issue
Block a user