New J2K: Add TypeElement.present() function

This commit is contained in:
Ilya Kirillov
2018-11-08 17:54:30 +03:00
committed by Ilya Kirillov
parent 77713c1877
commit ff700b5399
2 changed files with 6 additions and 4 deletions
@@ -234,11 +234,10 @@ class NewCodeBuilder {
ktProperty.modifierList.accept(this) ktProperty.modifierList.accept(this)
printer.printWithNoIndent(" ", ktProperty.name.value) printer.printWithNoIndent(" ", ktProperty.name.value)
if (ktProperty.type.type != JKNoTypeImpl) { if (ktProperty.type.present()) {
printer.printWithNoIndent(":") printer.printWithNoIndent(":")
ktProperty.type.accept(this) ktProperty.type.accept(this)
} }
ktProperty.type.accept(this)
if (ktProperty.initializer !is JKStubExpression) { if (ktProperty.initializer !is JKStubExpression) {
printer.printWithNoIndent(" = ") printer.printWithNoIndent(" = ")
ktProperty.initializer.accept(this) ktProperty.initializer.accept(this)
@@ -469,7 +468,7 @@ class NewCodeBuilder {
} }
printer.printWithNoIndent(" ", localVariable.name.value) printer.printWithNoIndent(" ", localVariable.name.value)
if (localVariable.type.type != JKContextType && localVariable.type.type !is JKNoTypeImpl) { if (localVariable.type.present() && localVariable.type.type != JKContextType) {
printer.printWithNoIndent(": ") printer.printWithNoIndent(": ")
localVariable.type.accept(this) localVariable.type.accept(this)
} }
@@ -467,4 +467,7 @@ class JKVarianceTypeParameterTypeImpl(
class JKTypeParameterTypeImpl( class JKTypeParameterTypeImpl(
override val name: String, override val name: String,
override val nullability: Nullability = Nullability.Default override val nullability: Nullability = Nullability.Default
) : JKTypeParameterType ) : JKTypeParameterType
fun JKTypeElement.present(): Boolean =
type != JKNoTypeImpl