Skip to content

Commit 8a0061b

Browse files
committed
Support (partially) EnumValueType
1 parent ce3488f commit 8a0061b

File tree

4 files changed

+39
-21
lines changed

4 files changed

+39
-21
lines changed

jacodb-ets/src/main/kotlin/org/jacodb/ets/dto/EtsTypeToDto.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.jacodb.ets.model.EtsAnyType
2121
import org.jacodb.ets.model.EtsArrayType
2222
import org.jacodb.ets.model.EtsBooleanType
2323
import org.jacodb.ets.model.EtsClassType
24+
import org.jacodb.ets.model.EtsEnumValueType
2425
import org.jacodb.ets.model.EtsFunctionType
2526
import org.jacodb.ets.model.EtsGenericType
2627
import org.jacodb.ets.model.EtsIntersectionType
@@ -55,11 +56,11 @@ private object EtsTypeToDto : EtsType.Visitor<TypeDto> {
5556
}
5657

5758
override fun visit(type: EtsUnionType): TypeDto {
58-
return UnionTypeDto(types = type.types.map { it.accept(this) })
59+
return UnionTypeDto(types = type.types.map { it.toDto() })
5960
}
6061

6162
override fun visit(type: EtsIntersectionType): TypeDto {
62-
return IntersectionTypeDto(types = type.types.map { it.accept(this) })
63+
return IntersectionTypeDto(types = type.types.map { it.toDto() })
6364
}
6465

6566
override fun visit(type: EtsGenericType): TypeDto {
@@ -81,6 +82,13 @@ private object EtsTypeToDto : EtsType.Visitor<TypeDto> {
8182
)
8283
}
8384

85+
override fun visit(type: EtsEnumValueType): TypeDto {
86+
return EnumValueTypeDto(
87+
signature = type.signature.toDto(),
88+
constant = type.constant?.toDto(),
89+
)
90+
}
91+
8492
override fun visit(type: EtsBooleanType): TypeDto {
8593
return BooleanTypeDto
8694
}
@@ -153,7 +161,7 @@ private object EtsTypeToDto : EtsType.Visitor<TypeDto> {
153161
}
154162

155163
override fun visit(type: EtsTupleType): TypeDto {
156-
return TupleTypeDto(types = type.types.map { it.accept(this) })
164+
return TupleTypeDto(types = type.types.map { it.toDto() })
157165
}
158166

159167
override fun visit(type: EtsFunctionType): TypeDto {

jacodb-ets/src/main/kotlin/org/jacodb/ets/dto/EtsValueToDto.kt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,43 +32,43 @@ import org.jacodb.ets.model.EtsValue
3232

3333
fun EtsValue.toDto(): ValueDto = accept(EtsValueToDto)
3434

35-
private object EtsValueToDto : EtsValue.Visitor<ValueDto> {
36-
override fun visit(value: EtsLocal): ValueDto {
37-
return LocalDto(
38-
name = value.name,
39-
type = value.type.toDto(),
40-
)
41-
}
35+
fun EtsLocal.toDto(): LocalDto = LocalDto(
36+
name = name,
37+
type = type.toDto(),
38+
)
4239

43-
private fun visitConstant(value: EtsConstant): ValueDto {
44-
return ConstantDto(
45-
value = value.toString(),
46-
type = value.type.toDto(),
47-
)
40+
fun EtsConstant.toDto(): ConstantDto = ConstantDto(
41+
value = toString(),
42+
type = type.toDto(),
43+
)
44+
45+
private object EtsValueToDto : EtsValue.Visitor<ValueDto> {
46+
override fun visit(value: EtsLocal): LocalDto {
47+
return value.toDto()
4848
}
4949

5050
override fun visit(value: EtsConstant): ValueDto {
51-
return visitConstant(value)
51+
return value.toDto()
5252
}
5353

5454
override fun visit(value: EtsStringConstant): ValueDto {
55-
return visitConstant(value)
55+
return value.toDto()
5656
}
5757

5858
override fun visit(value: EtsBooleanConstant): ValueDto {
59-
return visitConstant(value)
59+
return value.toDto()
6060
}
6161

6262
override fun visit(value: EtsNumberConstant): ValueDto {
63-
return visitConstant(value)
63+
return value.toDto()
6464
}
6565

6666
override fun visit(value: EtsNullConstant): ValueDto {
67-
return visitConstant(value)
67+
return value.toDto()
6868
}
6969

7070
override fun visit(value: EtsUndefinedConstant): ValueDto {
71-
return visitConstant(value)
71+
return value.toDto()
7272
}
7373

7474
override fun visit(value: EtsThis): ValueDto {

jacodb-ets/src/main/kotlin/org/jacodb/ets/grpc/EtsTypeToProto.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import org.jacodb.ets.model.EtsAnyType
4141
import org.jacodb.ets.model.EtsArrayType
4242
import org.jacodb.ets.model.EtsBooleanType
4343
import org.jacodb.ets.model.EtsClassType
44+
import org.jacodb.ets.model.EtsEnumValueType
4445
import org.jacodb.ets.model.EtsFunctionType
4546
import org.jacodb.ets.model.EtsGenericType
4647
import org.jacodb.ets.model.EtsIntersectionType
@@ -112,6 +113,10 @@ private class EtsTypeToProto(
112113
}
113114
}
114115

116+
override fun visit(type: EtsEnumValueType) {
117+
TODO("${type::class.java.simpleName} is not supported yet")
118+
}
119+
115120
override fun visit(type: EtsBooleanType) {
116121
dsl.booleanType = booleanType { }
117122
}

jacodb-ets/src/main/kotlin/org/jacodb/ets/proto/EtsTypeToProto.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.jacodb.ets.model.EtsAnyType
2121
import org.jacodb.ets.model.EtsArrayType
2222
import org.jacodb.ets.model.EtsBooleanType
2323
import org.jacodb.ets.model.EtsClassType
24+
import org.jacodb.ets.model.EtsEnumValueType
2425
import org.jacodb.ets.model.EtsFunctionType
2526
import org.jacodb.ets.model.EtsGenericType
2627
import org.jacodb.ets.model.EtsIntersectionType
@@ -85,6 +86,10 @@ private object EtsTypeToProto : EtsType.Visitor<IProtoType> {
8586
)
8687
}
8788

89+
override fun visit(type: EtsEnumValueType): IProtoType {
90+
TODO("${type::class.java.simpleName} is not supported yet")
91+
}
92+
8893
override fun visit(type: EtsBooleanType): IProtoType {
8994
return ProtoBooleanType
9095
}

0 commit comments

Comments
 (0)