remove nodesWithEndToken type
This commit is contained in:
@@ -174,6 +174,16 @@ func (b *PositionBuilder) NewNodeNodeListPosition(n node.Node, list []node.Node)
|
||||
)
|
||||
}
|
||||
|
||||
// NewNodeListNodePosition returns new Position
|
||||
func (b *PositionBuilder) NewNodeListNodePosition(list []node.Node, n node.Node) *position.Position {
|
||||
return position.NewPosition(
|
||||
b.getListStartPos(list).startLine,
|
||||
b.getNodeEndPos(n).endLine,
|
||||
b.getListStartPos(list).startPos,
|
||||
b.getNodeEndPos(n).endPos,
|
||||
)
|
||||
}
|
||||
|
||||
// NewOptionalListTokensPosition returns new Position
|
||||
func (b *PositionBuilder) NewOptionalListTokensPosition(list []node.Node, t *scanner.Token, endToken *scanner.Token) *position.Position {
|
||||
if list == nil {
|
||||
|
||||
@@ -259,6 +259,41 @@ func TestNewNodeNodeListPosition(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewNodeListNodePosition(t *testing.T) {
|
||||
n1 := node.NewIdentifier("test node")
|
||||
n2 := node.NewIdentifier("test node")
|
||||
n3 := node.NewIdentifier("test node")
|
||||
|
||||
builder := parser.PositionBuilder{
|
||||
Positions: &parser.Positions{
|
||||
n1: &position.Position{
|
||||
StartLine: 1,
|
||||
EndLine: 1,
|
||||
StartPos: 0,
|
||||
EndPos: 8,
|
||||
},
|
||||
n2: &position.Position{
|
||||
StartLine: 2,
|
||||
EndLine: 2,
|
||||
StartPos: 9,
|
||||
EndPos: 17,
|
||||
},
|
||||
n3: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: 3,
|
||||
StartPos: 18,
|
||||
EndPos: 26,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
pos := builder.NewNodeListNodePosition([]node.Node{n1, n2}, n3)
|
||||
|
||||
if pos.String() != `Pos{Line: 1-3 Pos: 0-26}` {
|
||||
t.Errorf("token value is not equal\n")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewOptionalListTokensPosition(t *testing.T) {
|
||||
builder := parser.PositionBuilder{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user