New J2K: properly remove redundant modifiers in post-processing as #KT-30804 is fixed
This commit is contained in:
+2
-2
@@ -352,7 +352,7 @@ class RemoveRedundantModalityModifierProcessing : ApplicabilityBasedInspectionLi
|
||||
}
|
||||
|
||||
override fun apply(element: KtDeclaration) {
|
||||
element.removeModifierSmart(element.modalityModifierType()!!)
|
||||
element.removeModifier(element.modalityModifierType()!!)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ class RemoveRedundantVisibilityModifierProcessing : ApplicabilityBasedInspection
|
||||
}
|
||||
|
||||
override fun apply(element: KtDeclaration) {
|
||||
element.removeModifierSmart(element.visibilityModifierType()!!)
|
||||
element.removeModifier(element.visibilityModifierType()!!)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,14 +75,5 @@ fun KtElement.hasUsagesOutsideOf(inElement: KtElement, outsideElements: List<KtE
|
||||
outsideElements.none { it.isAncestor(reference.element) }
|
||||
}
|
||||
|
||||
|
||||
//hack until KT-30804 is fixed
|
||||
fun KtModifierListOwner.removeModifierSmart(modifierToken: KtModifierKeywordToken) {
|
||||
val newElement = copy() as KtModifierListOwner
|
||||
newElement.removeModifier(modifierToken)
|
||||
replace(newElement)
|
||||
containingFile.commitAndUnblockDocument()
|
||||
}
|
||||
|
||||
inline fun <reified T : PsiElement> List<PsiElement>.descendantsOfType(): List<T> =
|
||||
flatMap { it.collectDescendantsOfType() }
|
||||
Reference in New Issue
Block a user