location.go 592 B

12345678910111213141516171819202122232425262728293031
  1. package source
  2. import "kumachan/standalone/util/richtext"
  3. type Location struct {
  4. File File
  5. Pos Position
  6. }
  7. // note: File should be comparable
  8. type File interface {
  9. GetPath() string
  10. DescribePosition(Position) string
  11. FormatMessage(Position, richtext.Block) richtext.Block
  12. }
  13. type Position struct {
  14. Index1 uint32
  15. Index2 uint32
  16. }
  17. func (l Location) FilePath() string {
  18. return l.File.GetPath()
  19. }
  20. func (l Location) PosDesc() string {
  21. return l.File.DescribePosition(l.Pos)
  22. }
  23. func (l Location) FormatMessage(b richtext.Block) richtext.Block {
  24. return l.File.FormatMessage(l.Pos, b)
  25. }