[ 
https://issues.apache.org/jira/browse/GROOVY-11721?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18029600#comment-18029600
 ] 

Bartosz Popiela commented on GROOVY-11721:
------------------------------------------

_> Did you try the annotation collector option? I'm curious to know if it would 
still produce a target warning._
Yes, it produces a warning in the IDE (even though the test passes). However, 
that wouldn’t solve my issue, as I’d have to create an {{AnnotationCollector}} 
for every 3rd-party annotation I want to cover.
!image-2025-10-13-21-02-09-808.png!

_> Did you try changing the phase of your global transform to Conversion?_
Yes, the warning is still there.
_!image-2025-10-13-21-08-16-216.png!_
!image-2025-10-13-21-08-47-735.png!

_> Are you saying that IntelliJ does not detect the application of the Field 
transform because it is not directly represented in the source? That seems like 
a limitation of IntelliJ/PSI. (...) Eclipse IDE detects transforms applied in 
the conversion phase and semantic analysis phases._
Are you sure about that? That’s surprising, considering that the IDE would have 
to execute the transformation code to know what changes it introduces. IntelliJ 
PSI relies on static code analysis.

Just to make sure we’re on the same page — I inject my transformation using SPI 
({{{}META-INF/services/org.codehaus.groovy.transform.ASTTransformation{}}}), 
and it works at runtime. The only issue is that the IDE can’t know what changes 
will be applied without executing all Groovy transformations present on the 
compilation classpath. Moreover, the runtime classpath may differ from the 
compilation classpath. Therefore, it would be convenient if 
@{{{}groovy.transform.Field{}}} also supported {{@Target(\{ElementType.TYPE})}} 
(implicitely applying @Field to all local vars).

> @groovy.transform.Field to annotate a script class
> --------------------------------------------------
>
>                 Key: GROOVY-11721
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11721
>             Project: Groovy
>          Issue Type: New Feature
>    Affects Versions: 5.0.0-beta-2
>            Reporter: Bartosz Popiela
>            Priority: Major
>         Attachments: image-2025-08-27-14-08-33-523.png, 
> image-2025-08-28-02-47-30-911.png, image-2025-10-13-21-02-09-808.png, 
> image-2025-10-13-21-08-16-216.png, image-2025-10-13-21-08-47-735.png
>
>
> We use undeclared Groovy Scripts together with JUnit for writing unit tests 
> because it supports sentences as method names and doesn’t impose restrictions 
> on the file name (we need the test script name to match the name of the YAML 
> file being tested). This solution works very well; the only downside is that 
> in order to use annotations on a field, such as [email protected]_, we 
> also need to use [email protected]_, since those annotations typically 
> don’t have target = LOCAL_VARIABLE. It would be convenient if _@Field_ could 
> be placed on the script class (with _@Inherited_ to support a base script) 
> and be automatically applied to all local variables in the script



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to