expectActualUtil: add parameter useOnSelf to runOnExpectAndAllActuals
This commit is contained in:
@@ -133,7 +133,7 @@ fun KtDeclaration.isEffectivelyActual(checkConstructor: Boolean = true): Boolean
|
||||
else -> false
|
||||
}
|
||||
|
||||
fun KtDeclaration.runOnExpectAndAllActuals(checkExpect: Boolean = true, f: (KtDeclaration) -> Unit) {
|
||||
fun KtDeclaration.runOnExpectAndAllActuals(checkExpect: Boolean = true, useOnSelf: Boolean = false, f: (KtDeclaration) -> Unit) {
|
||||
if (hasActualModifier()) {
|
||||
val expectElement = liftToExpected()
|
||||
expectElement?.actualsForExpected()?.forEach {
|
||||
@@ -145,6 +145,8 @@ fun KtDeclaration.runOnExpectAndAllActuals(checkExpect: Boolean = true, f: (KtDe
|
||||
} else if (!checkExpect || isExpectDeclaration()) {
|
||||
actualsForExpected().forEach { f(it) }
|
||||
}
|
||||
|
||||
if (useOnSelf) f(this)
|
||||
}
|
||||
|
||||
fun KtDeclaration.collectAllExpectAndActualDeclaration(): Set<KtDeclaration> = when {
|
||||
|
||||
@@ -71,9 +71,10 @@ open class AddModifierFix(
|
||||
override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) {
|
||||
val originalElement = element
|
||||
if (originalElement is KtDeclaration && modifier.isMultiplatformPersistent()) {
|
||||
originalElement.runOnExpectAndAllActuals { invokeOnElement(it) }
|
||||
originalElement.runOnExpectAndAllActuals(useOnSelf = true) { invokeOnElement(it) }
|
||||
} else {
|
||||
invokeOnElement(originalElement)
|
||||
}
|
||||
invokeOnElement(originalElement)
|
||||
}
|
||||
|
||||
override fun isAvailableImpl(project: Project, editor: Editor?, file: PsiFile): Boolean {
|
||||
|
||||
@@ -52,11 +52,11 @@ open class ChangeVisibilityFix(
|
||||
val pointer = element?.createSmartPointer()
|
||||
val originalElement = pointer?.element
|
||||
if (originalElement is KtDeclaration) {
|
||||
originalElement.runOnExpectAndAllActuals { it.setVisibility(visibilityModifier) }
|
||||
originalElement.runOnExpectAndAllActuals(useOnSelf = true) { it.setVisibility(visibilityModifier) }
|
||||
} else {
|
||||
originalElement?.setVisibility(visibilityModifier)
|
||||
}
|
||||
|
||||
pointer?.element?.setVisibility(visibilityModifier)
|
||||
|
||||
val propertyAccessor = pointer?.element as? KtPropertyAccessor
|
||||
if (propertyAccessor?.isRedundantSetter() == true) {
|
||||
RemoveRedundantSetterFix.removeRedundantSetter(propertyAccessor)
|
||||
|
||||
Reference in New Issue
Block a user