You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "paulk-asert (via GitHub)" <gi...@apache.org> on 2026/05/22 23:46:11 UTC

[PR] GROOVY-12030: Graduate PropertyHandler from incubating to stable [groovy]

paulk-asert opened a new pull request, #2554:
URL: https://github.com/apache/groovy/pull/2554

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-12030: Graduate PropertyHandler from incubating to stable [groovy]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #2554:
URL: https://github.com/apache/groovy/pull/2554#issuecomment-4523612567

   ## ✅ All tests passed ✅
   
   🏷️ Commit: 310251d48275eb739ead30ceb4a9f37bc53bd262
   ▶️ Tests:  47378 executed
   ⚪️ Checks: 28/28 completed
   
   ---
   _Learn more about TestLens at [testlens.app](https://testlens.app)._
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-12030: Graduate PropertyHandler from incubating to stable [groovy]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2554:
URL: https://github.com/apache/groovy/pull/2554#issuecomment-4523576090

   ## [Codecov](https://app.codecov.io/gh/apache/groovy/pull/2554?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 68.1945%. Comparing base ([`5318145`](https://app.codecov.io/gh/apache/groovy/commit/53181454e08716af1fb76927215775fb75084f56?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`310251d`](https://app.codecov.io/gh/apache/groovy/commit/310251d48275eb739ead30ceb4a9f37bc53bd262?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 4 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/groovy/pull/2554/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/2554?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #2554        +/-   ##
   ==================================================
   + Coverage     68.1844%   68.1945%   +0.0101%     
   - Complexity      33086      33098        +12     
   ==================================================
     Files            1508       1508                
     Lines          126130     126145        +15     
     Branches        22878      22886         +8     
   ==================================================
   + Hits            86001      86024        +23     
   + Misses          32490      32485         -5     
   + Partials         7639       7636         -3     
   ```
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/groovy/pull/2554?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...oovy/transform/options/DefaultPropertyHandler.java](https://app.codecov.io/gh/apache/groovy/pull/2554?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Ftransform%2Foptions%2FDefaultPropertyHandler.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvdHJhbnNmb3JtL29wdGlvbnMvRGVmYXVsdFByb3BlcnR5SGFuZGxlci5qYXZh) | `92.3077% <100.0000%> (-0.2849%)` | :arrow_down: |
   | [...java/groovy/transform/options/PropertyHandler.java](https://app.codecov.io/gh/apache/groovy/pull/2554?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Ftransform%2Foptions%2FPropertyHandler.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvdHJhbnNmb3JtL29wdGlvbnMvUHJvcGVydHlIYW5kbGVyLmphdmE=) | `62.9630% <100.0000%> (+14.8148%)` | :arrow_up: |
   
   ... and [5 files with indirect coverage changes](https://app.codecov.io/gh/apache/groovy/pull/2554/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-12030: Graduate PropertyHandler from incubating to stable [groovy]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2554:
URL: https://github.com/apache/groovy/pull/2554#discussion_r3291653286


##########
src/test/groovy/groovy/transform/options/PropertyHandlerTest.groovy:
##########
@@ -0,0 +1,135 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package groovy.transform.options
+
+import org.codehaus.groovy.ast.AnnotationNode
+import org.codehaus.groovy.ast.ClassNode
+import org.codehaus.groovy.ast.Parameter
+import org.codehaus.groovy.ast.PropertyNode
+import org.codehaus.groovy.ast.stmt.Statement
+import org.codehaus.groovy.transform.AbstractASTTransformation
+import org.junit.jupiter.api.Test
+
+import static groovy.test.GroovyAssert.assertScript
+import static groovy.test.GroovyAssert.shouldFail
+import static org.codehaus.groovy.ast.tools.GeneralUtils.assignS
+import static org.codehaus.groovy.ast.tools.GeneralUtils.constX
+import static org.codehaus.groovy.ast.tools.GeneralUtils.plusX
+import static org.codehaus.groovy.ast.tools.GeneralUtils.propX
+import static org.codehaus.groovy.ast.tools.GeneralUtils.varX
+
+/**
+ * Locks in the public contract of {@link PropertyHandler}: that user-supplied
+ * handlers wired in via {@code @PropertyOptions(propertyHandler = …)} are
+ * loaded, validated and consulted at compile time.
+ */
+final class PropertyHandlerTest {
+
+    @Test
+    void testCustomHandlerControlsPropertyInitialisation() {
+        assertScript '''
+            import groovy.transform.PropertyOptions
+            import groovy.transform.TupleConstructor
+            import groovy.transform.options.PropertyHandlerTest.PrefixingPropertyHandler
+
+            @PropertyOptions(propertyHandler = PrefixingPropertyHandler)
+            @TupleConstructor
+            class Foo {
+                String name
+            }
+
+            assert new Foo('hello').name == 'X_hello'
+        '''
+    }
+
+    @Test
+    void testHandlerValidateAttributesCanRejectAnAttribute() {
+        // Exercises a list-valued attribute (`includes = [...]`); detection relies on
+        // PropertyHandler.isValidAttribute using AnnotationNode.getMember rather than
+        // the scalar-only AbstractASTTransformation.getMemberValue.

Review Comment:
   The comment describing `AbstractASTTransformation.getMemberValue` as "scalar-only" is a bit misleading; the key limitation is that it only returns values for `ConstantExpression` members (and returns null for `ListExpression`, closures, etc.). Tweaking the wording will make the test rationale more precise.
   



##########
src/main/java/groovy/transform/options/PropertyHandler.java:
##########
@@ -72,15 +82,18 @@ public boolean validateProperties(final AbstractASTTransformation xform, final B
     }
 
     /**
-     * Create a statement that will initialize the property including any defensive copying. Null if no statement should be added.
+     * Create a statement that will initialize the property including any defensive copying.
+     * Return {@code null} to indicate that no initialization statement should be emitted
+     * for this property; this is distinct from returning an empty block and skips the
+     * corresponding entry in the generated constructor body altogether.
      *
      * @param xform the transform being processed
      * @param anno the '@ImmutableBase' annotation node
      * @param cNode the classnode containing the property
      * @param pNode the property node to initialize
-     * @param namedArgMap an "args" Map if the property value should come from a named arg map or null if not
+     * @param namedArgsMap an "args" Map if the property value should come from a named arg map or null if not

Review Comment:
   The `createPropInit` Javadoc still says `anno` is the "'@ImmutableBase' annotation node", but this hook is used by multiple transforms (e.g. `@TupleConstructor`, `@MapConstructor`, `@ImmutableBase`, `@RecordType`). Since this PR is graduating `PropertyHandler` to a stable API, the parameter docs should be accurate/generic to avoid misleading implementers.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-12030: Graduate PropertyHandler from incubating to stable [groovy]

Posted by "daniellansun (via GitHub)" <gi...@apache.org>.
daniellansun merged PR #2554:
URL: https://github.com/apache/groovy/pull/2554


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org