Redundant semicolon: don't report when semicolon is between type and '!'
#KT-38240 Fixed
This commit is contained in:
committed by
Yan Zhulanow
parent
8e8171547b
commit
4cf83d9526
@@ -90,9 +90,13 @@ class RedundantSemicolonInspection : AbstractKotlinInspection(), CleanupLocalIns
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
val prevNameReference = semicolon.getPrevSiblingIgnoringWhitespaceAndComments() as? KtNameReferenceExpression
|
val prevSibling = semicolon.getPrevSiblingIgnoringWhitespaceAndComments()
|
||||||
if (prevNameReference != null && prevNameReference.text in softModifierKeywords
|
val nextSibling = semicolon.getNextSiblingIgnoringWhitespaceAndComments()
|
||||||
&& semicolon.getNextSiblingIgnoringWhitespaceAndComments() is KtDeclaration
|
if (prevSibling.safeAs<KtNameReferenceExpression>()?.text in softModifierKeywords &&
|
||||||
|
nextSibling is KtDeclaration
|
||||||
|
) return false
|
||||||
|
if (nextSibling.safeAs<KtPrefixExpression>()?.operationToken == KtTokens.EXCL &&
|
||||||
|
semicolon.prevLeaf()?.getStrictParentOfType<KtTypeReference>() != null
|
||||||
) return false
|
) return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
// PROBLEM: none
|
||||||
|
fun test(a: Any) {
|
||||||
|
foo {
|
||||||
|
val b = a as Boolean;<caret>
|
||||||
|
!b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(f: () -> Boolean) {}
|
||||||
+5
@@ -8416,6 +8416,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
runTest("idea/testData/inspectionsLocal/redundantSemicolon/betweenSoftModifierKeywordAndDeclaration3.kt");
|
runTest("idea/testData/inspectionsLocal/redundantSemicolon/betweenSoftModifierKeywordAndDeclaration3.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("betweenTypeAndNotOperator.kt")
|
||||||
|
public void testBetweenTypeAndNotOperator() throws Exception {
|
||||||
|
runTest("idea/testData/inspectionsLocal/redundantSemicolon/betweenTypeAndNotOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("companionBeforeFun.kt")
|
@TestMetadata("companionBeforeFun.kt")
|
||||||
public void testCompanionBeforeFun() throws Exception {
|
public void testCompanionBeforeFun() throws Exception {
|
||||||
runTest("idea/testData/inspectionsLocal/redundantSemicolon/companionBeforeFun.kt");
|
runTest("idea/testData/inspectionsLocal/redundantSemicolon/companionBeforeFun.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user