Migration to actual/expect: quick-fix CreateActualFix with tests

This commit is contained in:
Mikhail Glukhikh
2017-09-14 18:25:33 +03:00
parent 810d62bbaf
commit fba1a2a2db
41 changed files with 121 additions and 120 deletions
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createTypeParameter.Cr
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateLocalVariableActionFactory import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateLocalVariableActionFactory
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByNamedArgumentActionFactory import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByNamedArgumentActionFactory
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByRefActionFactory import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByRefActionFactory
import org.jetbrains.kotlin.idea.quickfix.createImpl.CreateHeaderImplementationFix import org.jetbrains.kotlin.idea.quickfix.createImpl.CreateActualFix
import org.jetbrains.kotlin.idea.quickfix.migration.MigrateExternalExtensionFix import org.jetbrains.kotlin.idea.quickfix.migration.MigrateExternalExtensionFix
import org.jetbrains.kotlin.idea.quickfix.migration.MigrateTypeParameterListFix import org.jetbrains.kotlin.idea.quickfix.migration.MigrateTypeParameterListFix
import org.jetbrains.kotlin.idea.quickfix.replaceWith.DeprecatedSymbolUsageFix import org.jetbrains.kotlin.idea.quickfix.replaceWith.DeprecatedSymbolUsageFix
@@ -476,7 +476,7 @@ class QuickFixRegistrar : QuickFixContributor {
OVERLOADS_LOCAL.registerFactory(RemoveAnnotationFix.JvmOverloads) OVERLOADS_LOCAL.registerFactory(RemoveAnnotationFix.JvmOverloads)
OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS.registerFactory(RemoveAnnotationFix.JvmOverloads) OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS.registerFactory(RemoveAnnotationFix.JvmOverloads)
HEADER_WITHOUT_IMPLEMENTATION.registerFactory(CreateHeaderImplementationFix) HEADER_WITHOUT_IMPLEMENTATION.registerFactory(CreateActualFix)
IMPL_MISSING.registerFactory(AddModifierFix.createFactory(KtTokens.IMPL_KEYWORD)) IMPL_MISSING.registerFactory(AddModifierFix.createFactory(KtTokens.IMPL_KEYWORD))
CAST_NEVER_SUCCEEDS.registerFactory(ReplacePrimitiveCastWithNumberConversionFix) CAST_NEVER_SUCCEEDS.registerFactory(ReplacePrimitiveCastWithNumberConversionFix)
@@ -43,9 +43,9 @@ import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.MultiTargetPlatform import org.jetbrains.kotlin.resolve.MultiTargetPlatform
import org.jetbrains.kotlin.resolve.getMultiTargetPlatform import org.jetbrains.kotlin.resolve.getMultiTargetPlatform
sealed class CreateHeaderImplementationFix<out D : KtNamedDeclaration>( sealed class CreateActualFix<out D : KtNamedDeclaration>(
declaration: D, declaration: D,
private val implPlatform: MultiTargetPlatform.Specific, private val actualPlatform: MultiTargetPlatform.Specific,
private val generateIt: KtPsiFactory.(Project, D) -> D? private val generateIt: KtPsiFactory.(Project, D) -> D?
) : KotlinQuickFixAction<D>(declaration) { ) : KotlinQuickFixAction<D>(declaration) {
@@ -53,7 +53,7 @@ sealed class CreateHeaderImplementationFix<out D : KtNamedDeclaration>(
protected abstract val elementType: String protected abstract val elementType: String
override fun getText() = "Create header $elementType implementation for platform ${implPlatform.platform}" override fun getText() = "Create actual $elementType for platform ${actualPlatform.platform}"
override fun startInWriteAction() = false override fun startInWriteAction() = false
@@ -61,35 +61,35 @@ sealed class CreateHeaderImplementationFix<out D : KtNamedDeclaration>(
val element = element ?: return val element = element ?: return
val factory = KtPsiFactory(project) val factory = KtPsiFactory(project)
val implFile = getOrCreateImplementationFile(project) ?: return val actualFile = getOrCreateImplementationFile(project) ?: return
val generated = factory.generateIt(project, element) ?: return val generated = factory.generateIt(project, element) ?: return
runWriteAction { runWriteAction {
if (implFile.packageDirective?.fqName != file.packageDirective?.fqName && if (actualFile.packageDirective?.fqName != file.packageDirective?.fqName &&
implFile.declarations.isEmpty()) { actualFile.declarations.isEmpty()) {
val packageDirective = file.packageDirective val packageDirective = file.packageDirective
packageDirective?.let { packageDirective?.let {
val oldPackageDirective = implFile.packageDirective val oldPackageDirective = actualFile.packageDirective
val newPackageDirective = factory.createPackageDirective(it.fqName) val newPackageDirective = factory.createPackageDirective(it.fqName)
if (oldPackageDirective != null) { if (oldPackageDirective != null) {
oldPackageDirective.replace(newPackageDirective) oldPackageDirective.replace(newPackageDirective)
} }
else { else {
implFile.add(newPackageDirective) actualFile.add(newPackageDirective)
} }
} }
} }
val implDeclaration = implFile.add(generated) as KtElement val actualDeclaration = actualFile.add(generated) as KtElement
val reformatted = CodeStyleManager.getInstance(project).reformat(implDeclaration) val reformatted = CodeStyleManager.getInstance(project).reformat(actualDeclaration)
ShortenReferences.DEFAULT.process(reformatted as KtElement) ShortenReferences.DEFAULT.process(reformatted as KtElement)
} }
} }
private fun Project.implementationModuleOf(headerModule: Module) = private fun Project.implementationModuleOf(expectedModule: Module) =
allModules().firstOrNull { allModules().firstOrNull {
PackageUtil.checkSourceRootsConfigured(it, false) && PackageUtil.checkSourceRootsConfigured(it, false) &&
TargetPlatformDetector.getPlatform(it).multiTargetPlatform == implPlatform && TargetPlatformDetector.getPlatform(it).multiTargetPlatform == actualPlatform &&
headerModule in ModuleRootManager.getInstance(it).dependencies expectedModule in ModuleRootManager.getInstance(it).dependencies
} }
private fun getOrCreateImplementationFile( private fun getOrCreateImplementationFile(
@@ -98,36 +98,36 @@ sealed class CreateHeaderImplementationFix<out D : KtNamedDeclaration>(
val declaration = element as? KtNamedDeclaration ?: return null val declaration = element as? KtNamedDeclaration ?: return null
val name = declaration.name ?: return null val name = declaration.name ?: return null
val headerDir = declaration.containingFile.containingDirectory val expectedDir = declaration.containingFile.containingDirectory
val headerPackage = JavaDirectoryService.getInstance().getPackage(headerDir) val expectedPackage = JavaDirectoryService.getInstance().getPackage(expectedDir)
val headerModule = ModuleUtilCore.findModuleForPsiElement(declaration) ?: return null val expectedModule = ModuleUtilCore.findModuleForPsiElement(declaration) ?: return null
val implModule = project.implementationModuleOf(headerModule) ?: return null val actualModule = project.implementationModuleOf(expectedModule) ?: return null
val implDirectory = PackageUtil.findOrCreateDirectoryForPackage( val actualDirectory = PackageUtil.findOrCreateDirectoryForPackage(
implModule, headerPackage?.qualifiedName ?: "", null, false actualModule, expectedPackage?.qualifiedName ?: "", null, false
) ?: return null ) ?: return null
return runWriteAction { return runWriteAction {
val fileName = "$name.kt" val fileName = "$name.kt"
val existingFile = implDirectory.findFile(fileName) val existingFile = actualDirectory.findFile(fileName)
val packageDirective = declaration.containingKtFile.packageDirective val packageDirective = declaration.containingKtFile.packageDirective
val packageName = val packageName =
if (packageDirective?.packageNameExpression == null) implDirectory.getPackage()?.qualifiedName if (packageDirective?.packageNameExpression == null) actualDirectory.getPackage()?.qualifiedName
else packageDirective.fqName.asString() else packageDirective.fqName.asString()
if (existingFile is KtFile) { if (existingFile is KtFile) {
val existingPackageDirective = existingFile.packageDirective val existingPackageDirective = existingFile.packageDirective
if (existingFile.declarations.isNotEmpty() && if (existingFile.declarations.isNotEmpty() &&
existingPackageDirective?.fqName != packageDirective?.fqName) { existingPackageDirective?.fqName != packageDirective?.fqName) {
val newName = KotlinNameSuggester.suggestNameByName(name) { val newName = KotlinNameSuggester.suggestNameByName(name) {
implDirectory.findFile("$it.kt") == null actualDirectory.findFile("$it.kt") == null
} + ".kt" } + ".kt"
createKotlinFile(newName, implDirectory, packageName) createKotlinFile(newName, actualDirectory, packageName)
} }
else { else {
existingFile existingFile
} }
} }
else { else {
createKotlinFile(fileName, implDirectory, packageName) createKotlinFile(fileName, actualDirectory, packageName)
} }
} }
} }
@@ -138,67 +138,68 @@ sealed class CreateHeaderImplementationFix<out D : KtNamedDeclaration>(
val declaration = d.psiElement as? KtNamedDeclaration ?: return null val declaration = d.psiElement as? KtNamedDeclaration ?: return null
val compatibility = d.c val compatibility = d.c
if (compatibility.isNotEmpty()) return null if (compatibility.isNotEmpty()) return null
val implPlatform = d.b.getMultiTargetPlatform() as? MultiTargetPlatform.Specific ?: return null val actualPlatform = d.b.getMultiTargetPlatform() as? MultiTargetPlatform.Specific ?: return null
return when (declaration) { return when (declaration) {
is KtClassOrObject -> CreateHeaderClassImplementationFix(declaration, implPlatform) is KtClassOrObject -> CreateActualClassFix(declaration, actualPlatform)
is KtFunction -> CreateHeaderFunctionImplementationFix(declaration, implPlatform) is KtFunction -> CreateActualFunctionFix(declaration, actualPlatform)
is KtProperty -> CreateHeaderPropertyImplementationFix(declaration, implPlatform) is KtProperty -> CreateActualPropertyFix(declaration, actualPlatform)
else -> null else -> null
} }
} }
} }
} }
class CreateHeaderClassImplementationFix( class CreateActualClassFix(
klass: KtClassOrObject, klass: KtClassOrObject,
implPlatform: MultiTargetPlatform.Specific actualPlatform: MultiTargetPlatform.Specific
) : CreateHeaderImplementationFix<KtClassOrObject>(klass, implPlatform, { project, element -> ) : CreateActualFix<KtClassOrObject>(klass, actualPlatform, { project, element ->
generateClassOrObject(project, element, implNeeded = true) generateClassOrObject(project, element, actualNeeded = true)
}) { }) {
override val elementType = if ((element as? KtClass)?.isInterface() ?: false) "interface" else "class" override val elementType = if ((element as? KtClass)?.isInterface() == true) "interface" else "class"
} }
class CreateHeaderPropertyImplementationFix( class CreateActualPropertyFix(
property: KtProperty, property: KtProperty,
implPlatform: MultiTargetPlatform.Specific actualPlatform: MultiTargetPlatform.Specific
) : CreateHeaderImplementationFix<KtProperty>(property, implPlatform, { project, element -> ) : CreateActualFix<KtProperty>(property, actualPlatform, { project, element ->
val descriptor = element.toDescriptor() as? PropertyDescriptor val descriptor = element.toDescriptor() as? PropertyDescriptor
descriptor?.let { generateProperty(project, element, descriptor, implNeeded = true) } descriptor?.let { generateProperty(project, element, descriptor, actualNeeded = true) }
}) { }) {
override val elementType = "property" override val elementType = "property"
} }
class CreateHeaderFunctionImplementationFix( class CreateActualFunctionFix(
function: KtFunction, function: KtFunction,
implPlatform: MultiTargetPlatform.Specific actualPlatform: MultiTargetPlatform.Specific
) : CreateHeaderImplementationFix<KtFunction>(function, implPlatform, { project, element -> ) : CreateActualFix<KtFunction>(function, actualPlatform, { project, element ->
val descriptor = element.toDescriptor() as? FunctionDescriptor val descriptor = element.toDescriptor() as? FunctionDescriptor
descriptor?.let { generateFunction(project, element, descriptor, implNeeded = true) } descriptor?.let { generateFunction(project, element, descriptor, actualNeeded = true) }
}) { }) {
override val elementType = "function" override val elementType = "function"
} }
private fun KtModifierListOwner.replaceHeaderModifier(implNeeded: Boolean) { private fun KtModifierListOwner.replaceExpectModifier(actualNeeded: Boolean) {
if (implNeeded) { if (actualNeeded) {
addModifier(KtTokens.IMPL_KEYWORD) addModifier(KtTokens.ACTUAL_KEYWORD)
} }
else { else {
removeModifier(KtTokens.HEADER_KEYWORD) removeModifier(KtTokens.HEADER_KEYWORD)
removeModifier(KtTokens.EXPECT_KEYWORD)
} }
} }
private fun KtPsiFactory.generateClassOrObject( private fun KtPsiFactory.generateClassOrObject(
project: Project, project: Project,
headerClass: KtClassOrObject, expectedClass: KtClassOrObject,
implNeeded: Boolean actualNeeded: Boolean
): KtClassOrObject { ): KtClassOrObject {
val header = headerClass.text val expectedText = expectedClass.text
val implClass = if (headerClass is KtObjectDeclaration) createObject(header) else createClass(header) val actualClass = if (expectedClass is KtObjectDeclaration) createObject(expectedText) else createClass(expectedText)
if (headerClass !is KtClass || !headerClass.isInterface()) { if (expectedClass !is KtClass || !expectedClass.isInterface()) {
implClass.declarations.forEach { actualClass.declarations.forEach {
if (it !is KtEnumEntry && if (it !is KtEnumEntry &&
it !is KtClassOrObject && it !is KtClassOrObject &&
!it.hasModifier(KtTokens.ABSTRACT_KEYWORD)) { !it.hasModifier(KtTokens.ABSTRACT_KEYWORD)) {
@@ -206,28 +207,28 @@ private fun KtPsiFactory.generateClassOrObject(
} }
} }
declLoop@ for (headerDeclaration in headerClass.declarations) { declLoop@ for (expectedDeclaration in expectedClass.declarations) {
if (headerDeclaration.hasModifier(KtTokens.ABSTRACT_KEYWORD)) continue if (expectedDeclaration.hasModifier(KtTokens.ABSTRACT_KEYWORD)) continue
val descriptor = headerDeclaration.toDescriptor() ?: continue val descriptor = expectedDeclaration.toDescriptor() ?: continue
val implDeclaration: KtDeclaration = when (headerDeclaration) { val actualDeclaration: KtDeclaration = when (expectedDeclaration) {
is KtFunction -> generateFunction(project, headerDeclaration, descriptor as FunctionDescriptor, implNeeded = true) is KtFunction -> generateFunction(project, expectedDeclaration, descriptor as FunctionDescriptor, actualNeeded = true)
is KtProperty -> generateProperty(project, headerDeclaration, descriptor as PropertyDescriptor, implNeeded = true) is KtProperty -> generateProperty(project, expectedDeclaration, descriptor as PropertyDescriptor, actualNeeded = true)
else -> continue@declLoop else -> continue@declLoop
} }
implClass.addDeclaration(implDeclaration) actualClass.addDeclaration(actualDeclaration)
} }
} }
return implClass.apply { return actualClass.apply {
replaceHeaderModifier(implNeeded) replaceExpectModifier(actualNeeded)
} }
} }
private fun KtPsiFactory.generateFunction( private fun KtPsiFactory.generateFunction(
project: Project, project: Project,
headerFunction: KtFunction, expectedFunction: KtFunction,
descriptor: FunctionDescriptor, descriptor: FunctionDescriptor,
implNeeded: Boolean actualNeeded: Boolean
): KtFunction { ): KtFunction {
val returnType = descriptor.returnType val returnType = descriptor.returnType
val body = run { val body = run {
@@ -246,12 +247,12 @@ private fun KtPsiFactory.generateFunction(
} }
} }
return if (headerFunction is KtSecondaryConstructor) { return if (expectedFunction is KtSecondaryConstructor) {
createSecondaryConstructor(headerFunction.text + " " + body) createSecondaryConstructor(expectedFunction.text + " " + body)
} }
else { else {
createFunction(headerFunction.text + " " + body).apply { createFunction(expectedFunction.text + " " + body).apply {
replaceHeaderModifier(implNeeded) replaceExpectModifier(actualNeeded)
if (returnType != null && KotlinBuiltIns.isUnit(returnType)) { if (returnType != null && KotlinBuiltIns.isUnit(returnType)) {
typeReference = null typeReference = null
} }
@@ -261,9 +262,9 @@ private fun KtPsiFactory.generateFunction(
private fun KtPsiFactory.generateProperty( private fun KtPsiFactory.generateProperty(
project: Project, project: Project,
headerProperty: KtProperty, expectedProperty: KtProperty,
descriptor: PropertyDescriptor, descriptor: PropertyDescriptor,
implNeeded: Boolean actualNeeded: Boolean
): KtProperty { ): KtProperty {
val body = buildString { val body = buildString {
append("\nget()") append("\nget()")
@@ -278,8 +279,8 @@ private fun KtPsiFactory.generateProperty(
append("\nset(value) {}") append("\nset(value) {}")
} }
} }
return createProperty(headerProperty.text + " " + body).apply { return createProperty(expectedProperty.text + " " + body).apply {
replaceHeaderModifier(implNeeded) replaceExpectModifier(actualNeeded)
} }
} }
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JS" "true" // "Create actual class for platform JS" "true"
header abstract class <caret>Abstract { header abstract class <caret>Abstract {
fun foo(param: String): Int fun foo(param: String): Int
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JS" "true" // "Create actual class for platform JS" "true"
header abstract class Abstract { header abstract class Abstract {
fun foo(param: String): Int fun foo(param: String): Int
@@ -1,13 +1,13 @@
// Abstract: to be implemented // Abstract: to be implemented
impl abstract class Abstract { actual abstract class Abstract {
abstract fun String.bar(y: Double): Boolean abstract fun String.bar(y: Double): Boolean
abstract var status: Int abstract var status: Int
impl fun foo(param: String): Int { actual fun foo(param: String): Int {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
} }
impl val isGood: Boolean actual val isGood: Boolean
get() = TODO("not implemented") //To change body of created functions use File | Settings | File Templates. get() = TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
} }
+1 -1
View File
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JVM" "true" // "Create actual class for platform JVM" "true"
header class <caret>My { header class <caret>My {
fun foo(param: String): Int fun foo(param: String): Int
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JVM" "true" // "Create actual class for platform JVM" "true"
header class My { header class My {
fun foo(param: String): Int fun foo(param: String): Int
+6 -6
View File
@@ -1,22 +1,22 @@
// My: to be implemented // My: to be implemented
impl class My { actual class My {
impl fun foo(param: String): Int { actual fun foo(param: String): Int {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
} }
impl fun String.bar(y: Double): Boolean { actual fun String.bar(y: Double): Boolean {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
} }
impl fun baz() {} actual fun baz() {}
constructor(flag: Boolean) { constructor(flag: Boolean) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
} }
impl val isGood: Boolean actual val isGood: Boolean
get() = TODO("not implemented") //To change body of created functions use File | Settings | File Templates. get() = TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
impl var status: Int actual var status: Int
get() = TODO("not implemented") //To change body of created functions use File | Settings | File Templates. get() = TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
set(value) {} set(value) {}
+1 -1
View File
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JS" "true" // "Create actual class for platform JS" "true"
header enum class <caret>MyEnum { header enum class <caret>MyEnum {
FIRST, FIRST,
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JS" "true" // "Create actual class for platform JS" "true"
header enum class MyEnum { header enum class MyEnum {
FIRST, FIRST,
+2 -2
View File
@@ -1,10 +1,10 @@
// MyEnum: to be implemented // MyEnum: to be implemented
impl enum class MyEnum { actual enum class MyEnum {
FIRST, FIRST,
SECOND, SECOND,
LAST; LAST;
impl val num: Int actual val num: Int
get() = TODO("not implemented") //To change body of created functions use File | Settings | File Templates. get() = TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
} }
@@ -1,3 +1,3 @@
// "Create header function implementation for platform JVM" "true" // "Create actual function for platform JVM" "true"
header fun <caret>foo(arg: Int): String header fun <caret>foo(arg: Int): String
@@ -1,3 +1,3 @@
// "Create header function implementation for platform JVM" "true" // "Create actual function for platform JVM" "true"
header fun foo(arg: Int): String header fun foo(arg: Int): String
@@ -1,4 +1,4 @@
// foo: to be implemented // foo: to be implemented
impl fun foo(arg: Int): String { actual fun foo(arg: Int): String {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
} }
@@ -1,4 +1,4 @@
// "Create header interface implementation for platform JVM" "true" // "Create actual interface for platform JVM" "true"
header interface <caret>Interface { header interface <caret>Interface {
fun foo(param: String): Int fun foo(param: String): Int
@@ -1,4 +1,4 @@
// "Create header interface implementation for platform JVM" "true" // "Create actual interface for platform JVM" "true"
header interface Interface { header interface Interface {
fun foo(param: String): Int fun foo(param: String): Int
@@ -1,5 +1,5 @@
// Interface: to be implemented // Interface: to be implemented
impl interface Interface { actual interface Interface {
fun foo(param: String): Int fun foo(param: String): Int
fun String.bar(y: Double): Boolean fun String.bar(y: Double): Boolean
+1 -1
View File
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JVM" "true" // "Create actual class for platform JVM" "true"
header class <caret>WithNested { header class <caret>WithNested {
fun foo(): Int fun foo(): Int
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JVM" "true" // "Create actual class for platform JVM" "true"
header class WithNested { header class WithNested {
fun foo(): Int fun foo(): Int
@@ -1,5 +1,5 @@
// WithNested: to be implemented // WithNested: to be implemented
impl class WithNested { actual class WithNested {
class Nested { class Nested {
fun bar() fun bar()
@@ -9,7 +9,7 @@ impl class WithNested {
fun baz() fun baz()
} }
impl fun foo(): Int { actual fun foo(): Int {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
} }
} }
+1 -1
View File
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JVM" "true" // "Create actual class for platform JVM" "true"
header object <caret>Object { header object <caret>Object {
fun foo(): String fun foo(): String
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JVM" "true" // "Create actual class for platform JVM" "true"
header object Object { header object Object {
fun foo(): String fun foo(): String
@@ -1,6 +1,6 @@
// Object: to be implemented // Object: to be implemented
impl object Object { actual object Object {
impl fun foo(): String { actual fun foo(): String {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
} }
} }
+1 -1
View File
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JVM" "true" // "Create actual class for platform JVM" "true"
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION // SHOULD_BE_AVAILABLE_AFTER_EXECUTION
package test.inner package test.inner
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JVM" "true" // "Create actual class for platform JVM" "true"
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION // SHOULD_BE_AVAILABLE_AFTER_EXECUTION
package test.inner package test.inner
+1 -1
View File
@@ -1,3 +1,3 @@
package test.inner package test.inner
impl class My actual class My
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JVM" "true" // "Create actual class for platform JVM" "true"
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION // SHOULD_BE_AVAILABLE_AFTER_EXECUTION
package test.inner package test.inner
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JVM" "true" // "Create actual class for platform JVM" "true"
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION // SHOULD_BE_AVAILABLE_AFTER_EXECUTION
package test.inner package test.inner
@@ -1,3 +1,3 @@
package test.inner package test.inner
impl class My actual class My
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JVM" "true" // "Create actual class for platform JVM" "true"
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION // SHOULD_BE_AVAILABLE_AFTER_EXECUTION
package test.inner package test.inner
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JVM" "true" // "Create actual class for platform JVM" "true"
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION // SHOULD_BE_AVAILABLE_AFTER_EXECUTION
package test.inner package test.inner
@@ -1,3 +1,3 @@
package test.inner package test.inner
impl class My actual class My
@@ -1,3 +1,3 @@
// "Create header property implementation for platform JVM" "true" // "Create actual property for platform JVM" "true"
header var <caret>x: Int header var <caret>x: Int
@@ -1,3 +1,3 @@
// "Create header property implementation for platform JVM" "true" // "Create actual property for platform JVM" "true"
header var x: Int header var x: Int
+1 -1
View File
@@ -1,4 +1,4 @@
// x: to be implemented // x: to be implemented
impl var x: Int actual var x: Int
get() = TODO("not implemented") //To change body of created functions use File | Settings | File Templates. get() = TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
set(value) {} set(value) {}
+1 -1
View File
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JS" "true" // "Create actual class for platform JS" "true"
header sealed class <caret>Sealed { header sealed class <caret>Sealed {
object Obj : Sealed object Obj : Sealed
@@ -1,4 +1,4 @@
// "Create header class implementation for platform JS" "true" // "Create actual class for platform JS" "true"
header sealed class Sealed { header sealed class Sealed {
object Obj : Sealed object Obj : Sealed
@@ -1,5 +1,5 @@
// Sealed: to be implemented // Sealed: to be implemented
impl sealed class Sealed { actual sealed class Sealed {
object Obj : Sealed object Obj : Sealed
class Klass(x: Int) : Sealed class Klass(x: Int) : Sealed
@@ -1,4 +1,4 @@
// "Create header function implementation for platform JVM" "true" // "Create actual function for platform JVM" "true"
package test package test
@@ -1,4 +1,4 @@
// "Create header function implementation for platform JVM" "true" // "Create actual function for platform JVM" "true"
package test package test
@@ -2,4 +2,4 @@
package test package test
impl fun testHelper() {} actual fun testHelper() {}