Ported from Go implementations
bzl_library
Here is a simple real-world example. Here we have ported the bzl_library
generator from the Go code in bazel-skylib.
To query the Starlark language and gather all load
statements, we use this Tree-sitter query:
"loads": aspect.AstQuery(
grammar = "starlark",
query = """(module
(expression_statement
(call
function: (identifier) @id
arguments: (argument_list
(string) @path
(string)
)
)
(#eq? @id "load")
)
)""",
)
Here’s the full code listing:
Kotlin
As another example, we’ve ported the Kotlin Go implementation from https://github.com/aspect-build/aspect-cli/tree/main/gazelle/kotlin:
From scratch
PostCSS
This one is OSS from a third-party: Embed GitHub
C++
This rudimentary extension demonstrates the value of being able to hard-code some dependencies like @sqlite3
. It’s not generalized enough to publish as a generic extension in OSS, but it’s much quicker to iterate and solves basic cases.