Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
positioner: fix token verification when key is not set
Browse files Browse the repository at this point in the history
Signed-off-by: Denys Smirnov <[email protected]>
  • Loading branch information
Denys Smirnov authored and dennwc committed Jan 22, 2019
1 parent 1293a56 commit a31c27a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions uast/transformer/positioner/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ type VerifyToken struct {
}

func (t VerifyToken) Verify(code string, root nodes.Node) error {
f := newTokenFilter(code, t.Key, t.Types)
key := t.Key
if key == "" {
key = uast.KeyToken
}
f := newTokenFilter(code, key, t.Types)

var last error
nodes.WalkPreOrder(root, func(node nodes.Node) bool {
Expand All @@ -144,7 +148,7 @@ func (t VerifyToken) Verify(code string, root nodes.Node) error {
// skip node, but recurse to children
return true
}
token1, ok := obj[t.Key].(nodes.String)
token1, ok := obj[key].(nodes.String)
if !ok {
return true
}
Expand Down

0 comments on commit a31c27a

Please sign in to comment.