![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/cyber-cicco/tree-sitter-query-builder
TQB is a golang library that sould be used in conjonction with the go-tree-sitter library.
You can get more details on tree sitter queries from here
It aims to ease the construction of Pattern Macthing queries, and provide you a way create queries dynamically, like such:
func Query() string {
query := querier.NewQB()
i := 0
query.
NewSExpression("call_expression").
If(
i == 0,
func(e *SExpression) {
e.For(func() bool {return i < 10},
func(e2 *SExpression){
e2.NewSExpression("string_literal").
If(i < 9,
func(e *SExpression) {e.Prop("field")},
).
NewSExpression("string_value")
},
func(){i += 1})
}).
Var("myexpression", query).
End()
return query.Marshal()
}
This is the equivalent of that string :
const QUERY = `(
(call_expression
field: (string_literal
(string_value))
field: (string_literal
(string_value))
field: (string_literal
(string_value))
field: (string_literal
(string_value))
field: (string_literal
(string_value))
field: (string_literal
(string_value))
field: (string_literal
(string_value))
field: (string_literal
(string_value))
field: (string_literal
(string_value))
(string_literal
(string_value))) @myexpression
)`
You can find example of building queries from the tree sitter documentation in this file
That way, you souldn't have to worry about syntax errors in your string queries anymore.
Benchmarking shows that it takes approximately 5x times to get a query from the query builder than the parameterized query for a medium sized query. However, doing the query takes approximately 1000x more time than getting the query object with a query builder, so the difference is slim.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.