KT-5287 J2K: Convert class with private constructor and static functions to "object" instead of class with "class object"
#KT-5287 Fixed
This commit is contained in:
@@ -49,14 +49,15 @@ enum class AccessorKind {
|
||||
|
||||
class ClassBodyConverter(private val psiClass: PsiClass,
|
||||
private val converter: Converter,
|
||||
private val isOpenClass: Boolean) {
|
||||
private val isOpenClass: Boolean,
|
||||
private val isObject: Boolean) {
|
||||
private val membersToRemove = HashSet<PsiMember>()
|
||||
private val fieldCorrections = HashMap<PsiField, FieldCorrectionInfo>()
|
||||
|
||||
public fun convertBody(): ClassBody {
|
||||
processAccessorsToDrop()
|
||||
|
||||
val constructorConverter = if (psiClass.getName() != null)
|
||||
val constructorConverter = if (psiClass.getName() != null && !isObject)
|
||||
ConstructorConverter(psiClass, converter, fieldCorrections)
|
||||
else
|
||||
null
|
||||
@@ -65,9 +66,10 @@ class ClassBodyConverter(private val psiClass: PsiClass,
|
||||
for (element in psiClass.getChildren()) {
|
||||
if (element is PsiMember) {
|
||||
if (element is PsiAnnotationMethod) continue // converted in convertAnnotationType()
|
||||
if (isObject && element.isConstructor()) continue // no constructor in object
|
||||
|
||||
val converted = converter.convertMember(element, membersToRemove, constructorConverter)
|
||||
if (converted != null/* && !converted.isEmpty()*/) {
|
||||
if (converted != null) {
|
||||
convertedMembers.put(element, converted)
|
||||
}
|
||||
}
|
||||
@@ -77,6 +79,13 @@ class ClassBodyConverter(private val psiClass: PsiClass,
|
||||
convertedMembers.remove(member)
|
||||
}
|
||||
|
||||
val lBrace = LBrace().assignPrototype(psiClass.getLBrace())
|
||||
val rBrace = RBrace().assignPrototype(psiClass.getRBrace())
|
||||
|
||||
if (isObject) {
|
||||
return ClassBody(null, emptyList(), convertedMembers.values().toList(), emptyList(), lBrace, rBrace)
|
||||
}
|
||||
|
||||
val useCompanionObject = shouldGenerateCompanionObject(convertedMembers)
|
||||
|
||||
val members = ArrayList<Member>()
|
||||
@@ -105,9 +114,6 @@ class ClassBodyConverter(private val psiClass: PsiClass,
|
||||
primaryConstructorSignature = null // no "()" after class name is needed in this case
|
||||
}
|
||||
|
||||
val lBrace = LBrace().assignPrototype(psiClass.getLBrace())
|
||||
val rBrace = RBrace().assignPrototype(psiClass.getRBrace())
|
||||
|
||||
return ClassBody(primaryConstructorSignature, constructorConverter?.baseClassParams ?: listOf(), members, companionObjectMembers, lBrace, rBrace)
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ class CodeConverter(
|
||||
}
|
||||
|
||||
public fun convertAnonymousClassBody(anonymousClass: PsiAnonymousClass): AnonymousClassBody {
|
||||
return AnonymousClassBody(ClassBodyConverter(anonymousClass, converter, false).convertBody(),
|
||||
return AnonymousClassBody(ClassBodyConverter(anonymousClass, converter, isOpenClass = false, isObject = false).convertBody(),
|
||||
anonymousClass.getBaseClassType().resolve()?.isInterface() ?: false).assignPrototype(anonymousClass)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,20 +16,21 @@
|
||||
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.CommonClassNames.*
|
||||
import com.intellij.psi.util.PsiMethodUtil
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
import org.jetbrains.kotlin.j2k.ast.Annotation
|
||||
import org.jetbrains.kotlin.j2k.ast.Class
|
||||
import org.jetbrains.kotlin.j2k.ast.Enum
|
||||
import java.util.*
|
||||
import com.intellij.psi.CommonClassNames.*
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions.*
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.util.PsiMethodUtil
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.j2k.usageProcessing.UsageProcessing
|
||||
import org.jetbrains.kotlin.j2k.ast.Object
|
||||
import org.jetbrains.kotlin.j2k.usageProcessing.FieldToPropertyProcessing
|
||||
import org.jetbrains.kotlin.j2k.usageProcessing.UsageProcessing
|
||||
import org.jetbrains.kotlin.j2k.usageProcessing.UsageProcessingExpressionConverter
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions.*
|
||||
import java.util.ArrayList
|
||||
|
||||
class Converter private(
|
||||
private val elementToConvert: PsiElement,
|
||||
@@ -150,42 +151,71 @@ class Converter private(
|
||||
val annotations = convertAnnotations(psiClass)
|
||||
var modifiers = convertModifiers(psiClass)
|
||||
val typeParameters = convertTypeParameterList(psiClass.getTypeParameterList())
|
||||
val implementsTypes = convertToNotNullableTypes(psiClass.getImplementsListTypes())
|
||||
val extendsTypes = convertToNotNullableTypes(psiClass.getExtendsListTypes())
|
||||
val implementsTypes = convertToNotNullableTypes(psiClass.getImplementsListTypes())
|
||||
val name = psiClass.declarationIdentifier()
|
||||
|
||||
return when {
|
||||
psiClass.isInterface() -> {
|
||||
var classBody = ClassBodyConverter(psiClass, this, false).convertBody()
|
||||
val classBody = ClassBodyConverter(psiClass, this, isOpenClass = false, isObject = false).convertBody()
|
||||
Trait(name, annotations, modifiers, typeParameters, extendsTypes, listOf(), implementsTypes, classBody)
|
||||
}
|
||||
|
||||
psiClass.isEnum() -> {
|
||||
var classBody = ClassBodyConverter(psiClass, this, false).convertBody()
|
||||
val classBody = ClassBodyConverter(psiClass, this, isOpenClass = false, isObject = false).convertBody()
|
||||
Enum(name, annotations, modifiers, typeParameters, listOf(), listOf(), implementsTypes, classBody)
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (needOpenModifier(psiClass)) {
|
||||
modifiers = modifiers.with(Modifier.OPEN)
|
||||
if (shouldConvertIntoObject(psiClass)) {
|
||||
val classBody = ClassBodyConverter(psiClass, this, isOpenClass = false, isObject = true).convertBody()
|
||||
Object(name, annotations, modifiers.without(Modifier.ABSTRACT), classBody)
|
||||
}
|
||||
else {
|
||||
if (psiClass.getContainingClass() != null && !psiClass.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
modifiers = modifiers.with(Modifier.INNER)
|
||||
}
|
||||
|
||||
if (psiClass.getContainingClass() != null && !psiClass.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
modifiers = modifiers.with(Modifier.INNER)
|
||||
val openModifier = if (psiClass.hasModifierProperty(PsiModifier.FINAL) || psiClass.hasModifierProperty(PsiModifier.ABSTRACT))
|
||||
false
|
||||
else
|
||||
settings.openByDefault || referenceSearcher.hasInheritors(psiClass)
|
||||
|
||||
if (openModifier) {
|
||||
modifiers = modifiers.with(Modifier.OPEN)
|
||||
}
|
||||
|
||||
val classBody = ClassBodyConverter(psiClass, this, modifiers.contains(Modifier.OPEN) || modifiers.contains(Modifier.ABSTRACT), isObject = false).convertBody()
|
||||
Class(name, annotations, modifiers, typeParameters, extendsTypes, classBody.baseClassParams, implementsTypes, classBody)
|
||||
}
|
||||
|
||||
var classBody = ClassBodyConverter(psiClass, this, modifiers.contains(Modifier.OPEN)).convertBody()
|
||||
|
||||
Class(name, annotations, modifiers, typeParameters, extendsTypes, classBody.baseClassParams, implementsTypes, classBody)
|
||||
}
|
||||
}.assignPrototype(psiClass)
|
||||
}
|
||||
|
||||
private fun needOpenModifier(psiClass: PsiClass): Boolean {
|
||||
return if (settings.openByDefault)
|
||||
!psiClass.hasModifierProperty(PsiModifier.FINAL) && !psiClass.hasModifierProperty(PsiModifier.ABSTRACT)
|
||||
else
|
||||
referenceSearcher.hasInheritors(psiClass)
|
||||
private fun shouldConvertIntoObject(psiClass: PsiClass): Boolean {
|
||||
val methods = psiClass.getMethods()
|
||||
val fields = psiClass.getFields()
|
||||
val classes = psiClass.getInnerClasses()
|
||||
if (methods.isEmpty() && fields.isEmpty()) return false
|
||||
fun isStatic(member: PsiMember) = member.hasModifierProperty(PsiModifier.STATIC)
|
||||
if (!methods.all { isStatic(it) || it.isConstructor() } || !fields.all(::isStatic) || !classes.all(::isStatic)) return false
|
||||
|
||||
val constructors = psiClass.getConstructors()
|
||||
if (constructors.size() > 1) return false
|
||||
val constructor = constructors.singleOrNull()
|
||||
if (constructor != null) {
|
||||
if (!constructor.hasModifierProperty(PsiModifier.PRIVATE)) return false
|
||||
if (constructor.getParameterList().getParameters().isNotEmpty()) return false
|
||||
if (constructor.getBody()?.getStatements()?.isNotEmpty() ?: false) return false
|
||||
if (constructor.getModifierList().getAnnotations().isNotEmpty()) return false
|
||||
}
|
||||
|
||||
if (psiClass.getExtendsListTypes().isNotEmpty() || psiClass.getImplementsListTypes().isNotEmpty()) return false
|
||||
if (psiClass.getTypeParameters().isNotEmpty()) return false
|
||||
|
||||
if (referenceSearcher.hasInheritors(psiClass)) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private fun convertAnnotationType(psiClass: PsiClass): Class {
|
||||
@@ -215,7 +245,7 @@ class Converter private(
|
||||
null
|
||||
|
||||
// to convert fields and nested types - they are not allowed in Kotlin but we convert them and let user refactor code
|
||||
var classBody = ClassBodyConverter(psiClass, this, false).convertBody()
|
||||
var classBody = ClassBodyConverter(psiClass, this, isOpenClass = false, isObject = false).convertBody()
|
||||
classBody = ClassBody(constructorSignature, classBody.baseClassParams, classBody.members, classBody.companionObjectMembers, classBody.lBrace, classBody.rBrace)
|
||||
|
||||
val annotationAnnotation = Annotation(Identifier("annotation").assignNoPrototype(), listOf(), false, false).assignNoPrototype()
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.CodeBuilder
|
||||
import org.jetbrains.kotlin.j2k.append
|
||||
|
||||
open class Class(
|
||||
val name: Identifier,
|
||||
@@ -68,3 +69,14 @@ open class Class(
|
||||
protected open fun presentationModifiers(): Modifiers
|
||||
= if (modifiers.contains(Modifier.ABSTRACT)) modifiers.without(Modifier.OPEN) else modifiers
|
||||
}
|
||||
|
||||
class Object(
|
||||
name: Identifier,
|
||||
annotations: Annotations,
|
||||
modifiers: Modifiers,
|
||||
body: ClassBody
|
||||
) : Class(name, annotations, modifiers, TypeParameterList.Empty, emptyList(), emptyList(), emptyList(), body) {
|
||||
|
||||
override val keyword: String
|
||||
get() = "object"
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
class Test {
|
||||
companion object {
|
||||
var str: String
|
||||
object Test {
|
||||
var str: String
|
||||
|
||||
init {
|
||||
str = "Ola"
|
||||
}
|
||||
init {
|
||||
str = "Ola"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
// ERROR: Property must be initialized or be abstract
|
||||
class Library {
|
||||
companion object {
|
||||
val ourOut: java.io.PrintStream
|
||||
}
|
||||
object Library {
|
||||
val ourOut: java.io.PrintStream
|
||||
}
|
||||
|
||||
class User {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
class Library {
|
||||
companion object {
|
||||
fun call() {
|
||||
}
|
||||
object Library {
|
||||
fun call() {
|
||||
}
|
||||
|
||||
fun getString(): String {
|
||||
return ""
|
||||
}
|
||||
fun getString(): String {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package test;
|
||||
|
||||
import java.lang.String;
|
||||
|
||||
public class Short {
|
||||
public static Short valueOf(String value) {return new Short();}
|
||||
public Short(String s){}
|
||||
public static Short valueOf(String value) {return new Short(value);}
|
||||
}
|
||||
|
||||
class Test {
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package test
|
||||
|
||||
public class Short {
|
||||
public class Short(s: String) {
|
||||
companion object {
|
||||
public fun valueOf(value: String): Short {
|
||||
return Short()
|
||||
return Short(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
companion object {
|
||||
public fun test() {
|
||||
test.Short.valueOf("1")
|
||||
test.Short.valueOf("1")
|
||||
java.lang.Short.valueOf("1")
|
||||
}
|
||||
object Test {
|
||||
public fun test() {
|
||||
test.Short.valueOf("1")
|
||||
test.Short.valueOf("1")
|
||||
java.lang.Short.valueOf("1")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Base {
|
||||
public static final int CONSTANT = 10;
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
void foo(){}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
open class Base {
|
||||
companion object {
|
||||
public val CONSTANT: Int = 10
|
||||
}
|
||||
}
|
||||
|
||||
class Derived : Base() {
|
||||
fun foo() {
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
class S {
|
||||
companion object {
|
||||
fun staticF(): Boolean {
|
||||
return true
|
||||
}
|
||||
object S {
|
||||
fun staticF(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
class S {
|
||||
companion object {
|
||||
fun sB(): Boolean {
|
||||
return true
|
||||
}
|
||||
object S {
|
||||
fun sB(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
fun sI(): Int {
|
||||
return 1
|
||||
}
|
||||
fun sI(): Int {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class Util {
|
||||
public static void util1() {}
|
||||
public static void util2() {}
|
||||
|
||||
public static final int CONSTANT = 10;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
object Util {
|
||||
public fun util1() {
|
||||
}
|
||||
|
||||
public fun util2() {
|
||||
}
|
||||
|
||||
public val CONSTANT: Int = 10
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Util {
|
||||
private Util(){}
|
||||
|
||||
public static void util1() {}
|
||||
public static void util2() {}
|
||||
|
||||
public static final int CONSTANT = 10;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
object Util {
|
||||
|
||||
public fun util1() {
|
||||
}
|
||||
|
||||
public fun util2() {
|
||||
}
|
||||
|
||||
public val CONSTANT: Int = 10
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
abstract class Util {
|
||||
public static void util1() {}
|
||||
public static void util2() {}
|
||||
|
||||
public static final int CONSTANT = 10;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
object Util {
|
||||
public fun util1() {
|
||||
}
|
||||
|
||||
public fun util2() {
|
||||
}
|
||||
|
||||
public val CONSTANT: Int = 10
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
public class A {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
System.out.println(Void.TYPE)
|
||||
System.out.println(Integer.TYPE)
|
||||
System.out.println(java.lang.Double.TYPE)
|
||||
System.out.println(javaClass<IntArray>())
|
||||
System.out.println(javaClass<Array<Any>>())
|
||||
System.out.println(javaClass<Array<Array<Any>>>())
|
||||
}
|
||||
public object A {
|
||||
public fun main(args: Array<String>) {
|
||||
System.out.println(Void.TYPE)
|
||||
System.out.println(Integer.TYPE)
|
||||
System.out.println(java.lang.Double.TYPE)
|
||||
System.out.println(javaClass<IntArray>())
|
||||
System.out.println(javaClass<Array<Any>>())
|
||||
System.out.println(javaClass<Array<Array<Any>>>())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,10 @@ package pack
|
||||
|
||||
class C(arg1: Int, arg2: Int = 0, arg3: Int = 0)
|
||||
|
||||
public class User {
|
||||
companion object {
|
||||
public fun main() {
|
||||
val c1 = C(100, 100, 100)
|
||||
val c2 = C(100, 100)
|
||||
val c3 = C(100)
|
||||
}
|
||||
public object User {
|
||||
public fun main() {
|
||||
val c1 = C(100, 100, 100)
|
||||
val c2 = C(100, 100)
|
||||
val c3 = C(100)
|
||||
}
|
||||
}
|
||||
@@ -18,12 +18,10 @@ class C(val myArg1: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
public class User {
|
||||
companion object {
|
||||
public fun main() {
|
||||
val c1 = C(100, 100, 100)
|
||||
val c2 = C(100, 100)
|
||||
val c3 = C(100)
|
||||
}
|
||||
public object User {
|
||||
public fun main() {
|
||||
val c1 = C(100, 100, 100)
|
||||
val c2 = C(100, 100)
|
||||
val c3 = C(100)
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,10 @@ class C(arg1: Int, arg2: Int, arg3: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
public class User {
|
||||
companion object {
|
||||
public fun main() {
|
||||
val c1 = C(1, 2, 3)
|
||||
val c2 = C(5, 6)
|
||||
val c3 = C(7)
|
||||
}
|
||||
public object User {
|
||||
public fun main() {
|
||||
val c1 = C(1, 2, 3)
|
||||
val c2 = C(5, 6)
|
||||
val c3 = C(7)
|
||||
}
|
||||
}
|
||||
@@ -33,12 +33,10 @@ class CustomerBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public class User {
|
||||
companion object {
|
||||
public fun main() {
|
||||
val customer = CustomerBuilder().WithFirstName("Homer").WithLastName("Simpson").Build()
|
||||
System.out.println(customer.firstName)
|
||||
System.out.println(customer.lastName)
|
||||
}
|
||||
public object User {
|
||||
public fun main() {
|
||||
val customer = CustomerBuilder().WithFirstName("Homer").WithLastName("Simpson").Build()
|
||||
System.out.println(customer.firstName)
|
||||
System.out.println(customer.lastName)
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,10 @@ public class Identifier<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public class User {
|
||||
companion object {
|
||||
public fun main() {
|
||||
val i1 = Identifier("name", false, true)
|
||||
val i2 = Identifier("name", false)
|
||||
val i3 = Identifier("name")
|
||||
}
|
||||
public object User {
|
||||
public fun main() {
|
||||
val i1 = Identifier("name", false, true)
|
||||
val i2 = Identifier("name", false)
|
||||
val i3 = Identifier("name")
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,10 @@ public class Identifier {
|
||||
}
|
||||
}
|
||||
|
||||
public class User {
|
||||
companion object {
|
||||
public fun main() {
|
||||
val i1 = Identifier("name", false, true)
|
||||
val i2 = Identifier("name", false)
|
||||
val i3 = Identifier("name")
|
||||
}
|
||||
public object User {
|
||||
public fun main() {
|
||||
val i1 = Identifier("name", false, true)
|
||||
val i2 = Identifier("name", false)
|
||||
val i3 = Identifier("name")
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,10 @@ class C {
|
||||
}
|
||||
}
|
||||
|
||||
public class User {
|
||||
companion object {
|
||||
public fun main() {
|
||||
val c1 = C(1, 2, 3)
|
||||
val c2 = C(5, 6)
|
||||
val c3 = C(7)
|
||||
}
|
||||
public object User {
|
||||
public fun main() {
|
||||
val c1 = C(1, 2, 3)
|
||||
val c2 = C(5, 6)
|
||||
val c3 = C(7)
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,10 @@ class C(arg1: Int, arg2: Int = 0, arg3: Int = 0) {
|
||||
}
|
||||
}
|
||||
|
||||
public class User {
|
||||
companion object {
|
||||
public fun main() {
|
||||
val c1 = C(100, 100, 100)
|
||||
val c2 = C(100, 100)
|
||||
val c3 = C(100)
|
||||
}
|
||||
public object User {
|
||||
public fun main() {
|
||||
val c1 = C(100, 100, 100)
|
||||
val c2 = C(100, 100)
|
||||
val c3 = C(100)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
class Outer {
|
||||
object Outer {
|
||||
private class Nested1() {
|
||||
|
||||
public constructor(a: Int) : this() {
|
||||
@@ -48,13 +48,10 @@ class Outer {
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun foo() {
|
||||
val nested1 = Nested1(1)
|
||||
val nested2 = Nested2(2)
|
||||
val nested3 = Nested3(3)
|
||||
val nested4 = Nested4(4)
|
||||
}
|
||||
fun foo() {
|
||||
val nested1 = Nested1(1)
|
||||
val nested2 = Nested2(2)
|
||||
val nested3 = Nested3(3)
|
||||
val nested4 = Nested4(4)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,8 @@ public class Test {
|
||||
}
|
||||
}
|
||||
|
||||
public class User {
|
||||
companion object {
|
||||
public fun main() {
|
||||
val t = Test("name")
|
||||
}
|
||||
public object User {
|
||||
public fun main() {
|
||||
val t = Test("name")
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
public class TestClass {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
var i = 0
|
||||
while (i < 10) {
|
||||
if (i == 4 || i == 8) {
|
||||
i++
|
||||
++i
|
||||
continue
|
||||
}
|
||||
System.err.println(i)
|
||||
public object TestClass {
|
||||
public fun main(args: Array<String>) {
|
||||
var i = 0
|
||||
while (i < 10) {
|
||||
if (i == 4 || i == 8) {
|
||||
i++
|
||||
++i
|
||||
continue
|
||||
}
|
||||
System.err.println(i)
|
||||
++i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
public class TestClass {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
var i = 0
|
||||
var j = 1
|
||||
while (i < 10) {
|
||||
if (i == 4 || i == 8) {
|
||||
i++
|
||||
++i
|
||||
j *= 2
|
||||
continue
|
||||
}
|
||||
System.err.println(j)
|
||||
public object TestClass {
|
||||
public fun main(args: Array<String>) {
|
||||
var i = 0
|
||||
var j = 1
|
||||
while (i < 10) {
|
||||
if (i == 4 || i == 8) {
|
||||
i++
|
||||
++i
|
||||
j *= 2
|
||||
continue
|
||||
}
|
||||
System.err.println(j)
|
||||
++i
|
||||
j *= 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
public class TestClass {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
var i = 1
|
||||
while (i < 1000) {
|
||||
if (i == 4 || i == 8) {
|
||||
i *= 2
|
||||
continue
|
||||
}
|
||||
System.err.println(i)
|
||||
public object TestClass {
|
||||
public fun main(args: Array<String>) {
|
||||
var i = 1
|
||||
while (i < 1000) {
|
||||
if (i == 4 || i == 8) {
|
||||
i *= 2
|
||||
continue
|
||||
}
|
||||
System.err.println(i)
|
||||
i *= 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
// ERROR: The label '@OuterLoop1' does not denote a loop
|
||||
public class TestClass {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
var i = 1
|
||||
@OuterLoop1 @OuterLoop2 while (i < 1000) {
|
||||
var j = 1
|
||||
@InnerLoop while (j < 100) {
|
||||
if (j == 3) {
|
||||
j *= 3
|
||||
continue@InnerLoop
|
||||
}
|
||||
if (i == j) {
|
||||
i *= 2
|
||||
continue@OuterLoop1
|
||||
}
|
||||
System.err.println(j)
|
||||
if (j == 9) {
|
||||
j *= 3
|
||||
continue
|
||||
}
|
||||
public object TestClass {
|
||||
public fun main(args: Array<String>) {
|
||||
var i = 1
|
||||
@OuterLoop1 @OuterLoop2 while (i < 1000) {
|
||||
var j = 1
|
||||
@InnerLoop while (j < 100) {
|
||||
if (j == 3) {
|
||||
j *= 3
|
||||
continue@InnerLoop
|
||||
}
|
||||
i *= 2
|
||||
if (i == j) {
|
||||
i *= 2
|
||||
continue@OuterLoop1
|
||||
}
|
||||
System.err.println(j)
|
||||
if (j == 9) {
|
||||
j *= 3
|
||||
continue
|
||||
}
|
||||
j *= 3
|
||||
}
|
||||
i *= 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
class F {
|
||||
companion object {
|
||||
object F {
|
||||
|
||||
//c1
|
||||
//c1
|
||||
|
||||
/*c2*/
|
||||
/*c2*/
|
||||
|
||||
fun f1() {
|
||||
}
|
||||
fun f1() {
|
||||
}
|
||||
|
||||
|
||||
//c3
|
||||
//c3
|
||||
|
||||
|
||||
|
||||
|
||||
//c4
|
||||
//c4
|
||||
|
||||
fun f2() {
|
||||
}
|
||||
fun f2() {
|
||||
}
|
||||
|
||||
var i: Int? = 0
|
||||
var i: Int? = 0
|
||||
|
||||
fun f3() {
|
||||
}
|
||||
fun f3() {
|
||||
}
|
||||
|
||||
//c5
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
}
|
||||
public fun main(args: Array<String>) {
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
public class A {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
}
|
||||
public object A {
|
||||
public fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// !forceNotNullTypes: false
|
||||
public class A {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
}
|
||||
public object A {
|
||||
public fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
class Test {
|
||||
companion object {
|
||||
public fun foo(args: Array<String>): Int {
|
||||
return args.size()
|
||||
}
|
||||
object Test {
|
||||
public fun foo(args: Array<String>): Int {
|
||||
return args.size()
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
class Outer {
|
||||
object Outer {
|
||||
public var o: Any? = Object()
|
||||
|
||||
public class Nested {
|
||||
public fun foo() {
|
||||
o = null
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
public var o: Any? = Object()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package demo
|
||||
|
||||
class Test {
|
||||
companion object {
|
||||
fun subListRangeCheck(fromIndex: Int, toIndex: Int, size: Int) {
|
||||
if (fromIndex < 0)
|
||||
throw IndexOutOfBoundsException("fromIndex = " + fromIndex)
|
||||
if (toIndex > size)
|
||||
throw IndexOutOfBoundsException("toIndex = " + toIndex)
|
||||
if (fromIndex > toIndex)
|
||||
throw IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")")
|
||||
}
|
||||
object Test {
|
||||
fun subListRangeCheck(fromIndex: Int, toIndex: Int, size: Int) {
|
||||
if (fromIndex < 0)
|
||||
throw IndexOutOfBoundsException("fromIndex = " + fromIndex)
|
||||
if (toIndex > size)
|
||||
throw IndexOutOfBoundsException("toIndex = " + toIndex)
|
||||
if (fromIndex > toIndex)
|
||||
throw IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")")
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,11 @@ public class Identifier<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public class User {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
val i1 = Identifier("name", false, true)
|
||||
val i2 = Identifier("name", false)
|
||||
val i3 = Identifier("name")
|
||||
}
|
||||
public object User {
|
||||
public fun main(args: Array<String>) {
|
||||
val i1 = Identifier("name", false, true)
|
||||
val i2 = Identifier("name", false)
|
||||
val i3 = Identifier("name")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,23 +4,21 @@
|
||||
// ERROR: Unresolved reference: close
|
||||
import java.io.*
|
||||
|
||||
class FileRead {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
try {
|
||||
val fstream = FileInputStream()
|
||||
val `in` = DataInputStream(fstream)
|
||||
val br = BufferedReader(InputStreamReader(`in`))
|
||||
val strLine: String
|
||||
while ((strLine = br.readLine()) != null) {
|
||||
System.out.println(strLine)
|
||||
}
|
||||
`in`.close()
|
||||
} catch (e: Exception) {
|
||||
System.err.println("Error: " + e.getMessage())
|
||||
object FileRead {
|
||||
public fun main(args: Array<String>) {
|
||||
try {
|
||||
val fstream = FileInputStream()
|
||||
val `in` = DataInputStream(fstream)
|
||||
val br = BufferedReader(InputStreamReader(`in`))
|
||||
val strLine: String
|
||||
while ((strLine = br.readLine()) != null) {
|
||||
System.out.println(strLine)
|
||||
}
|
||||
|
||||
`in`.close()
|
||||
} catch (e: Exception) {
|
||||
System.err.println("Error: " + e.getMessage())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,8 @@ class Container {
|
||||
var myString = "1"
|
||||
}
|
||||
|
||||
class One {
|
||||
companion object {
|
||||
var myContainer = Container()
|
||||
}
|
||||
object One {
|
||||
var myContainer = Container()
|
||||
}
|
||||
|
||||
class StringContainer(s: String)
|
||||
|
||||
@@ -4,10 +4,8 @@ class Container {
|
||||
var myInt = 1
|
||||
}
|
||||
|
||||
class One {
|
||||
companion object {
|
||||
var myContainer = Container()
|
||||
}
|
||||
object One {
|
||||
var myContainer = Container()
|
||||
}
|
||||
|
||||
class IntContainer(i: Int)
|
||||
|
||||
@@ -4,10 +4,8 @@ class Container {
|
||||
var myInt = 1
|
||||
}
|
||||
|
||||
class One {
|
||||
companion object {
|
||||
var myContainer = Container()
|
||||
}
|
||||
object One {
|
||||
var myContainer = Container()
|
||||
}
|
||||
|
||||
class Test {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
class Test {
|
||||
companion object {
|
||||
public fun toFileSystemSafeName(name: String): String {
|
||||
val size = name.length()
|
||||
return name
|
||||
}
|
||||
object Test {
|
||||
public fun toFileSystemSafeName(name: String): String {
|
||||
val size = name.length()
|
||||
return name
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,8 @@ class Container {
|
||||
var myInt = 1
|
||||
}
|
||||
|
||||
class One {
|
||||
companion object {
|
||||
var myContainer = Container()
|
||||
}
|
||||
object One {
|
||||
var myContainer = Container()
|
||||
}
|
||||
|
||||
class Test {
|
||||
|
||||
@@ -5,17 +5,15 @@ import java.io.File
|
||||
/**
|
||||
* User: ignatov
|
||||
*/
|
||||
public class Test {
|
||||
companion object {
|
||||
public fun isDir(parent: File?): Boolean {
|
||||
if (parent == null || !parent.exists()) {
|
||||
return false
|
||||
}
|
||||
val result = true
|
||||
if (parent.isDirectory()) {
|
||||
return true
|
||||
} else
|
||||
return false
|
||||
public object Test {
|
||||
public fun isDir(parent: File?): Boolean {
|
||||
if (parent == null || !parent.exists()) {
|
||||
return false
|
||||
}
|
||||
val result = true
|
||||
if (parent.isDirectory()) {
|
||||
return true
|
||||
} else
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,8 @@ class Container {
|
||||
var myBoolean = true
|
||||
}
|
||||
|
||||
class One {
|
||||
companion object {
|
||||
var myContainer = Container()
|
||||
}
|
||||
object One {
|
||||
var myContainer = Container()
|
||||
}
|
||||
|
||||
class Test {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package demo
|
||||
|
||||
class Program {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
System.out.println("Halo!")
|
||||
}
|
||||
object Program {
|
||||
public fun main(args: Array<String>) {
|
||||
System.out.println("Halo!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
class Test {
|
||||
companion object {
|
||||
public fun getInt(i: Int): Int {
|
||||
when (i) {
|
||||
0 -> return 0
|
||||
1 -> return 1
|
||||
2 -> return 2
|
||||
3 -> return 3
|
||||
else -> return -1
|
||||
}
|
||||
object Test {
|
||||
public fun getInt(i: Int): Int {
|
||||
when (i) {
|
||||
0 -> return 0
|
||||
1 -> return 1
|
||||
2 -> return 2
|
||||
3 -> return 3
|
||||
else -> return -1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
import java.lang.reflect.Constructor
|
||||
|
||||
class X {
|
||||
companion object {
|
||||
throws(javaClass<Exception>())
|
||||
fun <T> foo(constructor: Constructor<T>, args1: Array<Any>, args2: Array<Any>) {
|
||||
constructor.newInstance(*args1)
|
||||
constructor.newInstance(args1, args2)
|
||||
}
|
||||
object X {
|
||||
throws(javaClass<Exception>())
|
||||
fun <T> foo(constructor: Constructor<T>, args1: Array<Any>, args2: Array<Any>) {
|
||||
constructor.newInstance(*args1)
|
||||
constructor.newInstance(args1, args2)
|
||||
}
|
||||
}
|
||||
@@ -1,86 +1,84 @@
|
||||
package demo
|
||||
|
||||
public class SwitchDemo {
|
||||
companion object {
|
||||
public fun print(o: Any) {
|
||||
System.out.println(o)
|
||||
}
|
||||
public object SwitchDemo {
|
||||
public fun print(o: Any) {
|
||||
System.out.println(o)
|
||||
}
|
||||
|
||||
public fun test(i: Int) {
|
||||
var monthString = "<empty>"
|
||||
when (i) {
|
||||
1 -> {
|
||||
print(1)
|
||||
print(2)
|
||||
print(3)
|
||||
print(4)
|
||||
print(5)
|
||||
}
|
||||
2 -> {
|
||||
print(2)
|
||||
print(3)
|
||||
print(4)
|
||||
print(5)
|
||||
}
|
||||
3 -> {
|
||||
print(3)
|
||||
print(4)
|
||||
print(5)
|
||||
}
|
||||
4 -> {
|
||||
print(4)
|
||||
print(5)
|
||||
}
|
||||
5 -> print(5)
|
||||
6 -> {
|
||||
print(6)
|
||||
print(7)
|
||||
print(8)
|
||||
print(9)
|
||||
print(10)
|
||||
print(11)
|
||||
monthString = "December"
|
||||
}
|
||||
7 -> {
|
||||
print(7)
|
||||
print(8)
|
||||
print(9)
|
||||
print(10)
|
||||
print(11)
|
||||
monthString = "December"
|
||||
}
|
||||
8 -> {
|
||||
print(8)
|
||||
print(9)
|
||||
print(10)
|
||||
print(11)
|
||||
monthString = "December"
|
||||
}
|
||||
9 -> {
|
||||
print(9)
|
||||
print(10)
|
||||
print(11)
|
||||
monthString = "December"
|
||||
}
|
||||
10 -> {
|
||||
print(10)
|
||||
print(11)
|
||||
monthString = "December"
|
||||
}
|
||||
11 -> {
|
||||
print(11)
|
||||
monthString = "December"
|
||||
}
|
||||
12 -> monthString = "December"
|
||||
else -> monthString = "Invalid month"
|
||||
public fun test(i: Int) {
|
||||
var monthString = "<empty>"
|
||||
when (i) {
|
||||
1 -> {
|
||||
print(1)
|
||||
print(2)
|
||||
print(3)
|
||||
print(4)
|
||||
print(5)
|
||||
}
|
||||
System.out.println(monthString)
|
||||
2 -> {
|
||||
print(2)
|
||||
print(3)
|
||||
print(4)
|
||||
print(5)
|
||||
}
|
||||
3 -> {
|
||||
print(3)
|
||||
print(4)
|
||||
print(5)
|
||||
}
|
||||
4 -> {
|
||||
print(4)
|
||||
print(5)
|
||||
}
|
||||
5 -> print(5)
|
||||
6 -> {
|
||||
print(6)
|
||||
print(7)
|
||||
print(8)
|
||||
print(9)
|
||||
print(10)
|
||||
print(11)
|
||||
monthString = "December"
|
||||
}
|
||||
7 -> {
|
||||
print(7)
|
||||
print(8)
|
||||
print(9)
|
||||
print(10)
|
||||
print(11)
|
||||
monthString = "December"
|
||||
}
|
||||
8 -> {
|
||||
print(8)
|
||||
print(9)
|
||||
print(10)
|
||||
print(11)
|
||||
monthString = "December"
|
||||
}
|
||||
9 -> {
|
||||
print(9)
|
||||
print(10)
|
||||
print(11)
|
||||
monthString = "December"
|
||||
}
|
||||
10 -> {
|
||||
print(10)
|
||||
print(11)
|
||||
monthString = "December"
|
||||
}
|
||||
11 -> {
|
||||
print(11)
|
||||
monthString = "December"
|
||||
}
|
||||
12 -> monthString = "December"
|
||||
else -> monthString = "Invalid month"
|
||||
}
|
||||
System.out.println(monthString)
|
||||
}
|
||||
|
||||
public fun main(args: Array<String>) {
|
||||
for (i in 1..12)
|
||||
test(i)
|
||||
}
|
||||
public fun main(args: Array<String>) {
|
||||
for (i in 1..12)
|
||||
test(i)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
public class NonDefault {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
public object NonDefault {
|
||||
public fun main(args: Array<String>) {
|
||||
|
||||
val value = 3
|
||||
val valueString = ""
|
||||
when (value) {
|
||||
val value = 3
|
||||
val valueString = ""
|
||||
when (value) {
|
||||
|
||||
}
|
||||
System.out.println(valueString)
|
||||
}
|
||||
System.out.println(valueString)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package switch_demo
|
||||
|
||||
public class SwitchDemo {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
val month = 8
|
||||
val monthString: String
|
||||
when (month) {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 -> monthString = "December"
|
||||
else -> monthString = "Invalid month"
|
||||
}
|
||||
System.out.println(monthString)
|
||||
public object SwitchDemo {
|
||||
public fun main(args: Array<String>) {
|
||||
val month = 8
|
||||
val monthString: String
|
||||
when (month) {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 -> monthString = "December"
|
||||
else -> monthString = "Invalid month"
|
||||
}
|
||||
System.out.println(monthString)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
public class C {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
when (args.size()) {
|
||||
1 -> {
|
||||
run {
|
||||
val a = 1
|
||||
System.out.print("1")
|
||||
}
|
||||
run {
|
||||
val a = 2
|
||||
System.out.print("2")
|
||||
}
|
||||
public object C {
|
||||
public fun main(args: Array<String>) {
|
||||
when (args.size()) {
|
||||
1 -> {
|
||||
run {
|
||||
val a = 1
|
||||
System.out.print("1")
|
||||
}
|
||||
|
||||
2 -> {
|
||||
run {
|
||||
val a = 2
|
||||
System.out.print("2")
|
||||
}
|
||||
}
|
||||
|
||||
2 -> {
|
||||
val a = 2
|
||||
System.out.print("2")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
package switch_demo
|
||||
|
||||
public class SwitchDemo {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
public object SwitchDemo {
|
||||
public fun main(args: Array<String>) {
|
||||
|
||||
val month = 8
|
||||
val monthString: String
|
||||
when (month) {
|
||||
1 -> monthString = "January"
|
||||
2 -> monthString = "February"
|
||||
3 -> monthString = "March"
|
||||
4 -> monthString = "April"
|
||||
5 -> monthString = "May"
|
||||
6 -> monthString = "June"
|
||||
7 -> monthString = "July"
|
||||
8 -> monthString = "August"
|
||||
9 -> monthString = "September"
|
||||
10 -> monthString = "October"
|
||||
11 -> monthString = "November"
|
||||
12 -> monthString = "December"
|
||||
else -> monthString = "Invalid month"
|
||||
}
|
||||
System.out.println(monthString)
|
||||
val month = 8
|
||||
val monthString: String
|
||||
when (month) {
|
||||
1 -> monthString = "January"
|
||||
2 -> monthString = "February"
|
||||
3 -> monthString = "March"
|
||||
4 -> monthString = "April"
|
||||
5 -> monthString = "May"
|
||||
6 -> monthString = "June"
|
||||
7 -> monthString = "July"
|
||||
8 -> monthString = "August"
|
||||
9 -> monthString = "September"
|
||||
10 -> monthString = "October"
|
||||
11 -> monthString = "November"
|
||||
12 -> monthString = "December"
|
||||
else -> monthString = "Invalid month"
|
||||
}
|
||||
System.out.println(monthString)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
public class NonDefault {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
public object NonDefault {
|
||||
public fun main(args: Array<String>) {
|
||||
|
||||
val value = 3
|
||||
var valueString = ""
|
||||
when (value) {
|
||||
1 -> valueString = "ONE"
|
||||
2 -> valueString = "TWO"
|
||||
3 -> valueString = "THREE"
|
||||
}
|
||||
System.out.println(valueString)
|
||||
val value = 3
|
||||
var valueString = ""
|
||||
when (value) {
|
||||
1 -> valueString = "ONE"
|
||||
2 -> valueString = "TWO"
|
||||
3 -> valueString = "THREE"
|
||||
}
|
||||
System.out.println(valueString)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// ERROR: Type inference failed. Expected type mismatch: found: java.util.HashMap<kotlin.Any!, kotlin.Any!> required: kotlin.Map<kotlin.String, kotlin.String>
|
||||
import java.util.*
|
||||
|
||||
class A {
|
||||
companion object {
|
||||
public fun foo(): Map<String, String> {
|
||||
val props = Properties()
|
||||
return HashMap(props as Map<Any, Any>)
|
||||
}
|
||||
object A {
|
||||
public fun foo(): Map<String, String> {
|
||||
val props = Properties()
|
||||
return HashMap(props as Map<Any, Any>)
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public abstract class AbstractJavaToKotlinConverterSingleFileTest : AbstractJava
|
||||
}
|
||||
|
||||
private fun methodToKotlin(text: String, settings: ConverterSettings, project: Project): String {
|
||||
val result = fileToKotlin("final class C {" + text + "}", settings, project).replaceAll("class C \\{", "")
|
||||
val result = fileToKotlin("final class C {" + text + "}", settings, project).replaceAll("class C \\{", "").replaceAll("object C \\{", "")
|
||||
return result.substring(0, (result.lastIndexOf("}"))).trim()
|
||||
}
|
||||
|
||||
|
||||
@@ -886,6 +886,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("notUtilityClass.java")
|
||||
public void testNotUtilityClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/class/notUtilityClass.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("oneStaticFieldOneNonStatic.java")
|
||||
public void testOneStaticFieldOneNonStatic() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/class/oneStaticFieldOneNonStatic.java");
|
||||
@@ -939,6 +945,24 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/class/twoStaticMethod.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("utilityClass1.java")
|
||||
public void testUtilityClass1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/class/utilityClass1.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("utilityClass2.java")
|
||||
public void testUtilityClass2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/class/utilityClass2.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("utilityClass3.java")
|
||||
public void testUtilityClass3() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/class/utilityClass3.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("j2k/testData/fileOrElement/classExpression")
|
||||
|
||||
@@ -886,6 +886,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("notUtilityClass.java")
|
||||
public void testNotUtilityClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/class/notUtilityClass.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("oneStaticFieldOneNonStatic.java")
|
||||
public void testOneStaticFieldOneNonStatic() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/class/oneStaticFieldOneNonStatic.java");
|
||||
@@ -939,6 +945,24 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/class/twoStaticMethod.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("utilityClass1.java")
|
||||
public void testUtilityClass1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/class/utilityClass1.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("utilityClass2.java")
|
||||
public void testUtilityClass2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/class/utilityClass2.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("utilityClass3.java")
|
||||
public void testUtilityClass3() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/class/utilityClass3.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("j2k/testData/fileOrElement/classExpression")
|
||||
|
||||
Reference in New Issue
Block a user