Skip to content

Commit 1b6b8fd

Browse files
committed
Fix toDotLabel for types
1 parent 2f69601 commit 1b6b8fd

1 file changed

Lines changed: 22 additions & 14 deletions

File tree

jacodb-ets/src/main/kotlin/org/jacodb/ets/utils/CfgDtoToDot.kt

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,27 @@ private fun TypeDto.toDotLabel(): String {
227227
is StringTypeDto -> "string"
228228
is BooleanTypeDto -> "boolean"
229229

230+
is LiteralTypeDto -> when (literal) {
231+
is PrimitiveLiteralDto.StringLiteral -> "\"${literal.value}\""
232+
is PrimitiveLiteralDto.NumberLiteral -> literal.value.toString()
233+
is PrimitiveLiteralDto.BooleanLiteral -> literal.value.toString()
234+
}
235+
230236
// Complex types
231-
is ClassTypeDto -> signature.name
237+
is ClassTypeDto -> if (typeParameters.isNotEmpty()) {
238+
val generics = typeParameters.joinToString(", ") { it.toDotLabel() }
239+
"${signature.name}<$generics>"
240+
} else {
241+
signature.name
242+
}
243+
244+
is UnclearReferenceTypeDto -> if (typeParameters.isNotEmpty()) {
245+
val generics = typeParameters.joinToString(", ") { it.toDotLabel() }
246+
"$name<$generics>"
247+
} else {
248+
name
249+
}
250+
232251
is ArrayTypeDto -> "${elementType.toDotLabel()}${"[]".repeat(dimensions)}"
233252
is TupleTypeDto -> types.joinToString(", ", "[", "]") { it.toDotLabel() }
234253

@@ -249,20 +268,9 @@ private fun TypeDto.toDotLabel(): String {
249268

250269
// Special types
251270
is GenericTypeDto -> name
252-
is AliasTypeDto -> name
271+
is AliasTypeDto -> "$name=${originalType.toDotLabel()}"
253272
is EnumValueTypeDto -> "${signature.name}${name?.let { ".$it" } ?: ""}"
254-
is LexicalEnvTypeDto -> "LexicalEnv<${method.name}>"
255-
256-
is LiteralTypeDto -> when (literal) {
257-
is PrimitiveLiteralDto.StringLiteral -> "\"${literal.value}\""
258-
is PrimitiveLiteralDto.NumberLiteral -> literal.value.toString()
259-
is PrimitiveLiteralDto.BooleanLiteral -> literal.value.toString()
260-
}
261-
262-
is UnclearReferenceTypeDto -> {
263-
if (typeParameters.isEmpty()) name
264-
else "$name<${typeParameters.joinToString(", ") { it.toDotLabel() }}>"
265-
}
273+
is LexicalEnvTypeDto -> "<${method.name}>(${closures.joinToString { it.name }})"
266274

267275
// Raw type
268276
is RawTypeDto -> "raw:$kind"

0 commit comments

Comments
 (0)