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
@@ -48,7 +48,7 @@ class PlatformStaticGenerator(
val iv = InstructionAdapter(methodVisitor)
val classDescriptor = descriptor.getContainingDeclaration() as ClassDescriptor
val singletonValue = StackValue.singleton(classDescriptor, typeMapper)!!
singletonValue.put(singletonValue.`type`, iv);
singletonValue.put(singletonValue.type, iv);
var index = 0;
for (paramType in asmMethod.getArgumentTypes()) {
iv.load(index, paramType);
@@ -33,7 +33,7 @@ trait IntervalWithHandler {
val startLabel: LabelNode
val endLabel: LabelNode
val handler: LabelNode
val `type`: String?
val type: String?
}
class TryCatchBlockNodeInfo(val node: TryCatchBlockNode, val onlyCopyNotProcess: Boolean) : IntervalWithHandler {
@@ -44,15 +44,15 @@ class TryCatchBlockNodeInfo(val node: TryCatchBlockNode, val onlyCopyNotProcess:
get() = node.end
override val handler: LabelNode
get() = node.handler!!
override val `type`: String?
get() = node.`type`
override val type: String?
get() = node.type
}
class TryCatchBlockNodePosition(val nodeInfo: TryCatchBlockNodeInfo, var position: TryCatchPosition): IntervalWithHandler by nodeInfo
class TryBlockCluster<T : IntervalWithHandler>(val blocks: MutableList<T>) {
val defaultHandler: T?
get() = blocks.firstOrNull() { it.`type` == null }
get() = blocks.firstOrNull() { it.type == null }
}
@@ -67,8 +67,8 @@ public class JetPsiFactory(private val project: Project) {
return (property.getInitializer() as JetCallExpression).getTypeArgumentList()!!
}
public fun createType(`type`: String): JetTypeReference {
return createProperty("val x : $`type`").getTypeReference()!!
public fun createType(type: String): JetTypeReference {
return createProperty("val x : $type").getTypeReference()!!
}
public fun createStar(): PsiElement {
@@ -152,13 +152,13 @@ public class JetPsiFactory(private val project: Project) {
return PsiFileFactory.getInstance(project).createFileFromText(fileName, JetFileType.INSTANCE, text, LocalTimeCounter.currentTime(), true) as JetFile
}
public fun createProperty(name: String, `type`: String?, isVar: Boolean, initializer: String?): JetProperty {
val text = (if (isVar) "var " else "val ") + name + (if (`type` != null) ":" + `type` else "") + (if (initializer == null) "" else " = " + initializer)
public fun createProperty(name: String, type: String?, isVar: Boolean, initializer: String?): JetProperty {
val text = (if (isVar) "var " else "val ") + name + (if (type != null) ":" + type else "") + (if (initializer == null) "" else " = " + initializer)
return createProperty(text)
}
public fun createProperty(name: String, `type`: String?, isVar: Boolean): JetProperty {
return createProperty(name, `type`, isVar, null)
public fun createProperty(name: String, type: String?, isVar: Boolean): JetProperty {
return createProperty(name, type, isVar, null)
}
public fun createProperty(text: String): JetProperty {
@@ -545,14 +545,14 @@ public class JetPsiFactory(private val project: Project) {
return this
}
public fun param(name: String, `type`: String): CallableBuilder {
public fun param(name: String, type: String): CallableBuilder {
assert(target == Target.FUNCTION)
assert(state == State.FIRST_PARAM || state == State.REST_PARAMS)
if (state == State.REST_PARAMS) {
sb.append(", ")
}
sb.append(name).append(": ").append(`type`)
sb.append(name).append(": ").append(type)
if (state == State.FIRST_PARAM) {
state = State.REST_PARAMS
}
@@ -560,9 +560,9 @@ public class JetPsiFactory(private val project: Project) {
return this
}
public fun returnType(`type`: String): CallableBuilder {
public fun returnType(type: String): CallableBuilder {
closeParams()
sb.append(": ").append(`type`)
sb.append(": ").append(type)
return this
}
@@ -154,7 +154,7 @@ class LazyJavaAnnotationDescriptor(
private fun resolveFromJavaClassObjectType(javaType: JavaType): CompileTimeConstant<*>? {
// Class type is never nullable in 'Foo.class' in Java
val `type` = TypeUtils.makeNotNullable(c.typeResolver.transformJavaType(
val type = TypeUtils.makeNotNullable(c.typeResolver.transformJavaType(
javaType,
TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes(allowFlexible = false))
)
@@ -162,7 +162,7 @@ class LazyJavaAnnotationDescriptor(
val jlClass = c.packageFragmentProvider.module.resolveTopLevelClass(FqName("java.lang.Class"))
if (jlClass == null) return null
val arguments = listOf(TypeProjectionImpl(`type`))
val arguments = listOf(TypeProjectionImpl(type))
val javaClassObjectType = object : LazyJavaType(c.storageManager) {
override fun computeTypeConstructor() = jlClass.getTypeConstructor()
@@ -54,12 +54,12 @@ public trait Eval {
}
class SingleInstructionInterpreter(private val eval: Eval) : Interpreter<Value>(ASM5) {
override fun newValue(`type`: Type?): Value? {
if (`type` == null) {
override fun newValue(type: Type?): Value? {
if (type == null) {
return NOT_A_VALUE
}
return makeNotInitializedValue(`type`)
return makeNotInitializedValue(type)
}
override fun newOperation(insn: AbstractInsnNode): Value? {
@@ -103,7 +103,7 @@ public fun interpreterLoop(
fun exceptionCaught(exceptionValue: Value, instanceOf: (Type) -> Boolean): Boolean {
val catchBlocks = handlers[m.instructions.indexOf(currentInsn)] ?: listOf()
for (catch in catchBlocks) {
val exceptionTypeInternalName = catch.`type`
val exceptionTypeInternalName = catch.type
if (exceptionTypeInternalName != null) {
val exceptionType = Type.getObjectType(exceptionTypeInternalName)
if (instanceOf(exceptionType)) {
+10 -10
View File
@@ -35,14 +35,14 @@ public class JDIEval(
) : Eval {
private val primitiveTypes = mapOf(
Type.BOOLEAN_TYPE.getClassName() to vm.mirrorOf(true).`type`(),
Type.BYTE_TYPE.getClassName() to vm.mirrorOf(1.toByte()).`type`(),
Type.SHORT_TYPE.getClassName() to vm.mirrorOf(1.toShort()).`type`(),
Type.INT_TYPE.getClassName() to vm.mirrorOf(1.toInt()).`type`(),
Type.CHAR_TYPE.getClassName() to vm.mirrorOf('1').`type`(),
Type.LONG_TYPE.getClassName() to vm.mirrorOf(1L).`type`(),
Type.FLOAT_TYPE.getClassName() to vm.mirrorOf(1.0f).`type`(),
Type.DOUBLE_TYPE.getClassName() to vm.mirrorOf(1.0).`type`()
Type.BOOLEAN_TYPE.getClassName() to vm.mirrorOf(true).type(),
Type.BYTE_TYPE.getClassName() to vm.mirrorOf(1.toByte()).type(),
Type.SHORT_TYPE.getClassName() to vm.mirrorOf(1.toShort()).type(),
Type.INT_TYPE.getClassName() to vm.mirrorOf(1.toInt()).type(),
Type.CHAR_TYPE.getClassName() to vm.mirrorOf('1').type(),
Type.LONG_TYPE.getClassName() to vm.mirrorOf(1L).type(),
Type.FLOAT_TYPE.getClassName() to vm.mirrorOf(1.0f).type(),
Type.DOUBLE_TYPE.getClassName() to vm.mirrorOf(1.0).type()
)
override fun loadClass(classType: Type): Value {
@@ -178,7 +178,7 @@ public class JDIEval(
throwBrokenCodeException(NoSuchFieldError("Can't a field in a non-class: $field"))
}
val jdiValue = newValue.asJdiValue(vm, field.`type`().asType())
val jdiValue = newValue.asJdiValue(vm, field.type().asType())
mayThrow { _class.setValue(field, jdiValue) }
}
@@ -220,7 +220,7 @@ public class JDIEval(
val field = findField(fieldDesc)
val obj = instance.jdiObj.checkNull()
val jdiValue = newValue.asJdiValue(vm, field.`type`().asType())
val jdiValue = newValue.asJdiValue(vm, field.type().asType())
mayThrow { obj.setValue(field, jdiValue) }
}
@@ -63,7 +63,7 @@ public fun jdi.Value?.asValue(): Value {
is jdi.LongValue -> LongValue(longValue())
is jdi.FloatValue -> FloatValue(floatValue())
is jdi.DoubleValue -> DoubleValue(doubleValue())
is jdi.ObjectReference -> ObjectValue(this, `type`().asType())
is jdi.ObjectReference -> ObjectValue(this, type().asType())
else -> throw JDIFailureException("Unknown value: $this")
}
}
@@ -74,10 +74,10 @@ enum class Tail {
ELSE
}
open data class ExpectedInfo(val `type`: JetType, val name: String?, val tail: Tail?)
open data class ExpectedInfo(val type: JetType, val name: String?, val tail: Tail?)
class PositionalArgumentExpectedInfo(`type`: JetType, name: String?, tail: Tail?, val function: FunctionDescriptor, val argumentIndex: Int)
: ExpectedInfo(`type`, name, tail) {
class PositionalArgumentExpectedInfo(type: JetType, name: String?, tail: Tail?, val function: FunctionDescriptor, val argumentIndex: Int)
: ExpectedInfo(type, name, tail) {
override fun equals(other: Any?)
= other is PositionalArgumentExpectedInfo && super.equals(other) && function == other.function && argumentIndex == other.argumentIndex
@@ -211,13 +211,13 @@ class ExpectedInfos(val bindingContext: BindingContext, val resolveSession: Reso
return when (expressionWithType) {
ifExpression.getCondition() -> listOf(ExpectedInfo(KotlinBuiltIns.getInstance().getBooleanType(), null, Tail.RPARENTH))
ifExpression.getThen() -> calculate(ifExpression)?.map { ExpectedInfo(it.`type`, it.name, Tail.ELSE) }
ifExpression.getThen() -> calculate(ifExpression)?.map { ExpectedInfo(it.type, it.name, Tail.ELSE) }
ifExpression.getElse() -> {
val ifExpectedInfo = calculate(ifExpression)
val thenType = bindingContext[BindingContext.EXPRESSION_TYPE, ifExpression.getThen()]
if (thenType != null)
ifExpectedInfo?.filter { it.`type`.isSubtypeOf(thenType) }
ifExpectedInfo?.filter { it.type.isSubtypeOf(thenType) }
else
ifExpectedInfo
}
@@ -237,7 +237,7 @@ class ExpectedInfos(val bindingContext: BindingContext, val resolveSession: Reso
val expectedInfos = calculate(binaryExpression)
if (expectedInfos != null) {
return if (leftTypeNotNullable != null)
expectedInfos.filter { leftTypeNotNullable.isSubtypeOf(it.`type`) }
expectedInfos.filter { leftTypeNotNullable.isSubtypeOf(it.type) }
else
expectedInfos
}
@@ -252,7 +252,7 @@ class ExpectedInfos(val bindingContext: BindingContext, val resolveSession: Reso
private fun calculateForBlockExpression(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
val block = expressionWithType.getParent() as? JetBlockExpression ?: return null
if (expressionWithType != block.getStatements().last()) return null
return calculate(block)?.map { ExpectedInfo(it.`type`, it.name, null) }
return calculate(block)?.map { ExpectedInfo(it.type, it.name, null) }
}
private fun calculateForWhenEntryValue(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
@@ -88,7 +88,7 @@ private fun needExplicitParameterTypes(context: InsertionContext, placeholderRan
val resolveSession = file.getLazyResolveSession()
val bindingContext = resolveSession.resolveToElement(expression)
val expectedInfos = ExpectedInfos(bindingContext, resolveSession).calculate(expression) ?: return false
val functionTypes = expectedInfos.map { it.`type` }.filter { KotlinBuiltIns.getInstance().isExactFunctionOrExtensionFunctionType(it) }.toSet()
val functionTypes = expectedInfos.map { it.type }.filter { KotlinBuiltIns.getInstance().isExactFunctionOrExtensionFunctionType(it) }.toSet()
if (functionTypes.size <= 1) return false
val lambdaParameterCount = KotlinBuiltIns.getInstance().getParameterTypeProjectionsFromFunctionType(lambdaType).size
@@ -48,14 +48,14 @@ object KeywordValues {
if (!skipTrueFalse) {
val booleanInfoClassifier = { (info: ExpectedInfo) ->
if (info.`type` == KotlinBuiltIns.getInstance().getBooleanType()) ExpectedInfoClassification.MATCHES else ExpectedInfoClassification.NOT_MATCHES
if (info.type == KotlinBuiltIns.getInstance().getBooleanType()) ExpectedInfoClassification.MATCHES else ExpectedInfoClassification.NOT_MATCHES
}
collection.addLookupElements(expectedInfos, booleanInfoClassifier, { LookupElementBuilder.create("true").bold() })
collection.addLookupElements(expectedInfos, booleanInfoClassifier, { LookupElementBuilder.create("false").bold() })
}
collection.addLookupElements(expectedInfos,
{ info -> if (info.`type`.isNullable()) ExpectedInfoClassification.MATCHES else ExpectedInfoClassification.NOT_MATCHES },
{ info -> if (info.type.isNullable()) ExpectedInfoClassification.MATCHES else ExpectedInfoClassification.NOT_MATCHES },
{ LookupElementBuilder.create("null").bold() })
}
}
@@ -28,7 +28,7 @@ import org.jetbrains.jet.plugin.completion.suppressAutoInsertion
object LambdaItems {
public fun addToCollection(collection: MutableCollection<LookupElement>, functionExpectedInfos: Collection<ExpectedInfo>) {
val distinctTypes = functionExpectedInfos.map { it.`type` }.toSet()
val distinctTypes = functionExpectedInfos.map { it.type }.toSet()
val singleType = if (distinctTypes.size == 1) distinctTypes.single() else null
val singleSignatureLength = singleType?.let { KotlinBuiltIns.getInstance().getParameterTypeProjectionsFromFunctionType(it).size }
@@ -53,7 +53,7 @@ object LambdaItems {
insertLambdaTemplate(context, TextRange(offset, offset + placeholder.length), functionType)
})
.suppressAutoInsertion()
.addTailAndNameSimilarity(functionExpectedInfos.filter { it.`type` == functionType })
.addTailAndNameSimilarity(functionExpectedInfos.filter { it.type == functionType })
lookupElement.putUserData(JetCompletionCharFilter.ACCEPT_OPENING_BRACE, true)
collection.add(lookupElement)
}
@@ -89,12 +89,12 @@ class SmartCompletion(val expression: JetSimpleNameExpression,
}
val allExpectedInfos = calcExpectedInfos(expressionWithType) ?: return null
val filteredExpectedInfos = allExpectedInfos.filter { !it.`type`.isError() }
val filteredExpectedInfos = allExpectedInfos.filter { !it.type.isError() }
if (filteredExpectedInfos.isEmpty()) return null
// if we complete argument of == or !=, make types in expected info's nullable to allow nullable items too
val expectedInfos = if ((expressionWithType.getParent() as? JetBinaryExpression)?.getOperationToken() in setOf(JetTokens.EQEQ, JetTokens.EXCLEQ))
filteredExpectedInfos.map { ExpectedInfo(it.`type`.makeNullable(), it.name, it.tail) }
filteredExpectedInfos.map { ExpectedInfo(it.type.makeNullable(), it.name, it.tail) }
else
filteredExpectedInfos
@@ -102,7 +102,7 @@ class SmartCompletion(val expression: JetSimpleNameExpression,
val itemsToSkip = calcItemsToSkip(expressionWithType)
val functionExpectedInfos = expectedInfos.filter { KotlinBuiltIns.getInstance().isExactFunctionOrExtensionFunctionType(it.`type`) }
val functionExpectedInfos = expectedInfos.filter { KotlinBuiltIns.getInstance().isExactFunctionOrExtensionFunctionType(it.type) }
fun filterDeclaration(descriptor: DeclarationDescriptor): Collection<LookupElement> {
val result = ArrayList<LookupElement>()
@@ -111,8 +111,8 @@ class SmartCompletion(val expression: JetSimpleNameExpression,
val nonNullTypes = types.map { it.makeNotNullable() }
val classifier = { (expectedInfo: ExpectedInfo) ->
when {
types.any { it.isSubtypeOf(expectedInfo.`type`) } -> ExpectedInfoClassification.MATCHES
nonNullTypes.any { it.isSubtypeOf(expectedInfo.`type`) } -> ExpectedInfoClassification.MAKE_NOT_NULLABLE
types.any { it.isSubtypeOf(expectedInfo.type) } -> ExpectedInfoClassification.MATCHES
nonNullTypes.any { it.isSubtypeOf(expectedInfo.type) } -> ExpectedInfoClassification.MAKE_NOT_NULLABLE
else -> ExpectedInfoClassification.NOT_MATCHES
}
}
@@ -234,7 +234,7 @@ class SmartCompletion(val expression: JetSimpleNameExpression,
val functionType = functionType(descriptor)
if (functionType == null) return null
val matchedExpectedInfos = functionExpectedInfos.filter { functionType.isSubtypeOf(it.`type`) }
val matchedExpectedInfos = functionExpectedInfos.filter { functionType.isSubtypeOf(it.type) }
if (matchedExpectedInfos.isEmpty()) return null
var lookupElement = createLookupElement(descriptor, resolveSession)
@@ -278,7 +278,7 @@ class SmartCompletion(val expression: JetSimpleNameExpression,
if (elementType != JetTokens.AS_KEYWORD && elementType != JetTokens.AS_SAFE) return null
val expectedInfos = calcExpectedInfos(binaryExpression) ?: return null
val expectedInfosGrouped: Map<JetType, List<ExpectedInfo>> = expectedInfos.groupBy { it.`type`.makeNotNullable() }
val expectedInfosGrouped: Map<JetType, List<ExpectedInfo>> = expectedInfos.groupBy { it.type.makeNotNullable() }
val items = ArrayList<LookupElement>()
for ((jetType, infos) in expectedInfosGrouped) {
@@ -44,7 +44,7 @@ class StaticMembers(val bindingContext: BindingContext, val resolveSession: Reso
val scope = bindingContext[BindingContext.RESOLUTION_SCOPE, context]
if (scope == null) return
val expectedInfosByClass = expectedInfos.groupBy { TypeUtils.getClassDescriptor(it.`type`) }
val expectedInfosByClass = expectedInfos.groupBy { TypeUtils.getClassDescriptor(it.type) }
for ((classDescriptor, expectedInfosForClass) in expectedInfosByClass) {
if (classDescriptor != null && !classDescriptor.getName().isSpecial()) {
addToCollection(collection, classDescriptor, expectedInfosForClass, scope, enumEntriesToSkip)
@@ -69,8 +69,8 @@ class StaticMembers(val bindingContext: BindingContext, val resolveSession: Reso
classifier = {
expectedInfo ->
when {
returnType.isSubtypeOf(expectedInfo.`type`) -> ExpectedInfoClassification.MATCHES
returnType.isNullable() && returnType.makeNotNullable().isSubtypeOf(expectedInfo.`type`) -> ExpectedInfoClassification.MAKE_NOT_NULLABLE
returnType.isSubtypeOf(expectedInfo.type) -> ExpectedInfoClassification.MATCHES
returnType.isNullable() && returnType.makeNotNullable().isSubtypeOf(expectedInfo.type) -> ExpectedInfoClassification.MAKE_NOT_NULLABLE
else -> ExpectedInfoClassification.NOT_MATCHES
}
}
@@ -80,7 +80,7 @@ class StaticMembers(val bindingContext: BindingContext, val resolveSession: Reso
}
else if (descriptor is ClassDescriptor && DescriptorUtils.isObject(descriptor)) {
classifier = { expectedInfo ->
if (descriptor.getDefaultType().isSubtypeOf(expectedInfo.`type`)) ExpectedInfoClassification.MATCHES else ExpectedInfoClassification.NOT_MATCHES
if (descriptor.getDefaultType().isSubtypeOf(expectedInfo.type)) ExpectedInfoClassification.MATCHES else ExpectedInfoClassification.NOT_MATCHES
}
}
else {
@@ -43,8 +43,8 @@ class ThisItems(val bindingContext: BindingContext) {
val thisType = receiver.getType()
val classifier = { (expectedInfo: ExpectedInfo) ->
when {
thisType.isSubtypeOf(expectedInfo.`type`) -> ExpectedInfoClassification.MATCHES
thisType.isNullable() && thisType.makeNotNullable().isSubtypeOf(expectedInfo.`type`) -> ExpectedInfoClassification.MAKE_NOT_NULLABLE
thisType.isSubtypeOf(expectedInfo.type) -> ExpectedInfoClassification.MATCHES
thisType.isNullable() && thisType.makeNotNullable().isSubtypeOf(expectedInfo.type) -> ExpectedInfoClassification.MAKE_NOT_NULLABLE
else -> ExpectedInfoClassification.NOT_MATCHES
}
}
@@ -39,7 +39,7 @@ import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers
class TypeInstantiationItems(val resolveSession: ResolveSessionForBodies, val visibilityFilter: (DeclarationDescriptor) -> Boolean) {
public fun addToCollection(collection: MutableCollection<LookupElement>, expectedInfos: Collection<ExpectedInfo>) {
val expectedInfosGrouped: Map<JetType, List<ExpectedInfo>> = expectedInfos.groupBy { it.`type`.makeNotNullable() }
val expectedInfosGrouped: Map<JetType, List<ExpectedInfo>> = expectedInfos.groupBy { it.type.makeNotNullable() }
for ((jetType, infos) in expectedInfosGrouped) {
val tail = mergeTails(infos.map { it.tail })
addToCollection(collection, jetType, tail)
@@ -31,7 +31,7 @@ class DelegatedPropertyFieldDescriptor(
append(getName())
if (classRenderer.SHOW_DECLARED_TYPE) {
append(": ")
append(classRenderer.renderTypeName(getValue()?.`type`()?.name()))
append(classRenderer.renderTypeName(getValue()?.type()?.name()))
}
toString()
}
@@ -30,9 +30,9 @@ fun specifyTypeExplicitly(declaration: JetNamedFunction, typeText: String) {
specifyTypeExplicitly(declaration, JetPsiFactory(declaration).createType(typeText))
}
fun specifyTypeExplicitly(declaration: JetNamedFunction, `type`: JetType) {
if (`type`.isError()) return
val typeReference = JetPsiFactory(declaration).createType(IdeDescriptorRenderers.SOURCE_CODE.renderType(`type`))
fun specifyTypeExplicitly(declaration: JetNamedFunction, type: JetType) {
if (type.isError()) return
val typeReference = JetPsiFactory(declaration).createType(IdeDescriptorRenderers.SOURCE_CODE.renderType(type))
specifyTypeExplicitly(declaration, typeReference)
ShortenReferences.process(declaration.getTypeReference()!!)
}
@@ -111,13 +111,13 @@ public class BasicCompletionHandlerTest : CompletionHandlerTestBase(){
fun testSingleBrackets() {
fixture.configureByFile(fileName())
fixture.`type`('(')
fixture.type('(')
checkResult()
}
fun testInsertFunctionWithBothParentheses() {
fixture.configureByFile(fileName())
fixture.`type`("test()")
fixture.type("test()")
checkResult()
}
@@ -138,7 +138,7 @@ public abstract class CompletionHandlerTestBase() : JetLightCodeInsightFixtureTe
}).execute().throwException()
}
else {
fixture.`type`(completionChar)
fixture.type(completionChar)
}
}
}
@@ -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(".")) {
+1 -1
View File
@@ -86,7 +86,7 @@ native public trait DOMConfiguration {
}
native public trait DOMError {
public val `type`: String
public val type: String
public val location: DOMLocator
public val message: String
public val relatedData: Any
+1 -1
View File
@@ -18,7 +18,7 @@ native public trait DocumentEvent {
}
native public trait Event {
public val `type`: String
public val type: String
public val bubbles: Boolean
public val cancelable: Boolean
public val currentTarget: EventTarget
+14 -14
View File
@@ -72,7 +72,7 @@ public native trait Event {
public native var width: Double
public native var modifiers: Double
public native var keyCode: Double
public native var `type`: String
public native var type: String
public native var which: Any
public native var altKey: Boolean
public native var ctrlKey: Boolean
@@ -258,7 +258,7 @@ public native trait HTMLLinkElement : HTMLElement {
public native var rel: String
public native var rev: String
public native var target: String
public native var `type`: String
public native var type: String
}
public native trait HTMLTitleElement : HTMLElement {
@@ -285,7 +285,7 @@ public native trait HTMLIsIndexElement : HTMLElement {
public native trait HTMLStyleElement : HTMLElement {
public native var disabled: Boolean
public native var media: String
public native var `type`: String
public native var type: String
}
public native trait HTMLBodyElement : HTMLElement {
@@ -313,7 +313,7 @@ public native trait HTMLFormElement {
}
public native trait HTMLSelectElement : HTMLElement {
public native val `type`: String
public native val type: String
public native var selectedIndex: Double
public native var value: String
public native var length: Double
@@ -362,7 +362,7 @@ public native trait HTMLInputElement : HTMLElement {
public native var size: Double
public native var src: String
public native var tabIndex: Double
public native var `type`: String
public native var type: String
public native var useMap: String
public native var value: String
public native fun blur(): Unit
@@ -383,7 +383,7 @@ public native trait HTMLTextAreaElement : HTMLElement {
public native var readOnly: Boolean
public native var rows: Double
public native var tabIndex: Double
public native var `type`: String
public native var type: String
public native var value: String
public native fun blur(): Unit
public native fun focus(): Unit
@@ -396,7 +396,7 @@ public native trait HTMLButtonElement : HTMLElement {
public native var disabled: Boolean
public native var name: String
public native var tabIndex: Double
public native var `type`: String
public native var type: String
public native var value: String
}
@@ -418,13 +418,13 @@ public native trait HTMLLegendElement : HTMLElement {
public native trait HTMLUListElement : HTMLElement {
public native var compact: Boolean
public native var `type`: String
public native var type: String
}
public native trait HTMLOListElement : HTMLElement {
public native var compact: Boolean
public native var start: Double
public native var `type`: String
public native var type: String
}
public native trait HTMLDListElement : HTMLElement {
@@ -440,7 +440,7 @@ public native trait HTMLMenuElement : HTMLElement {
}
public native trait HTMLLIElement : HTMLElement {
public native var `type`: String
public native var type: String
public native var value: Double
}
@@ -504,7 +504,7 @@ public native trait HTMLAnchorElement : HTMLElement {
public native var shape: String
public native var tabIndex: Double
public native var target: String
public native var `type`: String
public native var type: String
public native fun blur(): Unit
public native fun focus(): Unit
}
@@ -539,7 +539,7 @@ public native trait HTMLObjectElement : HTMLElement {
public native var name: String
public native var standby: String
public native var tabIndex: Double
public native var `type`: String
public native var type: String
public native var useMap: String
public native var vspace: Double
public native var width: String
@@ -548,7 +548,7 @@ public native trait HTMLObjectElement : HTMLElement {
public native trait HTMLParamElement : HTMLElement {
public native var name: String
public native var `type`: String
public native var type: String
public native var value: String
public native var valueType: String
}
@@ -590,7 +590,7 @@ public native trait HTMLScriptElement : HTMLElement {
public native var charset: String
public native var defer: Boolean
public native var src: String
public native var `type`: String
public native var type: String
}
public native trait HTMLTableElement : HTMLElement {
+1 -1
View File
@@ -27,7 +27,7 @@ public class File() : Blob() {
native
public open class Blob() {
public val size : Int = noImpl
public val `type` : String = noImpl
public val type : String = noImpl
//Blob slice(optional long long start,
//optional long long end,
//optional DOMString contentType);
@@ -36,9 +36,9 @@ class HtmlKotlinVisitor: JetTreeVisitor<StringBuilder>() {
return super.visitClassBody(classBody, data)
}
override fun visitFunctionType(`type`: JetFunctionType, data: StringBuilder?): Void? {
println("======================= function Type $`type`")
return super.visitFunctionType(`type`, data)
override fun visitFunctionType(type: JetFunctionType, data: StringBuilder?): Void? {
println("======================= function Type $type")
return super.visitFunctionType(type, data)
}
protected fun accept(child: PsiElement?, data: StringBuilder?): Unit {
@@ -99,8 +99,8 @@ $imports
val name = method.getName() ?: ""
fun propertyName(): String {
val answer = name.substring(3).decapitalize()
return if (answer == "type") {
"`type`"
return if (answer == "typealias") {
"typealias"
} else answer
}
fun propertyType() = simpleTypeName(method.getReturnType())