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