Unverified Commit 8c44a5b1 authored by Bryan Liles's avatar Bryan Liles Committed by GitHub
Browse files

Merge pull request #498 from bryanl/updating-ksonnet-lib-printer

updating ksonnet-lib to v0.1.3
parents b0012b7e db01a3df
......@@ -276,8 +276,8 @@
"ksonnet-gen/nodemaker",
"ksonnet-gen/printer"
]
revision = "cd6bc29c939b79f8e3acdd289356b8fbebf09c50"
version = "v0.1.2"
revision = "d15220fdcdd07fd377894abff6276d86cb2d776d"
version = "v0.1.3"
[[projects]]
name = "github.com/magiconair/properties"
......@@ -683,6 +683,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "066e8e0e2eb8273f1f1249c55430ee212d20b3ebe5db9b7070d7e61cf2e61524"
inputs-digest = "4723225126a0d372380758876922a0039f08308216c8dce85461e7c7c742351f"
solver-name = "gps-cdcl"
solver-version = 1
......@@ -50,7 +50,7 @@
[[constraint]]
name = "github.com/ksonnet/ksonnet-lib"
version = "v0.1.2"
version = "v0.1.3"
[[constraint]]
name = "github.com/mattn/go-isatty"
......
......@@ -112,6 +112,12 @@ func (p *printer) writeString(s string) {
}
}
func (p *printer) writeStringNoIndent(s string) {
for _, b := range []byte(s) {
p.output = append(p.output, b)
}
}
// printer prints a node.
// nolint: gocyclo
func (p *printer) print(n interface{}) {
......@@ -158,6 +164,8 @@ func (p *printer) print(n interface{}) {
p.print(t.Right)
case *ast.Conditional:
p.handleConditional(t)
case *ast.Dollar:
p.writeString("$")
case *ast.Function:
p.writeString("function")
p.addMethodSignature(t)
......@@ -242,6 +250,11 @@ func (p *printer) print(n interface{}) {
p.writeString(strconv.Quote(t.Value))
case ast.StringSingle:
p.writeString(fmt.Sprintf("'%s'", t.Value))
case ast.StringBlock:
p.writeString("|||")
p.writeByte(newline, 1)
p.writeString(t.Value)
p.writeStringNoIndent("\n|||")
}
case *ast.LiteralNumber:
......@@ -254,6 +267,9 @@ func (p *printer) print(n interface{}) {
p.writeString(string(t.Id))
case *ast.LiteralNull:
p.writeString("null")
case *ast.SuperIndex:
p.writeString("super.")
p.writeString(string(*t.Id))
}
}
......@@ -585,6 +601,9 @@ func indexID(i *ast.Index) (string, error) {
switch t := i.Index.(type) {
default:
return "", errors.Errorf("can't handle index type %T", t)
case *ast.LiteralNumber:
id := t.OriginalString
return fmt.Sprintf(`[%s]`, id), nil
case *ast.LiteralString:
if t == nil {
return "", errors.New("string id is nil")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment