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