Skip to content

Langspec generics - #104

Open
lm-sousa wants to merge 14 commits into
multi-weaverfrom
langspec-generics
Open

Langspec generics#104
lm-sousa wants to merge 14 commits into
multi-weaverfrom
langspec-generics

Conversation

@lm-sousa

Copy link
Copy Markdown
Member

No description provided.

Copilot AI lite review requested due to automatic review settings August 28, 2026 20:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1268ecde76

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

javaType = ConvertUtils.getAttributeConvertedType(attrClassStr, generator);
// Use IType-aware conversion that resolves ThisType while preserving
// primitive signatures in generated impl methods.
javaType = ConvertUtils.getConvertedType(attrType, generator, currentJpType);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve boxed primitive attribute hooks

Use the attribute-return conversion here rather than the standard conversion. For an attribute declared as int or boolean, this now generates int getFooImpl()/boolean getFooImpl() instead of the previous Integer/Boolean hooks, so existing concrete weavers that implement the generated API with boxed return types stop overriding those methods and fail to compile after regeneration; it also prevents implementations from representing an unavailable attribute with null. The newly retained getAttributeConvertedType(...) API provides the compatibility-preserving conversion but is currently unused by generation.

Useful? React with 👍 / 👎.

Comment on lines +335 to +337
for (IType typeArg : paramType.getTypeArguments()) {
JavaType argJavaType = convert(typeArg, generator, currentJpType, strategy);
baseJavaType.addGeneric(new JavaGenericType(argJavaType));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Box primitive generic arguments

Box a direct primitive type argument before adding it to the parameterized Java type. The language parser accepts declarations such as List<int> and represents int as Primitive.INT, but this loop converts it with the standard strategy and emits List<int>, which is illegal Java and causes generated sources to fail compilation; direct primitive generic arguments need wrapper types such as Integer while primitive arrays like int[] may remain unchanged.

Useful? React with 👍 / 👎.

public final class JavaMethodSignatureUtils {

private static final Pattern METHOD_SIGNATURE_PATTERN = Pattern.compile(
"(?m)^\\s*(?:public|protected|private)\\s+(?:final\\s+|static\\s+|abstract\\s+|synchronized\\s+|native\\s+)*[^\\s(]+(?:\\s*<[^>]+>)?(?:\\s*\\[\\])*(?:\\s+[^\\s(]+(?:\\s*<[^>]+>)?(?:\\s*\\[\\])*)*\\s+(\\w+)\\s*\\(([^)]*)\\)\\s*(?:throws\\s+[^\\{]+)?\\{");
public final class JavaMethodSignatureUtils {

private static final Pattern METHOD_SIGNATURE_PATTERN = Pattern.compile(
"(?m)^\\s*(?:public|protected|private)\\s+(?:final\\s+|static\\s+|abstract\\s+|synchronized\\s+|native\\s+)*[^\\s(]+(?:\\s*<[^>]+>)?(?:\\s*\\[\\])*(?:\\s+[^\\s(]+(?:\\s*<[^>]+>)?(?:\\s*\\[\\])*)*\\s+(\\w+)\\s*\\(([^)]*)\\)\\s*(?:throws\\s+[^\\{]+)?\\{");
- Add WildcardType IType implementation to represent ?, ? extends T, and ? super T, including factory methods (unbounded(), extendsType(), superType()), singleton for unbounded, proper toString()/type(), equals/hashCode and validation.
- Parse wildcard type arguments in LanguageSpecification:
  - Detect wildcard tokens in getType() and route to parseWildcardType(...).
  - Parse ?, ? extends X, ? super X and build corresponding WildcardType instances.
  - Preserve nested generics and array handling (e.g., List<?[]>, ? extends this[]).
- Add extensive XML fixtures for wildcard scenarios:
  - artifacts.xml
  - actionModel.xml
  - joinPointModel.xml
  - Fixtures include nested wildcards, wildcard arrays, multiple wildcards, this-bound wildcards, and attributes with parameters using wildcard types.
- Add integration tests:
  - WildcardTypeXmlIntegrationTest.java — 39 tests covering parsing of wildcard generics, nested cases, arrays, actions, parameters, and inheritance with this.
- Add unit tests:
  - WildcardTypeTest.java — comprehensive unit tests for WildcardType.
- Small supporting changes:
  - Update LanguageSpecification.java to add wildcard handling and parsing helper.
  - Add attribute-parameter tests covering parameters whose types are wildcards and compound generics (e.g., Map<String, ?>, List<? super this>).
  - Minor test resource and test class additions/adjustments to ensure coverage and validation.
…d actions

- Implemented exception handling with ThistypeWeaverException for better error reporting.
- Updated XML specifications of integration tests for actions and artifacts to test 'this' type and generics.
- Enhanced Java code generation tests to ensure 'this' type integration and method signature uniqueness.
- Added regression tests to verify correct behavior of generated code and prevent duplicate signatures.
- Developed utility tests for conversion behavior related to 'this' type in the context of attribute conversion.
… and SuperAbstractJoinPointGenerator; add TypeTraversalUtils for type checks
…or and SuperAbstractJoinPointGenerator; enhance type conversion in ConvertUtils
…'s langspec;

Added utility classes for artifact manifest and JSON invariants

- Introduced `ArtifactManifestEntry` for representing file metadata with methods for TSV conversion.
- Added `InvariantSnapshot` to encapsulate JSON and Java invariants in a structured format.
- Created `JavaDeclarationSignature` to represent Java declaration signatures with normalization functionality.
- Implemented `JavaInvariantUtils` for processing Java files, extracting declarations, and computing snapshots.
- Developed `JsonInvariantUtils` for parsing JSON files, computing snapshots, and validating joinpoint hierarchies.
- Added `ManifestUtils` for computing and managing artifact manifests, including hash generation and comparison methods.
…d extend golden file regeneration to all integrations tests.
@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2026

Copy link
Copy Markdown

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.

3 participants