Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.OriginTextPosition() always return 0 and Text() return empty #1425

Open
zjcxc opened this issue Sep 14, 2022 · 0 comments
Open

Node.OriginTextPosition() always return 0 and Text() return empty #1425

zjcxc opened this issue Sep 14, 2022 · 0 comments

Comments

@zjcxc
Copy link

zjcxc commented Sep 14, 2022

I want to got foreach Node OriginTextPosition and Text, but ican't got it, why

type FingerprintVisitor struct{}

func (f *FingerprintVisitor) Enter(n ast.Node) (node ast.Node, skipChildren bool) {
fmt.Printf("[%T] %d --> %s\n", n, n.OriginTextPosition(), n.Text())
return n, false
}

func (f *FingerprintVisitor) Leave(n ast.Node) (node ast.Node, ok bool) {
fmt.Printf("[%T] %d <-- %s\n", n, n.OriginTextPosition(), n.Text())
return n, true
}

func main(){
sql = select * from tb force index(a)
pa := parser.New()
if node, err := pa.ParseOneStmt(sql, "", ""); err == nil {
var v = &FingerprintVisitor{}
node.Accept(v)
} else {
fmt.Println(err)
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant