ToString for type notation might be done now?

This commit is contained in:
Sasha Koshka 2022-09-16 12:00:16 -04:00
parent 319b60bfcd
commit 2111960f6d

View File

@ -67,12 +67,22 @@ func (identifier Identifier) ToString () (output string) {
} }
func (values ObjectDefaultValues) ToString (indent int) (output string) { func (values ObjectDefaultValues) ToString (indent int) (output string) {
output += doIndent(indent, "(\n")
for name, value := range values {
output += doIndent (
indent,
name + ":" + value.ToString(indent, true))
}
output += doIndent(indent, ")\n")
return return
} }
func (values ArrayDefaultValues) ToString (indent int) (output string) { func (values ArrayDefaultValues) ToString (indent int) (output string) {
output += doIndent(indent, "<\n")
for _, value := range values {
output += doIndent(indent, value.ToString(indent, true))
}
output += doIndent(indent, ">\n")
return return
} }
@ -99,13 +109,12 @@ func (what Type) ToString (indent int) (output string) {
} }
if what.members != nil { if what.members != nil {
output += ":(" output += ":\n" + doIndent(indent, "(\n")
for _, member := range what.members { for _, member := range what.members {
output += doIndent ( output += doIndent (
indent, indent, member.ToString(indent + 1), "\n")
"\n" + member.ToString(indent + 1))
} }
output += ")" output += doIndent(indent, ")")
} }
defaultValueKind := what.defaultValue.kind defaultValueKind := what.defaultValue.kind
@ -117,13 +126,12 @@ func (what Type) ToString (indent int) (output string) {
if isComplexDefaultValue { if isComplexDefaultValue {
output += ":\n" output += ":\n"
output += what.defaultValue.ToString(indent, true) output += what.defaultValue.ToString(indent, true)
} else {
output += ":<"
output += what.defaultValue.ToString(indent, true)
output += ">\n"
} }
} }
if what.defaultValue.kind == ArgumentKindObjectDefaultValues {
} else if what.defaultValue.kind != ArgumentKindNil {
output += ":<" + what.defaultValue.ToString(indent, true) + ">"
}
return return
} }
@ -150,10 +158,12 @@ func (argument Argument) ToString (indent int, breakLine bool) (output string) {
case ArgumentKindObjectDefaultValues: case ArgumentKindObjectDefaultValues:
output += argument.value.(ObjectDefaultValues). output += argument.value.(ObjectDefaultValues).
ToString(indent) ToString(indent)
if breakLine { output += "\n" }
case ArgumentKindArrayDefaultValues: case ArgumentKindArrayDefaultValues:
output += argument.value.(ArrayDefaultValues). output += argument.value.(ArrayDefaultValues).
ToString(indent) ToString(indent)
if breakLine { output += "\n" }
case ArgumentKindIdentifier: case ArgumentKindIdentifier:
output += doIndent ( output += doIndent (