From 568134a7e9c53f7fd6c284a6180aa4e28df65d04 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 18 Aug 2022 00:42:47 -0400 Subject: [PATCH] Add getter functions to Location --- file/location.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/file/location.go b/file/location.go index 1be5ff6..becb579 100644 --- a/file/location.go +++ b/file/location.go @@ -13,3 +13,26 @@ type Location struct { func (location Location) NewError (message string, kind ErrorKind) (err Error) { return NewError(location, message, kind) } + +// File returns the file the location is in +func (location Location) File () (file *File) { + return location.file +} + +// Row returns the row the location is positioned at in the file, starting at +// zero. +func (location Location) Row () (row int) { + return location.row +} + +// Column returns the column the location is positioned at in the file, starting +// at zero. +func (location Location) Column () (column int) { + return location.column +} + +// Width returns the amount of runes spanned by the location, starting at row +// and column. +func (location Location) Width () (width int) { + return location.width +}