2016-11-15 20:30:34 +01:00
|
|
|
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
|
|
|
|
|
|
|
package diag
|
|
|
|
|
|
|
|
// Pos represents a position in a file.
|
|
|
|
type Pos struct {
|
2016-11-16 03:00:43 +01:00
|
|
|
Ln int
|
2016-11-15 20:30:34 +01:00
|
|
|
Col int
|
|
|
|
}
|
|
|
|
|
|
|
|
// EmptyPos may be used when no position is needed.
|
|
|
|
var EmptyPos = Pos{0, 0}
|
|
|
|
|
2016-11-16 03:00:43 +01:00
|
|
|
// IsEmpty returns true if the Pos information is missing.
|
|
|
|
func (pos Pos) IsEmpty() bool {
|
|
|
|
return pos.Ln == 0 && pos.Col == 0
|
|
|
|
}
|
|
|
|
|
2016-11-16 02:42:22 +01:00
|
|
|
// Location represents a region spanning two positions in a file.
|
|
|
|
type Location struct {
|
2016-11-16 18:29:44 +01:00
|
|
|
From Pos
|
|
|
|
To Pos
|
2016-11-15 20:30:34 +01:00
|
|
|
}
|
|
|
|
|
2016-11-16 02:42:22 +01:00
|
|
|
// EmptyLocation may be used when no position information is available.
|
|
|
|
var EmptyLocation = Location{EmptyPos, EmptyPos}
|
2016-11-16 03:00:43 +01:00
|
|
|
|
|
|
|
// IsEmpty returns true if the Location information is missing.
|
|
|
|
func (loc Location) IsEmpty() bool {
|
2016-11-16 18:29:44 +01:00
|
|
|
return loc.From.IsEmpty() && loc.To.IsEmpty()
|
2016-11-16 03:00:43 +01:00
|
|
|
}
|