Pull Up: Java -> Kotlin interoperability

#KT-5803 Fixed
This commit is contained in:
Alexey Sedunov
2015-08-06 16:20:12 +03:00
parent 556285f2c7
commit 7125989c69
50 changed files with 1337 additions and 337 deletions
@@ -136,6 +136,10 @@ public class JetPsiFactory(private val project: Project) {
return createDeclaration(text)
}
public fun createCompanionObject(): JetObjectDeclaration {
return createClass("class A {\n companion object{\n}\n}").getCompanionObjects().first()
}
public fun createFile(text: String): JetFile {
return createFile("dummy.kt", text)
}
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes;
import java.util.Collections;
import java.util.List;
abstract class JetTypeParameterListOwnerStub<T extends KotlinStubWithFqName<?>> extends JetNamedDeclarationStub<T> implements JetTypeParameterListOwner {
public abstract class JetTypeParameterListOwnerStub<T extends KotlinStubWithFqName<?>> extends JetNamedDeclarationStub<T> implements JetTypeParameterListOwner {
public JetTypeParameterListOwnerStub(@NotNull T stub, @NotNull IStubElementType nodeType) {
super(stub, nodeType);
}
@@ -19,9 +19,7 @@ package org.jetbrains.kotlin.test.util
import com.intellij.codeInspection.SmartHashMap
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
import com.intellij.openapi.util.io.FileUtil
import com.intellij.psi.PsiComment
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.*
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.SmartFMap
import org.jetbrains.kotlin.psi.*
@@ -77,11 +75,11 @@ public fun String.trimIndent(): String {
}.joinToString(separator = "\n")
}
public fun JetFile.findElementByCommentPrefix(commentText: String): JetElement? =
public fun PsiFile.findElementByCommentPrefix(commentText: String): PsiElement? =
findElementsByCommentPrefix(commentText).keySet().singleOrNull()
public fun JetFile.findElementsByCommentPrefix(prefix: String): Map<JetElement, String> {
var result = SmartFMap.emptyMap<JetElement, String>()
public fun PsiFile.findElementsByCommentPrefix(prefix: String): Map<PsiElement, String> {
var result = SmartFMap.emptyMap<PsiElement, String>()
accept(
object : JetTreeVisitorVoid() {
override fun visitComment(comment: PsiComment) {
@@ -90,11 +88,12 @@ public fun JetFile.findElementsByCommentPrefix(prefix: String): Map<JetElement,
val parent = comment.getParent()
val elementToAdd = when (parent) {
is JetDeclaration -> parent
is PsiMember -> parent
else -> PsiTreeUtil.skipSiblingsForward(
comment,
javaClass<PsiWhiteSpace>(), javaClass<PsiComment>(), javaClass<JetPackageDirective>()
)
} as? JetElement ?: return
} as? PsiElement ?: return
result = result.plus(elementToAdd, commentText.substring(prefix.length()).trim())
}
@@ -658,7 +658,9 @@ fun main(args: Array<String>) {
}
testClass(javaClass<AbstractPullUpTest>()) {
model("refactoring/pullUp", extension = "kt", singleClass = true)
model("refactoring/pullUp/k2k", extension = "kt", singleClass = true, testClassName = "K2K", testMethod = "doKotlinTest")
model("refactoring/pullUp/k2j", extension = "kt", singleClass = true, testClassName = "K2J", testMethod = "doKotlinTest")
model("refactoring/pullUp/j2k", extension = "java", singleClass = true, testClassName = "J2K", testMethod = "doJavaTest")
}
testClass(javaClass<AbstractSelectExpressionForDebuggerTest>()) {
@@ -30,4 +30,4 @@ public fun Project.allScope(): GlobalSearchScope = GlobalSearchScope.allScope(th
public fun Project.projectScope(): GlobalSearchScope = GlobalSearchScope.projectScope(this)
public fun PsiFile.fileScope(): GlobalSearchScope = GlobalSearchScope.fileScope(this)
public fun PsiFile.fileScope(): GlobalSearchScope = GlobalSearchScope.fileScope(this)
@@ -148,4 +148,9 @@ private fun deleteElementWithDelimiters(element: PsiElement) {
public fun PsiElement.deleteSingle() {
CodeEditUtil.removeChild(getParent()?.getNode() ?: return, getNode() ?: return)
}
public fun JetClass.getOrCreateCompanionObject() : JetObjectDeclaration {
getCompanionObjects().firstOrNull()?.let { return it }
return addDeclaration(JetPsiFactory(this).createCompanionObject()) as JetObjectDeclaration
}
+7 -1
View File
@@ -534,7 +534,13 @@
language="jet"
implementationClass="org.jetbrains.kotlin.idea.search.ideaExtensions.JetTargetElementEvaluator" />
<refactoring.pullUpHelperFactory language="jet" implementationClass="org.jetbrains.kotlin.idea.refactoring.pullUp.KotlinPullUpHelperFactory"/>
<refactoring.pullUpHelperFactory
language="jet"
implementationClass="org.jetbrains.kotlin.idea.refactoring.pullUp.KotlinPullUpHelperFactory"/>
<refactoring.pullUpHelperFactory
language="JAVA"
order="first"
implementationClass="org.jetbrains.kotlin.idea.refactoring.pullUp.JavaToKotlinPullUpHelperFactory"/>
<problemFileHighlightFilter implementation="org.jetbrains.kotlin.idea.projectView.KotlinProblemFileHighlightFilter"/>
@@ -512,8 +512,8 @@ fun createJavaField(property: JetProperty, targetClass: PsiClass): PsiField {
return field
}
fun createJavaClass(klass: JetClass, targetClass: PsiClass): PsiMember {
val kind = (klass.resolveToDescriptor() as ClassDescriptor).getKind()
fun createJavaClass(klass: JetClass, targetClass: PsiClass?, forcePlainClass: Boolean = false): PsiClass {
val kind = if (forcePlainClass) ClassKind.CLASS else (klass.resolveToDescriptor() as ClassDescriptor).getKind()
val factory = PsiElementFactory.SERVICE.getInstance(klass.getProject())
val className = klass.getName()!!
@@ -524,7 +524,7 @@ fun createJavaClass(klass: JetClass, targetClass: PsiClass): PsiMember {
ClassKind.ENUM_CLASS -> factory.createEnum(className)
else -> throw AssertionError("Unexpected class kind: ${klass.getElementTextWithContext()}")
}
val javaClass = targetClass.add(javaClassToAdd) as PsiClass
val javaClass = (targetClass?.add(javaClassToAdd) ?: javaClassToAdd) as PsiClass
val template = LightClassUtil.getPsiClass(klass)
?: throw AssertionError("Can't generate light class: ${klass.getElementTextWithContext()}")
@@ -538,17 +538,27 @@ fun createJavaClass(klass: JetClass, targetClass: PsiClass): PsiMember {
klass.addAfter(typeParameterList, klass.getNameIdentifier())
}
val extendsList = factory.createReferenceListWithRole(
template.getExtendsList()?.getReferenceElements() ?: PsiJavaCodeReferenceElement.EMPTY_ARRAY,
PsiReferenceList.Role.EXTENDS_LIST
)
extendsList?.let { javaClass.getExtendsList()?.replace(it) }
// Turning interface to class
if (!javaClass.isInterface && template.isInterface) {
val implementsList = factory.createReferenceListWithRole(
template.extendsList?.referenceElements ?: PsiJavaCodeReferenceElement.EMPTY_ARRAY,
PsiReferenceList.Role.IMPLEMENTS_LIST
)
implementsList?.let { javaClass.implementsList?.replace(it) }
}
else {
val extendsList = factory.createReferenceListWithRole(
template.extendsList?.referenceElements ?: PsiJavaCodeReferenceElement.EMPTY_ARRAY,
PsiReferenceList.Role.EXTENDS_LIST
)
extendsList?.let { javaClass.extendsList?.replace(it) }
val implementsList = factory.createReferenceListWithRole(
template.getImplementsList()?.getReferenceElements() ?: PsiJavaCodeReferenceElement.EMPTY_ARRAY,
PsiReferenceList.Role.IMPLEMENTS_LIST
)
implementsList?.let { javaClass.getImplementsList()?.replace(it) }
val implementsList = factory.createReferenceListWithRole(
template.implementsList?.referenceElements ?: PsiJavaCodeReferenceElement.EMPTY_ARRAY,
PsiReferenceList.Role.IMPLEMENTS_LIST
)
implementsList?.let { javaClass.implementsList?.replace(it) }
}
for (method in template.getMethods()) {
val hasParams = method.getParameterList().getParametersCount() > 0
@@ -567,15 +577,23 @@ fun createJavaClass(klass: JetClass, targetClass: PsiClass): PsiMember {
return javaClass
}
fun PsiExpression.j2k(): JetExpression? {
if (getLanguage() != JavaLanguage.INSTANCE) return null
fun PsiElement.j2kText(): String? {
if (language != JavaLanguage.INSTANCE) return null
val project = getProject()
val j2kConverter = JavaToKotlinConverter(project,
ConverterSettings.defaultSettings,
IdeaJavaToKotlinServices)
val text = j2kConverter.elementsToKotlin(listOf(this)).results.single()?.text ?: return null //TODO: insert imports
return JetPsiFactory(getProject()).createExpression(text)
return j2kConverter.elementsToKotlin(listOf(this)).results.single()?.text ?: return null //TODO: insert imports
}
fun PsiExpression.j2k(): JetExpression? {
val text = j2kText() ?: return null
return JetPsiFactory(project).createExpression(text)
}
fun PsiMember.j2k(): JetNamedDeclaration? {
val text = j2kText() ?: return null
return JetPsiFactory(project).createDeclaration(text)
}
public fun (() -> Any).runRefactoringWithPostprocessing(
@@ -0,0 +1,50 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.refactoring.pullUp
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiField
import com.intellij.psi.PsiMember
import com.intellij.psi.PsiSubstitutor
import com.intellij.refactoring.memberPullUp.PullUpData
import com.intellij.refactoring.memberPullUp.PullUpHelper
import com.intellij.refactoring.util.classMembers.MemberInfo
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.psi.JetSimpleNameExpression
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector
import org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression
import java.util.LinkedHashSet
public class JavaToKotlinPostconversionPullUpHelper(private val data: PullUpData) : PullUpHelper<MemberInfo> {
override fun setCorrectVisibility(info: MemberInfo?) { }
override fun encodeContextInfo(info: MemberInfo?) { }
override fun move(info: MemberInfo?, substitutor: PsiSubstitutor?) { }
override fun postProcessMember(member: PsiMember?) { }
// TODO: To be implemented
override fun moveFieldInitializations(movedFields: LinkedHashSet<PsiField>?) { }
override fun updateUsage(element: PsiElement?) {
if (element !is JetSimpleNameExpression) return
val qualifier = element.getReceiverExpression()?.getQualifiedElementSelector() as? JetSimpleNameExpression ?: return
qualifier.mainReference.bindToElement(data.targetClass.unwrapped!!)
}
}
@@ -0,0 +1,168 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.refactoring.pullUp
import com.intellij.openapi.util.Key
import com.intellij.psi.*
import com.intellij.psi.search.searches.ReferencesSearch
import com.intellij.refactoring.encapsulateFields.*
import com.intellij.refactoring.memberPullUp.JavaPullUpHelper
import com.intellij.refactoring.memberPullUp.PullUpData
import com.intellij.refactoring.memberPullUp.PullUpHelper
import com.intellij.refactoring.util.DocCommentPolicy
import com.intellij.refactoring.util.RefactoringUtil
import com.intellij.refactoring.util.classMembers.MemberInfo
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
import org.jetbrains.kotlin.idea.core.getOrCreateCompanionObject
import org.jetbrains.kotlin.idea.core.refactoring.j2k
import org.jetbrains.kotlin.idea.core.refactoring.j2kText
import org.jetbrains.kotlin.idea.refactoring.safeDelete.removeOverrideModifier
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.psi.*
import java.util.HashMap
public class JavaToKotlinPreconversionPullUpHelper(
private val data: PullUpData,
private val dummyTargetClass: PsiClass,
private val javaHelper: JavaPullUpHelper
) : PullUpHelper<MemberInfo> by javaHelper {
private val membersToDummyDeclarations = HashMap<PsiMember, JetElement>()
private val encapsulateFieldsDescriptor = object: EncapsulateFieldsDescriptor {
override fun getSelectedFields(): Array<out FieldDescriptor>? = arrayOf()
override fun isToEncapsulateGet() = true
override fun isToEncapsulateSet() = true
override fun isToUseAccessorsWhenAccessible() = true
override fun getFieldsVisibility() = null
override fun getAccessorsVisibility() = PsiModifier.PUBLIC
override fun getTargetClass() = dummyTargetClass
override fun getJavadocPolicy() = DocCommentPolicy.ASIS
}
private val fieldsToUsages = HashMap<PsiField, List<EncapsulateFieldUsageInfo>>()
private val dummyAccessorByName = HashMap<String, PsiMethod>()
private val platformStaticAnnotation = JetPsiFactory(data.sourceClass.project).createAnnotationEntry("kotlin.platform.platformStatic")
companion object {
private var PsiMember.originalMember: PsiMember? by CopyableUserDataProperty(Key.create("ORIGINAL_MEMBER"))
}
private fun collectFieldReferencesToEncapsulate(member: PsiField) {
val helper = EncapsulateFieldHelper.getHelper(member.language) ?: return
val fieldName = member.name!!
val getterName = JvmAbi.getterName(fieldName)
val setterName = JvmAbi.setterName(fieldName)
val getter = helper.generateMethodPrototype(member, getterName, true)
val setter = helper.generateMethodPrototype(member, setterName, false)
val fieldDescriptor = FieldDescriptorImpl(member, getterName, setterName, getter, setter)
getter?.let { dummyAccessorByName[getterName] = dummyTargetClass.add(it) as PsiMethod }
setter?.let { dummyAccessorByName[setterName] = dummyTargetClass.add(it) as PsiMethod }
fieldsToUsages[member] = ReferencesSearch
.search(member)
.map { helper.createUsage(encapsulateFieldsDescriptor, fieldDescriptor, it) }
.filterNotNull()
}
override fun move(info: MemberInfo, substitutor: PsiSubstitutor) {
val member = info.member
val movingSuperInterface = member is PsiClass && info.overrides == false
if (!movingSuperInterface) {
member.originalMember = member
}
if (info.isStatic) {
info.isToAbstract = false
}
if (member is PsiField && !info.isStatic) {
collectFieldReferencesToEncapsulate(member)
}
val superInterfaceCount = getCurrentSuperInterfaceCount()
javaHelper.move(info, substitutor)
if (info.isStatic) {
member.removeOverrideModifier()
}
val targetClass = data.targetClass.unwrapped as JetClass
if (member.hasModifierProperty(PsiModifier.ABSTRACT) && !movingSuperInterface) targetClass.makeAbstract()
val psiFactory = JetPsiFactory(member.project)
if (movingSuperInterface) {
if (getCurrentSuperInterfaceCount() == superInterfaceCount) return
val typeText = RefactoringUtil.findReferenceToClass(dummyTargetClass.implementsList, member as PsiClass)?.j2kText() ?: return
targetClass.addDelegationSpecifier(psiFactory.createDelegatorToSuperClass(typeText))
return
}
val memberOwner = when {
member.hasModifierProperty(PsiModifier.STATIC) && member !is PsiClass -> targetClass.getOrCreateCompanionObject()
else -> targetClass
}
val dummyDeclaration : JetNamedDeclaration = when (member) {
is PsiField -> psiFactory.createProperty("val foo = 0")
is PsiMethod -> psiFactory.createFunction("fun foo() = 0")
is PsiClass -> psiFactory.createClass("class Foo")
else -> return
}
// postProcessMember() call order is unstable so in order to stabilize resulting member order we add dummies to target class
// and replace them after postprocessing
membersToDummyDeclarations[member] = addMemberToTarget(dummyDeclaration, memberOwner)
}
private fun getCurrentSuperInterfaceCount() = dummyTargetClass.implementsList?.referenceElements?.size() ?: 0
override fun postProcessMember(member: PsiMember) {
javaHelper.postProcessMember(member)
val originalMember = member.originalMember ?: return
originalMember.originalMember = null
val targetClass = data.targetClass.unwrapped as? JetClass ?: return
val convertedDeclaration = member.j2k() ?: return
val newDeclaration = membersToDummyDeclarations[originalMember]?.replace(convertedDeclaration) as JetNamedDeclaration
if (targetClass.isInterface()) {
newDeclaration.removeModifier(JetTokens.ABSTRACT_KEYWORD)
}
if (member.hasModifierProperty(PsiModifier.STATIC) && newDeclaration is JetNamedFunction) {
newDeclaration.addAnnotationWithSpace(platformStaticAnnotation).addToShorteningWaitSet()
}
if (originalMember is PsiField) {
val usages = fieldsToUsages[originalMember] ?: return
val firstUsage = usages.firstOrNull() ?: return
val fieldDescriptor = firstUsage.fieldDescriptor
val targetLightClass = (firstUsage.reference?.resolve() as? PsiField)?.containingClass ?: return
val getter = targetLightClass.findMethodBySignature(fieldDescriptor.getterPrototype, false)
val setter = targetLightClass.findMethodBySignature(fieldDescriptor.setterPrototype, false)
for (usage in usages) {
EncapsulateFieldHelper
.getHelper(usage.element!!.language)
?.processUsage(usage, encapsulateFieldsDescriptor, setter, getter)
}
}
}
}
@@ -37,14 +37,12 @@ import org.jetbrains.kotlin.idea.JetLanguage
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
import org.jetbrains.kotlin.idea.core.refactoring.createJavaField
import org.jetbrains.kotlin.idea.core.refactoring.createJavaMethod
import org.jetbrains.kotlin.idea.core.replaced
import org.jetbrains.kotlin.idea.imports.importableFqName
import org.jetbrains.kotlin.idea.refactoring.safeDelete.removeOverrideModifier
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.idea.util.ShortenReferences
import org.jetbrains.kotlin.idea.util.psi.patternMatching.JetPsiUnifier
import org.jetbrains.kotlin.lexer.JetModifierKeywordToken
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.*
@@ -377,24 +375,6 @@ class KotlinPullUpHelper(
}
}
private fun addMemberToTarget(targetMember: JetNamedDeclaration): JetNamedDeclaration {
data.targetClass as JetClass
val anchor = data.targetClass.declarations.filterIsInstance(targetMember.javaClass).lastOrNull()
val movedMember = when {
anchor == null && targetMember is JetProperty -> data.targetClass.addDeclarationBefore(targetMember, null)
else -> data.targetClass.addDeclarationAfter(targetMember, anchor)
}
return movedMember as JetNamedDeclaration
}
private fun doAddCallableMember(memberCopy: JetCallableDeclaration, clashingSuper: JetCallableDeclaration?): JetCallableDeclaration {
if (clashingSuper != null && clashingSuper.hasModifier(JetTokens.ABSTRACT_KEYWORD)) {
return clashingSuper.replaced(memberCopy)
}
return addMemberToTarget(memberCopy) as JetCallableDeclaration
}
private fun markElements(member: JetNamedDeclaration): List<JetElement> {
val affectedElements = ArrayList<JetElement>()
@@ -510,12 +490,6 @@ class KotlinPullUpHelper(
}
}
// TODO: Formatting rules don't apply here for some reason
private fun JetNamedDeclaration.addModifierWithSpace(modifier: JetModifierKeywordToken) {
addModifier(modifier)
addAfter(JetPsiFactory(this).createWhiteSpace(), modifierList)
}
private fun moveSuperInterface(member: JetClass, substitutor: PsiSubstitutor) {
val classDescriptor = data.memberDescriptors[member] as? ClassDescriptor ?: return
val currentSpecifier =
@@ -635,7 +609,7 @@ class KotlinPullUpHelper(
memberCopy.removeModifier(JetTokens.INNER_KEYWORD)
}
val movedMember = addMemberToTarget(memberCopy) as JetClassOrObject
val movedMember = addMemberToTarget(memberCopy, data.targetClass as JetClass) as JetClassOrObject
member.delete()
return movedMember
}
@@ -658,7 +632,7 @@ class KotlinPullUpHelper(
makeAbstract(member, memberCopy)
}
movedMember = doAddCallableMember(memberCopy, clashingSuper)
movedMember = doAddCallableMember(memberCopy, clashingSuper, data.targetClass)
if (member.typeReference == null) {
movedMember.typeReference?.addToShorteningWaitSet()
}
@@ -666,7 +640,7 @@ class KotlinPullUpHelper(
removeOriginalMemberOrAddOverride(member)
}
else {
movedMember = doAddCallableMember(memberCopy, clashingSuper)
movedMember = doAddCallableMember(memberCopy, clashingSuper, data.targetClass)
member.delete()
}
@@ -674,10 +648,8 @@ class KotlinPullUpHelper(
movedMember.removeModifier(JetTokens.ABSTRACT_KEYWORD)
}
if (!data.isInterfaceTarget
&& !data.targetClass.hasModifier(JetTokens.ABSTRACT_KEYWORD)
&& (movedMember.hasModifier(JetTokens.ABSTRACT_KEYWORD))) {
data.targetClass.addModifierWithSpace(JetTokens.ABSTRACT_KEYWORD)
if (movedMember.hasModifier(JetTokens.ABSTRACT_KEYWORD)) {
data.targetClass.makeAbstract()
}
return movedMember
}
@@ -16,19 +16,25 @@
package org.jetbrains.kotlin.idea.refactoring.pullUp
import com.intellij.psi.PsiNamedElement
import com.intellij.ide.highlighter.JavaFileType
import com.intellij.lang.StdLanguages
import com.intellij.psi.*
import com.intellij.refactoring.memberPullUp.JavaPullUpHelper
import com.intellij.refactoring.memberPullUp.PullUpData
import com.intellij.refactoring.memberPullUp.PullUpHelper
import com.intellij.refactoring.memberPullUp.PullUpHelperFactory
import org.jetbrains.kotlin.asJava.namedUnwrappedElement
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.idea.JetLanguage
import org.jetbrains.kotlin.idea.core.refactoring.createJavaClass
import org.jetbrains.kotlin.psi.JetClass
import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.JetNamedDeclaration
import org.jetbrains.kotlin.psi.psiUtil.parents
import org.jetbrains.kotlin.psi.psiUtil.startOffset
public class KotlinPullUpHelperFactory : PullUpHelperFactory {
private fun PullUpData.toKotlinPullUpData(): KotlinPullUpData? {
if (!sourceClass.isInheritor(targetClass, true)) return null
val sourceClass = sourceClass.unwrapped as? JetClassOrObject ?: return null
val targetClass = targetClass.unwrapped as? PsiNamedElement ?: return null
val membersToMove = membersToMove
@@ -39,7 +45,64 @@ public class KotlinPullUpHelperFactory : PullUpHelperFactory {
}
override fun createPullUpHelper(data: PullUpData): PullUpHelper<*> {
val kotlinPullUpData = data.toKotlinPullUpData() ?: return EmptyPullUpHelper
return KotlinPullUpHelper(data, kotlinPullUpData)
if (!data.sourceClass.isInheritor(data.targetClass, true)) return EmptyPullUpHelper
data.toKotlinPullUpData()?.let { return KotlinPullUpHelper(data, it) }
if (data.targetClass.language.`is`(JetLanguage.INSTANCE) && data.sourceClass.language.`is`(StdLanguages.JAVA)) {
return JavaToKotlinPostconversionPullUpHelper(data)
}
return EmptyPullUpHelper
}
}
public class JavaToKotlinPullUpHelperFactory : PullUpHelperFactory {
private fun createJavaToKotlinPullUpHelper(data: PullUpData): JavaToKotlinPreconversionPullUpHelper? {
if (!data.sourceClass.isInheritor(data.targetClass, true)) return null
val dummyTargetClass = createDummyTargetClass(data) ?: return null
val dataForDelegate = object : PullUpData by data {
override fun getTargetClass() = dummyTargetClass
}
return JavaToKotlinPreconversionPullUpHelper(data, dummyTargetClass, JavaPullUpHelper(dataForDelegate))
}
private fun createDummyTargetClass(data: PullUpData): PsiClass? {
val targetClass = data.targetClass.unwrapped as? JetClass ?: return null
val project = targetClass.project
val targetPackage = targetClass.getContainingJetFile().packageFqName.asString()
val dummyFile = PsiFileFactory.getInstance(project).createFileFromText(
"dummy.java",
JavaFileType.INSTANCE,
if (targetPackage.isNotEmpty()) "package $targetPackage;\n" else ""
)
val elementFactory = PsiElementFactory.SERVICE.getInstance(project)
val dummyTargetClass = createJavaClass(targetClass, null, forcePlainClass = true)
val outerClasses = targetClass.parents.filterIsInstance<JetClassOrObject>().toList().reverse()
if (outerClasses.isEmpty()) return dummyFile.add(dummyTargetClass) as PsiClass
val outerPsiClasses = outerClasses.map {
val psiClass = elementFactory.createClass(it.name!!)
if (!(it is JetClass && it.isInner())) {
psiClass.modifierList!!.setModifierProperty(PsiModifier.STATIC, true)
}
psiClass
}
return outerPsiClasses
.drop(1)
.plus(dummyTargetClass)
.fold(dummyFile.add(outerPsiClasses.first())) { parent, child -> parent.add(child) } as PsiClass
}
override fun createPullUpHelper(data: PullUpData): PullUpHelper<*> {
createJavaToKotlinPullUpHelper(data)?.let { return it }
return PullUpHelper.INSTANCE
.allForLanguage(StdLanguages.JAVA)
.firstOrNull { it !is JavaToKotlinPullUpHelperFactory }
?.createPullUpHelper(data)
?: EmptyPullUpHelper
}
}
@@ -17,10 +17,10 @@
package org.jetbrains.kotlin.idea.refactoring.pullUp
import com.intellij.psi.PsiClass
import org.jetbrains.kotlin.idea.core.replaced
import org.jetbrains.kotlin.lexer.JetModifierKeywordToken
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi.JetNamedDeclaration
import org.jetbrains.kotlin.psi.JetNamedFunction
import org.jetbrains.kotlin.psi.JetProperty
import org.jetbrains.kotlin.psi.*
fun JetProperty.mustBeAbstractInInterface() =
hasInitializer() || hasDelegate() || (!hasInitializer() && !hasDelegate() && accessors.isEmpty())
@@ -37,3 +37,40 @@ fun JetNamedDeclaration.canMoveMemberToJavaClass(targetClass: PsiClass): Boolean
else -> false
}
}
fun addMemberToTarget(targetMember: JetNamedDeclaration, targetClass: JetClassOrObject): JetNamedDeclaration {
val anchor = targetClass.declarations.filterIsInstance(targetMember.javaClass).lastOrNull()
val movedMember = when {
anchor == null && targetMember is JetProperty -> targetClass.addDeclarationBefore(targetMember, null)
else -> targetClass.addDeclarationAfter(targetMember, anchor)
}
return movedMember as JetNamedDeclaration
}
fun doAddCallableMember(
memberCopy: JetCallableDeclaration,
clashingSuper: JetCallableDeclaration?,
targetClass: JetClass): JetCallableDeclaration {
if (clashingSuper != null && clashingSuper.hasModifier(JetTokens.ABSTRACT_KEYWORD)) {
return clashingSuper.replaced(memberCopy)
}
return addMemberToTarget(memberCopy, targetClass) as JetCallableDeclaration
}
// TODO: Formatting rules don't apply here for some reason
fun JetNamedDeclaration.addModifierWithSpace(modifier: JetModifierKeywordToken) {
addModifier(modifier)
addAfter(JetPsiFactory(this).createWhiteSpace(), modifierList)
}
// TODO: Formatting rules don't apply here for some reason
fun JetNamedDeclaration.addAnnotationWithSpace(annotationEntry: JetAnnotationEntry): JetAnnotationEntry {
val result = addAnnotationEntry(annotationEntry)
addAfter(JetPsiFactory(this).createWhiteSpace(), modifierList)
return result
}
fun JetClass.makeAbstract() {
if (isInterface() || hasModifier(JetTokens.ABSTRACT_KEYWORD)) return
addModifierWithSpace(JetTokens.ABSTRACT_KEYWORD)
}
@@ -0,0 +1,43 @@
abstract class <caret>B extends A {
// INFO: {"checked": "true"}
int x = 2*3;
// INFO: {"checked": "true"}
static String X = "1" + "2";
// INFO: {"checked": "true"}
boolean foo(int n) {
return n > 0;
}
// INFO: {"checked": "true"}
static String foo2(int n) {
return "_" + n + "_";
}
// INFO: {"checked": "true"}
abstract int bar(String s);
// INFO: {"checked": "true"}
class X {
}
// INFO: {"checked": "true"}
static class Y {
}
}
class Test {
static void test() {
B b = new B() {
public int bar(String s) {
return s.length();
}
};
int t1 = b.x;
b.x = t1 + 1;
String t2 = b.X;
String t3 = B.X;
b.foo(1);
b.foo2(2);
B.foo2(3);
b.new X();
new B.Y();
}
}
@@ -0,0 +1,21 @@
abstract class B extends A {
}
class Test {
static void test() {
B b = new B() {
public int bar(String s) {
return s.length();
}
};
int t1 = b.getX();
b.setX(t1 + 1);
String t2 = b.X;
String t3 = A.X;
b.foo(1);
b.foo2(2);
A.foo2(3);
b.new X();
new B.Y();
}
}
@@ -0,0 +1,13 @@
open class A
fun test() {
val b = object : B() {
override fun bar(s: String) = s.length()
}
val t1 = b.x
b.x = t1 + 1
val t2 = B.X
b.foo(1)
B.foo2(2)
B.Y()
}
@@ -0,0 +1,42 @@
import kotlin.platform.platformStatic
abstract class A {
// INFO: {"checked": "true"}
var x = 2 * 3
// INFO: {"checked": "true"}
inner class X
// INFO: {"checked": "true"}
class Y
// INFO: {"checked": "true"}
fun foo(n: Int): Boolean {
return n > 0
}
// INFO: {"checked": "true"}
abstract fun bar(s: String): Int
companion object {
// INFO: {"checked": "true"}
var X = "1" + "2"
// INFO: {"checked": "true"}
platformStatic fun foo2(n: Int): String {
return "_" + n + "_"
}
}
}
fun test() {
val b = object : B() {
override fun bar(s: String) = s.length()
}
val t1 = b.x
b.x = t1 + 1
val t2 = A.X
b.foo(1)
A.foo2(2)
A.Y()
}
@@ -0,0 +1,24 @@
abstract class <caret>B extends A {
// INFO: {"checked": "true", "toAbstract": "true"}
int x = 2*3;
// INFO: {"checked": "true", "toAbstract": "true"}
static String X = "1" + "2";
// INFO: {"checked": "true", "toAbstract": "true"}
boolean foo(int n) {
return n > 0;
}
// INFO: {"checked": "true", "toAbstract": "true"}
static String foo2(int n) {
return "_" + n + "_";
}
// INFO: {"checked": "true", "toAbstract": "true"}
abstract int bar(String s);
// INFO: {"checked": "true", "toAbstract": "true"}
class X {
}
// INFO: {"checked": "true", "toAbstract": "true"}
static class Y {
}
}
@@ -0,0 +1,7 @@
abstract class B extends A {
// INFO: {"checked": "true", "toAbstract": "true"}
@Override
boolean foo(int n) {
return n > 0;
}
}
@@ -0,0 +1 @@
open class A
@@ -0,0 +1,28 @@
import kotlin.platform.platformStatic
abstract class A {
// INFO: {"checked": "true", "toAbstract": "true"}
var x = 2 * 3
// INFO: {"checked": "true", "toAbstract": "true"}
inner class X
// INFO: {"checked": "true", "toAbstract": "true"}
class Y
// INFO: {"checked": "true", "toAbstract": "true"}
abstract fun foo(n: Int): Boolean
// INFO: {"checked": "true", "toAbstract": "true"}
abstract fun bar(s: String): Int
companion object {
// INFO: {"checked": "true", "toAbstract": "true"}
var X = "1" + "2"
// INFO: {"checked": "true", "toAbstract": "true"}
platformStatic fun foo2(n: Int): String {
return "_" + n + "_"
}
}
}
@@ -0,0 +1,20 @@
class C<W extends I> {
abstract class <caret>B<X extends I, Y> extends A<X, I, Z<Y>> {
// INFO: {"checked": "true"}
<S extends X> void foo(X x1, Z<X> x2, Y y1, Z<Y> y2, W w1, Z<W> w2, S s1, Z<S> s2) {
}
// INFO: {"checked": "true"}
class Foo<S> extends A<X, I, Z<Y>> implements Z<W> {
}
// INFO: {"checked": "true"}
X foo1;
// INFO: {"checked": "true"}
Z<X> foo2;
// INFO: {"checked": "true"}
Y foo3;
// INFO: {"checked": "true"}
Z<Y> foo4;
}
}
@@ -0,0 +1,4 @@
class C<W extends I> {
abstract class B<X extends I, Y> extends A<X, I, Z<Y>> {
}
}
@@ -0,0 +1,5 @@
interface I
interface Z<T>
open class A<T : I, U : I, V>
@@ -0,0 +1,22 @@
interface I
interface Z<T>
open class A<T : I, U : I, V> {
// INFO: {"checked": "true"}
var foo1: T
// INFO: {"checked": "true"}
var foo2: Z<T>
// INFO: {"checked": "true"}
var foo3: Any
// INFO: {"checked": "true"}
var foo4: Z<Any>
// INFO: {"checked": "true"}
inner class Foo<S> : A<T, I, Z<Any>>(), Z<I>
// INFO: {"checked": "true"}
fun <S : T> foo(x1: T, x2: Z<T>, y1: Any, y2: Z<Any>, w1: I, w2: Z<I>, s1: S, s2: Z<S>) {
}
}
@@ -0,0 +1,18 @@
abstract class <caret>B implements A {
// INFO: {"checked": "true"}
static String X = "1" + "2";
// INFO: {"checked": "true"}
boolean foo(int n) {
return n > 0;
}
// INFO: {"checked": "true"}
static String foo2(int n) {
return "_" + n + "_";
}
// INFO: {"checked": "true"}
abstract int bar(String s);
// INFO: {"checked": "true"}
static class Y {
}
}
@@ -0,0 +1,2 @@
abstract class B implements A {
}
@@ -0,0 +1 @@
interface A
@@ -0,0 +1,24 @@
import kotlin.platform.platformStatic
interface A {
// INFO: {"checked": "true"}
class Y
// INFO: {"checked": "true"}
fun foo(n: Int): Boolean {
return n > 0
}
// INFO: {"checked": "true"}
fun bar(s: String): Int
companion object {
// INFO: {"checked": "true"}
var X = "1" + "2"
// INFO: {"checked": "true"}
platformStatic fun foo2(n: Int): String {
return "_" + n + "_"
}
}
}
@@ -0,0 +1,24 @@
abstract class <caret>B implements A {
// INFO: {"checked": "true"}
int x = 2*3;
// INFO: {"checked": "true"}
static String X = "1" + "2";
// INFO: {"checked": "true"}
boolean foo(int n) {
return n > 0;
}
// INFO: {"checked": "true"}
static String foo2(int n) {
return "_" + n + "_";
}
// INFO: {"checked": "true"}
abstract int bar(String s);
// INFO: {"checked": "true"}
class X {
}
// INFO: {"checked": "true"}
static class Y {
}
}
@@ -0,0 +1,2 @@
Class B.X is not static. It cannot be moved to the interface
Field x is not static. It cannot be moved to the interface
@@ -0,0 +1 @@
interface A
@@ -0,0 +1,43 @@
abstract class <caret>B extends T.U.A {
// INFO: {"checked": "true"}
int x = 2*3;
// INFO: {"checked": "true"}
static String X = "1" + "2";
// INFO: {"checked": "true"}
boolean foo(int n) {
return n > 0;
}
// INFO: {"checked": "true"}
static String foo2(int n) {
return "_" + n + "_";
}
// INFO: {"checked": "true"}
abstract int bar(String s);
// INFO: {"checked": "true"}
class X {
}
// INFO: {"checked": "true"}
static class Y {
}
}
class Test {
static void test() {
B b = new B() {
public int bar(String s) {
return s.length();
}
};
int t1 = b.x;
b.x = t1 + 1;
String t2 = b.X;
String t3 = B.X;
b.foo(1);
b.foo2(2);
B.foo2(3);
b.new X();
new B.Y();
}
}
@@ -0,0 +1,21 @@
abstract class B extends T.U.A {
}
class Test {
static void test() {
B b = new B() {
public int bar(String s) {
return s.length();
}
};
int t1 = b.getX();
b.setX(t1 + 1);
String t2 = b.X;
String t3 = T.U.A.X;
b.foo(1);
b.foo2(2);
T.U.A.foo2(3);
b.new X();
new B.Y();
}
}
@@ -0,0 +1,17 @@
class T {
class U {
open class A
}
}
fun test() {
val b = object : B() {
override fun bar(s: String) = s.length()
}
val t1 = b.x
b.x = t1 + 1
val t2 = B.X
b.foo(1)
B.foo2(2)
B.Y()
}
@@ -0,0 +1,46 @@
import kotlin.platform.platformStatic
class T {
class U {
abstract class A {
// INFO: {"checked": "true"}
var x = 2 * 3
// INFO: {"checked": "true"}
inner class X
// INFO: {"checked": "true"}
class Y
// INFO: {"checked": "true"}
fun foo(n: Int): Boolean {
return n > 0
}
// INFO: {"checked": "true"}
abstract fun bar(s: String): Int
companion object {
// INFO: {"checked": "true"}
var X = "1" + "2"
// INFO: {"checked": "true"}
platformStatic fun foo2(n: Int): String {
return "_" + n + "_"
}
}
}
}
}
fun test() {
val b = object : B() {
override fun bar(s: String) = s.length()
}
val t1 = b.x
b.x = t1 + 1
val t2 = T.U.A.X
b.foo(1)
T.U.A.foo2(2)
T.U.A.Y()
}
@@ -0,0 +1,18 @@
// INFO: {"checked": "true"}
interface X {
}
// INFO: {"checked": "false"}
interface Y {
}
// INFO: {"checked": "true"}
interface Z {
}
class <caret>B extends A implements X, Y, Z {
}
@@ -0,0 +1,18 @@
// INFO: {"checked": "true"}
interface X {
}
// INFO: {"checked": "false"}
interface Y {
}
// INFO: {"checked": "true"}
interface Z {
}
class B extends A implements Y {
}
@@ -0,0 +1 @@
class A : Z
@@ -0,0 +1 @@
class A : Z, X
@@ -0,0 +1,18 @@
// INFO: {"checked": "true"}
interface X {
}
// INFO: {"checked": "false"}
interface Y {
}
// INFO: {"checked": "true"}
interface Z {
}
class <caret>B implements I, X, Y, Z {
}
@@ -0,0 +1,18 @@
// INFO: {"checked": "true"}
interface X {
}
// INFO: {"checked": "false"}
interface Y {
}
// INFO: {"checked": "true"}
interface Z {
}
class B implements I, Y {
}
@@ -0,0 +1 @@
interface I : Z
@@ -0,0 +1 @@
interface I : Z, X
@@ -0,0 +1,22 @@
// INFO: {"checked": "true"}
interface X<T, U> {
}
// INFO: {"checked": "false"}
interface Y<V> {
}
// INFO: {"checked": "true"}
interface Z<T> {
}
class P {
}
class <caret>B<S, U, V> extends A<S> implements X<P, S>, Y<U>, Z<V> {
}
@@ -0,0 +1,22 @@
// INFO: {"checked": "true"}
interface X<T, U> {
}
// INFO: {"checked": "false"}
interface Y<V> {
}
// INFO: {"checked": "true"}
interface Z<T> {
}
class P {
}
class B<S, U, V> extends A<S> implements Y<U> {
}
@@ -0,0 +1 @@
class A<T> : Z<T>
@@ -0,0 +1 @@
class A<T> : Z<T>, X<P, T>
@@ -19,18 +19,25 @@ package org.jetbrains.kotlin.idea.refactoring.pullUp
import com.google.gson.JsonParser
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.io.FileUtil
import com.intellij.psi.PsiNamedElement
import com.intellij.psi.*
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.refactoring.BaseRefactoringProcessor
import com.intellij.refactoring.classMembers.MemberInfoBase
import com.intellij.refactoring.memberPullUp.PullUpConflictsUtil
import com.intellij.refactoring.memberPullUp.PullUpProcessor
import com.intellij.refactoring.util.CommonRefactoringUtil
import com.intellij.refactoring.util.DocCommentPolicy
import com.intellij.refactoring.util.RefactoringHierarchyUtil
import com.intellij.refactoring.util.classMembers.MemberInfoStorage
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import com.intellij.util.ui.UIUtil
import org.jetbrains.kotlin.idea.core.getPackage
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo
import org.jetbrains.kotlin.idea.refactoring.memberInfo.qualifiedClassNameForRendering
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil
import org.jetbrains.kotlin.idea.test.JetLightCodeInsightFixtureTestCase
import org.jetbrains.kotlin.idea.test.JetWithJdkAndRuntimeLightProjectDescriptor
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
import org.jetbrains.kotlin.psi.JetElement
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.psi.NotNullableUserDataProperty
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import org.jetbrains.kotlin.test.JetTestUtils
@@ -41,17 +48,17 @@ public abstract class AbstractPullUpTest : JetLightCodeInsightFixtureTestCase()
private data class ElementInfo(val checked: Boolean, val toAbstract: Boolean)
companion object {
private var JetElement.elementInfo: ElementInfo
private var PsiElement.elementInfo: ElementInfo
by NotNullableUserDataProperty(Key.create("ELEMENT_INFO"), ElementInfo(false, false))
}
override fun getProjectDescriptor() = LightCodeInsightFixtureTestCase.JAVA_LATEST
override fun getProjectDescriptor() = JetWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
val fixture: JavaCodeInsightTestFixture get() = myFixture
protected override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase()
protected fun doTest(path: String) {
protected fun doTest(path: String, action: (mainFile: PsiFile) -> Unit) {
val mainFile = File(path)
val afterFile = File("$path.after")
val conflictFile = File("$path.messages")
@@ -60,11 +67,11 @@ public abstract class AbstractPullUpTest : JetLightCodeInsightFixtureTestCase()
val mainFileName = mainFile.getName()
val mainFileBaseName = FileUtil.getNameWithoutExtension(mainFileName)
val extraFiles = mainFile.getParentFile().listFiles { file, name ->
val extraFiles = mainFile.parentFile.listFiles { file, name ->
name != mainFileName && name.startsWith("$mainFileBaseName.") && (name.endsWith(".kt") || name.endsWith(".java"))
}
val extraFilesToPsi = extraFiles.toMap { fixture.configureByFile(it.getName()) }
val file = fixture.configureByFile(mainFileName) as JetFile
val file = fixture.configureByFile(mainFileName)
val addKotlinRuntime = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// WITH_RUNTIME") != null
if (addKotlinRuntime) {
@@ -77,33 +84,13 @@ public abstract class AbstractPullUpTest : JetLightCodeInsightFixtureTestCase()
element.elementInfo = ElementInfo(parsedInfo["checked"]?.asBoolean ?: false,
parsedInfo["toAbstract"]?.asBoolean ?: false)
}
val targetClassName = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// TARGET_CLASS: ")
val helper = object: KotlinPullUpHandler.TestHelper {
override fun adjustMembers(members: List<KotlinMemberInfo>): List<KotlinMemberInfo> {
members.forEach {
val info = it.member.elementInfo
it.isChecked = info.checked
it.isToAbstract = info.toAbstract
}
return members.filter { it.isChecked }
}
override fun chooseSuperClass(superClasses: List<PsiNamedElement>): PsiNamedElement {
if (targetClassName != null) {
return superClasses.single { it.qualifiedClassNameForRendering() == targetClassName }
}
return superClasses.first()
}
}
KotlinPullUpHandler().invoke(getProject(), getEditor(), file) {
if (it == KotlinPullUpHandler.PULLUP_TEST_HELPER_KEY) helper else null
}
action(file)
assert(!conflictFile.exists()) { "Conflict file $conflictFile should not exist" }
JetTestUtils.assertEqualsToFile(afterFile, file.text!!)
for ((extraPsiFile, extraFile) in extraFilesToPsi) {
JetTestUtils.assertEqualsToFile(File("${extraFile.getPath()}.after"), extraPsiFile.getText())
JetTestUtils.assertEqualsToFile(File("${extraFile.getPath()}.after"), extraPsiFile.text)
}
}
catch(e: Exception) {
@@ -120,4 +107,67 @@ public abstract class AbstractPullUpTest : JetLightCodeInsightFixtureTestCase()
}
}
}
private fun getTargetClassName(file: PsiFile) = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// TARGET_CLASS: ")
private fun chooseMembers<T : MemberInfoBase<*>>(members: List<T>): List<T> {
members.forEach {
val info = it.member.elementInfo
it.isChecked = info.checked
it.isToAbstract = info.toAbstract
}
return members.filter { it.isChecked }
}
protected fun doKotlinTest(path: String) {
doTest(path) { file ->
val targetClassName = getTargetClassName(file)
val helper = object: KotlinPullUpHandler.TestHelper {
override fun adjustMembers(members: List<KotlinMemberInfo>): List<KotlinMemberInfo> {
return chooseMembers(members)
}
override fun chooseSuperClass(superClasses: List<PsiNamedElement>): PsiNamedElement {
if (targetClassName != null) {
return superClasses.single { it.qualifiedClassNameForRendering() == targetClassName }
}
return superClasses.first()
}
}
KotlinPullUpHandler().invoke(getProject(), getEditor(), file) {
if (it == KotlinPullUpHandler.PULLUP_TEST_HELPER_KEY) helper else null
}
}
}
// Based on com.intellij.refactoring.PullUpTest.doTest()
protected fun doJavaTest(path: String) {
doTest(path) { file ->
val elementAt = getFile().findElementAt(getEditor().caretModel.offset)
val sourceClass = PsiTreeUtil.getParentOfType(elementAt, javaClass<PsiClass>())!!
val targetClassName = getTargetClassName(file)
val superClasses = RefactoringHierarchyUtil.createBasesList(sourceClass, false, true)
val targetClass = targetClassName?.let { name -> superClasses.first { it.qualifiedName == name } } ?: superClasses.first()
val storage = MemberInfoStorage(sourceClass) { true }
val memberInfoList = chooseMembers(storage.getClassMemberInfos(sourceClass))
val memberInfos = memberInfoList.toTypedArray()
val targetDirectory = targetClass.containingFile.containingDirectory
val conflicts = PullUpConflictsUtil.checkConflicts(
memberInfos,
sourceClass,
targetClass,
targetDirectory.getPackage()!!,
targetDirectory,
{ psiMethod : PsiMethod -> PullUpProcessor.checkedInterfacesContain(memberInfoList, psiMethod) },
true
)
if (!conflicts.isEmpty) throw BaseRefactoringProcessor.ConflictsInTestsException(conflicts.values())
PullUpProcessor(sourceClass, targetClass, memberInfos, DocCommentPolicy<PsiComment>(DocCommentPolicy.ASIS)).run()
UIUtil.dispatchAllInvocationEvents()
}
}
}
@@ -27,257 +27,332 @@ import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("idea/testData/refactoring/pullUp")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class PullUpTestGenerated extends AbstractPullUpTest {
public void testAllFilesPresentInPullUp() throws Exception {
JetTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/refactoring/pullUp"), Pattern.compile("^(.+)\\.kt$"));
@TestMetadata("idea/testData/refactoring/pullUp/k2k")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class K2K extends AbstractPullUpTest {
@TestMetadata("accidentalOverrides.kt")
public void testAccidentalOverrides() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/accidentalOverrides.kt");
doKotlinTest(fileName);
}
public void testAllFilesPresentInK2K() throws Exception {
JetTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/refactoring/pullUp/k2k"), Pattern.compile("^(.+)\\.kt$"));
}
@TestMetadata("clashWithSuper.kt")
public void testClashWithSuper() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/clashWithSuper.kt");
doKotlinTest(fileName);
}
@TestMetadata("fromClassToClass.kt")
public void testFromClassToClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/fromClassToClass.kt");
doKotlinTest(fileName);
}
@TestMetadata("fromClassToClassMakeAbstract.kt")
public void testFromClassToClassMakeAbstract() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/fromClassToClassMakeAbstract.kt");
doKotlinTest(fileName);
}
@TestMetadata("fromClassToClassWithGenerics.kt")
public void testFromClassToClassWithGenerics() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/fromClassToClassWithGenerics.kt");
doKotlinTest(fileName);
}
@TestMetadata("fromClassToInterface.kt")
public void testFromClassToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/fromClassToInterface.kt");
doKotlinTest(fileName);
}
@TestMetadata("fromClassToInterfaceMakeAbstract.kt")
public void testFromClassToInterfaceMakeAbstract() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/fromClassToInterfaceMakeAbstract.kt");
doKotlinTest(fileName);
}
@TestMetadata("implicitCompanionUsages.kt")
public void testImplicitCompanionUsages() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/implicitCompanionUsages.kt");
doKotlinTest(fileName);
}
@TestMetadata("inaccessibleMemberUsed.kt")
public void testInaccessibleMemberUsed() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/inaccessibleMemberUsed.kt");
doKotlinTest(fileName);
}
@TestMetadata("initializerInConstructor.kt")
public void testInitializerInConstructor() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/initializerInConstructor.kt");
doKotlinTest(fileName);
}
@TestMetadata("initializerInMultipleConstructorsEq.kt")
public void testInitializerInMultipleConstructorsEq() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/initializerInMultipleConstructorsEq.kt");
doKotlinTest(fileName);
}
@TestMetadata("initializerInMultipleConstructorsNonEq.kt")
public void testInitializerInMultipleConstructorsNonEq() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/initializerInMultipleConstructorsNonEq.kt");
doKotlinTest(fileName);
}
@TestMetadata("innerClassToInterface.kt")
public void testInnerClassToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/innerClassToInterface.kt");
doKotlinTest(fileName);
}
@TestMetadata("moveAllSuperInterfaces.kt")
public void testMoveAllSuperInterfaces() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/moveAllSuperInterfaces.kt");
doKotlinTest(fileName);
}
@TestMetadata("moveAllSuperInterfacesWithGenerics.kt")
public void testMoveAllSuperInterfacesWithGenerics() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/moveAllSuperInterfacesWithGenerics.kt");
doKotlinTest(fileName);
}
@TestMetadata("moveSuperInterfaces.kt")
public void testMoveSuperInterfaces() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/moveSuperInterfaces.kt");
doKotlinTest(fileName);
}
@TestMetadata("moveSuperInterfacesToEmptySpecifierList.kt")
public void testMoveSuperInterfacesToEmptySpecifierList() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/moveSuperInterfacesToEmptySpecifierList.kt");
doKotlinTest(fileName);
}
@TestMetadata("moveSuperInterfaceToItSelf.kt")
public void testMoveSuperInterfaceToItSelf() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/moveSuperInterfaceToItSelf.kt");
doKotlinTest(fileName);
}
@TestMetadata("multipleInitializersInConstructorsEq.kt")
public void testMultipleInitializersInConstructorsEq() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/multipleInitializersInConstructorsEq.kt");
doKotlinTest(fileName);
}
@TestMetadata("noCaret.kt")
public void testNoCaret() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/noCaret.kt");
doKotlinTest(fileName);
}
@TestMetadata("noClashWithAbstractSuper.kt")
public void testNoClashWithAbstractSuper() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/noClashWithAbstractSuper.kt");
doKotlinTest(fileName);
}
@TestMetadata("noInitializationInInterface.kt")
public void testNoInitializationInInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/noInitializationInInterface.kt");
doKotlinTest(fileName);
}
@TestMetadata("noSuperClass.kt")
public void testNoSuperClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/noSuperClass.kt");
doKotlinTest(fileName);
}
@TestMetadata("outsideOfClass.kt")
public void testOutsideOfClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/outsideOfClass.kt");
doKotlinTest(fileName);
}
@TestMetadata("parametersInPrimaryInitializer.kt")
public void testParametersInPrimaryInitializer() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/parametersInPrimaryInitializer.kt");
doKotlinTest(fileName);
}
@TestMetadata("propertyDependenceSatisfied.kt")
public void testPropertyDependenceSatisfied() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/propertyDependenceSatisfied.kt");
doKotlinTest(fileName);
}
@TestMetadata("propertyDependenceUnsatisfied.kt")
public void testPropertyDependenceUnsatisfied() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/propertyDependenceUnsatisfied.kt");
doKotlinTest(fileName);
}
@TestMetadata("publicToInterface.kt")
public void testPublicToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/publicToInterface.kt");
doKotlinTest(fileName);
}
@TestMetadata("superToThis.kt")
public void testSuperToThis() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/superToThis.kt");
doKotlinTest(fileName);
}
@TestMetadata("toIndirectSuperClass.kt")
public void testToIndirectSuperClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/toIndirectSuperClass.kt");
doKotlinTest(fileName);
}
@TestMetadata("usedPrivateToClass.kt")
public void testUsedPrivateToClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/usedPrivateToClass.kt");
doKotlinTest(fileName);
}
}
@TestMetadata("k2j/fromClassToClass.kt")
public void testK2j_FromClassToClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/fromClassToClass.kt");
doTest(fileName);
@TestMetadata("idea/testData/refactoring/pullUp/k2j")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class K2J extends AbstractPullUpTest {
public void testAllFilesPresentInK2J() throws Exception {
JetTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/refactoring/pullUp/k2j"), Pattern.compile("^(.+)\\.kt$"));
}
@TestMetadata("fromClassToClass.kt")
public void testFromClassToClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/fromClassToClass.kt");
doKotlinTest(fileName);
}
@TestMetadata("fromClassToClassAndMakeAbstract.kt")
public void testFromClassToClassAndMakeAbstract() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/fromClassToClassAndMakeAbstract.kt");
doKotlinTest(fileName);
}
@TestMetadata("fromClassToClassWithGenerics.kt")
public void testFromClassToClassWithGenerics() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/fromClassToClassWithGenerics.kt");
doKotlinTest(fileName);
}
@TestMetadata("fromClassToInterface.kt")
public void testFromClassToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/fromClassToInterface.kt");
doKotlinTest(fileName);
}
@TestMetadata("fromClassToNestedClass.kt")
public void testFromClassToNestedClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/fromClassToNestedClass.kt");
doKotlinTest(fileName);
}
@TestMetadata("moveSuperInterfacesToClass.kt")
public void testMoveSuperInterfacesToClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/moveSuperInterfacesToClass.kt");
doKotlinTest(fileName);
}
@TestMetadata("moveSuperInterfacesToInterface.kt")
public void testMoveSuperInterfacesToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/moveSuperInterfacesToInterface.kt");
doKotlinTest(fileName);
}
@TestMetadata("moveSuperInterfacesWithGenerics.kt")
public void testMoveSuperInterfacesWithGenerics() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/moveSuperInterfacesWithGenerics.kt");
doKotlinTest(fileName);
}
@TestMetadata("publicToInterface.kt")
public void testPublicToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/publicToInterface.kt");
doKotlinTest(fileName);
}
@TestMetadata("usedPrivateToClass.kt")
public void testUsedPrivateToClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/usedPrivateToClass.kt");
doKotlinTest(fileName);
}
}
@TestMetadata("k2j/fromClassToClassAndMakeAbstract.kt")
public void testK2j_FromClassToClassAndMakeAbstract() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/fromClassToClassAndMakeAbstract.kt");
doTest(fileName);
}
@TestMetadata("idea/testData/refactoring/pullUp/j2k")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class J2K extends AbstractPullUpTest {
public void testAllFilesPresentInJ2K() throws Exception {
JetTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/refactoring/pullUp/j2k"), Pattern.compile("^(.+)\\.java$"));
}
@TestMetadata("k2j/fromClassToClassWithGenerics.kt")
public void testK2j_FromClassToClassWithGenerics() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/fromClassToClassWithGenerics.kt");
doTest(fileName);
}
@TestMetadata("fromClassToClass.java")
public void testFromClassToClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/j2k/fromClassToClass.java");
doJavaTest(fileName);
}
@TestMetadata("k2j/fromClassToInterface.kt")
public void testK2j_FromClassToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/fromClassToInterface.kt");
doTest(fileName);
}
@TestMetadata("fromClassToClassAndMakeAbstract.java")
public void testFromClassToClassAndMakeAbstract() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/j2k/fromClassToClassAndMakeAbstract.java");
doJavaTest(fileName);
}
@TestMetadata("k2j/fromClassToNestedClass.kt")
public void testK2j_FromClassToNestedClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/fromClassToNestedClass.kt");
doTest(fileName);
}
@TestMetadata("fromClassToClassWithGenerics.java")
public void testFromClassToClassWithGenerics() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/j2k/fromClassToClassWithGenerics.java");
doJavaTest(fileName);
}
@TestMetadata("k2j/moveSuperInterfacesToClass.kt")
public void testK2j_MoveSuperInterfacesToClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/moveSuperInterfacesToClass.kt");
doTest(fileName);
}
@TestMetadata("fromClassToInterface.java")
public void testFromClassToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/j2k/fromClassToInterface.java");
doJavaTest(fileName);
}
@TestMetadata("k2j/moveSuperInterfacesToInterface.kt")
public void testK2j_MoveSuperInterfacesToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/moveSuperInterfacesToInterface.kt");
doTest(fileName);
}
@TestMetadata("fromClassToInterfaceWithConflicts.java")
public void testFromClassToInterfaceWithConflicts() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/j2k/fromClassToInterfaceWithConflicts.java");
doJavaTest(fileName);
}
@TestMetadata("k2j/moveSuperInterfacesWithGenerics.kt")
public void testK2j_MoveSuperInterfacesWithGenerics() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/moveSuperInterfacesWithGenerics.kt");
doTest(fileName);
}
@TestMetadata("fromClassToNestedClass.java")
public void testFromClassToNestedClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/j2k/fromClassToNestedClass.java");
doJavaTest(fileName);
}
@TestMetadata("k2j/publicToInterface.kt")
public void testK2j_PublicToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/publicToInterface.kt");
doTest(fileName);
}
@TestMetadata("moveSuperInterfacesToClass.java")
public void testMoveSuperInterfacesToClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/j2k/moveSuperInterfacesToClass.java");
doJavaTest(fileName);
}
@TestMetadata("k2j/usedPrivateToClass.kt")
public void testK2j_UsedPrivateToClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2j/usedPrivateToClass.kt");
doTest(fileName);
}
@TestMetadata("moveSuperInterfacesToInterface.java")
public void testMoveSuperInterfacesToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/j2k/moveSuperInterfacesToInterface.java");
doJavaTest(fileName);
}
@TestMetadata("k2k/accidentalOverrides.kt")
public void testK2k_AccidentalOverrides() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/accidentalOverrides.kt");
doTest(fileName);
}
@TestMetadata("k2k/clashWithSuper.kt")
public void testK2k_ClashWithSuper() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/clashWithSuper.kt");
doTest(fileName);
}
@TestMetadata("k2k/fromClassToClass.kt")
public void testK2k_FromClassToClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/fromClassToClass.kt");
doTest(fileName);
}
@TestMetadata("k2k/fromClassToClassMakeAbstract.kt")
public void testK2k_FromClassToClassMakeAbstract() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/fromClassToClassMakeAbstract.kt");
doTest(fileName);
}
@TestMetadata("k2k/fromClassToClassWithGenerics.kt")
public void testK2k_FromClassToClassWithGenerics() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/fromClassToClassWithGenerics.kt");
doTest(fileName);
}
@TestMetadata("k2k/fromClassToInterface.kt")
public void testK2k_FromClassToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/fromClassToInterface.kt");
doTest(fileName);
}
@TestMetadata("k2k/fromClassToInterfaceMakeAbstract.kt")
public void testK2k_FromClassToInterfaceMakeAbstract() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/fromClassToInterfaceMakeAbstract.kt");
doTest(fileName);
}
@TestMetadata("k2k/implicitCompanionUsages.kt")
public void testK2k_ImplicitCompanionUsages() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/implicitCompanionUsages.kt");
doTest(fileName);
}
@TestMetadata("k2k/inaccessibleMemberUsed.kt")
public void testK2k_InaccessibleMemberUsed() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/inaccessibleMemberUsed.kt");
doTest(fileName);
}
@TestMetadata("k2k/initializerInConstructor.kt")
public void testK2k_InitializerInConstructor() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/initializerInConstructor.kt");
doTest(fileName);
}
@TestMetadata("k2k/initializerInMultipleConstructorsEq.kt")
public void testK2k_InitializerInMultipleConstructorsEq() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/initializerInMultipleConstructorsEq.kt");
doTest(fileName);
}
@TestMetadata("k2k/initializerInMultipleConstructorsNonEq.kt")
public void testK2k_InitializerInMultipleConstructorsNonEq() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/initializerInMultipleConstructorsNonEq.kt");
doTest(fileName);
}
@TestMetadata("k2k/innerClassToInterface.kt")
public void testK2k_InnerClassToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/innerClassToInterface.kt");
doTest(fileName);
}
@TestMetadata("k2k/moveAllSuperInterfaces.kt")
public void testK2k_MoveAllSuperInterfaces() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/moveAllSuperInterfaces.kt");
doTest(fileName);
}
@TestMetadata("k2k/moveAllSuperInterfacesWithGenerics.kt")
public void testK2k_MoveAllSuperInterfacesWithGenerics() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/moveAllSuperInterfacesWithGenerics.kt");
doTest(fileName);
}
@TestMetadata("k2k/moveSuperInterfaces.kt")
public void testK2k_MoveSuperInterfaces() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/moveSuperInterfaces.kt");
doTest(fileName);
}
@TestMetadata("k2k/moveSuperInterfacesToEmptySpecifierList.kt")
public void testK2k_MoveSuperInterfacesToEmptySpecifierList() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/moveSuperInterfacesToEmptySpecifierList.kt");
doTest(fileName);
}
@TestMetadata("k2k/moveSuperInterfaceToItSelf.kt")
public void testK2k_MoveSuperInterfaceToItSelf() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/moveSuperInterfaceToItSelf.kt");
doTest(fileName);
}
@TestMetadata("k2k/multipleInitializersInConstructorsEq.kt")
public void testK2k_MultipleInitializersInConstructorsEq() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/multipleInitializersInConstructorsEq.kt");
doTest(fileName);
}
@TestMetadata("k2k/noCaret.kt")
public void testK2k_NoCaret() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/noCaret.kt");
doTest(fileName);
}
@TestMetadata("k2k/noClashWithAbstractSuper.kt")
public void testK2k_NoClashWithAbstractSuper() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/noClashWithAbstractSuper.kt");
doTest(fileName);
}
@TestMetadata("k2k/noInitializationInInterface.kt")
public void testK2k_NoInitializationInInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/noInitializationInInterface.kt");
doTest(fileName);
}
@TestMetadata("k2k/noSuperClass.kt")
public void testK2k_NoSuperClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/noSuperClass.kt");
doTest(fileName);
}
@TestMetadata("k2k/outsideOfClass.kt")
public void testK2k_OutsideOfClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/outsideOfClass.kt");
doTest(fileName);
}
@TestMetadata("k2k/parametersInPrimaryInitializer.kt")
public void testK2k_ParametersInPrimaryInitializer() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/parametersInPrimaryInitializer.kt");
doTest(fileName);
}
@TestMetadata("k2k/propertyDependenceSatisfied.kt")
public void testK2k_PropertyDependenceSatisfied() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/propertyDependenceSatisfied.kt");
doTest(fileName);
}
@TestMetadata("k2k/propertyDependenceUnsatisfied.kt")
public void testK2k_PropertyDependenceUnsatisfied() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/propertyDependenceUnsatisfied.kt");
doTest(fileName);
}
@TestMetadata("k2k/publicToInterface.kt")
public void testK2k_PublicToInterface() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/publicToInterface.kt");
doTest(fileName);
}
@TestMetadata("k2k/superToThis.kt")
public void testK2k_SuperToThis() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/superToThis.kt");
doTest(fileName);
}
@TestMetadata("k2k/toIndirectSuperClass.kt")
public void testK2k_ToIndirectSuperClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/toIndirectSuperClass.kt");
doTest(fileName);
}
@TestMetadata("k2k/usedPrivateToClass.kt")
public void testK2k_UsedPrivateToClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/k2k/usedPrivateToClass.kt");
doTest(fileName);
@TestMetadata("moveSuperInterfacesWithGenerics.java")
public void testMoveSuperInterfacesWithGenerics() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/pullUp/j2k/moveSuperInterfacesWithGenerics.java");
doJavaTest(fileName);
}
}
}