You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/12/19 17:22:00 UTC
[jira] [Commented] (GROOVY-7681) ability to add warnings from AST transformations
[ https://issues.apache.org/jira/browse/GROOVY-7681?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17462240#comment-17462240 ]
Eric Milles commented on GROOVY-7681:
-------------------------------------
This is how I add a warning for an AST node ({{argument}} in this case):
{code}
getErrorCollector().addWarning(0, warning, new org.codehaus.groovy.syntax.Token(0, argument.getText(), argument.getLineNumber(), argument.getColumnNumber()), getSourceUnit());
{code}
> ability to add warnings from AST transformations
> ------------------------------------------------
>
> Key: GROOVY-7681
> URL: https://issues.apache.org/jira/browse/GROOVY-7681
> Project: Groovy
> Issue Type: Improvement
> Affects Versions: 2.4.5
> Reporter: Christopher Smith
> Priority: Minor
>
> {{AbstractASTTransformation}} has a convenience method {{addError}} to attach an error to a particular node, such as an offending field, but it does not have a corresponding method to attach a warning. In examining the {{addWarning}} methods on {{ErrorCollector}}, it seems that {{WarningMessage}} makes the assumption that warnings can only happen on *CST* nodes; I couldn't find any way to register a warning that didn't have a CST location attached.
> I am trying to add a semantic warning if a transformation is asked to add a property that is explicitly declared but exactly matches the one that would be generated.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)