-
Notifications
You must be signed in to change notification settings - Fork 20
/
meta.go
30 lines (26 loc) · 774 Bytes
/
meta.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package meta
import "github.com/yoheimuta/go-protoparser/internal/lexer/scanner"
// Meta represents a meta information about the parsed element.
type Meta struct {
// Pos is the source position.
Pos Position
// LastPos is the last source position.
// Currently it is set when the parsed element type is message, enum, oneof, rpc or service.
LastPos Position
}
// NewMeta creates a new Meta from scanner.Position.
func NewMeta(fromPos scanner.Position) Meta {
return Meta{
Pos: NewPosition(fromPos),
}
}
// NewMetaWithLastPos creates a new Meta with LastPos from scanner.Position.
func NewMetaWithLastPos(
fromPos scanner.Position,
fromLastPos scanner.Position,
) Meta {
return Meta{
Pos: NewPosition(fromPos),
LastPos: NewPosition(fromLastPos),
}
}