back to compilable and working state
This commit is contained in:
committed by
Pavel V. Talanov
parent
5932eb3539
commit
0e2d0a4a5b
@@ -107,7 +107,7 @@ public open class Converter() {
|
||||
val typeParameters: List<Element> = elementsToElementList(psiClass.getTypeParameters())
|
||||
val implementsTypes: List<Type> = typesToNotNullableTypeList(psiClass.getImplementsListTypes())
|
||||
val extendsTypes: List<Type> = typesToNotNullableTypeList(psiClass.getExtendsListTypes())
|
||||
val name: Identifier = Identifier(psiClass.getName())
|
||||
val name: Identifier = Identifier(psiClass.getName()!!)
|
||||
val baseClassParams: List<Expression> = arrayList()
|
||||
val members: List<Member> = getMembers(psiClass)
|
||||
val visitor: SuperVisitor = SuperVisitor()
|
||||
@@ -187,10 +187,13 @@ public open class Converter() {
|
||||
private fun fieldToField(field: PsiField, psiClass: PsiClass?): Field {
|
||||
val modifiers: Set<String> = modifiersListToModifiersSet(field.getModifierList())
|
||||
if (field is PsiEnumConstant?) {
|
||||
return EnumConstant(Identifier(field.getName()), modifiers, typeToType(field.getType()), elementToElement(field.getArgumentList()))
|
||||
return EnumConstant(Identifier(field.getName()!!),
|
||||
modifiers,
|
||||
typeToType(field.getType()),
|
||||
elementToElement(field.getArgumentList()))
|
||||
}
|
||||
|
||||
return Field(Identifier(field.getName()),
|
||||
return Field(Identifier(field.getName()!!),
|
||||
modifiers,
|
||||
typeToType(field.getType()),
|
||||
expressionToExpression(field.getInitializer(), field.getType()),
|
||||
@@ -242,9 +245,8 @@ public open class Converter() {
|
||||
|
||||
private fun createFunctionParameters(method: PsiMethod): ParameterList {
|
||||
val result: List<Parameter> = arrayList()
|
||||
for (parameter : PsiParameter? in method.getParameterList().getParameters())
|
||||
{
|
||||
result.add(Parameter(Identifier(parameter?.getName()),
|
||||
for (parameter : PsiParameter? in method.getParameterList().getParameters()) {
|
||||
result.add(Parameter(Identifier(parameter?.getName()!!),
|
||||
typeToType(parameter?.getType(),
|
||||
ConverterUtil.isAnnotatedAsNotNull(parameter?.getModifierList())),
|
||||
ConverterUtil.isReadOnly(parameter, method.getBody())))
|
||||
@@ -376,7 +378,7 @@ public open class Converter() {
|
||||
}
|
||||
|
||||
public open fun parameterToParameter(parameter: PsiParameter): Parameter {
|
||||
return Parameter(Identifier(parameter.getName()),
|
||||
return Parameter(Identifier(parameter.getName()!!),
|
||||
typeToType(parameter.getType(),
|
||||
ConverterUtil.isAnnotatedAsNotNull(parameter.getModifierList())), true)
|
||||
}
|
||||
@@ -420,12 +422,10 @@ public open class Converter() {
|
||||
if (actualType != null) {
|
||||
if (isConversionNeeded(actualType, expectedType) && !(expression is LiteralExpression))
|
||||
{
|
||||
var conversion: String? = PRIMITIVE_TYPE_CONVERSIONS.get(expectedType?.getCanonicalText())
|
||||
if (conversion != null)
|
||||
{
|
||||
val conversion: String? = PRIMITIVE_TYPE_CONVERSIONS.get(expectedType?.getCanonicalText())
|
||||
if (conversion != null) {
|
||||
expression = DummyMethodCallExpression(expression, conversion, Identifier.EMPTY_IDENTIFIER)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -467,7 +467,7 @@ public open class Converter() {
|
||||
}
|
||||
|
||||
private fun createParametersFromFields(fields: List<Field>): List<Parameter> {
|
||||
return fields.map { Parameter(Identifier("_" + it.identifier.getName()), it.`type`, true) }
|
||||
return fields.map { Parameter(Identifier("_" + it.identifier.name), it.`type`, true) }
|
||||
}
|
||||
|
||||
private fun createInitStatementsFromFields(fields: List<out Field>): List<Statement> {
|
||||
@@ -529,7 +529,7 @@ public open class Converter() {
|
||||
return false
|
||||
}
|
||||
private fun removeEmpty(statements: List<Statement>): List<Statement> {
|
||||
return statements.filterNot { it is EmptyStatement || it == Expression.EMPTY_EXPRESSION }
|
||||
return statements.filterNot { it == Statement.EMPTY_STATEMENT || it == Expression.EMPTY_EXPRESSION }
|
||||
}
|
||||
|
||||
private fun isNotOpenMethod(method: PsiMethod): Boolean {
|
||||
@@ -547,7 +547,7 @@ public open class Converter() {
|
||||
|
||||
private fun normalCase(method: PsiMethod): Boolean {
|
||||
var counter: Int = 0
|
||||
for (s : HierarchicalMethodSignature? in method.getHierarchicalMethodSignature()?.getSuperSignatures())
|
||||
for (s : HierarchicalMethodSignature? in method.getHierarchicalMethodSignature().getSuperSignatures())
|
||||
{
|
||||
var containingClass: PsiClass? = s?.getMethod()?.getContainingClass()
|
||||
var qualifiedName: String? = (if (containingClass != null)
|
||||
@@ -580,16 +580,15 @@ public open class Converter() {
|
||||
}
|
||||
|
||||
private fun isOverrideObjectDirect(method: PsiMethod): Boolean {
|
||||
var superSignatures: List<HierarchicalMethodSignature?>? = method?.getHierarchicalMethodSignature()?.getSuperSignatures()
|
||||
var superSignatures: List<HierarchicalMethodSignature?>? = method.getHierarchicalMethodSignature().getSuperSignatures()
|
||||
if (superSignatures?.size()!! == 1)
|
||||
{
|
||||
val containingClass: PsiClass? = superSignatures?.get(0)?.getMethod()?.getContainingClass()
|
||||
val qualifiedName: String? = (if (containingClass != null)
|
||||
containingClass?.getQualifiedName()
|
||||
containingClass.getQualifiedName()
|
||||
else
|
||||
"")
|
||||
if (qualifiedName != null && qualifiedName?.equals(JAVA_LANG_OBJECT)!!)
|
||||
{
|
||||
if (qualifiedName == JAVA_LANG_OBJECT) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -627,7 +626,7 @@ public open class Converter() {
|
||||
if (identifier == null)
|
||||
return Identifier.EMPTY_IDENTIFIER
|
||||
|
||||
return Identifier(identifier?.getText())
|
||||
return Identifier(identifier.getText()!!)
|
||||
}
|
||||
|
||||
public open fun modifiersListToModifiersSet(modifierList: PsiModifierList?): Set<String> {
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.jet.j2k.ast;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author ignatov
|
||||
*/
|
||||
public abstract class Expression extends Statement {
|
||||
@NotNull
|
||||
public static final Expression EMPTY_EXPRESSION = new EmptyExpression();
|
||||
|
||||
/**
|
||||
* @author ignatov
|
||||
*/
|
||||
private static class EmptyExpression extends Expression {
|
||||
@NotNull
|
||||
@Override
|
||||
public String toKotlin() {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNullable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
|
||||
|
||||
public abstract class Expression(): Statement() {
|
||||
public open fun isNullable(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
class object {
|
||||
public val EMPTY_EXPRESSION: Expression = object: Expression() {
|
||||
public override fun toKotlin()= ""
|
||||
public override fun isEmpty() = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
|
||||
import java.util.Set
|
||||
|
||||
|
||||
public open class Identifier(val name: String,
|
||||
val nullable: Boolean = true,
|
||||
val myNullable: Boolean = true,
|
||||
val quotingNeeded: Boolean = true): Expression() {
|
||||
public override fun isEmpty(): Boolean {
|
||||
return name.length() == 0
|
||||
}
|
||||
private open fun ifNeedQuote(): String {
|
||||
if (quotingNeeded && (ONLY_KOTLIN_KEYWORDS?.contains(name)) || name.contains("$"))) {
|
||||
public override fun isEmpty() = name.length() == 0
|
||||
|
||||
private open fun ifNeedQuote(): String {
|
||||
if (quotingNeeded && (ONLY_KOTLIN_KEYWORDS.contains(name)) || name.contains("$")) {
|
||||
return quote(name)
|
||||
}
|
||||
|
||||
@@ -16,11 +17,16 @@ public open class Identifier(val name: String,
|
||||
}
|
||||
|
||||
public override fun toKotlin(): String = ifNeedQuote()
|
||||
public override fun isNullable(): Boolean = myNullable
|
||||
|
||||
class object {
|
||||
public val EMPTY_IDENTIFIER: Identifier = Identifier("")
|
||||
private open fun quote(str: String): String {
|
||||
return "`" + str + "`"
|
||||
}
|
||||
|
||||
public val ONLY_KOTLIN_KEYWORDS: Set<String> = hashSet(
|
||||
"package", "as", "type", "val", "var", "fun", "is", "in", "object", "when", "trait", "This"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
|
||||
|
||||
public open class LiteralExpression(val identifier: Identifier): Expression() {
|
||||
public override fun toKotlin() = identifier.toKotlin()
|
||||
public open class LiteralExpression(val literalText: String): Expression() {
|
||||
public override fun toKotlin() = literalText
|
||||
}
|
||||
|
||||
@@ -27,10 +27,6 @@ import java.util.Set;
|
||||
* @author ignatov
|
||||
*/
|
||||
public abstract class Node {
|
||||
@NotNull
|
||||
final static Set<String> ONLY_KOTLIN_KEYWORDS = new HashSet<String>(Arrays.asList(
|
||||
"package", "as", "type", "val", "var", "fun", "is", "in", "object", "when", "trait", "This"
|
||||
));
|
||||
|
||||
@NotNull
|
||||
public final static Set<String> PRIMITIVE_TYPES = new HashSet<String>(Arrays.asList(
|
||||
|
||||
@@ -2,5 +2,5 @@ package org.jetbrains.jet.j2k.ast
|
||||
|
||||
|
||||
public open class PostfixOperator(val op: String, val expression: Expression): Expression() {
|
||||
public override fun toKotlin() = expression.toKotlin() + op
|
||||
public override fun toKotlin(): String = expression.toKotlin() + op
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.List
|
||||
|
||||
public abstract class Statement(): Element() {
|
||||
class object {
|
||||
public val EMPTY_STATEMENT = object : Statement {
|
||||
public val EMPTY_STATEMENT: Statement = object : Statement() {
|
||||
public override fun toKotlin() = ""
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public open class ReturnStatement(val expression: Expression): Statement() {
|
||||
public open class IfStatement(val condition: Expression, val thenStatement: Statement, val elseStatement: Statement): Expression() {
|
||||
public override fun toKotlin(): String {
|
||||
val result: String = "if (" + condition.toKotlin() + ")\n" + thenStatement.toKotlin() + "\n"
|
||||
if (elseStatement !is EmptyStatement) {
|
||||
if (elseStatement != Statement.EMPTY_STATEMENT) {
|
||||
return result + "else\n" + elseStatement.toKotlin()
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,16 @@ import java.util.Set
|
||||
|
||||
public open class ClassVisitor(): JavaRecursiveElementVisitor() {
|
||||
private val myClassIdentifiers: Set<String> = HashSet<String>()
|
||||
|
||||
public open fun getClassIdentifiers(): Set<String> {
|
||||
return HashSet<String>(myClassIdentifiers)
|
||||
}
|
||||
|
||||
public override fun visitClass(aClass: PsiClass?): Unit {
|
||||
myClassIdentifiers.add(aClass?.getQualifiedName()!!)
|
||||
val qName = aClass?.getQualifiedName()
|
||||
if (qName != null) {
|
||||
myClassIdentifiers.add(qName)
|
||||
}
|
||||
super.visitClass(aClass)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public open class ElementVisitor(val myConverter : Converter) : JavaElementVisit
|
||||
|
||||
public override fun visitLocalVariable(variable : PsiLocalVariable?) : Unit {
|
||||
val theVariable = variable!!
|
||||
myResult = LocalVariable(Identifier(theVariable.getName()),
|
||||
myResult = LocalVariable(Identifier(theVariable.getName()!!),
|
||||
Converter.modifiersListToModifiersSet(theVariable.getModifierList()),
|
||||
myConverter.typeToType(theVariable.getType(), isAnnotatedAsNotNull(theVariable.getModifierList())),
|
||||
myConverter.expressionToExpression(theVariable.getInitializer(), theVariable.getType()))
|
||||
@@ -34,15 +34,15 @@ public open class ElementVisitor(val myConverter : Converter) : JavaElementVisit
|
||||
val theReference = reference!!
|
||||
val types : List<Type> = myConverter.typesToTypeList(theReference.getTypeParameters())
|
||||
if (!theReference.isQualified()) {
|
||||
myResult = ReferenceElement(Identifier(theReference.getReferenceName()), types)
|
||||
myResult = ReferenceElement(Identifier(theReference.getReferenceName()!!), types)
|
||||
}
|
||||
else {
|
||||
var result : String = Identifier(reference?.getReferenceName()).toKotlin()
|
||||
var result : String = Identifier(reference?.getReferenceName()!!).toKotlin()
|
||||
var qualifier : PsiElement? = theReference.getQualifier()
|
||||
while (qualifier != null)
|
||||
{
|
||||
val p : PsiJavaCodeReferenceElement = (qualifier as PsiJavaCodeReferenceElement)
|
||||
result = Identifier(p.getReferenceName()).toKotlin() + "." + result
|
||||
result = Identifier(p.getReferenceName()!!).toKotlin() + "." + result
|
||||
qualifier = p.getQualifier()
|
||||
}
|
||||
myResult = ReferenceElement(Identifier(result), types)
|
||||
@@ -54,7 +54,7 @@ public open class ElementVisitor(val myConverter : Converter) : JavaElementVisit
|
||||
}
|
||||
|
||||
public override fun visitTypeParameter(classParameter : PsiTypeParameter?) : Unit {
|
||||
myResult = TypeParameter(Identifier(classParameter!!.getName()),
|
||||
myResult = TypeParameter(Identifier(classParameter!!.getName()!!),
|
||||
classParameter!!.getExtendsListTypes().map { myConverter.typeToType(it) } )
|
||||
}
|
||||
|
||||
|
||||
@@ -101,9 +101,8 @@ public open class ExpressionVisitor(converter: Converter): StatementVisitor(conv
|
||||
var text: String = expression?.getText()!!
|
||||
var isQuotingNeeded: Boolean = true
|
||||
val `type`: PsiType? = expression?.getType()
|
||||
if (`type` != null)
|
||||
{
|
||||
var canonicalTypeStr: String? = `type`.getCanonicalText()
|
||||
if (`type` != null) {
|
||||
val canonicalTypeStr: String? = `type`.getCanonicalText()
|
||||
if (canonicalTypeStr?.equals("double")!! || canonicalTypeStr?.equals(JAVA_LANG_DOUBLE)!!) {
|
||||
text = text.replace("D", "").replace("d", "")
|
||||
if (!text.contains(".")) {
|
||||
@@ -123,18 +122,9 @@ public open class ExpressionVisitor(converter: Converter): StatementVisitor(conv
|
||||
if (canonicalTypeStr?.equals("int")!! || canonicalTypeStr?.equals(JAVA_LANG_INTEGER)!!) {
|
||||
text = (if (value != null) value.toString() else text)
|
||||
}
|
||||
|
||||
if (canonicalTypeStr?.equals(JAVA_LANG_STRING)!!) {
|
||||
isQuotingNeeded = false
|
||||
}
|
||||
|
||||
if (canonicalTypeStr?.equals("char")!! || canonicalTypeStr?.equals(JAVA_LANG_CHARACTER)!!) {
|
||||
isQuotingNeeded = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
myResult = LiteralExpression(Identifier(text, false, isQuotingNeeded))
|
||||
myResult = LiteralExpression(text)
|
||||
}
|
||||
|
||||
public override fun visitMethodCallExpression(expression: PsiMethodCallExpression?): Unit {
|
||||
@@ -197,8 +187,8 @@ public open class ExpressionVisitor(converter: Converter): StatementVisitor(conv
|
||||
|
||||
private fun createNewEmptyArrayWithoutInitialization(expression: PsiNewExpression): Expression {
|
||||
return ArrayWithoutInitializationExpression(
|
||||
getConverter().typeToType(expression?.getType(), true),
|
||||
getConverter().expressionsToExpressionList(expression?.getArrayDimensions()))
|
||||
getConverter().typeToType(expression.getType(), true),
|
||||
getConverter().expressionsToExpressionList(expression.getArrayDimensions()))
|
||||
}
|
||||
|
||||
private fun createNewEmptyArray(expression: PsiNewExpression?): Expression {
|
||||
@@ -232,10 +222,10 @@ public open class ExpressionVisitor(converter: Converter): StatementVisitor(conv
|
||||
val isThis: Boolean = isThisExpression(expression!!)
|
||||
val isNullable: Boolean = getConverter().typeToType(expression?.getType()).nullable
|
||||
val className: String = getClassNameWithConstructor(expression!!)
|
||||
var identifier: Expression = Identifier(expression?.getReferenceName(), isNullable)
|
||||
val __: String? = "__"
|
||||
var identifier: Expression = Identifier(expression?.getReferenceName()!!, isNullable)
|
||||
val __: String = "__"
|
||||
if (hasReceiver){
|
||||
identifier = CallChainExpression(Identifier(__, false), Identifier(expression?.getReferenceName(), isNullable))
|
||||
identifier = CallChainExpression(Identifier(__, false), Identifier(expression?.getReferenceName()!!, isNullable))
|
||||
}
|
||||
else
|
||||
if (insideSecondaryConstructor && isThis) {
|
||||
@@ -248,7 +238,7 @@ public open class ExpressionVisitor(converter: Converter): StatementVisitor(conv
|
||||
public override fun visitSuperExpression(expression: PsiSuperExpression?): Unit {
|
||||
val qualifier: PsiJavaCodeReferenceElement? = expression?.getQualifier()
|
||||
myResult = SuperExpression((if (qualifier != null)
|
||||
Identifier(qualifier.getQualifiedName())
|
||||
Identifier(qualifier.getQualifiedName()!!)
|
||||
else
|
||||
Identifier.EMPTY_IDENTIFIER))
|
||||
}
|
||||
@@ -256,7 +246,7 @@ public open class ExpressionVisitor(converter: Converter): StatementVisitor(conv
|
||||
public override fun visitThisExpression(expression: PsiThisExpression?): Unit {
|
||||
val qualifier: PsiJavaCodeReferenceElement? = expression?.getQualifier()
|
||||
myResult = ThisExpression((if (qualifier != null)
|
||||
Identifier(qualifier.getQualifiedName())
|
||||
Identifier(qualifier.getQualifiedName()!!)
|
||||
else
|
||||
Identifier.EMPTY_IDENTIFIER))
|
||||
}
|
||||
@@ -264,7 +254,7 @@ public open class ExpressionVisitor(converter: Converter): StatementVisitor(conv
|
||||
public override fun visitTypeCastExpression(expression: PsiTypeCastExpression?): Unit {
|
||||
val castType: PsiTypeElement? = expression?.getCastType()
|
||||
if (castType != null) {
|
||||
myResult = TypeCastExpression(getConverter()?.typeToType(castType.getType()),
|
||||
myResult = TypeCastExpression(getConverter().typeToType(castType.getType()),
|
||||
getConverter().expressionToExpression(expression?.getOperand()))
|
||||
}
|
||||
}
|
||||
@@ -272,7 +262,7 @@ public open class ExpressionVisitor(converter: Converter): StatementVisitor(conv
|
||||
public override fun visitPolyadicExpression(expression: PsiPolyadicExpression?): Unit {
|
||||
var parameters: List<Expression> = ArrayList<Expression>()
|
||||
for (operand : PsiExpression? in expression?.getOperands()) {
|
||||
parameters?.add(getConverter().expressionToExpression(operand, expression?.getType()))
|
||||
parameters.add(getConverter().expressionToExpression(operand, expression?.getType()))
|
||||
}
|
||||
myResult = PolyadicExpression(parameters, getOperatorString(expression?.getOperationTokenType()!!))
|
||||
}
|
||||
@@ -345,17 +335,17 @@ public open class ExpressionVisitor(converter: Converter): StatementVisitor(conv
|
||||
if (tokenType == JavaTokenType.EXCL)
|
||||
return "!"
|
||||
|
||||
System.out?.println("UNSUPPORTED TOKEN TYPE: " + tokenType?.toString())
|
||||
// System.out.println("UNSUPPORTED TOKEN TYPE: " + tokenType?.toString())
|
||||
return ""
|
||||
}
|
||||
|
||||
private fun getClassNameWithConstructor(expression: PsiReferenceExpression): String {
|
||||
var context: PsiElement? = expression?.getContext()
|
||||
var context: PsiElement? = expression.getContext()
|
||||
while (context != null) {
|
||||
if (context is PsiMethod && ((context as PsiMethod)).isConstructor()) {
|
||||
val containingClass: PsiClass? = ((context as PsiMethod)).getContainingClass()
|
||||
if (containingClass != null) {
|
||||
val identifier: PsiIdentifier? = containingClass?.getNameIdentifier()
|
||||
val identifier: PsiIdentifier? = containingClass.getNameIdentifier()
|
||||
if (identifier != null) {
|
||||
return identifier.getText()!!
|
||||
}
|
||||
@@ -388,9 +378,9 @@ public open class ExpressionVisitor(converter: Converter): StatementVisitor(conv
|
||||
}
|
||||
|
||||
private fun isFieldReference(expression: PsiReferenceExpression, currentClass: PsiClass?): Boolean {
|
||||
val reference: PsiReference? = expression?.getReference()
|
||||
val reference: PsiReference? = expression.getReference()
|
||||
if (reference != null) {
|
||||
val resolvedReference: PsiElement? = reference?.resolve()
|
||||
val resolvedReference: PsiElement? = reference.resolve()
|
||||
if (resolvedReference is PsiField) {
|
||||
return (resolvedReference as PsiField).getContainingClass() == currentClass
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ public open class ExpressionVisitorForDirectObjectInheritors(converter: Converte
|
||||
myResult = DummyMethodCallExpression(Identifier("this"), "identityEquals", getConverter().elementToElement(expression?.getArgumentList()))
|
||||
}
|
||||
else if (superMethodInvocation(methodExpression, "toString")) {
|
||||
myResult = DummyStringExpression(String.format("getJavaClass<%s>.getName() + '@' + Integer.toHexString(hashCode())", ExpressionVisitor.getClassName(methodExpression)))
|
||||
myResult = DummyStringExpression(String.format("getJavaClass<%s>.getName() + '@' + Integer.toHexString(hashCode())",
|
||||
ExpressionVisitor.getClassName(methodExpression))!!)
|
||||
}
|
||||
else {
|
||||
convertMethodCallExpression(expression!!)
|
||||
|
||||
@@ -12,7 +12,8 @@ import java.util.List
|
||||
import org.jetbrains.jet.j2k.ConverterUtil.countWritingAccesses
|
||||
|
||||
public open class StatementVisitor(converter: Converter): ElementVisitor(converter) {
|
||||
private var myResult: Statement =
|
||||
private var myResult: Statement = Statement.EMPTY_STATEMENT
|
||||
|
||||
public override fun getResult(): Statement {
|
||||
return myResult
|
||||
}
|
||||
@@ -97,7 +98,7 @@ public open class StatementVisitor(converter: Converter): ElementVisitor(convert
|
||||
BinaryExpression(end, Identifier("1"), "-")
|
||||
else
|
||||
end)
|
||||
myResult = ForeachWithRangeStatement(Identifier(firstChild.getName()),
|
||||
myResult = ForeachWithRangeStatement(Identifier(firstChild.getName()!!),
|
||||
getConverter().expressionToExpression(firstChild.getInitializer()),
|
||||
endExpression,
|
||||
getConverter().statementToStatement(body))
|
||||
|
||||
@@ -70,9 +70,8 @@ public open class TypeVisitor(private val myConverter : Converter) : PsiTypeVisi
|
||||
}
|
||||
}
|
||||
|
||||
val classTypeName : String? = createQualifiedName(classType)
|
||||
if (classTypeName?.isEmpty().sure())
|
||||
{
|
||||
val classTypeName = createQualifiedName(classType)
|
||||
if (classTypeName.isEmpty()) {
|
||||
return Identifier(getClassTypeName(classType))
|
||||
}
|
||||
|
||||
@@ -125,14 +124,13 @@ public open class TypeVisitor(private val myConverter : Converter) : PsiTypeVisi
|
||||
if (classType is PsiClassReferenceType)
|
||||
{
|
||||
val reference : PsiJavaCodeReferenceElement? = (classType as PsiClassReferenceType).getReference()
|
||||
if (reference != null && reference.isQualified())
|
||||
{
|
||||
var result : String = Identifier(reference.getReferenceName()).toKotlin()
|
||||
if (reference != null && reference.isQualified()) {
|
||||
var result : String = Identifier(reference.getReferenceName()!!).toKotlin()
|
||||
var qualifier : PsiElement? = reference.getQualifier()
|
||||
while (qualifier != null)
|
||||
{
|
||||
val p : PsiJavaCodeReferenceElement = (qualifier as PsiJavaCodeReferenceElement)
|
||||
result = Identifier(p.getReferenceName()).toKotlin() + "." + result
|
||||
result = Identifier(p.getReferenceName()!!).toKotlin() + "." + result
|
||||
qualifier = p.getQualifier()
|
||||
}
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user