Pull Up: Remove visibility modifiers on adding 'override'
#KT-13535 Fixed
This commit is contained in:
@@ -97,6 +97,10 @@ These artifacts include extensions for the types available in the latter JDKs, s
|
||||
|
||||
- [`KT-9125`](https://youtrack.jetbrains.com/issue/KT-9125) Support Type Hierarchy on references inside of super type call entries
|
||||
|
||||
#### Refactorings
|
||||
|
||||
- [`KT-13535`](https://youtrack.jetbrains.com/issue/KT-13535) Pull Up: Remove visibility modifiers on adding 'override'
|
||||
|
||||
## 1.0.4
|
||||
|
||||
### Compiler
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.idea.refactoring.createJavaField
|
||||
import org.jetbrains.kotlin.idea.refactoring.safeDelete.removeOverrideModifier
|
||||
import org.jetbrains.kotlin.idea.util.anonymousObjectSuperTypeOrNull
|
||||
import org.jetbrains.kotlin.idea.util.psi.patternMatching.KotlinPsiUnifier
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.allChildren
|
||||
@@ -359,6 +360,7 @@ class KotlinPullUpHelper(
|
||||
}
|
||||
else {
|
||||
member.addModifier(KtTokens.OVERRIDE_KEYWORD)
|
||||
KtTokens.VISIBILITY_MODIFIERS.types.forEach { member.removeModifier(it as KtModifierKeywordToken) }
|
||||
(member as? KtNamedFunction)?.valueParameters?.forEach { it.dropDefaultValue() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class B: A() {
|
||||
// INFO: {"checked": "true"}
|
||||
protected override fun foo(): Int = 1
|
||||
override fun foo(): Int = 1
|
||||
|
||||
fun bar() = foo() + 1
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
open class A {
|
||||
|
||||
}
|
||||
|
||||
open class <caret>B : A() {
|
||||
// INFO: {"checked": "true", "toAbstract": "true"}
|
||||
protected fun foo() {}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
abstract class A {
|
||||
// INFO: {"checked": "true", "toAbstract": "true"}
|
||||
protected abstract fun foo()
|
||||
|
||||
}
|
||||
|
||||
open class B : A() {
|
||||
// INFO: {"checked": "true", "toAbstract": "true"}
|
||||
override fun foo() {}
|
||||
}
|
||||
@@ -5,5 +5,5 @@ abstract class Upper {
|
||||
|
||||
open class Lower : Upper() {
|
||||
// INFO: {"checked": "true", "toAbstract": "true"}
|
||||
protected override val moving: Int = 0
|
||||
override val moving: Int = 0
|
||||
}
|
||||
@@ -223,6 +223,12 @@ public class PullUpTestGenerated extends AbstractPullUpTest {
|
||||
doKotlinTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("removeVisibilityOnOverride.kt")
|
||||
public void testRemoveVisibilityOnOverride() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/removeVisibilityOnOverride.kt");
|
||||
doKotlinTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("skipFakeOverrides.kt")
|
||||
public void testSkipFakeOverrides() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/skipFakeOverrides.kt");
|
||||
|
||||
Reference in New Issue
Block a user