pulumi/pkg/diag/pos.go
joeduffy ff0059cd7b Print relative filenames in errors
Error messages could get quite lengthy as the code was written previously,
because we always used the complete absolute path for the file in question.
This change "prettifies" this to be relative to whatever contextual path
the user has chosen during compilation.  This shortens messages considerably.
2016-11-15 18:00:43 -08:00

32 lines
745 B
Go

// Copyright 2016 Marapongo, Inc. All rights reserved.
package diag
// Pos represents a position in a file.
type Pos struct {
Ln int
Col int
}
// EmptyPos may be used when no position is needed.
var EmptyPos = Pos{0, 0}
// IsEmpty returns true if the Pos information is missing.
func (pos Pos) IsEmpty() bool {
return pos.Ln == 0 && pos.Col == 0
}
// Location represents a region spanning two positions in a file.
type Location struct {
Start Pos
End Pos
}
// EmptyLocation may be used when no position information is available.
var EmptyLocation = Location{EmptyPos, EmptyPos}
// IsEmpty returns true if the Location information is missing.
func (loc Location) IsEmpty() bool {
return loc.Start.IsEmpty() && loc.End.IsEmpty()
}