-
Notifications
You must be signed in to change notification settings - Fork 106
Add api for static initializers #386
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
Conversation
|
Looks good, but we need some tests also |
|
Okay I have implemented some tests now, please tell me if anything is missing not up to standards :) |
impl/src/main/java/org/jboss/forge/roaster/model/impl/InitializerImpl.java
Outdated
Show resolved
Hide resolved
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.
Pull request overview
This PR adds API support for static initializers to Roaster, enabling users to add, retrieve, and remove initializer blocks for Java classes, enums, and records. This addresses issue #237 by introducing a comprehensive initializer management API.
Key changes:
- Introduced new API interfaces (
Initializer,InitializerHolder,InitializerSource,InitializerHolderSource) to represent and manage initializer blocks - Implemented initializer support in
JavaClassImpl,JavaEnumImpl, andJavaRecordImplwith methods to add, get, and remove initializers - Added comprehensive test coverage for initializer functionality across all three Java type implementations
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
api/src/main/java/org/jboss/forge/roaster/model/Initializer.java |
New interface defining the base contract for initializer blocks with body retrieval |
api/src/main/java/org/jboss/forge/roaster/model/InitializerHolder.java |
New interface for types that can contain initializers, providing getInitializers() |
api/src/main/java/org/jboss/forge/roaster/model/source/InitializerSource.java |
Source-level initializer interface extending Initializer with setBody() capability |
api/src/main/java/org/jboss/forge/roaster/model/source/InitializerHolderSource.java |
Source-level interface for adding and removing initializers |
api/src/main/java/org/jboss/forge/roaster/model/JavaClass.java |
Updated to extend InitializerHolder interface |
api/src/main/java/org/jboss/forge/roaster/model/JavaEnum.java |
Updated to extend InitializerHolder interface |
api/src/main/java/org/jboss/forge/roaster/model/JavaRecord.java |
Updated to extend InitializerHolder interface |
api/src/main/java/org/jboss/forge/roaster/model/source/JavaClassSource.java |
Updated to extend InitializerHolderSource interface |
api/src/main/java/org/jboss/forge/roaster/model/source/JavaEnumSource.java |
Updated to extend InitializerHolderSource interface |
api/src/main/java/org/jboss/forge/roaster/model/source/JavaRecordSource.java |
Updated to extend InitializerHolderSource interface |
impl/src/main/java/org/jboss/forge/roaster/model/impl/InitializerImpl.java |
New implementation class handling initializer body parsing, static modifier management, and JavaDoc support |
impl/src/main/java/org/jboss/forge/roaster/model/impl/JavaClassImpl.java |
Implements initializer management methods for classes |
impl/src/main/java/org/jboss/forge/roaster/model/impl/JavaEnumImpl.java |
Implements initializer management methods for enums, includes formatting fix |
impl/src/main/java/org/jboss/forge/roaster/model/impl/JavaRecordImpl.java |
Implements initializer management methods for records |
tests/src/test/java/org/jboss/forge/test/roaster/model/JavaClassInitializerTest.java |
Tests for class initializer static flag operations |
tests/src/test/java/org/jboss/forge/test/roaster/model/JavaEnumInitializerTest.java |
Tests for enum initializer static flag operations |
tests/src/test/java/org/jboss/forge/test/roaster/model/JavaRecordInitializerTest.java |
Tests for record initializer static flag operations |
tests/src/test/java/org/jboss/forge/test/roaster/model/InitializerBodyTest.java |
Tests for initializer body manipulation including lambdas and complex statements |
tests/src/test/java/org/jboss/forge/test/roaster/model/InitializerImplementationTest.java |
Tests for initializer validation and error handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
impl/src/main/java/org/jboss/forge/roaster/model/impl/InitializerImpl.java
Show resolved
Hide resolved
impl/src/main/java/org/jboss/forge/roaster/model/impl/JavaClassImpl.java
Show resolved
Hide resolved
api/src/main/java/org/jboss/forge/roaster/model/source/InitializerHolderSource.java
Show resolved
Hide resolved
tests/src/test/java/org/jboss/forge/test/roaster/model/JavaClassInitializerTest.java
Show resolved
Hide resolved
tests/src/test/java/org/jboss/forge/test/roaster/model/JavaEnumInitializerTest.java
Show resolved
Hide resolved
tests/src/test/java/org/jboss/forge/test/roaster/model/JavaRecordInitializerTest.java
Show resolved
Hide resolved
tests/src/test/java/org/jboss/forge/test/roaster/model/JavaClassInitializerTest.java
Outdated
Show resolved
Hide resolved
tests/src/test/java/org/jboss/forge/test/roaster/model/JavaEnumInitializerTest.java
Outdated
Show resolved
Hide resolved
As introduced in forge#387
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
gastaldi
left a comment
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.
LGTM
|
Thanks! I'll cut a release later today |
This adds an api to Roaster which allows to add/remove/get static initializers of enums, classes and records.
This should close #237