From 3b9ef2b56d8fe154aa99440c8928ecc19f89ff72 Mon Sep 17 00:00:00 2001 From: Vadym Slizov Date: Sun, 10 May 2020 08:53:00 +0300 Subject: [PATCH] refactor position package --- pkg/position/position.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 pkg/position/position.go diff --git a/pkg/position/position.go b/pkg/position/position.go new file mode 100644 index 0000000..d4099cd --- /dev/null +++ b/pkg/position/position.go @@ -0,0 +1,27 @@ +package position + +import ( + "fmt" +) + +// Position represents node position +type Position struct { + StartLine int + EndLine int + StartPos int + EndPos int +} + +// NewPosition Position constructor +func NewPosition(StartLine int, EndLine int, StartPos int, EndPos int) *Position { + return &Position{ + StartLine: StartLine, + EndLine: EndLine, + StartPos: StartPos, + EndPos: EndPos, + } +} + +func (p Position) String() string { + return fmt.Sprintf("Pos{Line: %d-%d Pos: %d-%d}", p.StartLine, p.EndLine, p.StartPos, p.EndPos) +}