dimitarvp
To @jonatanklosko and @the-mikedavis:
I see that there is a Rust crate at crates.io: Rust Package Registry but it is pointing at https://github.com/tree-sitter/tree-sitter-elixir – and that no longer exists.
Can this be fixed to correctly point to GitHub - elixir-lang/tree-sitter-elixir: Elixir grammar for tree-sitter · GitHub, please? Assuming they are even the same which they might not be.
I am looking into making a PR to GitHub - ast-grep/ast-grep: ⚡A CLI tool for code structural search, lint and rewriting. Written in Rust · GitHub so Elixir can be included in the semantic / structural code search that this tool provides.
I am asking for this because the project’s Cargo.toml needs a valid crate to point at a language grammar before the small boilerplate required to add a language can work: ast-grep/crates/language/Cargo.toml at 782b175dacaf161cd567538f01929c5e78074e9f · ast-grep/ast-grep · GitHub
/CC @josevalim
Trending in Proposals: Ideas
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
To clarify further: I can and have started a PR to add Elixir to the
ast-greptool because Cargo allows GIT dependencies just fine. But I thought it would be more… hygienic might be the word… for us to have a proper Rust crate hosted on crates.io.shanesveller
Notably you cannot publish a release to
crates.ioif it contains any git dependencies, so many packages that are actually CLIs or other end-user applications may forbid introducing such changes. On the projects’ side the stance is mainly motivated to protect the ability tocargo installthe package by name.I knew this from past friction; and Specifying Dependencies - The Cargo Book mentions that near the bottom of that section, but I couldn’t trivially find a page directly on crate.io to cite.
dimitarvp
Thanks for pointing this out, I overlooked it.
And yikes, I guess in that case repairing the crate is indeed a blocker if I am to contribute to
ast-grep.dimitarvp
OK, I have forked the repo and made a bunch of changes that plug in the Elixir TreeSitter implementation – it seems that the moved repo is indeed doing the same things that the old (the one that no longer exists) was doing.
The only thing that is missing is replacing this line in
Cargo.toml:with:
(or whatever the version gets bumped to)
There’s a problem though, searching for
$A != nilyields an error:Looking for e.g.
is_nil($A)works fine.I have zero clue as to how TreeSitter works so this is still a mystery. Hopefully I can find some more time to experiment and see how this can be solved (if it can at all).
Here’s the forked repo. Running
cargo test elixiris easy enough, and so is findingelixir.rsinside the project, if anybody wants to tinker.F.ex.
test_match("$A = 0", "a = 0");also breaks with the “multiple nodes” error. Try and put it insideelixir.rs’s functiontest_elixir_pattern()and re-runcargo test elixir.Finally, tinkering would be done like so:
dimitarvp
I’ve also opened a pull request in the original repo.
dimitarvp
…and posted an issue to the
tree-sitter-elixirrepo: Publish to crates.io with the current GitHub location · Issue #62 · elixir-lang/tree-sitter-elixir · GitHubdimitarvp
It seems that replacing one Rust macro incantation with another fixed the strange “multiple AST nodes” error. I’ll work on adding better and more convincing tests and will then ask the tool authors to merge the PR, after which we’ll be able to use
ast-grepto search and replace Elixir code from the CLI.…if the owners of the
tree-sitter-elixirre-publish the Rust crate with the right GitHub repo URL that is.dimitarvp
tree-sitter-elixirhas been fixed to have its correct GIT URL on crates.io.I’ll proceed to enrich the tests in my PR and we’ll have Elixir support for
ast-grepvery soon.dimitarvp
My PR has been merged.
We’ll have Elixir support in
ast-grepcome next release (so a matter of days).dimitarvp
ast-grep version 0.14.3 has been released and is now supporting Elixir.
Example usage: