php-parser/position/position.go

28 lines
567 B
Go
Raw Normal View History

2018-01-09 13:51:32 +00:00
package position
import (
"fmt"
"github.com/z7zmey/php-parser/node"
)
2018-01-12 06:23:58 +00:00
// Position represents node position
2018-01-09 13:51:32 +00:00
type Position struct {
StartLine int
EndLine int
StartPos int
EndPos int
}
func (p Position) String() string {
return fmt.Sprintf("Pos{Line: %d-%d Pos: %d-%d}", p.StartLine, p.EndLine, p.StartPos, p.EndPos)
}
2018-01-12 06:23:58 +00:00
// Positions a collection of positions attached to nodes
2018-01-09 13:51:32 +00:00
type Positions map[node.Node]*Position
2018-01-12 06:23:58 +00:00
// AddPosition attaches a position to a node
2018-01-09 13:51:32 +00:00
func (p Positions) AddPosition(node node.Node, position *Position) {
p[node] = position
}