Redundant semicolon: fix false negative on start of line

^KT-40704 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-08-04 08:37:32 +02:00
committed by Vladimir Dolzhenko
parent 02c31a711c
commit 33969c5f9a
6 changed files with 37 additions and 0 deletions
@@ -49,6 +49,9 @@ class RedundantSemicolonInspection : AbstractKotlinInspection(), CleanupLocalIns
if (semicolon.parent is KtPackageDirective && (nextLeaf as? KtImportList)?.imports?.isEmpty() == true) {
return true
}
if (semicolon.prevLeaf { it !is PsiWhiteSpace && it !is PsiComment || it.isLineBreak() } is PsiWhiteSpace) {
return true
}
return false
}
@@ -0,0 +1,6 @@
fun test() {
foo()
<caret>;foo()
}
fun foo() {}
@@ -0,0 +1,6 @@
fun test() {
foo()
foo()
}
fun foo() {}
@@ -0,0 +1,6 @@
fun test() {
foo()
/* comment */<caret>;foo()
}
fun foo() {}
@@ -0,0 +1,6 @@
fun test() {
foo()
/* comment */foo()
}
fun foo() {}
@@ -8890,6 +8890,16 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
public void testIfElse() throws Exception {
runTest("idea/testData/inspectionsLocal/redundantSemicolon/ifElse.kt");
}
@TestMetadata("startOfLine.kt")
public void testStartOfLine() throws Exception {
runTest("idea/testData/inspectionsLocal/redundantSemicolon/startOfLine.kt");
}
@TestMetadata("startOfLine2.kt")
public void testStartOfLine2() throws Exception {
runTest("idea/testData/inspectionsLocal/redundantSemicolon/startOfLine2.kt");
}
}
@TestMetadata("idea/testData/inspectionsLocal/redundantSetter")