-
Notifications
You must be signed in to change notification settings - Fork 6
✨ Dart #48
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
✨ Dart #48
Conversation
WalkthroughThis PR introduces support for the Dart language in the AST-Grep ecosystem. It adds a new package ( Changes
Sequence Diagram(s)sequenceDiagram
participant Nursery as Nursery.js
participant Registration as Language Module
participant Parser as Tree-sitter Parser
Nursery->>Registration: Import language registration data
Nursery->>Parser: Initialize parser with registration details
Parser-->>Nursery: Return syntax tree
Nursery->>Nursery: Validate AST nodes
sequenceDiagram
participant Installer as Package Manager
participant PostInstall as postinstall.js
participant SetupLang as @ast-grep/setup-lang
Installer->>PostInstall: Run postinstall script
PostInstall->>SetupLang: Invoke setup with __dirname
SetupLang-->>PostInstall: Complete post-installation tasks
Possibly related PRs
Suggested reviewers
Poem
🪧 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 (6)
packages/dart/nursery.js (1)
1-16
: LGTM! Test setup follows the standard pattern.The nursery script properly sets up a testing environment for Dart language parsing with a simple but effective validation test to ensure the parser can correctly identify an identifier.
Consider expanding test coverage in the future to include more complex Dart language constructs, such as:
- Class definitions
- Function declarations
- Type annotations
- Dart-specific syntax like async/await
packages/dart/README.md (1)
1-24
: LGTM! Documentation contains essential information.The README provides clear installation and usage instructions that follow the standard format for AST-Grep language packages.
Consider these enhancements to make the documentation more helpful for new users:
- Add a brief description of what the package does and its purpose
- Include a more complete usage example showing actual results
- Add a link to the main AST-Grep documentation
- Specify whether the example uses ES modules or provide a CommonJS alternative
packages/dart/index.d.ts (1)
1-10
: LGTM! Type definitions match the expected interface.The TypeScript declarations correctly define the
LanguageRegistration
type with all the required properties and properly export the registration object.Consider adding JSDoc comments to explain the purpose of each property, especially the less obvious ones like
metaVarChar
andexpandoChar
, to make the code more self-documenting:type LanguageRegistration = { + /** Path to the language library (.so/.dll) */ libraryPath: string + /** File extensions associated with this language */ extensions: string[] + /** Symbol name for the language in the library */ languageSymbol?: string + /** Character used for meta variables in pattern matching */ metaVarChar?: string + /** Character used for multi-meta variables in pattern matching */ expandoChar?: string }packages/dart/package.json (3)
1-5
: Enhance Package Metadata
The basic package metadata is correctly established. However, the"description"
field is left empty. Providing a concise description (e.g., "Dart language support for AST-Grep") will improve clarity on registries and package listings.- "description": "", + "description": "Dart language support for AST-Grep",
13-20
: Files Array Validation
Thefiles
array includes all necessary artifacts for publishing. Confirm that including both"index.d.ts"
and"type.d.ts"
is intentional and that they serve distinct purposes.
21-23
: Metadata Details Improvement
While thekeywords
,author
, andlicense
fields are present, consider adding proper author details for correct attribution.
📜 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/dart/README.md
(1 hunks)packages/dart/index.d.ts
(1 hunks)packages/dart/index.js
(1 hunks)packages/dart/nursery.js
(1 hunks)packages/dart/package.json
(1 hunks)packages/dart/postinstall.js
(1 hunks)
🔇 Additional comments (10)
packages/dart/postinstall.js (1)
1-4
: LGTM! Postinstall script follows the standard pattern.The implementation correctly imports and uses the
postinstall
function from@ast-grep/setup-lang
, following the established pattern used in other language packages.packages/dart/index.js (2)
1-2
: Modern Import Usage
The use ofrequire('node:path')
is appropriate for recent Node.js versions. If backward compatibility for older Node.js versions is a concern, ensure this import style is acceptable.
4-9
: Clear and Concise Export Structure
The exported object clearly defines the properties needed for Dart language support. Each key (i.e.libraryPath
,extensions
,languageSymbol
, andexpandoChar
) is appropriately set, ensuring ease of use for downstream consumers.packages/dart/package.json (7)
6-12
: Review of Scripts Section
The defined scripts for building, sourcing, prepublishing, post-installation, and testing are in line with standard package lifecycle operations. Ensure that commands like"prepublishOnly": "node nursery.js source"
behave as expected in your CI/CD pipeline.
24-26
: Dependencies Declaration
The dependency on@ast-grep/setup-lang
is clearly declared with version"0.0.3"
. Double-check that this version aligns with your project’s expectations and that it is compatible with the Dart language support tooling.
27-29
: Peer Dependency Check
The peer dependency on"tree-sitter-cli"
is specified correctly. Verify that this version ("0.24.6"
) satisfies the requirements from other related packages.
30-34
: Optional Peer Dependency Setup
The configuration underpeerDependenciesMeta
correctly marks"tree-sitter-cli"
as optional, which enhances installation flexibility.
35-39
: Dev Dependencies Verification
The dev dependencies are aptly listed for testing and building, including@ast-grep/nursery
,tree-sitter-cli
, andtree-sitter-dart
. Confirm that these versions ("0.0.2"
,"0.24.6"
, and"1.0.0"
, respectively) integrate smoothly with your build and test workflow.
40-43
: Publish Configuration
ThepublishConfig
section is well-formed for ensuring public publication to npm. This will aid in streamlining the package deployment process.
44-46
: PNPM Configuration Appropriateness
The pnpm configuration specifying"onlyBuiltDependencies"
for@ast-grep/lang-dart
andtree-sitter-cli
looks correct. Revisit this list if additional dependencies need bundling in future releases.
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 (3)
packages/dart/package.json (3)
1-5
: Suggestion: Enhance Package Metadata
The basic metadata is correctly defined; however, the"description"
field is currently empty. Adding a brief description would improve package discoverability and help users understand its purpose.
6-12
: Review: Validate Package Scripts
The scripts (build
,source
,prepublishOnly
,postinstall
, andtest
) are clearly defined and align with managing the package lifecycle. Please ensure that thetree-sitter
commands (e.g.,tree-sitter build -o parser.so
) work uniformly across different platforms and environments.
21-23
: Suggestion: Complete Package Fields
Consider updating the"author"
field with proper contact information or attribution, and filling out the"description"
field to provide clarity on the package's functionality and benefits.
📜 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 (7)
.changeset/yummy-hats-sniff.md
(1 hunks)packages/dart/README.md
(1 hunks)packages/dart/index.d.ts
(1 hunks)packages/dart/index.js
(1 hunks)packages/dart/nursery.js
(1 hunks)packages/dart/package.json
(1 hunks)packages/dart/postinstall.js
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
- packages/dart/postinstall.js
- packages/dart/README.md
- packages/dart/index.js
- .changeset/yummy-hats-sniff.md
- packages/dart/nursery.js
- packages/dart/index.d.ts
🔇 Additional comments (5)
packages/dart/package.json (5)
13-20
: Confirmation: Package Files Inclusion
The"files"
array includes all the necessary files (index.js
, TypeScript definitions,postinstall.js
, and source directories). This setup should guarantee that consumers get the complete set of required assets.
24-34
: Review: Dependencies and Peer Dependencies
The dependency on"@ast-grep/setup-lang": "0.0.3"
and the peer dependency on"tree-sitter-cli": "0.24.6"
(with its optional flag) are appropriately declared. Verify that these version specifications align with the broader ecosystem and that downstream packages are aware of these requirements.
35-39
: Confirmation: Dev Dependencies Setup
The development dependencies (including"@ast-grep/nursery"
,"tree-sitter-cli"
, and"tree-sitter-dart"
) are well specified to support testing and parser building.
40-43
: Validation: Publish Configuration
The"publishConfig"
is correctly set to publish the package publicly to the npm registry, ensuring easy access for users.
44-46
: Evaluation: pnpm Configuration
The pnpm configuration, targeting only built dependencies ("@ast-grep/lang-dart"
and"tree-sitter-cli"
), is properly specified. This helps keep the final package lean and ensures that only necessary assets are distributed.
Actually one of my favourite languages :P
Summary by CodeRabbit
Documentation
New Features
Chores
package.json
file for managing package metadata and dependencies.