move Positions and Comments into parser package
This commit is contained in:
@@ -2,8 +2,6 @@ package position
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
// Position represents node position
|
||||
@@ -27,11 +25,3 @@ func NewPosition(StartLine int, EndLine int, StartPos int, EndPos int) *Position
|
||||
func (p Position) String() string {
|
||||
return fmt.Sprintf("Pos{Line: %d-%d Pos: %d-%d}", p.StartLine, p.EndLine, p.StartPos, p.EndPos)
|
||||
}
|
||||
|
||||
// Positions a collection of positions attached to nodes
|
||||
type Positions map[node.Node]*Position
|
||||
|
||||
// AddPosition attaches a position to a node
|
||||
func (p Positions) AddPosition(node node.Node, position *Position) {
|
||||
p[node] = position
|
||||
}
|
||||
|
||||
19
position/position_test.go
Normal file
19
position/position_test.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package position_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/z7zmey/php-parser/position"
|
||||
)
|
||||
|
||||
func TestPrintPosition(t *testing.T) {
|
||||
pos := position.NewPosition(1, 1, 2, 5)
|
||||
|
||||
expected := "Pos{Line: 1-1 Pos: 2-5}"
|
||||
|
||||
actual := pos.String()
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("expected and actual are not equal\n")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user