diff --git a/src/org/jetbrains/jet/j2k/Converter.kt b/src/org/jetbrains/jet/j2k/Converter.kt index 8a2ed61c688..a151831e255 100644 --- a/src/org/jetbrains/jet/j2k/Converter.kt +++ b/src/org/jetbrains/jet/j2k/Converter.kt @@ -28,47 +28,49 @@ import com.intellij.openapi.Disposable import org.jetbrains.jet.lang.resolve.name.FqName public open class Converter() { - private var classIdentifiers: MutableSet = Sets.newHashSet()!! + + private var classIdentifiersSet: MutableSet = Sets.newHashSet()!! + private val dispatcher: Dispatcher = Dispatcher(this) - private var methodReturnType: PsiType? = null + private val flags: MutableSet? = Sets.newHashSet() - private val jetCoreEnvironment: JetCoreEnvironment + + private val jetCoreEnvironment = JetCoreEnvironment( + object : Disposable { + public override fun dispose() { + } + }, CompilerConfiguration()) + + + private val project = jetCoreEnvironment.getProject(); + { - val disposable = (object : Disposable { - public override fun dispose() {} - }) - jetCoreEnvironment = JetCoreEnvironment(disposable, CompilerConfiguration()) - } - private val project: Project - { - project = jetCoreEnvironment.getProject() KotlinBuiltIns.initialize(project) } - private val javaToKotlinClassMap: JavaToKotlinClassMap - { - javaToKotlinClassMap = JavaToKotlinClassMap.getInstance() - } + + private val javaToKotlinClassMap: JavaToKotlinClassMap = JavaToKotlinClassMap.getInstance() + + public open var methodReturnType: PsiType? = null + private set + public open fun addFlag(flag: J2KConverterFlags): Boolean { return flags?.add(flag)!! } + public open fun hasFlag(flag: J2KConverterFlags): Boolean { return flags?.contains(flag)!! } public open fun setClassIdentifiers(identifiers: MutableSet) { - classIdentifiers = identifiers + classIdentifiersSet = identifiers } public open fun getClassIdentifiers(): Set { - return Collections.unmodifiableSet(classIdentifiers) - } - - public open fun getMethodReturnType(): PsiType? { - return methodReturnType + return Collections.unmodifiableSet(classIdentifiersSet) } public open fun clearClassIdentifiers(): Unit { - classIdentifiers.clear() + classIdentifiersSet.clear() } public open fun elementToKotlin(element: PsiElement): String { diff --git a/src/org/jetbrains/jet/j2k/visitors/StatementVisitor.kt b/src/org/jetbrains/jet/j2k/visitors/StatementVisitor.kt index ec11074dff5..7c13f3a8c29 100644 --- a/src/org/jetbrains/jet/j2k/visitors/StatementVisitor.kt +++ b/src/org/jetbrains/jet/j2k/visitors/StatementVisitor.kt @@ -217,7 +217,7 @@ public open class StatementVisitor(converter: Converter): ElementVisitor(convert public override fun visitReturnStatement(statement: PsiReturnStatement?): Unit { val returnValue: PsiExpression? = statement?.getReturnValue() - val methodReturnType: PsiType? = getConverter().getMethodReturnType() + val methodReturnType: PsiType? = getConverter().methodReturnType val expression: Expression = (if (returnValue != null && methodReturnType != null) this.getConverter().expressionToExpression(returnValue, methodReturnType) else