Skip to content

✨ Java #52

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

Merged
merged 3 commits into from
Apr 5, 2025
Merged

✨ Java #52

merged 3 commits into from
Apr 5, 2025

Conversation

NatoBoram
Copy link
Collaborator

@NatoBoram NatoBoram commented Apr 2, 2025

Summary by CodeRabbit

  • New Features

    • Introduced comprehensive support for Java language processing, enabling integration and parsing of Java code.
  • Documentation

    • Added detailed instructions covering installation and usage to help users adopt the new Java capabilities.
  • Tests

    • Implemented a testing setup to validate the Java language functionalities.
  • Chores

    • Updated package configurations and post-install routines to seamlessly integrate the new Java support.

Copy link

coderabbitai bot commented Apr 2, 2025

Walkthrough

This pull request introduces a new Java language module in the project. A changeset entry has been added to include the dependency @ast-grep/lang-java. New documentation, type definitions, and implementation files have been created to support Java language parsing. Additionally, a test setup using a nursery environment verifies the module’s functionality. Package configuration files, including a fresh package.json and a post-installation script, ensure proper setup and dependency management for the Java package.

Changes

File(s) Change Summary
.changeset/solid-donkeys-pump.md Added entry to include the dependency @ast-grep/lang-java.
packages/java/README.md New README providing installation instructions and usage details for Java language support.
packages/java/(index.d.ts, index.js) Introduced type definitions and module exports for Java language registration and integration.
packages/java/nursery.js Added a testing file that sets up a nursery environment to parse and validate Java code snippets.
packages/java/(package.json, postinstall.js) Added package manifest with metadata, scripts, and a post-install script for configuration.

Sequence Diagram(s)

sequenceDiagram
    participant TestRunner as Nursery Test Runner
    participant Nursery as @ast-grep/nursery
    participant LangReg as Language Registration
    participant Parser as Java Parser (Tree-sitter)
    
    TestRunner->>Nursery: Initiate test setup for Java
    Nursery->>LangReg: Import and register language module
    LangReg->>Parser: Initialize parser with libPath and config
    Parser-->>LangReg: Return parsed syntax tree
    LangReg->>Nursery: Provide syntax tree to test runner
    Nursery->>TestRunner: Assert the correctness of the syntax tree
Loading

Suggested reviewers

  • HerringtonDarkholme

Poem

I'm just a rabbit hopping by,
Seeing new Java paths that fly,
Code and tests all in a row,
With modules and docs all set to go,
Carrots and code make my day shine bright 🥕,
Cheers to new changes taking flight!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c3b8cc3 and 4a2ffdb.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • .changeset/solid-donkeys-pump.md (1 hunks)
  • packages/java/README.md (1 hunks)
  • packages/java/index.d.ts (1 hunks)
  • packages/java/index.js (1 hunks)
  • packages/java/nursery.js (1 hunks)
  • packages/java/package.json (1 hunks)
  • packages/java/postinstall.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/java/postinstall.js
  • packages/java/index.d.ts
  • packages/java/README.md
  • .changeset/solid-donkeys-pump.md
  • packages/java/nursery.js
  • packages/java/index.js
  • packages/java/package.json

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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/java/index.d.ts (1)

1-10: Consider adding JSDoc comments to the type definition.

The LanguageRegistration type and its properties would benefit from documentation comments explaining their purpose and expected values, especially for the optional properties like languageSymbol, metaVarChar, and expandoChar.

+/**
+ * Registration information for the Java language parser
+ */
 type LanguageRegistration = {
+  /** Path to the compiled language library */
   libraryPath: string
+  /** File extensions associated with this language */
   extensions: string[]
+  /** Symbol used to identify the language in the parser */
   languageSymbol?: string
+  /** Character used for metavariables in pattern matching */
   metaVarChar?: string
+  /** Character used for expando variables in pattern matching */
   expandoChar?: string
 }
packages/java/package.json (2)

4-4: Add a descriptive package description.

The description field is currently empty. Consider adding a concise description of what this package does, such as "Java language support for ast-grep".


22-22: Add author information.

The author field is empty. Consider adding appropriate author information to maintain consistency with other packages.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7a802d and c3b8cc3.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • .changeset/solid-donkeys-pump.md (1 hunks)
  • packages/java/README.md (1 hunks)
  • packages/java/index.d.ts (1 hunks)
  • packages/java/index.js (1 hunks)
  • packages/java/nursery.js (1 hunks)
  • packages/java/package.json (1 hunks)
  • packages/java/postinstall.js (1 hunks)
🔇 Additional comments (8)
.changeset/solid-donkeys-pump.md (1)

1-6: LGTM! Changeset correctly documents the new Java language package.

The changeset entry properly specifies the new package @ast-grep/lang-java as a patch version and includes a clear description.

packages/java/postinstall.js (1)

1-4: LGTM! Post-installation script looks good.

The script appropriately imports and calls the postinstall function from the setup module, passing the current directory as expected.

packages/java/README.md (1)

1-24: LGTM! Documentation is clear and complete.

The README provides clear installation instructions and a concise usage example that demonstrates the essential functionality of the package.

packages/java/nursery.js (1)

1-16: LGTM! Good test setup for Java language support.

The nursery setup correctly configures the test environment for Java language processing. The test is simple but effectively verifies that basic Java syntax is properly parsed into the expected AST structure.

packages/java/index.js (1)

1-9: LGTM! Proper language registration configuration.

The module correctly exports the necessary configuration for Java language support, including the library path, file extensions, language symbol, and expando character for syntax tree manipulation.

packages/java/package.json (3)

1-47: LGTM! Well-structured package configuration.

The package.json is well-structured with appropriate dependencies, scripts, and configuration. The minor suggestions above aside, this looks ready to go.


10-10:

✅ Verification successful

Verify postinstall.js exists.

The postinstall script references postinstall.js, which is included in the files array but not provided in the changeset. Make sure this file exists or will be created.


🏁 Script executed:

#!/bin/bash
# Check if postinstall.js exists in the repository
find packages/java -name "postinstall.js" -type f

Length of output: 78


Postinstall.js file exists and is correctly referenced.

  • The file at packages/java/postinstall.js is present in the repository per the verification script, so no further action is needed.

23-23:

✅ Verification successful

Verify license consistency.

Ensure the ISC license is consistent with the licensing approach used in other packages in the repository.


🏁 Script executed:

#!/bin/bash
# Check licenses used in other package.json files
grep -r "\"license\":" packages/*/package.json | sort | uniq -c

Length of output: 777


License Consistency Verified

The ISC license is used uniformly across all packages (e.g., packages/angular, packages/c, packages/cpp, packages/csharp, packages/go, packages/java, packages/python, packages/sql, and packages/toml). No changes are needed.

@HerringtonDarkholme HerringtonDarkholme merged commit 14131e0 into ast-grep:main Apr 5, 2025
3 checks passed
@NatoBoram NatoBoram deleted the feature/java branch April 5, 2025 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants