Rename package jet -> kotlin in j2k
org.jetbrains.jet.j2k -> org.jetbrains.kotlin.j2k Also update calls to deprecated functions: size -> size(), length -> length(), withIndices() -> withIndex()
This commit is contained in:
@@ -109,7 +109,7 @@ import org.jetbrains.jet.plugin.stubs.AbstractResolveByStubTest
|
||||
import org.jetbrains.jet.plugin.stubs.AbstractMultiFileHighlightingTest
|
||||
import org.jetbrains.jet.cfg.AbstractPseudoValueTest
|
||||
import org.jetbrains.jet.plugin.structureView.AbstractKotlinFileStructureTest
|
||||
import org.jetbrains.jet.j2k.test.AbstractJavaToKotlinConverterSingleFileTest
|
||||
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterSingleFileTest
|
||||
import org.jetbrains.jet.jps.build.AbstractIncrementalJpsTest
|
||||
import org.jetbrains.jet.asJava.AbstractKotlinLightClassTest
|
||||
import org.jetbrains.jet.lang.resolve.java.AbstractJavaTypeSubstitutorTest
|
||||
@@ -123,8 +123,8 @@ import org.jetbrains.kotlin.generators.tests.reservedWords.generateTestDataForRe
|
||||
import org.jetbrains.k2js.test.semantics.AbstractReservedWordTest
|
||||
import org.jetbrains.jet.resolve.AbstractReferenceResolveInJavaTest
|
||||
import org.jetbrains.k2js.test.semantics.AbstractBridgeTest
|
||||
import org.jetbrains.jet.j2k.test.AbstractJavaToKotlinConverterMultiFileTest
|
||||
import org.jetbrains.jet.j2k.test.AbstractJavaToKotlinConverterForWebDemoTest
|
||||
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterMultiFileTest
|
||||
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterForWebDemoTest
|
||||
import org.jetbrains.jet.plugin.decompiler.textBuilder.AbstractDecompiledTextTest
|
||||
import org.jetbrains.jet.completion.AbstractMultiFileSmartCompletionTest
|
||||
import org.jetbrains.jet.completion.handlers.AbstractCompletionCharFilterTest
|
||||
@@ -775,5 +775,5 @@ private fun getDefaultSuiteTestClass(baseTestClass:Class<*>): String {
|
||||
if (!baseName.startsWith("Abstract")) {
|
||||
throw IllegalArgumentException("Doesn't start with \"Abstract\": $baseName")
|
||||
}
|
||||
return baseName.substring("Abstract".length) + "Generated"
|
||||
return baseName.substring("Abstract".length()) + "Generated"
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.command.CommandProcessor
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.jet.j2k.ConverterSettings
|
||||
import org.jetbrains.jet.j2k.FilesConversionScope
|
||||
import org.jetbrains.jet.j2k.IdeaReferenceSearcher
|
||||
import org.jetbrains.jet.j2k.JavaToKotlinConverter
|
||||
import org.jetbrains.kotlin.j2k.ConverterSettings
|
||||
import org.jetbrains.kotlin.j2k.FilesConversionScope
|
||||
import org.jetbrains.kotlin.j2k.IdeaReferenceSearcher
|
||||
import org.jetbrains.kotlin.j2k.JavaToKotlinConverter
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiJavaFile
|
||||
import com.intellij.psi.PsiManager
|
||||
@@ -109,7 +109,7 @@ public class JavaToKotlinAction : AnAction() {
|
||||
val convertedTexts = converter.elementsToKotlin(javaFiles.map { it to J2kPostProcessor(it) })
|
||||
|
||||
val result = ArrayList<VirtualFile>()
|
||||
for ((i, psiFile) in javaFiles.withIndices()) {
|
||||
for ((i, psiFile) in javaFiles.withIndex()) {
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
result.addIfNotNull(saveConversionResult(psiFile.getVirtualFile(), convertedTexts[i], project))
|
||||
}
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.plugin.editor.JetEditorOptions
|
||||
import java.awt.datatransfer.Transferable
|
||||
@@ -99,7 +99,7 @@ public class ConvertJavaCopyPastePostProcessor() : CopyPastePostProcessor<TextBl
|
||||
)
|
||||
val startOffsets = code.startOffsets
|
||||
val endOffsets = code.endOffsets
|
||||
assert(startOffsets.size == endOffsets.size) { "Must have the same size" }
|
||||
assert(startOffsets.size() == endOffsets.size()) { "Must have the same size" }
|
||||
val result = StringBuilder()
|
||||
for (i in startOffsets.indices) {
|
||||
val startOffset = startOffsets[i]
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package org.jetbrains.jet.plugin.j2k
|
||||
|
||||
import org.jetbrains.jet.j2k.ResolverForConverter
|
||||
import org.jetbrains.kotlin.j2k.ResolverForConverter
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||
import org.jetbrains.jet.plugin.caches.resolve.resolveToDescriptor
|
||||
|
||||
public object IdeaResolverForConverter : ResolverForConverter {
|
||||
override fun resolveToDescriptor(declaration: JetDeclaration) = declaration.resolveToDescriptor()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.plugin.j2k
|
||||
|
||||
import org.jetbrains.jet.j2k.PostProcessor
|
||||
import org.jetbrains.kotlin.j2k.PostProcessor
|
||||
import org.jetbrains.jet.lang.psi.*
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.plugin.intentions.RemoveExplicitTypeArguments
|
||||
@@ -46,4 +46,4 @@ public class J2kPostProcessor(override val contextToAnalyzeIn: PsiElement) : Pos
|
||||
typeArgs.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||
import com.intellij.openapi.project.Project
|
||||
@@ -23,9 +23,6 @@ import org.jetbrains.jet.lang.diagnostics.Errors
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||
import org.jetbrains.jet.lang.psi.JetUnaryExpression
|
||||
import org.jetbrains.jet.lang.psi.JetProperty
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
class AfterConversionPass(val project: Project, val postProcessor: PostProcessor) {
|
||||
public fun run(kotlinCode: String): String {
|
||||
@@ -69,4 +66,4 @@ class AfterConversionPass(val project: Project, val postProcessor: PostProcessor
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.jet.j2k.ast.*
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
import com.intellij.codeInsight.NullableNotNullManager
|
||||
|
||||
class AnnotationConverter(private val converter: Converter) {
|
||||
@@ -98,7 +98,7 @@ class AnnotationConverter(private val converter: Converter) {
|
||||
|
||||
private fun convertAttributeValue(value: PsiAnnotationMemberValue?, expectedType: PsiType?, isVararg: Boolean, isUnnamed: Boolean): List<(CodeConverter) -> Expression> {
|
||||
when (value) {
|
||||
is PsiExpression -> return listOf({ codeConverter -> codeConverter.convertExpression(value as? PsiExpression, expectedType).assignPrototype(value) })
|
||||
is PsiExpression -> return listOf({ codeConverter -> codeConverter.convertExpression(value, expectedType).assignPrototype(value) })
|
||||
|
||||
is PsiArrayInitializerMemberValue -> {
|
||||
val componentType = (expectedType as? PsiArrayType)?.getComponentType()
|
||||
@@ -129,4 +129,4 @@ class AnnotationConverter(private val converter: Converter) {
|
||||
else -> return listOf({ codeConverter -> DummyStringExpression(value?.getText() ?: "").assignPrototype(value) })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.PsiClass
|
||||
import java.util.HashSet
|
||||
@@ -24,7 +24,7 @@ import com.intellij.psi.PsiAnnotationMethod
|
||||
import java.util.ArrayList
|
||||
import com.intellij.psi.PsiModifier
|
||||
import com.intellij.psi.PsiMethod
|
||||
import org.jetbrains.jet.j2k.ast.*
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
import com.intellij.psi.PsiField
|
||||
import com.intellij.psi.PsiReturnStatement
|
||||
import com.intellij.psi.PsiReferenceExpression
|
||||
@@ -35,7 +35,7 @@ import com.intellij.psi.PsiExpressionStatement
|
||||
import com.intellij.psi.PsiAssignmentExpression
|
||||
import com.intellij.psi.PsiExpression
|
||||
import com.intellij.psi.JavaTokenType
|
||||
import org.jetbrains.jet.j2k.usageProcessing.AccessorToPropertyProcessing
|
||||
import org.jetbrains.kotlin.j2k.usageProcessing.AccessorToPropertyProcessing
|
||||
|
||||
class FieldCorrectionInfo(val name: String, val access: Modifier?, val setterAccess: Modifier?) {
|
||||
val identifier = Identifier(name).assignNoPrototype()
|
||||
@@ -195,7 +195,7 @@ class ClassBodyConverter(private val psiClass: PsiClass,
|
||||
val field = fieldByExpression(returnStatement.getReturnValue()) ?: return null
|
||||
if (field.getType() != method.getReturnType()) return null
|
||||
if (converter.typeConverter.variableMutability(field) != converter.typeConverter.methodMutability(method)) return null
|
||||
val propertyName = StringUtil.decapitalize(name.substring("get".length))
|
||||
val propertyName = StringUtil.decapitalize(name.substring("get".length()))
|
||||
return AccessorInfo(method, field, AccessorKind.GETTER, propertyName)
|
||||
}
|
||||
else if (name.startsWith("set") && method.getParameterList().getParametersCount() == 1) {
|
||||
@@ -207,7 +207,7 @@ class ClassBodyConverter(private val psiClass: PsiClass,
|
||||
val parameter = method.getParameterList().getParameters().single()
|
||||
if ((assignment.getRExpression() as? PsiReferenceExpression)?.resolve() != parameter) return null
|
||||
if (field.getType() != parameter.getType()) return null
|
||||
val propertyName = StringUtil.decapitalize(name.substring("set".length))
|
||||
val propertyName = StringUtil.decapitalize(name.substring("set".length()))
|
||||
return AccessorInfo(method, field, AccessorKind.SETTER, propertyName)
|
||||
}
|
||||
else {
|
||||
@@ -222,4 +222,4 @@ class ClassBodyConverter(private val psiClass: PsiClass,
|
||||
if (field.getContainingClass() != psiClass || field.hasModifierProperty(PsiModifier.STATIC)) return null
|
||||
return field
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,15 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.*
|
||||
import java.util.HashSet
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.isAncestor
|
||||
import java.util.ArrayList
|
||||
import org.jetbrains.jet.j2k.ast.Element
|
||||
import org.jetbrains.kotlin.j2k.ast.Element
|
||||
import kotlin.platform.platformName
|
||||
import org.jetbrains.jet.j2k.ast.CommentsAndSpacesInheritance
|
||||
import org.jetbrains.kotlin.j2k.ast.CommentsAndSpacesInheritance
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
|
||||
fun<T> CodeBuilder.append(generators: Collection<() -> T>, separator: String, prefix: String = "", suffix: String = ""): CodeBuilder {
|
||||
@@ -114,7 +114,7 @@ class CodeBuilder(private val topElement: PsiElement?) {
|
||||
commentsAndSpacesUsed.addAll(prefixElements)
|
||||
commentsAndSpacesUsed.addAll(postfixElements)
|
||||
|
||||
for ((i, e) in prefixElements.withIndices()) {
|
||||
for ((i, e) in prefixElements.withIndex()) {
|
||||
if (i == 0 && e is PsiWhiteSpace) {
|
||||
val blankLines = e.newLinesCount() - 1
|
||||
for (_ in 1..blankLines) {
|
||||
@@ -166,7 +166,7 @@ class CodeBuilder(private val topElement: PsiElement?) {
|
||||
}
|
||||
|
||||
if (!inheritance.blankLinesBefore && firstSpace != null) {
|
||||
before.remove(before.size - 1)
|
||||
before.remove(before.lastIndex)
|
||||
}
|
||||
|
||||
addAll(before.reverse())
|
||||
@@ -183,7 +183,7 @@ class CodeBuilder(private val topElement: PsiElement?) {
|
||||
if (after.isNotEmpty()) {
|
||||
val last = after.last()
|
||||
if (last is PsiWhiteSpace) {
|
||||
after.remove(after.size - 1)
|
||||
after.remove(after.lastIndex)
|
||||
}
|
||||
}
|
||||
|
||||
+26
-26
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,32 +14,32 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.PsiType
|
||||
import com.intellij.psi.PsiCodeBlock
|
||||
import com.intellij.psi.PsiStatement
|
||||
import org.jetbrains.jet.j2k.ast.Block
|
||||
import org.jetbrains.jet.j2k.ast.LBrace
|
||||
import org.jetbrains.jet.j2k.ast.assignPrototype
|
||||
import org.jetbrains.jet.j2k.ast.RBrace
|
||||
import org.jetbrains.jet.j2k.ast.Statement
|
||||
import org.jetbrains.kotlin.j2k.ast.Block
|
||||
import org.jetbrains.kotlin.j2k.ast.LBrace
|
||||
import org.jetbrains.kotlin.j2k.ast.assignPrototype
|
||||
import org.jetbrains.kotlin.j2k.ast.RBrace
|
||||
import org.jetbrains.kotlin.j2k.ast.Statement
|
||||
import com.intellij.psi.PsiExpression
|
||||
import org.jetbrains.jet.j2k.ast.Expression
|
||||
import org.jetbrains.kotlin.j2k.ast.Expression
|
||||
import com.intellij.psi.PsiLocalVariable
|
||||
import org.jetbrains.jet.j2k.ast.LocalVariable
|
||||
import org.jetbrains.kotlin.j2k.ast.LocalVariable
|
||||
import com.intellij.psi.PsiModifier
|
||||
import org.jetbrains.jet.j2k.ast.declarationIdentifier
|
||||
import org.jetbrains.jet.j2k.ast.Identifier
|
||||
import org.jetbrains.kotlin.j2k.ast.declarationIdentifier
|
||||
import org.jetbrains.kotlin.j2k.ast.Identifier
|
||||
import com.intellij.psi.PsiPrimitiveType
|
||||
import com.intellij.psi.PsiClassType
|
||||
import org.jetbrains.jet.j2k.ast.BangBangExpression
|
||||
import org.jetbrains.jet.j2k.ast.assignNoPrototype
|
||||
import org.jetbrains.jet.j2k.ast.LiteralExpression
|
||||
import org.jetbrains.jet.j2k.ast.MethodCallExpression
|
||||
import org.jetbrains.jet.j2k.ast.Type
|
||||
import org.jetbrains.jet.j2k.ast.ErrorType
|
||||
import org.jetbrains.jet.j2k.ast.Nullability
|
||||
import org.jetbrains.kotlin.j2k.ast.BangBangExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.assignNoPrototype
|
||||
import org.jetbrains.kotlin.j2k.ast.LiteralExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.MethodCallExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.Type
|
||||
import org.jetbrains.kotlin.j2k.ast.ErrorType
|
||||
import org.jetbrains.kotlin.j2k.ast.Nullability
|
||||
import com.intellij.psi.CommonClassNames.JAVA_LANG_BYTE
|
||||
import com.intellij.psi.CommonClassNames.JAVA_LANG_SHORT
|
||||
import com.intellij.psi.CommonClassNames.JAVA_LANG_INTEGER
|
||||
@@ -48,12 +48,14 @@ import com.intellij.psi.CommonClassNames.JAVA_LANG_FLOAT
|
||||
import com.intellij.psi.CommonClassNames.JAVA_LANG_DOUBLE
|
||||
import com.intellij.psi.CommonClassNames.JAVA_LANG_CHARACTER
|
||||
import com.intellij.psi.PsiAnonymousClass
|
||||
import org.jetbrains.jet.j2k.ast.AnonymousClassBody
|
||||
import org.jetbrains.kotlin.j2k.ast.AnonymousClassBody
|
||||
|
||||
class CodeConverter(public val converter: Converter,
|
||||
private val expressionConverter: ExpressionConverter,
|
||||
private val statementConverter: StatementConverter,
|
||||
public val methodReturnType: PsiType?) {
|
||||
class CodeConverter(
|
||||
public val converter: Converter,
|
||||
private val expressionConverter: ExpressionConverter,
|
||||
private val statementConverter: StatementConverter,
|
||||
public val methodReturnType: PsiType?
|
||||
) {
|
||||
|
||||
public val typeConverter: TypeConverter = converter.typeConverter
|
||||
public val settings: ConverterSettings = converter.settings
|
||||
@@ -169,6 +171,4 @@ class CodeConverter(public val converter: Converter,
|
||||
JAVA_LANG_DOUBLE to "double",
|
||||
JAVA_LANG_CHARACTER to "char"
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+22
-20
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,18 +14,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.jet.j2k.ast.*
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
import com.intellij.psi.util.PsiUtil
|
||||
import java.util.HashMap
|
||||
import java.util.ArrayList
|
||||
import java.util.HashSet
|
||||
|
||||
class ConstructorConverter(private val psiClass: PsiClass,
|
||||
private val converter: Converter,
|
||||
private val fieldCorrections: Map<PsiField, FieldCorrectionInfo>) {
|
||||
class ConstructorConverter(
|
||||
private val psiClass: PsiClass,
|
||||
private val converter: Converter,
|
||||
private val fieldCorrections: Map<PsiField, FieldCorrectionInfo>
|
||||
) {
|
||||
private val typeConverter = converter.typeConverter
|
||||
|
||||
private val tempValName: String = "__"
|
||||
@@ -35,7 +37,7 @@ class ConstructorConverter(private val psiClass: PsiClass,
|
||||
private val constructors = psiClass.getConstructors()
|
||||
private val constructorsToDrop = HashSet<PsiMethod>()
|
||||
private val lastParamDefaults = ArrayList<PsiExpression>() // defaults for a few last parameters of primary constructor in reverse order
|
||||
private val primaryConstructor: PsiMethod? = when (constructors.size) {
|
||||
private val primaryConstructor: PsiMethod? = when (constructors.size()) {
|
||||
0 -> null
|
||||
1 -> constructors.single()
|
||||
else -> choosePrimaryConstructor()
|
||||
@@ -55,7 +57,7 @@ class ConstructorConverter(private val psiClass: PsiClass,
|
||||
val toTargetConstructorMap = buildToTargetConstructorMap()
|
||||
|
||||
val candidates = constructors.filter { it !in toTargetConstructorMap }
|
||||
if (candidates.size != 1) return null // there should be only one constructor which does not call other constructor
|
||||
if (candidates.size() != 1) return null // there should be only one constructor which does not call other constructor
|
||||
val primary = candidates.single()
|
||||
if (toTargetConstructorMap.values().any() { it.constructor != primary }) return null // all other constructors call our candidate (directly or indirectly)
|
||||
|
||||
@@ -103,12 +105,12 @@ class ConstructorConverter(private val psiClass: PsiClass,
|
||||
}
|
||||
|
||||
private fun calcTargetParameterDefaults(constructor: PsiMethod, target: PsiMethod, targetCall: PsiMethodCallExpression): List<PsiExpression>? {
|
||||
if (constructor.getBody()!!.getStatements().size != 1) return null // constructor's body should consist of only "this(...)"
|
||||
if (constructor.getBody()!!.getStatements().size() != 1) return null // constructor's body should consist of only "this(...)"
|
||||
val parameters = constructor.getParameterList().getParameters()
|
||||
val targetParameters = target.getParameterList().getParameters()
|
||||
if (parameters.size >= targetParameters.size) return null
|
||||
if (parameters.size() >= targetParameters.size()) return null
|
||||
val args = targetCall.getArgumentList().getExpressions()
|
||||
if (args.size != targetParameters.size) return null // incorrect code
|
||||
if (args.size() != targetParameters.size()) return null // incorrect code
|
||||
|
||||
for (i in parameters.indices) {
|
||||
val parameter = parameters[i]
|
||||
@@ -118,7 +120,7 @@ class ConstructorConverter(private val psiClass: PsiClass,
|
||||
if (arg !is PsiReferenceExpression || arg.resolve() != parameter) return null
|
||||
}
|
||||
|
||||
return args.drop(parameters.size)
|
||||
return args.drop(parameters.size())
|
||||
}
|
||||
|
||||
private fun dropConstructorsForDefaultValues(primary: PsiMethod, toTargetConstructorMap: Map<PsiMethod, TargetConstructorInfo>) {
|
||||
@@ -133,11 +135,11 @@ class ConstructorConverter(private val psiClass: PsiClass,
|
||||
val paramCount = constructor.getParameterList().getParametersCount()
|
||||
assert(paramCount < primaryParamCount)
|
||||
val defaults = toTargetConstructorMap[constructor]!!.parameterDefaults!!
|
||||
assert(defaults.size == primaryParamCount - paramCount)
|
||||
assert(defaults.size() == primaryParamCount - paramCount)
|
||||
|
||||
for (i in defaults.indices) {
|
||||
val default = defaults[defaults.size - i - 1]
|
||||
if (i < lastParamDefaults.size) { // default for this parameter has already been assigned
|
||||
val default = defaults[defaults.size() - i - 1]
|
||||
if (i < lastParamDefaults.size()) { // default for this parameter has already been assigned
|
||||
if (lastParamDefaults[i].getText() != default.getText()) continue@DropCandidatesLoop
|
||||
}
|
||||
else {
|
||||
@@ -273,8 +275,8 @@ class ConstructorConverter(private val psiClass: PsiClass,
|
||||
|
||||
val parameterList = ParameterList(params.indices.map { i ->
|
||||
val parameter = params[i]
|
||||
val indexFromEnd = params.size - i - 1
|
||||
val defaultValue = if (indexFromEnd < lastParamDefaults.size)
|
||||
val indexFromEnd = params.size() - i - 1
|
||||
val defaultValue = if (indexFromEnd < lastParamDefaults.size())
|
||||
correctedConverter.deferredElement { codeConverter -> codeConverter.correct().convertExpression(lastParamDefaults[indexFromEnd], parameter.getType()) }
|
||||
else
|
||||
null
|
||||
@@ -332,7 +334,7 @@ class ConstructorConverter(private val psiClass: PsiClass,
|
||||
}
|
||||
|
||||
public fun postProcessConstructors(classBody: ClassBody): ClassBody {
|
||||
if (primaryConstructor == null && constructors.size > 1) {
|
||||
if (primaryConstructor == null && constructors.size() > 1) {
|
||||
return generateArtificialPrimaryConstructor(classBody)
|
||||
}
|
||||
else {
|
||||
@@ -387,7 +389,7 @@ class ConstructorConverter(private val psiClass: PsiClass,
|
||||
|
||||
// searching for other constructor call in form "this(...)"
|
||||
// it's not necessary the first statement because of statements inserted for writable parameters
|
||||
for ((i, statement) in statements.withIndices()) {
|
||||
for ((i, statement) in statements.withIndex()) {
|
||||
if (statement is MethodCallExpression) {
|
||||
if ((statement.methodExpression as? Identifier)?.name == "this") {
|
||||
val constructorCall = MethodCallExpression.buildNotNull(null, className, statement.arguments).assignPrototypesFrom(statement)
|
||||
@@ -487,4 +489,4 @@ class ConstructorConverter(private val psiClass: PsiClass,
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,19 +14,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.jet.j2k.ast.*
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
import java.util.*
|
||||
import com.intellij.psi.CommonClassNames.*
|
||||
import org.jetbrains.jet.lang.types.expressions.OperatorConventions.*
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.util.PsiMethodUtil
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.jet.j2k.usageProcessing.UsageProcessing
|
||||
import org.jetbrains.jet.j2k.usageProcessing.FieldToPropertyProcessing
|
||||
import org.jetbrains.jet.j2k.usageProcessing.UsageProcessingExpressionConverter
|
||||
import org.jetbrains.kotlin.j2k.usageProcessing.UsageProcessing
|
||||
import org.jetbrains.kotlin.j2k.usageProcessing.FieldToPropertyProcessing
|
||||
import org.jetbrains.kotlin.j2k.usageProcessing.UsageProcessingExpressionConverter
|
||||
|
||||
class Converter private(private val elementToConvert: PsiElement,
|
||||
val settings: ConverterSettings,
|
||||
@@ -97,7 +97,7 @@ class Converter private(private val elementToConvert: PsiElement,
|
||||
|
||||
// we use loop with index because new deferred elements can be added during unfolding
|
||||
var i = 0
|
||||
while (i < commonState.deferredElements.size) {
|
||||
while (i < commonState.deferredElements.size()) {
|
||||
val deferredElement = commonState.deferredElements[i++]
|
||||
deferredElement.unfold(codeConverter.withConverter(this.withState(deferredElement.converterState)))
|
||||
}
|
||||
@@ -480,7 +480,7 @@ class Converter private(private val elementToConvert: PsiElement,
|
||||
val throwsList = method.getThrowsList()
|
||||
val types = throwsList.getReferencedTypes()
|
||||
val refElements = throwsList.getReferenceElements()
|
||||
assert(types.size == refElements.size)
|
||||
assert(types.size() == refElements.size())
|
||||
if (types.isEmpty()) return Annotations.Empty
|
||||
val arguments = types.indices.map { index ->
|
||||
val convertedType = typeConverter.convertType(types[index], Nullability.NotNull)
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,13 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
public data class ConverterSettings(
|
||||
var forceNotNullTypes: Boolean,
|
||||
var specifyLocalVariableTypeByDefault: Boolean,
|
||||
var specifyFieldTypeByDefault: Boolean,
|
||||
var openByDefault: Boolean) {
|
||||
var openByDefault: Boolean
|
||||
) {
|
||||
|
||||
class object {
|
||||
public val defaultSettings: ConverterSettings = ConverterSettings(
|
||||
+10
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,21 +14,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import org.jetbrains.jet.j2k.ast.*
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
import org.jetbrains.jet.lang.types.expressions.OperatorConventions
|
||||
import com.intellij.psi.CommonClassNames.*
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.jet.lang.types.lang.PrimitiveType
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
import org.jetbrains.jet.asJava.KotlinLightMethod
|
||||
import org.jetbrains.jet.lang.psi.JetProperty
|
||||
import org.jetbrains.jet.lang.psi.JetFunction
|
||||
import org.jetbrains.jet.lang.psi.JetClassOrObject
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.getNonStrictParentOfType
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.isExtensionDeclaration
|
||||
import org.jetbrains.jet.lang.psi.JetPropertyAccessor
|
||||
import org.jetbrains.jet.lang.psi.JetParameter
|
||||
@@ -37,7 +36,6 @@ import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||
import org.jetbrains.jet.asJava.KotlinLightField
|
||||
import org.jetbrains.jet.lang.psi.JetObjectDeclaration
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.getStrictParentOfType
|
||||
|
||||
trait ExpressionConverter {
|
||||
@@ -219,8 +217,8 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
|
||||
origin.getParent() as JetProperty
|
||||
else
|
||||
origin as JetNamedDeclaration
|
||||
val parameterCount = target.getParameterList().getParameters().size
|
||||
if (parameterCount == arguments.size) {
|
||||
val parameterCount = target.getParameterList().getParameters().size()
|
||||
if (parameterCount == arguments.size()) {
|
||||
val propertyName = Identifier(property.getName()!!, isNullable).assignNoPrototype()
|
||||
val isExtension = property.isExtensionDeclaration()
|
||||
val propertyAccess = if (isTopLevel) {
|
||||
@@ -271,7 +269,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
|
||||
|
||||
if (target is PsiMethod) {
|
||||
val specialMethod = SpecialMethod.values().firstOrNull { it.matches(target) }
|
||||
if (specialMethod != null && arguments.size == specialMethod.parameterCount) {
|
||||
if (specialMethod != null && arguments.size() == specialMethod.parameterCount) {
|
||||
val converted = specialMethod.convertCall(methodExpr.getQualifierExpression(), arguments, typeArguments, codeConverter)
|
||||
if (converted != null) {
|
||||
result = converted
|
||||
@@ -290,7 +288,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
|
||||
var typeArgs = call.getTypeArguments().toList()
|
||||
|
||||
// always add explicit type arguments and remove them if they are redundant later
|
||||
if (typeArgs.size == 0) {
|
||||
if (typeArgs.size() == 0) {
|
||||
val resolve = call.resolveMethodGenerics()
|
||||
if (resolve.isValidResult()) {
|
||||
val method = resolve.getElement() as? PsiMethod
|
||||
@@ -311,7 +309,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
|
||||
if (expression.getArrayInitializer() != null) {
|
||||
result = codeConverter.convertExpression(expression.getArrayInitializer())
|
||||
}
|
||||
else if (expression.getArrayDimensions().size > 0 && expression.getType() is PsiArrayType) {
|
||||
else if (expression.getArrayDimensions().size() > 0 && expression.getType() is PsiArrayType) {
|
||||
result = ArrayWithoutInitializationExpression(
|
||||
typeConverter.convertType(expression.getType(), Nullability.NotNull) as ArrayType,
|
||||
codeConverter.convertExpressions(expression.getArrayDimensions()))
|
||||
@@ -437,7 +435,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
|
||||
val parameters = resolved?.getParameterList()?.getParameters()
|
||||
val expectedTypes = parameters?.map { it.getType() } ?: listOf()
|
||||
|
||||
return if (arguments.size == expectedTypes.size())
|
||||
return if (arguments.size() == expectedTypes.size())
|
||||
(0..arguments.lastIndex).map { i ->
|
||||
val argument = arguments[i]
|
||||
val converted = codeConverter.convertExpression(argument, expectedTypes[i])
|
||||
+25
-22
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,48 +14,51 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.PsiForStatement
|
||||
import org.jetbrains.jet.j2k.ast.ForeachStatement
|
||||
import org.jetbrains.kotlin.j2k.ast.ForeachStatement
|
||||
import com.intellij.psi.PsiDeclarationStatement
|
||||
import com.intellij.psi.PsiLocalVariable
|
||||
import com.intellij.psi.PsiBinaryExpression
|
||||
import com.intellij.psi.JavaTokenType
|
||||
import com.intellij.psi.PsiReferenceExpression
|
||||
import com.intellij.psi.PsiExpressionStatement
|
||||
import org.jetbrains.jet.j2k.ast.PrimitiveType
|
||||
import org.jetbrains.jet.j2k.ast.Identifier
|
||||
import org.jetbrains.jet.j2k.ast.assignNoPrototype
|
||||
import org.jetbrains.jet.j2k.ast.declarationIdentifier
|
||||
import org.jetbrains.kotlin.j2k.ast.PrimitiveType
|
||||
import org.jetbrains.kotlin.j2k.ast.Identifier
|
||||
import org.jetbrains.kotlin.j2k.ast.assignNoPrototype
|
||||
import org.jetbrains.kotlin.j2k.ast.declarationIdentifier
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiVariable
|
||||
import com.intellij.psi.PsiPostfixExpression
|
||||
import com.intellij.psi.PsiPrefixExpression
|
||||
import com.intellij.psi.PsiExpression
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import org.jetbrains.jet.j2k.ast.Expression
|
||||
import org.jetbrains.kotlin.j2k.ast.Expression
|
||||
import com.intellij.psi.PsiLiteralExpression
|
||||
import com.intellij.psi.PsiMethodCallExpression
|
||||
import com.intellij.psi.PsiElementFactory
|
||||
import com.intellij.psi.CommonClassNames
|
||||
import org.jetbrains.jet.j2k.ast.QualifiedExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.QualifiedExpression
|
||||
import com.intellij.psi.PsiArrayType
|
||||
import org.jetbrains.jet.j2k.ast.BinaryExpression
|
||||
import org.jetbrains.jet.j2k.ast.LiteralExpression
|
||||
import org.jetbrains.jet.j2k.ast.RangeExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.BinaryExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.LiteralExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.RangeExpression
|
||||
import com.intellij.psi.PsiBlockStatement
|
||||
import com.intellij.psi.PsiNamedElement
|
||||
import org.jetbrains.jet.j2k.ast.Block
|
||||
import org.jetbrains.jet.j2k.ast.LBrace
|
||||
import org.jetbrains.jet.j2k.ast.RBrace
|
||||
import org.jetbrains.jet.j2k.ast.assignPrototypesFrom
|
||||
import org.jetbrains.jet.j2k.ast.WhileStatement
|
||||
import org.jetbrains.jet.j2k.ast.MethodCallExpression
|
||||
import org.jetbrains.jet.j2k.ast.LambdaExpression
|
||||
import org.jetbrains.jet.j2k.ast.Statement
|
||||
import org.jetbrains.kotlin.j2k.ast.Block
|
||||
import org.jetbrains.kotlin.j2k.ast.LBrace
|
||||
import org.jetbrains.kotlin.j2k.ast.RBrace
|
||||
import org.jetbrains.kotlin.j2k.ast.assignPrototypesFrom
|
||||
import org.jetbrains.kotlin.j2k.ast.WhileStatement
|
||||
import org.jetbrains.kotlin.j2k.ast.MethodCallExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.LambdaExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.Statement
|
||||
|
||||
class ForConverter(private val statement: PsiForStatement, private val codeConverter: CodeConverter) {
|
||||
class ForConverter(
|
||||
private val statement: PsiForStatement,
|
||||
private val codeConverter: CodeConverter
|
||||
) {
|
||||
private val referenceSearcher = codeConverter.converter.referenceSearcher
|
||||
private val settings = codeConverter.settings
|
||||
private val project = codeConverter.converter.project
|
||||
@@ -191,4 +194,4 @@ class ForConverter(private val statement: PsiForStatement, private val codeConve
|
||||
return RangeExpression(codeConverter.convertExpression(start), endExpression)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,18 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.openapi.progress.ProcessCanceledException
|
||||
import org.jetbrains.jet.j2k.ast.Element
|
||||
import org.jetbrains.kotlin.j2k.ast.Element
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiJavaFile
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import java.util.ArrayList
|
||||
import org.jetbrains.jet.j2k.usageProcessing.UsageProcessing
|
||||
import org.jetbrains.kotlin.j2k.usageProcessing.UsageProcessing
|
||||
import java.util.HashMap
|
||||
|
||||
public trait ConversionScope {
|
||||
@@ -47,11 +47,11 @@ public class JavaToKotlinConverter(private val project: Project,
|
||||
private val conversionScope: ConversionScope /*TODO: drop this parameter*/,
|
||||
private val referenceSearcher: ReferenceSearcher,
|
||||
private val resolverForConverter: ResolverForConverter) {
|
||||
private val LOG = Logger.getInstance("#org.jetbrains.jet.j2k.JavaToKotlinConverter")
|
||||
private val LOG = Logger.getInstance("#org.jetbrains.kotlin.j2k.JavaToKotlinConverter")
|
||||
|
||||
public fun elementsToKotlin(psiElementsAndProcessors: List<Pair<PsiElement, PostProcessor?>>): List<String> {
|
||||
try {
|
||||
val intermediateResults = ArrayList<((Map<PsiElement, UsageProcessing>) -> String)?>(psiElementsAndProcessors.size)
|
||||
val intermediateResults = ArrayList<((Map<PsiElement, UsageProcessing>) -> String)?>(psiElementsAndProcessors.size())
|
||||
val usageProcessings = HashMap<PsiElement, UsageProcessing>()
|
||||
val usageProcessingCollector: (UsageProcessing) -> Unit = { usageProcessing ->
|
||||
assert(!usageProcessings.containsKey(usageProcessing.targetElement))
|
||||
@@ -64,14 +64,14 @@ public class JavaToKotlinConverter(private val project: Project,
|
||||
intermediateResults.add(result)
|
||||
}
|
||||
|
||||
val results = ArrayList<String>(psiElementsAndProcessors.size)
|
||||
for ((i, result) in intermediateResults.withIndices()) {
|
||||
val results = ArrayList<String>(psiElementsAndProcessors.size())
|
||||
for ((i, result) in intermediateResults.withIndex()) {
|
||||
results.add(if (result != null) result(usageProcessings) else "")
|
||||
intermediateResults[i] = null // to not hold unused objects in the heap
|
||||
}
|
||||
|
||||
val finalResults = ArrayList<String>(psiElementsAndProcessors.size)
|
||||
for ((i, result) in results.withIndices()) {
|
||||
val finalResults = ArrayList<String>(psiElementsAndProcessors.size())
|
||||
for ((i, result) in results.withIndex()) {
|
||||
val postProcessor = psiElementsAndProcessors[i].second
|
||||
if (postProcessor != null) {
|
||||
try {
|
||||
@@ -102,4 +102,4 @@ public class JavaToKotlinConverter(private val project: Project,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.core.JavaCoreApplicationEnvironment
|
||||
import com.intellij.core.JavaCoreProjectEnvironment
|
||||
@@ -98,7 +98,7 @@ public object JavaToKotlinTranslator {
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (args.size == 1) {
|
||||
if (args.size() == 1) {
|
||||
try {
|
||||
val kotlinCode = JavaToKotlinTranslator.generateKotlinCode(args[0])
|
||||
if (kotlinCode.isEmpty()) {
|
||||
@@ -120,4 +120,4 @@ fun main(args: Array<String>) {
|
||||
//used in Kotlin Web Demo
|
||||
public fun translateToKotlin(code: String): String {
|
||||
return JavaToKotlinTranslator.generateKotlinCode(code)
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.PsiVariable
|
||||
import com.intellij.psi.PsiElement
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
@@ -25,4 +25,4 @@ public trait ResolverForConverter {
|
||||
|
||||
object EmptyResolverForConverter : ResolverForConverter {
|
||||
override fun resolveToDescriptor(declaration: JetDeclaration) = null
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,19 +14,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.PsiExpression
|
||||
import org.jetbrains.jet.j2k.ast.BinaryExpression
|
||||
import org.jetbrains.jet.j2k.ast.Expression
|
||||
import org.jetbrains.jet.j2k.ast.MethodCallExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.BinaryExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.Expression
|
||||
import org.jetbrains.kotlin.j2k.ast.MethodCallExpression
|
||||
import com.intellij.psi.CommonClassNames.JAVA_LANG_OBJECT
|
||||
import com.intellij.psi.PsiSuperExpression
|
||||
import org.jetbrains.jet.j2k.ast.QualifiedExpression
|
||||
import org.jetbrains.jet.j2k.ast.Identifier
|
||||
import org.jetbrains.jet.j2k.ast.assignNoPrototype
|
||||
import org.jetbrains.jet.j2k.ast.Type
|
||||
import org.jetbrains.kotlin.j2k.ast.QualifiedExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.Identifier
|
||||
import org.jetbrains.kotlin.j2k.ast.assignNoPrototype
|
||||
import org.jetbrains.kotlin.j2k.ast.Type
|
||||
|
||||
enum class SpecialMethod(val qualifiedClassName: String?, val methodName: String, val parameterCount: Int) {
|
||||
OBJECT_EQUALS: SpecialMethod(null, "equals", 1) {
|
||||
@@ -83,4 +83,4 @@ enum class SpecialMethod(val qualifiedClassName: String?, val methodName: String
|
||||
}
|
||||
|
||||
abstract fun convertCall(qualifier: PsiExpression?, arguments: Array<PsiExpression>, typeArgumentsConverted: List<Type>, codeConverter: CodeConverter): Expression?
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.jet.j2k.ast.*
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
import java.util.ArrayList
|
||||
|
||||
trait StatementConverter {
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.jet.j2k.ast.*
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
import java.util.ArrayList
|
||||
|
||||
class SwitchConverter(private val codeConverter: CodeConverter) {
|
||||
@@ -33,7 +33,7 @@ class SwitchConverter(private val codeConverter: CodeConverter) {
|
||||
|
||||
val result = ArrayList<WhenEntry>()
|
||||
var pendingSelectors = ArrayList<WhenEntrySelector>()
|
||||
for ((i, case) in cases.withIndices()) {
|
||||
for ((i, case) in cases.withIndex()) {
|
||||
if (case.label == null) { // invalid switch - no case labels
|
||||
result.add(WhenEntry(listOf(ValueWhenEntrySelector(Expression.Empty).assignNoPrototype()), convertCaseStatementsToBody(cases, i)).assignNoPrototype())
|
||||
continue
|
||||
@@ -78,7 +78,7 @@ class SwitchConverter(private val codeConverter: CodeConverter) {
|
||||
|
||||
private fun convertCaseStatements(statements: List<PsiStatement>, allowBlock: Boolean = true): List<Statement> {
|
||||
val statementsToKeep = statements.filter { !isSwitchBreak(it) }
|
||||
if (allowBlock && statementsToKeep.size == 1) {
|
||||
if (allowBlock && statementsToKeep.size() == 1) {
|
||||
val block = statementsToKeep.single() as? PsiBlockStatement
|
||||
if (block != null) {
|
||||
return listOf(codeConverter.convertBlock(block.getCodeBlock(), true, { !isSwitchBreak(it) }))
|
||||
@@ -105,11 +105,11 @@ class SwitchConverter(private val codeConverter: CodeConverter) {
|
||||
|
||||
private fun convertCaseStatementsToBody(cases: List<Case>, caseIndex: Int): Statement {
|
||||
val statements = convertCaseStatements(cases, caseIndex)
|
||||
return if (statements.size == 1)
|
||||
return if (statements.size() == 1)
|
||||
statements.single()
|
||||
else
|
||||
Block(statements, LBrace().assignNoPrototype(), RBrace().assignNoPrototype(), true).assignNoPrototype()
|
||||
}
|
||||
|
||||
private fun isSwitchBreak(statement: PsiStatement) = statement is PsiBreakStatement && statement.getLabelIdentifier() == null
|
||||
}
|
||||
}
|
||||
+14
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,22 +14,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import org.jetbrains.jet.j2k.ast.Type
|
||||
import org.jetbrains.jet.j2k.ast.Nullability
|
||||
import org.jetbrains.kotlin.j2k.ast.Type
|
||||
import org.jetbrains.kotlin.j2k.ast.Nullability
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.jet.j2k.ast.assignPrototype
|
||||
import org.jetbrains.kotlin.j2k.ast.assignPrototype
|
||||
import com.intellij.psi.CommonClassNames.JAVA_LANG_OBJECT
|
||||
import org.jetbrains.jet.j2k.ast.assignNoPrototype
|
||||
import org.jetbrains.jet.j2k.ast.ErrorType
|
||||
import org.jetbrains.kotlin.j2k.ast.assignNoPrototype
|
||||
import org.jetbrains.kotlin.j2k.ast.ErrorType
|
||||
import com.intellij.codeInsight.NullableNotNullManager
|
||||
import org.jetbrains.jet.j2k.ast.ArrayType
|
||||
import org.jetbrains.jet.j2k.ast.ClassType
|
||||
import org.jetbrains.jet.j2k.ast.ReferenceElement
|
||||
import org.jetbrains.jet.j2k.ast.Identifier
|
||||
import org.jetbrains.kotlin.j2k.ast.ArrayType
|
||||
import org.jetbrains.kotlin.j2k.ast.ClassType
|
||||
import org.jetbrains.kotlin.j2k.ast.ReferenceElement
|
||||
import org.jetbrains.kotlin.j2k.ast.Identifier
|
||||
import java.util.HashMap
|
||||
import org.jetbrains.jet.j2k.ast.Mutability
|
||||
import org.jetbrains.kotlin.j2k.ast.Mutability
|
||||
import java.util.HashSet
|
||||
import org.jetbrains.jet.asJava.KotlinLightElement
|
||||
import org.jetbrains.jet.lang.psi.JetCallableDeclaration
|
||||
@@ -139,7 +139,7 @@ class TypeConverter(val converter: Converter) {
|
||||
val superSignatures = scope.getHierarchicalMethodSignature().getSuperSignatures()
|
||||
value = superSignatures.map { signature ->
|
||||
val params = signature.getMethod().getParameterList().getParameters()
|
||||
if (paramIndex < params.size) forVariableType(params[paramIndex]) else default
|
||||
if (paramIndex < params.size()) forVariableType(params[paramIndex]) else default
|
||||
}.firstOrNull { it != default } ?: default
|
||||
if (value != default) return value
|
||||
}
|
||||
@@ -305,7 +305,7 @@ class TypeConverter(val converter: Converter) {
|
||||
val parameterIndex = parameters.indexOf(variable)
|
||||
for (call in converter.referenceSearcher.findMethodCalls(method, scope)) {
|
||||
val args = call.getArgumentList().getExpressions()
|
||||
if (args.size == parameters.size) {
|
||||
if (args.size() == parameters.size()) {
|
||||
if (args[parameterIndex].nullability() == Nullability.Nullable) {
|
||||
return Nullability.Nullable
|
||||
}
|
||||
+8
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,19 +14,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.impl.source.PsiClassReferenceType
|
||||
import org.jetbrains.jet.j2k.ast.*
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType
|
||||
|
||||
private val PRIMITIVE_TYPES_NAMES = JvmPrimitiveType.values().map { it.getName() }
|
||||
|
||||
class TypeVisitor(private val converter: Converter,
|
||||
private val topLevelType: PsiType,
|
||||
private val topLevelTypeMutability: Mutability) : PsiTypeVisitor<Type>() {
|
||||
class TypeVisitor(
|
||||
private val converter: Converter,
|
||||
private val topLevelType: PsiType,
|
||||
private val topLevelTypeMutability: Mutability
|
||||
) : PsiTypeVisitor<Type>() {
|
||||
|
||||
private val typeConverter: TypeConverter = converter.typeConverter
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,12 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import org.jetbrains.jet.lang.types.expressions.OperatorConventions
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.util.PsiUtil
|
||||
import org.jetbrains.jet.j2k.ast.*
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
import com.intellij.psi.util.PsiMethodUtil
|
||||
|
||||
fun quoteKeywords(packageName: String): String = packageName.split("\\.").map { Identifier.toKotlin(it) }.joinToString(".")
|
||||
@@ -55,8 +55,8 @@ fun isVal(searcher: ReferenceSearcher, field: PsiField): Boolean {
|
||||
if (!field.hasModifierProperty(PsiModifier.PRIVATE)) return false
|
||||
val containingClass = field.getContainingClass() ?: return false
|
||||
val writes = searcher.findVariableUsages(field, containingClass).filter { PsiUtil.isAccessedForWriting(it) }
|
||||
if (writes.size == 0) return true
|
||||
if (writes.size > 1) return false
|
||||
if (writes.size() == 0) return true
|
||||
if (writes.size() > 1) return false
|
||||
val write = writes.single()
|
||||
val parent = write.getParent()
|
||||
if (parent is PsiAssignmentExpression &&
|
||||
@@ -120,8 +120,8 @@ fun PsiModifierListOwner.accessModifier(): String = when {
|
||||
|
||||
fun PsiMethod.isMainMethod(): Boolean = PsiMethodUtil.isMainMethod(this)
|
||||
|
||||
fun <T: Any> List<T>.singleOrNull2(): T? = if (size == 1) this[0] else null
|
||||
fun <T: Any> Array<T>.singleOrNull2(): T? = if (size == 1) this[0] else null
|
||||
fun <T: Any> List<T>.singleOrNull2(): T? = if (size() == 1) this[0] else null
|
||||
fun <T: Any> Array<T>.singleOrNull2(): T? = if (size() == 1) this[0] else null
|
||||
|
||||
fun PsiMember.isImported(file: PsiJavaFile): Boolean {
|
||||
if (this is PsiClass) {
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class Annotation(val name: Identifier, val arguments: List<Pair<Identifier?, DeferredElement<Expression>>>, val brackets: Boolean, val newLineAfter: Boolean) : Element() {
|
||||
private fun CodeBuilder.surroundWithBrackets(action: () -> Unit) {
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.CodeBuilder
|
||||
import org.jetbrains.kotlin.j2k.CodeBuilder
|
||||
|
||||
class AnonymousClassBody(body: ClassBody, val extendsTrait: Boolean)
|
||||
: Class(Identifier.Empty, Annotations.Empty, Modifiers.Empty, TypeParameterList.Empty, listOf(), listOf(), listOf(), body) {
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.CodeBuilder
|
||||
import org.jetbrains.jet.j2k.append
|
||||
import org.jetbrains.kotlin.j2k.CodeBuilder
|
||||
import org.jetbrains.kotlin.j2k.append
|
||||
|
||||
class ArrayWithoutInitializationExpression(val type: ArrayType, val expressions: List<Expression>) : Expression() {
|
||||
override fun generateCode(builder: CodeBuilder) {
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class Block(val statements: List<Statement>, val lBrace: LBrace, val rBrace: RBrace, val notEmpty: Boolean = false) : Statement() {
|
||||
override val isEmpty: Boolean
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
open class Class(
|
||||
val name: Identifier,
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
abstract class Member(val annotations: Annotations, val modifiers: Modifiers) : Element()
|
||||
|
||||
+9
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,16 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
import com.intellij.util.IncorrectOperationException
|
||||
|
||||
class PrimaryConstructor(annotations: Annotations,
|
||||
modifiers: Modifiers,
|
||||
val parameterList: ParameterList,
|
||||
val body: DeferredElement<Block>)
|
||||
: Member(annotations, modifiers) {
|
||||
class PrimaryConstructor(
|
||||
annotations: Annotations,
|
||||
modifiers: Modifiers,
|
||||
val parameterList: ParameterList,
|
||||
val body: DeferredElement<Block>
|
||||
) : Member(annotations, modifiers) {
|
||||
|
||||
override fun generateCode(builder: CodeBuilder) { throw IncorrectOperationException() }
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.CodeBuilder
|
||||
import org.jetbrains.kotlin.j2k.CodeBuilder
|
||||
|
||||
class DummyStringExpression(val string: String) : Expression() {
|
||||
override fun generateCode(builder: CodeBuilder) {
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
fun <TElement: Element> TElement.assignPrototype(prototype: PsiElement?, inheritance: CommentsAndSpacesInheritance = CommentsAndSpacesInheritance()): TElement {
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class Enum(
|
||||
name: Identifier,
|
||||
@@ -44,4 +44,4 @@ class Enum(
|
||||
|
||||
body.append(builder)
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class EnumConstant(
|
||||
val identifier: Identifier,
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,12 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.CodeBuilder
|
||||
import org.jetbrains.jet.j2k.CodeConverter
|
||||
import org.jetbrains.kotlin.j2k.CodeBuilder
|
||||
import org.jetbrains.kotlin.j2k.CodeConverter
|
||||
|
||||
abstract class Expression() : Statement() {
|
||||
abstract class Expression : Statement() {
|
||||
open val isNullable: Boolean get() = false
|
||||
|
||||
object Empty : Expression() {
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class ExpressionList(val expressions: List<Expression>) : Expression() {
|
||||
override fun generateCode(builder: CodeBuilder) {
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.lang.types.expressions.OperatorConventions
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class ArrayAccessExpression(val expression: Expression, val index: Expression, val lvalue: Boolean) : Expression() {
|
||||
override fun generateCode(builder: CodeBuilder) {
|
||||
@@ -184,4 +184,4 @@ fun createArrayInitializerExpression(arrayType: ArrayType, initializers: List<Ex
|
||||
}
|
||||
|
||||
return MethodCallExpression.buildNotNull(null, createArrayFunction, initializers.map { explicitConvertIfNeeded(it) })
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.CodeBuilder
|
||||
import org.jetbrains.jet.j2k.append
|
||||
import org.jetbrains.kotlin.j2k.CodeBuilder
|
||||
import org.jetbrains.kotlin.j2k.append
|
||||
|
||||
class PackageStatement(val packageName: String) : Element() {
|
||||
override fun generateCode(builder: CodeBuilder) {
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
open class Function(
|
||||
val name: Identifier,
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.CodeBuilder
|
||||
import org.jetbrains.kotlin.j2k.CodeBuilder
|
||||
import com.intellij.psi.PsiNameIdentifierOwner
|
||||
import org.jetbrains.jet.lexer.JetKeywordToken
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import com.intellij.psi.PsiImportStatementBase
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
import com.intellij.psi.PsiImportList
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||
import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMap
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class Initializer(val body: DeferredElement<Block>, modifiers: Modifiers) : Member(Annotations.Empty, modifiers) {
|
||||
override fun generateCode(builder: CodeBuilder) {
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.ConverterSettings
|
||||
import org.jetbrains.jet.j2k.CodeBuilder
|
||||
import org.jetbrains.jet.j2k.append
|
||||
import org.jetbrains.kotlin.j2k.ConverterSettings
|
||||
import org.jetbrains.kotlin.j2k.CodeBuilder
|
||||
import org.jetbrains.kotlin.j2k.append
|
||||
|
||||
class LocalVariable(
|
||||
private val identifier: Identifier,
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class MethodCallExpression(
|
||||
val methodExpression: Expression,
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
import java.util.HashSet
|
||||
|
||||
enum class Modifier(val name: String) {
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class NewClassExpression(
|
||||
val name: ReferenceElement?,
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class Parameter(val identifier: Identifier,
|
||||
val type: Type,
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class ParameterList(val parameters: List<Parameter>) : Element() {
|
||||
override fun generateCode(builder: CodeBuilder) {
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class Property(
|
||||
val identifier: Identifier,
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class ReferenceElement(val name: Identifier, val typeArgs: List<Element>) : Element() {
|
||||
override fun generateCode(builder: CodeBuilder) {
|
||||
+4
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,12 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
|
||||
abstract class Statement() : Element() {
|
||||
abstract class Statement : Element() {
|
||||
object Empty : Statement() {
|
||||
override fun generateCode(builder: CodeBuilder) { }
|
||||
override val isEmpty: Boolean get() = true
|
||||
+11
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,18 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.CodeBuilder
|
||||
|
||||
class Trait(name: Identifier,
|
||||
annotations: Annotations,
|
||||
modifiers: Modifiers,
|
||||
typeParameterList: TypeParameterList,
|
||||
extendsTypes: List<Type>,
|
||||
baseClassParams: List<DeferredElement<Expression>>,
|
||||
implementsTypes: List<Type>,
|
||||
body: ClassBody
|
||||
class Trait(
|
||||
name: Identifier,
|
||||
annotations: Annotations,
|
||||
modifiers: Modifiers,
|
||||
typeParameterList: TypeParameterList,
|
||||
extendsTypes: List<Type>,
|
||||
baseClassParams: List<DeferredElement<Expression>>,
|
||||
implementsTypes: List<Type>,
|
||||
body: ClassBody
|
||||
) : Class(name, annotations, modifiers, typeParameterList, extendsTypes, baseClassParams, implementsTypes, body) {
|
||||
|
||||
override val keyword: String
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
class TypeElement(val type: Type) : Element() {
|
||||
override fun generateCode(builder: CodeBuilder) {
|
||||
+4
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,12 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import com.intellij.psi.PsiTypeParameter
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
import com.intellij.psi.PsiTypeParameterList
|
||||
import java.util.ArrayList
|
||||
|
||||
class TypeParameter(val name: Identifier, val extendsTypes: List<Type>) : Element() {
|
||||
fun hasWhere(): Boolean = extendsTypes.size() > 1
|
||||
@@ -70,4 +69,4 @@ fun Converter.convertTypeParameterList(typeParameterList: PsiTypeParameterList?)
|
||||
TypeParameterList(typeParameterList.getTypeParameters()!!.toList().map { convertTypeParameter(it) }).assignPrototype(typeParameterList)
|
||||
else
|
||||
TypeParameterList.Empty
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
fun Type.isUnit(): Boolean = this is UnitType
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
package org.jetbrains.kotlin.j2k.ast
|
||||
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
|
||||
fun String.withSuffix(suffix: String): String = if (isEmpty()) "" else this + suffix
|
||||
fun String.withPrefix(prefix: String): String = if (isEmpty()) "" else prefix + this
|
||||
@@ -64,4 +64,4 @@ private fun Expression.precedence(): Int? {
|
||||
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.usageProcessing
|
||||
package org.jetbrains.kotlin.j2k.usageProcessing
|
||||
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.jet.j2k.*
|
||||
import org.jetbrains.jet.j2k.ast.*
|
||||
import org.jetbrains.kotlin.j2k.*
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
|
||||
class AccessorToPropertyProcessing(val accessorMethod: PsiMethod, val accessorKind: AccessorKind, val propertyName: String) : UsageProcessing {
|
||||
override val targetElement: PsiElement get() = accessorMethod
|
||||
@@ -53,4 +53,4 @@ class AccessorToPropertyProcessing(val accessorMethod: PsiMethod, val accessorKi
|
||||
//reference.getElement() as JetSimpleNameExpression
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.usageProcessing
|
||||
package org.jetbrains.kotlin.j2k.usageProcessing
|
||||
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.jet.j2k.CodeConverter
|
||||
import org.jetbrains.jet.j2k.ast.*
|
||||
import org.jetbrains.kotlin.j2k.CodeConverter
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
import com.intellij.util.IncorrectOperationException
|
||||
|
||||
class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, val isNullable: Boolean) : UsageProcessing {
|
||||
@@ -57,4 +57,4 @@ class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, v
|
||||
override val javaCodeProcessor: ExternalCodeProcessor? get() = null //TODO
|
||||
|
||||
override val kotlinCodeProcessor: ExternalCodeProcessor? get() = null //TODO
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,12 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.usageProcessing
|
||||
package org.jetbrains.kotlin.j2k.usageProcessing
|
||||
|
||||
import org.jetbrains.jet.j2k.ast.Expression
|
||||
import org.jetbrains.kotlin.j2k.ast.Expression
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.jet.j2k.CodeConverter
|
||||
import org.jetbrains.jet.j2k.SpecialExpressionConverter
|
||||
import org.jetbrains.kotlin.j2k.CodeConverter
|
||||
import org.jetbrains.kotlin.j2k.SpecialExpressionConverter
|
||||
|
||||
trait UsageProcessing {
|
||||
val targetElement: PsiElement
|
||||
@@ -58,4 +58,4 @@ class UsageProcessingExpressionConverter(val processings: Map<PsiElement, UsageP
|
||||
else -> return null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.j2k
|
||||
|
||||
import junit.framework.TestCase
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import java.io.File
|
||||
|
||||
public abstract class AbstractJavaToKotlinConverterForWebDemoTest : TestCase() {
|
||||
public fun doTest(javaPath: String) {
|
||||
try {
|
||||
val fileContents = FileUtil.loadFile(File(javaPath), true)
|
||||
translateToKotlin(fileContents)
|
||||
}
|
||||
finally {
|
||||
Disposer.dispose(JavaToKotlinTranslator.DISPOSABLE)
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.test
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import java.io.File
|
||||
import com.intellij.testFramework.LightPlatformTestCase
|
||||
@@ -22,19 +22,15 @@ import com.intellij.psi.codeStyle.CodeStyleManager
|
||||
import org.jetbrains.jet.JetTestUtils
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import org.jetbrains.jet.j2k.FilesConversionScope
|
||||
import org.jetbrains.jet.plugin.j2k.J2kPostProcessor
|
||||
import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor
|
||||
import com.intellij.psi.PsiJavaFile
|
||||
import org.jetbrains.jet.j2k.IdeaReferenceSearcher
|
||||
import org.jetbrains.jet.j2k.JavaToKotlinConverter
|
||||
import com.intellij.psi.PsiManager
|
||||
import java.util.ArrayList
|
||||
import org.jetbrains.jet.j2k.ConverterSettings
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.plugin.j2k.IdeaResolverForConverter
|
||||
|
||||
public abstract class AbstractJavaToKotlinConverterMultiFileTest() : AbstractJavaToKotlinConverterTest() {
|
||||
public abstract class AbstractJavaToKotlinConverterMultiFileTest : AbstractJavaToKotlinConverterTest() {
|
||||
public fun doTest(dirPath: String) {
|
||||
val project = LightPlatformTestCase.getProject()!!
|
||||
val psiManager = PsiManager.getInstance(project)
|
||||
@@ -60,7 +56,7 @@ public abstract class AbstractJavaToKotlinConverterMultiFileTest() : AbstractJav
|
||||
jetFiles.add(psiManager.findFile(virtualFile) as JetFile)
|
||||
}
|
||||
|
||||
for ((i, jetFile) in jetFiles.withIndices()) {
|
||||
for ((i, jetFile) in jetFiles.withIndex()) {
|
||||
JetTestUtils.assertEqualsToFile(expectedFile(i), addErrorsDump(jetFile))
|
||||
}
|
||||
}
|
||||
+3
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,11 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.test
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import java.io.File
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.jet.j2k.ConverterSettings
|
||||
import java.util.regex.Pattern
|
||||
import com.intellij.testFramework.LightPlatformTestCase
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager
|
||||
@@ -26,16 +25,13 @@ import org.jetbrains.jet.JetTestUtils
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import org.jetbrains.jet.test.util.trimIndent
|
||||
import org.jetbrains.jet.j2k.FilesConversionScope
|
||||
import org.jetbrains.jet.plugin.j2k.J2kPostProcessor
|
||||
import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor
|
||||
import com.intellij.psi.PsiJavaFile
|
||||
import org.jetbrains.jet.j2k.IdeaReferenceSearcher
|
||||
import org.jetbrains.jet.j2k.JavaToKotlinConverter
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.plugin.j2k.IdeaResolverForConverter
|
||||
|
||||
public abstract class AbstractJavaToKotlinConverterSingleFileTest() : AbstractJavaToKotlinConverterTest() {
|
||||
public abstract class AbstractJavaToKotlinConverterSingleFileTest : AbstractJavaToKotlinConverterTest() {
|
||||
val testHeaderPattern = Pattern.compile("//(element|expression|statement|method|class|file|comp)\n")
|
||||
|
||||
public fun doTest(javaPath: String) {
|
||||
+2
-17
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.test
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import java.io.File
|
||||
@@ -23,10 +23,6 @@ import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.util.Computable
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.jet.j2k.translateToKotlin
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import org.jetbrains.jet.j2k.JavaToKotlinTranslator
|
||||
import org.jetbrains.jet.lang.diagnostics.Severity
|
||||
import org.jetbrains.jet.lang.diagnostics.rendering.DefaultErrorMessages
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
@@ -82,14 +78,3 @@ public abstract class AbstractJavaToKotlinConverterTest : LightCodeInsightFixtur
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class AbstractJavaToKotlinConverterForWebDemoTest() : TestCase() {
|
||||
public fun doTest(javaPath: String) {
|
||||
try {
|
||||
val fileContents = FileUtil.loadFile(File(javaPath), true)
|
||||
translateToKotlin(fileContents)
|
||||
}
|
||||
finally {
|
||||
Disposer.dispose(JavaToKotlinTranslator.DISPOSABLE)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.test;
|
||||
package org.jetbrains.kotlin.j2k;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.test;
|
||||
package org.jetbrains.kotlin.j2k;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.test;
|
||||
package org.jetbrains.kotlin.j2k;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||
Reference in New Issue
Block a user