-
Notifications
You must be signed in to change notification settings - Fork 6
✨ Elixir #49
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
✨ Elixir #49
Conversation
WalkthroughThis pull request introduces Elixir language support for the AST grep tool. It provides a new README with installation and usage instructions, defines and exports a new language registration type and configuration in both TypeScript and JavaScript files, and includes scripts for package installation and testing. A testing setup file (nursery.js) configures a test environment using a sample Elixir code snippet, while the package metadata (package.json) and a post-install script complete the integration. Changes
Sequence Diagram(s)sequenceDiagram
participant T as Test Runner (nursery.js)
participant N as Nursery Setup (@ast-grep/nursery)
participant L as Language Registration (index.js / index.d.ts)
participant P as Parser Library
T->>N: Invoke setup(config with L)
N->>L: Retrieve language configuration
L->>P: Load parser using libraryPath and extensions
P-->>L: Provide parser instance
N->>T: Complete setup and run parsing test
T->>P: Parse sample code "IO.puts(\"123\")"
P-->>T: Return AST structure
T->>T: Assert node kind is 'call'
sequenceDiagram
participant NPM as npm install
participant P as postinstall.js
participant S as @ast-grep/setup-lang
NPM->>P: Trigger postinstall script
P->>S: Execute postinstall({ dirname: __dirname })
S-->>P: Complete language-specific setup
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (7)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/elixir/package.json (2)
4-4
: Add a descriptive package description.The description field is currently empty. Adding a clear description will help users understand the purpose of this package when browsing the npm registry.
- "description": "", + "description": "Elixir language support for ast-grep",
22-22
: Add author information.The author field is currently empty. Consider adding appropriate author information for attribution and contact purposes.
- "author": "", + "author": "NatoBoram <[email protected]>",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (6)
packages/elixir/README.md
(1 hunks)packages/elixir/index.d.ts
(1 hunks)packages/elixir/index.js
(1 hunks)packages/elixir/nursery.js
(1 hunks)packages/elixir/package.json
(1 hunks)packages/elixir/postinstall.js
(1 hunks)
🔇 Additional comments (12)
packages/elixir/postinstall.js (1)
1-4
: Implementation looks good!The postinstall script correctly imports and calls the setup function with the current directory, following the standard pattern for ast-grep language packages.
packages/elixir/index.d.ts (2)
1-7
: Type definition looks complete and appropriate.The
LanguageRegistration
type properly defines all required fields (libraryPath, extensions) and optional configuration fields (languageSymbol, metaVarChar, expandoChar) needed for Elixir language support in ast-grep.
9-10
: Export declaration is correct.The type declaration and default export of the registration constant follows proper TypeScript patterns and will work correctly with the implementation file.
packages/elixir/nursery.js (2)
1-4
: Correct import setup for testing environment.The necessary modules are properly imported for setting up the test environment, including the nursery setup function, Node.js assert module, and the language registration.
5-16
: Test configuration and runner look good.The setup configuration correctly specifies:
- The Elixir language name
- The appropriate Tree-sitter package ('tree-sitter-elixir')
- A test runner that validates basic parsing and pattern matching
The test case effectively verifies that an Elixir function call is correctly parsed and can be matched with a pattern containing a metavariable.
packages/elixir/README.md (3)
1-2
: Clear and concise title.The title accurately describes the package as an ast-grep NAPI language for Elixir.
3-12
: Installation instructions are complete.The installation section properly covers all required dependencies:
- The Elixir language package itself
- The NAPI package requirement
- The conditional installation of tree-sitter-cli
This provides users with a complete setup process for using Elixir with ast-grep in a pnpm environment.
14-24
: Usage example is clear and helpful.The example demonstrates the complete workflow:
- Importing the necessary modules
- Registering the Elixir language
- Parsing Elixir code
- Accessing the AST
This gives users a practical reference for implementing Elixir support in their projects.
packages/elixir/index.js (1)
1-9
: LGTM! Elixir language configuration is well-structured.The configuration exports all the necessary components for integrating Elixir with ast-grep:
- Correctly uses node:path module
- Properly references the parser.so file in the same directory
- Includes appropriate file extensions for Elixir (.ex and .exs)
- Sets the proper language symbol for Tree-sitter
- Defines an expandoChar that's unlikely to conflict with Elixir syntax
The implementation follows the expected pattern for language packages in ast-grep.
packages/elixir/package.json (3)
6-12
: LGTM! Scripts setup is comprehensive.The scripts section is well-configured with all necessary lifecycle hooks:
- Build script for creating the parser
- Source and prepublishOnly scripts for preparation
- Postinstall script for setup after installation
- Test script for verification
This provides a complete workflow for development, testing, and distribution.
13-20
: LGTM! Package files are properly configured.The files array correctly includes all necessary components:
- Main module file
- Type definitions
- Installation script
- Source code
- Prebuilt binaries
This ensures the package will be complete when published to npm.
35-39
:✅ Verification successful
Verify tree-sitter-elixir version.
The package uses tree-sitter-elixir at version 0.3.4. Please verify this is the latest stable version that properly supports the Elixir language syntax.
🌐 Web query:
What is the latest version of tree-sitter-elixir?
💡 Result:
The latest version of
tree-sitter-elixir
is 0.3.4, released on February 6, 2025[2]. This version is available on package managers like npm and Rust's crates.io[2][5]. The project continues to be actively maintained, with GitHub using it for Elixir syntax highlighting and code navigation[2][5][6].For context:
- Previous versions include 0.3.3 (December 2024) and 0.2.0 (April 2024)[2][9]
- The parser handles modern Elixir syntax including LiveView Native templates and improved error handling[9]
- Bindings exist for multiple languages including Rust, JavaScript (through npm), and Elixir itself via the
ex_tree_sitter
package[1][4][5]Citations:
- 1: https://docs.rs/tree-sitter-elixir
- 2: https://lib.rs/crates/tree-sitter-elixir
- 3: https://elixirforum.com/t/need-help-testing-emacs-elixir-tree-sitter/43975
- 4: https://hex.pm/packages/ex_tree_sitter
- 5: https://www.npmjs.com/package/tree-sitter-elixir
- 6: https://github.com/elixir-lang/tree-sitter-elixir
- 7: https://pypi.org/project/tree-sitter-languages/
- 8: https://tree-sitter.github.io
- 9: https://github.com/elixir-lang/tree-sitter-elixir/releases
- 10: https://elixir-lang.org/tree-sitter-elixir/
Tree-sitter-elixir version verified as up-to-date
After verifying the latest release from the official sources, it's confirmed that version 0.3.4 is indeed the latest stable release for tree-sitter-elixir. No modifications are needed in the
packages/elixir/package.json
as the dependency is current.
b88310b
to
3359e14
Compare
3359e14
to
c97bc12
Compare
A very fun language to learn. Functional programming is kinda mind-blowing.
Summary by CodeRabbit