cue/token: record File pointer in Pos
This is the first step to eliminate FileSet.
Change-Id: Ibb8a17e429d9b2dc2fda0a739520ebef40c67761
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2121
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
diff --git a/internal/protobuf/parse.go b/internal/protobuf/parse.go
index 19eb4ec..b81bd5c 100644
--- a/internal/protobuf/parse.go
+++ b/internal/protobuf/parse.go
@@ -386,7 +386,7 @@
if x.Repeated {
f.Value = &ast.ListLit{
- Ellipsis: token.Pos(token.NoSpace),
+ Ellipsis: token.NoSpace.Pos(),
Type: f.Value,
}
}
@@ -571,7 +571,7 @@
p.addTag(f, o.tags)
if !o.required {
- f.Optional = token.Pos(token.NoSpace)
+ f.Optional = token.NoSpace.Pos()
}
return f
}
@@ -606,7 +606,7 @@
addComments(constraint, 1, o.Comment, o.InlineComment)
p.message.Elts = append(p.message.Elts, constraint)
if !p.required {
- constraint.Optional = token.Pos(token.NoSpace)
+ constraint.Optional = token.NoSpace.Pos()
}
default:
diff --git a/internal/protobuf/util.go b/internal/protobuf/util.go
index e001fa8..980a7d3 100644
--- a/internal/protobuf/util.go
+++ b/internal/protobuf/util.go
@@ -38,8 +38,8 @@
}
var (
- newline = token.Pos(token.Newline)
- newSection = token.Pos(token.NewSection)
+ newline = token.Newline.Pos()
+ newSection = token.NewSection.Pos()
)
func addComments(f ast.Node, i int, doc, inline *proto.Comment) bool {
diff --git a/internal/third_party/yaml/decode.go b/internal/third_party/yaml/decode.go
index bc42da9..fc91a8e 100644
--- a/internal/third_party/yaml/decode.go
+++ b/internal/third_party/yaml/decode.go
@@ -322,7 +322,7 @@
}
// fp := d.p.info.Pos(c.mark.index, 0)
comments = append(comments, &ast.Comment{
- token.Pos(c.pos),
+ c.pos.Pos(),
"//" + c.text[1:],
})
d.p.parser.comments = d.p.parser.comments[1:]
@@ -343,7 +343,7 @@
c := d.p.parser.comments[0]
if c.mark.index == m.index {
comment := &ast.Comment{
- token.Pos(c.pos),
+ c.pos.Pos(),
// d.p.info.Pos(m.index+1, 0),
"//" + c.text[1:],
}
@@ -374,7 +374,7 @@
func (d *decoder) ident(n *node, name string) *ast.Ident {
return &ast.Ident{
// NamePos: d.pos(n.startPos),
- NamePos: token.Pos(d.p.parser.relPos()),
+ NamePos: d.p.parser.relPos().Pos(),
Name: name,
}
}
@@ -424,7 +424,7 @@
case yaml_TIMESTAMP_TAG:
return &ast.BasicLit{
// ValuePos: d.start(n),
- ValuePos: token.Pos(d.p.parser.relPos()),
+ ValuePos: d.p.parser.relPos().Pos(),
Kind: token.STRING,
Value: strconv.Quote(n.value),
}
@@ -432,7 +432,7 @@
case yaml_STR_TAG:
return &ast.BasicLit{
// ValuePos: d.start(n),
- ValuePos: token.Pos(d.p.parser.relPos()),
+ ValuePos: d.p.parser.relPos().Pos(),
Kind: token.STRING,
Value: d.quoteString(n.value),
}
@@ -443,7 +443,7 @@
buf[len(buf)-1] = '\''
return &ast.BasicLit{
// ValuePos: d.start(n),
- ValuePos: token.Pos(d.p.parser.relPos()),
+ ValuePos: d.p.parser.relPos().Pos(),
Kind: token.STRING,
Value: string(buf),
}
@@ -487,11 +487,11 @@
}
err := &ast.BottomLit{
// Bottom: d.pos(n.startPos)
- Bottom: token.Pos(d.p.parser.relPos()),
+ Bottom: d.p.parser.relPos().Pos(),
}
comment := &ast.Comment{
// Slash: d.start(n),
- Slash: token.Pos(token.Blank),
+ Slash: token.Blank.Pos(),
Text: "// " + d.terror(n, tag),
}
err.AddComment(&ast.CommentGroup{
@@ -522,7 +522,7 @@
}
stringLabel:
return &ast.BasicLit{
- ValuePos: token.Pos(d.p.parser.relPos()),
+ ValuePos: d.p.parser.relPos().Pos(),
// ValuePos: d.start(n),
Kind: token.STRING,
Value: strconv.Quote(n.value),
@@ -535,15 +535,15 @@
minuses++
}
expr = &ast.BasicLit{
- // ValuePos: d.start(n) + token.Pos(minuses),
- ValuePos: token.Pos(d.p.parser.relPos()),
+ // ValuePos: d.start(n) + minuses.Pos(),
+ ValuePos: d.p.parser.relPos().Pos(),
Kind: kind,
Value: val,
}
if minuses > 0 {
expr = &ast.UnaryExpr{
// OpPos: d.start(n),
- OpPos: token.Pos(d.p.parser.relPos()),
+ OpPos: d.p.parser.relPos().Pos(),
Op: token.SUB,
X: expr,
}