diff --git a/encoding/toml/testdata/decode/example.txtar b/encoding/toml/testdata/decode/example.txtar index ec14a12c909..405bef1cc8a 100644 --- a/encoding/toml/testdata/decode/example.txtar +++ b/encoding/toml/testdata/decode/example.txtar @@ -41,7 +41,7 @@ color = "gray" Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:4:1").WithRel("newline") + NamePos: token.Pos("example.toml:4:1", newline) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:4:9") @@ -49,38 +49,38 @@ color = "gray" } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:6:2").WithRel("newline") + NamePos: token.Pos("example.toml:6:2", newline) } Value: *ast.StructLit{ - Lbrace: token.Pos("-").WithRel("blank") + Lbrace: token.Pos("-", blank) Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:7:1").WithRel("newline") + NamePos: token.Pos("example.toml:7:1", newline) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:7:8") } } } - Rbrace: token.Pos("-").WithRel("newline") + Rbrace: token.Pos("-", newline) } } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:11:2").WithRel("newline") + NamePos: token.Pos("example.toml:11:2", newline) } Value: *ast.StructLit{ - Lbrace: token.Pos("-").WithRel("blank") + Lbrace: token.Pos("-", blank) Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:12:1").WithRel("newline") + NamePos: token.Pos("example.toml:12:1", newline) } } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:13:1").WithRel("newline") + NamePos: token.Pos("example.toml:13:1", newline) } Value: *ast.ListLit{ Elts: []ast.Expr{ @@ -98,7 +98,7 @@ color = "gray" } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:14:1").WithRel("newline") + NamePos: token.Pos("example.toml:14:1", newline) } Value: *ast.ListLit{ Elts: []ast.Expr{ @@ -124,14 +124,14 @@ color = "gray" } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:15:1").WithRel("newline") + NamePos: token.Pos("example.toml:15:1", newline) } Value: *ast.StructLit{ Lbrace: token.Pos("example.toml:15:16") Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:15:18").WithRel("blank") + NamePos: token.Pos("example.toml:15:18", blank) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:15:24") @@ -139,45 +139,45 @@ color = "gray" } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:15:30").WithRel("blank") + NamePos: token.Pos("example.toml:15:30", blank) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:15:37") } } } - Rbrace: token.Pos("-").WithRel("blank") + Rbrace: token.Pos("-", blank) } } } - Rbrace: token.Pos("-").WithRel("newline") + Rbrace: token.Pos("-", newline) } } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:17:2").WithRel("newline") + NamePos: token.Pos("example.toml:17:2", newline) } Value: *ast.StructLit{ - Lbrace: token.Pos("-").WithRel("blank") - Rbrace: token.Pos("-").WithRel("newline") + Lbrace: token.Pos("-", blank) + Rbrace: token.Pos("-", newline) } } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:19:2").WithRel("newline") + NamePos: token.Pos("example.toml:19:2", newline) } Value: *ast.StructLit{ Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:19:10").WithRel("blank") + NamePos: token.Pos("example.toml:19:10", blank) } Value: *ast.StructLit{ - Lbrace: token.Pos("-").WithRel("blank") + Lbrace: token.Pos("-", blank) Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:20:1").WithRel("newline") + NamePos: token.Pos("example.toml:20:1", newline) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:20:6") @@ -185,14 +185,14 @@ color = "gray" } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:21:1").WithRel("newline") + NamePos: token.Pos("example.toml:21:1", newline) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:21:8") } } } - Rbrace: token.Pos("-").WithRel("newline") + Rbrace: token.Pos("-", newline) } } } @@ -200,20 +200,20 @@ color = "gray" } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:23:2").WithRel("newline") + NamePos: token.Pos("example.toml:23:2", newline) } Value: *ast.StructLit{ Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:23:10").WithRel("blank") + NamePos: token.Pos("example.toml:23:10", blank) } Value: *ast.StructLit{ - Lbrace: token.Pos("-").WithRel("blank") + Lbrace: token.Pos("-", blank) Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:24:1").WithRel("newline") + NamePos: token.Pos("example.toml:24:1", newline) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:24:6") @@ -221,14 +221,14 @@ color = "gray" } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:25:1").WithRel("newline") + NamePos: token.Pos("example.toml:25:1", newline) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:25:8") } } } - Rbrace: token.Pos("-").WithRel("newline") + Rbrace: token.Pos("-", newline) } } } @@ -236,17 +236,17 @@ color = "gray" } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:27:3").WithRel("newline") + NamePos: token.Pos("example.toml:27:3", newline) } Value: *ast.ListLit{ - Lbrack: token.Pos("-").WithRel("blank") + Lbrack: token.Pos("-", blank) Elts: []ast.Expr{ *ast.StructLit{ - Lbrace: token.Pos("-").WithRel("newline") + Lbrace: token.Pos("-", newline) Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:28:1").WithRel("newline") + NamePos: token.Pos("example.toml:28:1", newline) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:28:8") @@ -254,25 +254,25 @@ color = "gray" } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:29:1").WithRel("newline") + NamePos: token.Pos("example.toml:29:1", newline) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:29:7") } } } - Rbrace: token.Pos("-").WithRel("newline") + Rbrace: token.Pos("-", newline) } *ast.StructLit{ - Lbrace: token.Pos("-").WithRel("newline") - Rbrace: token.Pos("-").WithRel("newline") + Lbrace: token.Pos("-", newline) + Rbrace: token.Pos("-", newline) } *ast.StructLit{ - Lbrace: token.Pos("-").WithRel("newline") + Lbrace: token.Pos("-", newline) Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:34:1").WithRel("newline") + NamePos: token.Pos("example.toml:34:1", newline) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:34:8") @@ -280,7 +280,7 @@ color = "gray" } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:35:1").WithRel("newline") + NamePos: token.Pos("example.toml:35:1", newline) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:35:7") @@ -288,17 +288,17 @@ color = "gray" } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("example.toml:37:1").WithRel("newline") + NamePos: token.Pos("example.toml:37:1", newline) } Value: *ast.BasicLit{ ValuePos: token.Pos("example.toml:37:9") } } } - Rbrace: token.Pos("-").WithRel("newline") + Rbrace: token.Pos("-", newline) } } - Rbrack: token.Pos("-").WithRel("newline") + Rbrack: token.Pos("-", newline) } } } diff --git a/internal/astinternal/debug.go b/internal/astinternal/debug.go index 9be711c99a3..84992a3efd2 100644 --- a/internal/astinternal/debug.go +++ b/internal/astinternal/debug.go @@ -58,11 +58,6 @@ type debugPrinter struct { level int } -var ( - typeTokenPos = reflect.TypeFor[token.Pos]() - typeTokenToken = reflect.TypeFor[token.Token]() -) - // value produces the given value, omitting type information if // its type is the same as implied type. It reports whether // anything was produced. @@ -99,17 +94,18 @@ func (d *debugPrinter) value0(v reflect.Value, impliedType reflect.Type) { } t := v.Type() - switch t { + switch v := v.Interface().(type) { // Simple types which can stringify themselves. - case typeTokenPos, typeTokenToken: - d.printf("%s(%q)", t, v) + case token.Pos: + d.printf("%s(%q", t, v) // Show relative positions too, if there are any, as they affect formatting. - if t == typeTokenPos { - pos := v.Interface().(token.Pos) - if pos.HasRelPos() { - d.printf(".WithRel(%q)", pos.RelPos()) - } + if v.HasRelPos() { + d.printf(", %v", v.RelPos()) } + d.printf(")") + return + case token.Token: + d.printf("%s(%q)", t, v) return } diff --git a/internal/astinternal/testdata/debugprint/comprehensions.txtar b/internal/astinternal/testdata/debugprint/comprehensions.txtar index 5e69edd4b2c..7d1f7f89c53 100644 --- a/internal/astinternal/testdata/debugprint/comprehensions.txtar +++ b/internal/astinternal/testdata/debugprint/comprehensions.txtar @@ -12,66 +12,66 @@ for k, v in input if v > 2 { *ast.Comprehension{ Clauses: []ast.Clause{ *ast.IfClause{ - If: token.Pos("comprehensions.cue:1:1").WithRel("nospace") + If: token.Pos("comprehensions.cue:1:1", nospace) Condition: *ast.Ident{ - NamePos: token.Pos("comprehensions.cue:1:4").WithRel("blank") + NamePos: token.Pos("comprehensions.cue:1:4", blank) Name: "condition" } } } Value: *ast.StructLit{ - Lbrace: token.Pos("comprehensions.cue:1:14").WithRel("blank") + Lbrace: token.Pos("comprehensions.cue:1:14", blank) Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("comprehensions.cue:2:2").WithRel("newline") + NamePos: token.Pos("comprehensions.cue:2:2", newline) Name: "a" } Optional: token.Pos("-") Constraint: token.Token("ILLEGAL") - TokenPos: token.Pos("comprehensions.cue:2:3").WithRel("nospace") + TokenPos: token.Pos("comprehensions.cue:2:3", nospace) Token: token.Token(":") Value: *ast.BasicLit{ - ValuePos: token.Pos("comprehensions.cue:2:5").WithRel("blank") + ValuePos: token.Pos("comprehensions.cue:2:5", blank) Kind: token.Token("true") Value: "true" } Attrs: []*ast.Attribute{} } } - Rbrace: token.Pos("comprehensions.cue:3:1").WithRel("newline") + Rbrace: token.Pos("comprehensions.cue:3:1", newline) } } *ast.Comprehension{ Clauses: []ast.Clause{ *ast.ForClause{ - For: token.Pos("comprehensions.cue:4:1").WithRel("newline") + For: token.Pos("comprehensions.cue:4:1", newline) Key: *ast.Ident{ - NamePos: token.Pos("comprehensions.cue:4:5").WithRel("blank") + NamePos: token.Pos("comprehensions.cue:4:5", blank) Name: "k" } - Colon: token.Pos("comprehensions.cue:4:6").WithRel("nospace") + Colon: token.Pos("comprehensions.cue:4:6", nospace) Value: *ast.Ident{ - NamePos: token.Pos("comprehensions.cue:4:8").WithRel("blank") + NamePos: token.Pos("comprehensions.cue:4:8", blank) Name: "v" } - In: token.Pos("comprehensions.cue:4:10").WithRel("blank") + In: token.Pos("comprehensions.cue:4:10", blank) Source: *ast.Ident{ - NamePos: token.Pos("comprehensions.cue:4:13").WithRel("blank") + NamePos: token.Pos("comprehensions.cue:4:13", blank) Name: "input" } } *ast.IfClause{ - If: token.Pos("comprehensions.cue:4:19").WithRel("blank") + If: token.Pos("comprehensions.cue:4:19", blank) Condition: *ast.BinaryExpr{ X: *ast.Ident{ - NamePos: token.Pos("comprehensions.cue:4:22").WithRel("blank") + NamePos: token.Pos("comprehensions.cue:4:22", blank) Name: "v" } - OpPos: token.Pos("comprehensions.cue:4:24").WithRel("blank") + OpPos: token.Pos("comprehensions.cue:4:24", blank) Op: token.Token(">") Y: *ast.BasicLit{ - ValuePos: token.Pos("comprehensions.cue:4:26").WithRel("blank") + ValuePos: token.Pos("comprehensions.cue:4:26", blank) Kind: token.Token("INT") Value: "2" } @@ -79,29 +79,29 @@ for k, v in input if v > 2 { } } Value: *ast.StructLit{ - Lbrace: token.Pos("comprehensions.cue:4:28").WithRel("blank") + Lbrace: token.Pos("comprehensions.cue:4:28", blank) Elts: []ast.Decl{ *ast.Field{ Label: *ast.ParenExpr{ - Lparen: token.Pos("comprehensions.cue:5:2").WithRel("newline") + Lparen: token.Pos("comprehensions.cue:5:2", newline) X: *ast.Ident{ - NamePos: token.Pos("comprehensions.cue:5:3").WithRel("nospace") + NamePos: token.Pos("comprehensions.cue:5:3", nospace) Name: "k" } - Rparen: token.Pos("comprehensions.cue:5:4").WithRel("nospace") + Rparen: token.Pos("comprehensions.cue:5:4", nospace) } Optional: token.Pos("-") Constraint: token.Token("ILLEGAL") - TokenPos: token.Pos("comprehensions.cue:5:5").WithRel("nospace") + TokenPos: token.Pos("comprehensions.cue:5:5", nospace) Token: token.Token(":") Value: *ast.Ident{ - NamePos: token.Pos("comprehensions.cue:5:7").WithRel("blank") + NamePos: token.Pos("comprehensions.cue:5:7", blank) Name: "v" } Attrs: []*ast.Attribute{} } } - Rbrace: token.Pos("comprehensions.cue:6:1").WithRel("newline") + Rbrace: token.Pos("comprehensions.cue:6:1", newline) } } } diff --git a/internal/astinternal/testdata/debugprint/fields.txtar b/internal/astinternal/testdata/debugprint/fields.txtar index 13320ec7438..0f2de480999 100644 --- a/internal/astinternal/testdata/debugprint/fields.txtar +++ b/internal/astinternal/testdata/debugprint/fields.txtar @@ -16,73 +16,73 @@ embed: { Decls: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("fields.cue:1:1").WithRel("nospace") + NamePos: token.Pos("fields.cue:1:1", nospace) Name: "a" } Optional: token.Pos("-") Constraint: token.Token("ILLEGAL") - TokenPos: token.Pos("fields.cue:1:2").WithRel("nospace") + TokenPos: token.Pos("fields.cue:1:2", nospace) Token: token.Token(":") Value: *ast.BasicLit{ - ValuePos: token.Pos("fields.cue:1:4").WithRel("blank") + ValuePos: token.Pos("fields.cue:1:4", blank) Kind: token.Token("INT") Value: "1" } Attrs: []*ast.Attribute{ { - At: token.Pos("fields.cue:1:6").WithRel("blank") + At: token.Pos("fields.cue:1:6", blank) Text: "@xml(,attr)" } } } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("fields.cue:2:1").WithRel("newline") + NamePos: token.Pos("fields.cue:2:1", newline) Name: "b" } Optional: token.Pos("-") Constraint: token.Token("ILLEGAL") - TokenPos: token.Pos("fields.cue:2:2").WithRel("nospace") + TokenPos: token.Pos("fields.cue:2:2", nospace) Token: token.Token(":") Value: *ast.BasicLit{ - ValuePos: token.Pos("fields.cue:2:4").WithRel("blank") + ValuePos: token.Pos("fields.cue:2:4", blank) Kind: token.Token("INT") Value: "2" } Attrs: []*ast.Attribute{ { - At: token.Pos("fields.cue:2:6").WithRel("blank") + At: token.Pos("fields.cue:2:6", blank) Text: "@foo(a,b=4)" } { - At: token.Pos("fields.cue:2:18").WithRel("blank") + At: token.Pos("fields.cue:2:18", blank) Text: "@go(Foo)" } } } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("fields.cue:3:1").WithRel("newline") + NamePos: token.Pos("fields.cue:3:1", newline) Name: "c" } - Optional: token.Pos("fields.cue:3:2").WithRel("nospace") + Optional: token.Pos("fields.cue:3:2", nospace) Constraint: token.Token("!") - TokenPos: token.Pos("fields.cue:3:3").WithRel("nospace") + TokenPos: token.Pos("fields.cue:3:3", nospace) Token: token.Token(":") Value: *ast.StructLit{ Lbrace: token.Pos("-") Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("fields.cue:3:5").WithRel("blank") + NamePos: token.Pos("fields.cue:3:5", blank) Name: "d" } - Optional: token.Pos("fields.cue:3:6").WithRel("nospace") + Optional: token.Pos("fields.cue:3:6", nospace) Constraint: token.Token("?") - TokenPos: token.Pos("fields.cue:3:7").WithRel("nospace") + TokenPos: token.Pos("fields.cue:3:7", nospace) Token: token.Token(":") Value: *ast.Ident{ - NamePos: token.Pos("fields.cue:3:9").WithRel("blank") + NamePos: token.Pos("fields.cue:3:9", blank) Name: "string" } Attrs: []*ast.Attribute{} @@ -95,46 +95,46 @@ embed: { *ast.Field{ Label: *ast.Alias{ Ident: *ast.Ident{ - NamePos: token.Pos("fields.cue:4:1").WithRel("newline") + NamePos: token.Pos("fields.cue:4:1", newline) Name: "X" } - Equal: token.Pos("fields.cue:4:2").WithRel("nospace") + Equal: token.Pos("fields.cue:4:2", nospace) Expr: *ast.Ident{ - NamePos: token.Pos("fields.cue:4:3").WithRel("nospace") + NamePos: token.Pos("fields.cue:4:3", nospace) Name: "e" } } Optional: token.Pos("-") Constraint: token.Token("ILLEGAL") - TokenPos: token.Pos("fields.cue:4:4").WithRel("nospace") + TokenPos: token.Pos("fields.cue:4:4", nospace) Token: token.Token(":") Value: *ast.StructLit{ Lbrace: token.Pos("-") Elts: []ast.Decl{ *ast.Field{ Label: *ast.ListLit{ - Lbrack: token.Pos("fields.cue:4:6").WithRel("blank") + Lbrack: token.Pos("fields.cue:4:6", blank) Elts: []ast.Expr{ *ast.Alias{ Ident: *ast.Ident{ - NamePos: token.Pos("fields.cue:4:7").WithRel("nospace") + NamePos: token.Pos("fields.cue:4:7", nospace) Name: "Y" } - Equal: token.Pos("fields.cue:4:8").WithRel("nospace") + Equal: token.Pos("fields.cue:4:8", nospace) Expr: *ast.Ident{ - NamePos: token.Pos("fields.cue:4:9").WithRel("nospace") + NamePos: token.Pos("fields.cue:4:9", nospace) Name: "string" } } } - Rbrack: token.Pos("fields.cue:4:15").WithRel("nospace") + Rbrack: token.Pos("fields.cue:4:15", nospace) } Optional: token.Pos("-") Constraint: token.Token("ILLEGAL") - TokenPos: token.Pos("fields.cue:4:16").WithRel("nospace") + TokenPos: token.Pos("fields.cue:4:16", nospace) Token: token.Token(":") Value: *ast.Ident{ - NamePos: token.Pos("fields.cue:4:18").WithRel("blank") + NamePos: token.Pos("fields.cue:4:18", blank) Name: "int" } Attrs: []*ast.Attribute{} @@ -146,60 +146,60 @@ embed: { } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("fields.cue:5:1").WithRel("newline") + NamePos: token.Pos("fields.cue:5:1", newline) Name: "#Schema" } Optional: token.Pos("-") Constraint: token.Token("ILLEGAL") - TokenPos: token.Pos("fields.cue:5:8").WithRel("nospace") + TokenPos: token.Pos("fields.cue:5:8", nospace) Token: token.Token(":") Value: *ast.StructLit{ - Lbrace: token.Pos("fields.cue:5:10").WithRel("blank") + Lbrace: token.Pos("fields.cue:5:10", blank) Elts: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("fields.cue:6:2").WithRel("newline") + NamePos: token.Pos("fields.cue:6:2", newline) Name: "name" } Optional: token.Pos("-") Constraint: token.Token("ILLEGAL") - TokenPos: token.Pos("fields.cue:6:6").WithRel("nospace") + TokenPos: token.Pos("fields.cue:6:6", nospace) Token: token.Token(":") Value: *ast.Ident{ - NamePos: token.Pos("fields.cue:6:8").WithRel("blank") + NamePos: token.Pos("fields.cue:6:8", blank) Name: "string" } Attrs: []*ast.Attribute{} } *ast.Ellipsis{ - Ellipsis: token.Pos("fields.cue:7:2").WithRel("newline") + Ellipsis: token.Pos("fields.cue:7:2", newline) Type: nil } } - Rbrace: token.Pos("fields.cue:8:1").WithRel("newline") + Rbrace: token.Pos("fields.cue:8:1", newline) } Attrs: []*ast.Attribute{} } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("fields.cue:9:1").WithRel("newline") + NamePos: token.Pos("fields.cue:9:1", newline) Name: "embed" } Optional: token.Pos("-") Constraint: token.Token("ILLEGAL") - TokenPos: token.Pos("fields.cue:9:6").WithRel("nospace") + TokenPos: token.Pos("fields.cue:9:6", nospace) Token: token.Token(":") Value: *ast.StructLit{ - Lbrace: token.Pos("fields.cue:9:8").WithRel("blank") + Lbrace: token.Pos("fields.cue:9:8", blank) Elts: []ast.Decl{ *ast.EmbedDecl{ Expr: *ast.Ident{ - NamePos: token.Pos("fields.cue:10:2").WithRel("newline") + NamePos: token.Pos("fields.cue:10:2", newline) Name: "#Schema" } } } - Rbrace: token.Pos("fields.cue:11:1").WithRel("newline") + Rbrace: token.Pos("fields.cue:11:1", newline) } Attrs: []*ast.Attribute{} } diff --git a/internal/astinternal/testdata/debugprint/file.txtar b/internal/astinternal/testdata/debugprint/file.txtar index f708c32e60a..fcdb528e46d 100644 --- a/internal/astinternal/testdata/debugprint/file.txtar +++ b/internal/astinternal/testdata/debugprint/file.txtar @@ -24,9 +24,9 @@ import ( Filename: "package_only.cue" Decls: []ast.Decl{ *ast.Package{ - PackagePos: token.Pos("package_only.cue:1:1").WithRel("nospace") + PackagePos: token.Pos("package_only.cue:1:1", nospace) Name: *ast.Ident{ - NamePos: token.Pos("package_only.cue:1:9").WithRel("blank") + NamePos: token.Pos("package_only.cue:1:9", blank) Name: "p" } } @@ -45,11 +45,11 @@ import ( Position: 0 List: []*ast.Comment{ { - Slash: token.Pos("comments_only.cue:1:1").WithRel("newline") + Slash: token.Pos("comments_only.cue:1:1", newline) Text: "// some" } { - Slash: token.Pos("comments_only.cue:2:1").WithRel("newline") + Slash: token.Pos("comments_only.cue:2:1", newline) Text: "// comment lines" } } @@ -61,20 +61,20 @@ import ( Filename: "imports.cue" Decls: []ast.Decl{ *ast.Package{ - PackagePos: token.Pos("imports.cue:1:1").WithRel("nospace") + PackagePos: token.Pos("imports.cue:1:1", nospace) Name: *ast.Ident{ - NamePos: token.Pos("imports.cue:1:9").WithRel("blank") + NamePos: token.Pos("imports.cue:1:9", blank) Name: "p" } } *ast.ImportDecl{ - Import: token.Pos("imports.cue:3:1").WithRel("section") + Import: token.Pos("imports.cue:3:1", section) Lparen: token.Pos("-") Specs: []*ast.ImportSpec{ { Name: nil Path: *ast.BasicLit{ - ValuePos: token.Pos("imports.cue:3:8").WithRel("blank") + ValuePos: token.Pos("imports.cue:3:8", blank) Kind: token.Token("STRING") Value: "\"foo\"" } @@ -84,13 +84,13 @@ import ( Rparen: token.Pos("-") } *ast.ImportDecl{ - Import: token.Pos("imports.cue:5:1").WithRel("section") - Lparen: token.Pos("imports.cue:5:8").WithRel("blank") + Import: token.Pos("imports.cue:5:1", section) + Lparen: token.Pos("imports.cue:5:8", blank) Specs: []*ast.ImportSpec{ { Name: nil Path: *ast.BasicLit{ - ValuePos: token.Pos("imports.cue:6:2").WithRel("newline") + ValuePos: token.Pos("imports.cue:6:2", newline) Kind: token.Token("STRING") Value: "\"bar\"" } @@ -98,25 +98,25 @@ import ( } { Name: *ast.Ident{ - NamePos: token.Pos("imports.cue:7:2").WithRel("newline") + NamePos: token.Pos("imports.cue:7:2", newline) Name: "name" } Path: *ast.BasicLit{ - ValuePos: token.Pos("imports.cue:7:7").WithRel("blank") + ValuePos: token.Pos("imports.cue:7:7", blank) Kind: token.Token("STRING") Value: "\"baz\"" } EndPos: token.Pos("-") } } - Rparen: token.Pos("imports.cue:8:1").WithRel("newline") + Rparen: token.Pos("imports.cue:8:1", newline) } } Imports: []*ast.ImportSpec{ { Name: nil Path: *ast.BasicLit{ - ValuePos: token.Pos("imports.cue:3:8").WithRel("blank") + ValuePos: token.Pos("imports.cue:3:8", blank) Kind: token.Token("STRING") Value: "\"foo\"" } @@ -125,7 +125,7 @@ import ( { Name: nil Path: *ast.BasicLit{ - ValuePos: token.Pos("imports.cue:6:2").WithRel("newline") + ValuePos: token.Pos("imports.cue:6:2", newline) Kind: token.Token("STRING") Value: "\"bar\"" } @@ -133,11 +133,11 @@ import ( } { Name: *ast.Ident{ - NamePos: token.Pos("imports.cue:7:2").WithRel("newline") + NamePos: token.Pos("imports.cue:7:2", newline) Name: "name" } Path: *ast.BasicLit{ - ValuePos: token.Pos("imports.cue:7:7").WithRel("blank") + ValuePos: token.Pos("imports.cue:7:7", blank) Kind: token.Token("STRING") Value: "\"baz\"" } diff --git a/internal/astinternal/testdata/debugprint/unify.txtar b/internal/astinternal/testdata/debugprint/unify.txtar index 64ab358ecda..14cec510a88 100644 --- a/internal/astinternal/testdata/debugprint/unify.txtar +++ b/internal/astinternal/testdata/debugprint/unify.txtar @@ -7,30 +7,30 @@ disjunctoin: b | c | *d Decls: []ast.Decl{ *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("unify.txtar:1:1").WithRel("nospace") + NamePos: token.Pos("unify.txtar:1:1", nospace) Name: "unification" } Optional: token.Pos("-") Constraint: token.Token("ILLEGAL") - TokenPos: token.Pos("unify.txtar:1:12").WithRel("nospace") + TokenPos: token.Pos("unify.txtar:1:12", nospace) Token: token.Token(":") Value: *ast.BinaryExpr{ X: *ast.BinaryExpr{ X: *ast.Ident{ - NamePos: token.Pos("unify.txtar:1:14").WithRel("blank") + NamePos: token.Pos("unify.txtar:1:14", blank) Name: "b" } - OpPos: token.Pos("unify.txtar:1:16").WithRel("blank") + OpPos: token.Pos("unify.txtar:1:16", blank) Op: token.Token("&") Y: *ast.Ident{ - NamePos: token.Pos("unify.txtar:1:18").WithRel("blank") + NamePos: token.Pos("unify.txtar:1:18", blank) Name: "c" } } - OpPos: token.Pos("unify.txtar:1:20").WithRel("blank") + OpPos: token.Pos("unify.txtar:1:20", blank) Op: token.Token("&") Y: *ast.Ident{ - NamePos: token.Pos("unify.txtar:1:22").WithRel("blank") + NamePos: token.Pos("unify.txtar:1:22", blank) Name: "d" } } @@ -38,33 +38,33 @@ disjunctoin: b | c | *d } *ast.Field{ Label: *ast.Ident{ - NamePos: token.Pos("unify.txtar:2:1").WithRel("newline") + NamePos: token.Pos("unify.txtar:2:1", newline) Name: "disjunctoin" } Optional: token.Pos("-") Constraint: token.Token("ILLEGAL") - TokenPos: token.Pos("unify.txtar:2:12").WithRel("nospace") + TokenPos: token.Pos("unify.txtar:2:12", nospace) Token: token.Token(":") Value: *ast.BinaryExpr{ X: *ast.BinaryExpr{ X: *ast.Ident{ - NamePos: token.Pos("unify.txtar:2:14").WithRel("blank") + NamePos: token.Pos("unify.txtar:2:14", blank) Name: "b" } - OpPos: token.Pos("unify.txtar:2:16").WithRel("blank") + OpPos: token.Pos("unify.txtar:2:16", blank) Op: token.Token("|") Y: *ast.Ident{ - NamePos: token.Pos("unify.txtar:2:18").WithRel("blank") + NamePos: token.Pos("unify.txtar:2:18", blank) Name: "c" } } - OpPos: token.Pos("unify.txtar:2:20").WithRel("blank") + OpPos: token.Pos("unify.txtar:2:20", blank) Op: token.Token("|") Y: *ast.UnaryExpr{ - OpPos: token.Pos("unify.txtar:2:22").WithRel("blank") + OpPos: token.Pos("unify.txtar:2:22", blank) Op: token.Token("*") X: *ast.Ident{ - NamePos: token.Pos("unify.txtar:2:23").WithRel("nospace") + NamePos: token.Pos("unify.txtar:2:23", nospace) Name: "d" } }