Langspec generics - #104
Conversation
There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
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 👍 / 👎.
| for (IType typeArg : paramType.getTypeArguments()) { | ||
| JavaType argJavaType = convert(typeArg, generator, currentJpType, strategy); | ||
| baseJavaType.addGeneric(new JavaGenericType(argJavaType)); |
There was a problem hiding this comment.
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 👍 / 👎.
1268ecd to
2caf429
Compare
| 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+[^\\{]+)?\\{"); |
2caf429 to
d7b19d3
Compare
- 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.
… field count and JSON structure
… and improve type handling
… and SuperAbstractJoinPointGenerator; add TypeTraversalUtils for type checks
…or and SuperAbstractJoinPointGenerator; enhance type conversion in ConvertUtils
…s WeaverGenerator
…'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.
…essary return type adjustments and imports
d7b19d3 to
7b50bbf
Compare
|



No description provided.