type unescaped in *.kt files

This commit is contained in:
Andrey Breslav
2014-10-14 08:27:21 +04:00
parent 56d1979d9b
commit b1e452b568
38 changed files with 130 additions and 130 deletions
@@ -209,7 +209,7 @@ class ConstructorConverter(private val psiClass: PsiClass, private val converter
val fieldType = correctedTypeConverter.convertVariableType(field)
val parameterType = correctedTypeConverter.convertVariableType(parameter)
// types can be different only in nullability
val `type` = if (fieldType == parameterType) {
val type = if (fieldType == parameterType) {
fieldType
}
else if (fieldType.toNotNullType() == parameterType.toNotNullType()) {
@@ -219,7 +219,7 @@ class ConstructorConverter(private val psiClass: PsiClass, private val converter
continue
}
parameterToField.put(parameter, field to `type`)
parameterToField.put(parameter, field to type)
statementsToRemove.add(initializationStatement)
membersToRemove.add(field)
@@ -263,9 +263,9 @@ class ConstructorConverter(private val psiClass: PsiClass, private val converter
correctedConverter.convertParameter(parameter, defaultValue = defaultValue)
}
else {
val (field, `type`) = parameterToField[parameter]!!
val (field, type) = parameterToField[parameter]!!
Parameter(field.declarationIdentifier(),
`type`,
type,
if (isVal(converter.referenceSearcher, field)) Parameter.VarValModifier.Val else Parameter.VarValModifier.Var,
converter.convertAnnotations(parameter) + converter.convertAnnotations(field),
converter.convertModifiers(field).filter { it in ACCESS_MODIFIERS },
@@ -332,7 +332,7 @@ class ConstructorConverter(private val psiClass: PsiClass, private val converter
val parameters = fieldsToInitialize.map { field ->
val varValModifier = if (field.isVal) Parameter.VarValModifier.Val else Parameter.VarValModifier.Var
Parameter(field.identifier, field.`type`, varValModifier, field.annotations, field.modifiers.filter { it in ACCESS_MODIFIERS }).assignPrototypesFrom(field)
Parameter(field.identifier, field.type, varValModifier, field.annotations, field.modifiers.filter { it in ACCESS_MODIFIERS }).assignPrototypesFrom(field)
}
val modifiers = Modifiers.Empty
+4 -4
View File
@@ -552,12 +552,12 @@ public class Converter private(val project: Project,
varValModifier: Parameter.VarValModifier = Parameter.VarValModifier.None,
modifiers: Modifiers = Modifiers.Empty,
defaultValue: Expression? = null): Parameter {
var `type` = typeConverter.convertVariableType(parameter)
var type = typeConverter.convertVariableType(parameter)
when (nullability) {
Nullability.NotNull -> `type` = `type`.toNotNullType()
Nullability.Nullable -> `type` = `type`.toNullableType()
Nullability.NotNull -> type = type.toNotNullType()
Nullability.Nullable -> type = type.toNullableType()
}
return Parameter(parameter.declarationIdentifier(), `type`, varValModifier,
return Parameter(parameter.declarationIdentifier(), type, varValModifier,
annotationConverter.convertAnnotations(parameter), modifiers, defaultValue).assignPrototype(parameter)
}
@@ -37,10 +37,10 @@ import org.jetbrains.jet.j2k.ast.Identifier
class TypeConverter(val converter: Converter) {
private val nullabilityCache = HashMap<PsiElement, Nullability>()
public fun convertType(`type`: PsiType?, nullability: Nullability = Nullability.Default): Type {
if (`type` == null) return ErrorType().assignNoPrototype()
public fun convertType(type: PsiType?, nullability: Nullability = Nullability.Default): Type {
if (type == null) return ErrorType().assignNoPrototype()
val result = `type`.accept<Type>(TypeVisitor(converter))!!.assignNoPrototype()
val result = type.accept<Type>(TypeVisitor(converter))!!.assignNoPrototype()
return when (nullability) {
Nullability.NotNull -> result.toNotNullType()
Nullability.Nullable -> result.toNullableType()
+1 -1
View File
@@ -31,7 +31,7 @@ fun PsiVariable.hasWriteAccesses(searcher: ReferenceSearcher, scope: PsiElement?
= if (scope != null) searcher.findVariableUsages(this, scope).any { PsiUtil.isAccessedForWriting(it) } else false
fun getDefaultInitializer(field: Field): Expression? {
val t = field.`type`
val t = field.type
val result = if (t.isNullable) {
LiteralExpression("null")
}
@@ -19,24 +19,24 @@ package org.jetbrains.jet.j2k.ast
import org.jetbrains.jet.j2k.CodeBuilder
import org.jetbrains.jet.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) {
fun appendConstructorName(`type`: ArrayType, hasInit: Boolean): CodeBuilder = when (`type`.elementType) {
is PrimitiveType -> builder.append(`type`.toNotNullType())
fun appendConstructorName(type: ArrayType, hasInit: Boolean): CodeBuilder = when (type.elementType) {
is PrimitiveType -> builder.append(type.toNotNullType())
is ArrayType ->
if (hasInit) {
builder.append(`type`.toNotNullType())
builder.append(type.toNotNullType())
}
else {
builder.append("arrayOfNulls<").append(`type`.elementType).append(">")
builder.append("arrayOfNulls<").append(type.elementType).append(">")
}
else -> builder.append("arrayOfNulls<").append(`type`.elementType).append(">")
else -> builder.append("arrayOfNulls<").append(type.elementType).append(">")
}
fun oneDim(`type`: ArrayType, size: Expression, init: (() -> Unit)? = null): CodeBuilder {
appendConstructorName(`type`, init != null).append("(").append(size)
fun oneDim(type: ArrayType, size: Expression, init: (() -> Unit)? = null): CodeBuilder {
appendConstructorName(type, init != null).append("(").append(size)
if (init != null) {
builder.append(", ")
init()
@@ -61,6 +61,6 @@ class ArrayWithoutInitializationExpression(val `type`: ArrayType, val expression
return appendConstructorName(hostType, expressions.isNotEmpty())
}
constructInnerType(`type`, expressions)
constructInnerType(type, expressions)
}
}
@@ -22,7 +22,7 @@ class EnumConstant(
val identifier: Identifier,
annotations: Annotations,
modifiers: Modifiers,
val `type`: Type,
val type: Type,
val params: Element
) : Member(annotations, modifiers) {
@@ -32,7 +32,7 @@ class EnumConstant(
return
}
builder append annotations append identifier append " : " append `type` append "(" append params append ")"
builder append annotations append identifier append " : " append type append "(" append params append ")"
}
@@ -47,13 +47,13 @@ class BinaryExpression(val left: Expression, val right: Expression, val op: Stri
class IsOperator(val expression: Expression, val typeElement: TypeElement) : Expression() {
override fun generateCode(builder: CodeBuilder) {
builder.appendOperand(this, expression).append(" is ").append(typeElement.`type`.toNotNullType())
builder.appendOperand(this, expression).append(" is ").append(typeElement.type.toNotNullType())
}
}
class TypeCastExpression(val `type`: Type, val expression: Expression) : Expression() {
class TypeCastExpression(val type: Type, val expression: Expression) : Expression() {
override fun generateCode(builder: CodeBuilder) {
builder.appendOperand(this, expression).append(" as ").append(`type`)
builder.appendOperand(this, expression).append(" as ").append(type)
}
}
+2 -2
View File
@@ -22,7 +22,7 @@ class Field(
val identifier: Identifier,
annotations: Annotations,
modifiers: Modifiers,
val `type`: Type,
val type: Type,
val initializer: Element,
val isVal: Boolean,
val explicitType: Boolean,
@@ -36,7 +36,7 @@ class Field(
.append(identifier)
if (explicitType) {
builder append ":" append `type`
builder append ":" append type
}
var initializerToUse = initializer
@@ -19,7 +19,7 @@ package org.jetbrains.jet.j2k.ast
import org.jetbrains.jet.j2k.*
class Parameter(val identifier: Identifier,
val `type`: Type,
val type: Type,
val varVal: Parameter.VarValModifier,
val annotations: Annotations,
val modifiers: Modifiers,
@@ -33,7 +33,7 @@ class Parameter(val identifier: Identifier,
override fun generateCode(builder: CodeBuilder) {
builder.append(annotations).appendWithSpaceAfter(modifiers)
if (`type` is VarArgType) {
if (type is VarArgType) {
builder.append("vararg ")
}
@@ -42,7 +42,7 @@ class Parameter(val identifier: Identifier,
VarValModifier.Val -> builder.append("val ")
}
builder append identifier append ":" append `type`
builder append identifier append ":" append type
if (defaultValue != null) {
builder append " = " append defaultValue
@@ -18,8 +18,8 @@ package org.jetbrains.jet.j2k.ast
import org.jetbrains.jet.j2k.*
class TypeElement(val `type`: Type) : Element() {
class TypeElement(val type: Type) : Element() {
override fun generateCode(builder: CodeBuilder) {
builder.append(`type`)
builder.append(type)
}
}
+2 -2
View File
@@ -129,8 +129,8 @@ class PrimitiveType(val name: Identifier) : NotNullType() {
}
}
class VarArgType(val `type`: Type) : NotNullType() {
class VarArgType(val type: Type) : NotNullType() {
override fun generateCode(builder: CodeBuilder) {
builder.append(`type`)
builder.append(type)
}
}
@@ -118,7 +118,7 @@ open class ExpressionVisitor(private val converter: Converter) : JavaElementVisi
}
else {
val typeElement = converter.convertTypeElement(operand)
result = MethodCallExpression.buildNotNull(null, "javaClass", listOf(), listOf(typeElement.`type`.toNotNullType()))
result = MethodCallExpression.buildNotNull(null, "javaClass", listOf(), listOf(typeElement.type.toNotNullType()))
return
}
@@ -134,9 +134,9 @@ open class ExpressionVisitor(private val converter: Converter) : JavaElementVisi
override fun visitConditionalExpression(expression: PsiConditionalExpression) {
val condition = expression.getCondition()
val `type` = condition.getType()
val expr = if (`type` != null)
converter.convertExpression(condition, `type`)
val type = condition.getType()
val expr = if (type != null)
converter.convertExpression(condition, type)
else
converter.convertExpression(condition)
result = IfStatement(expr,
@@ -154,9 +154,9 @@ open class ExpressionVisitor(private val converter: Converter) : JavaElementVisi
override fun visitLiteralExpression(expression: PsiLiteralExpression) {
val value = expression.getValue()
var text = expression.getText()!!
val `type` = expression.getType()
if (`type` != null) {
val canonicalTypeStr = `type`.getCanonicalText()
val type = expression.getType()
if (type != null) {
val canonicalTypeStr = type.getCanonicalText()
if (canonicalTypeStr == "double" || canonicalTypeStr == JAVA_LANG_DOUBLE) {
text = text.replace("D", "").replace("d", "")
if (!text.contains(".")) {