[antlr-interest] Generated classes - annotations

Terence Parr parrt at cs.usfca.edu
Sat Aug 1 14:31:38 PDT 2009


  Don't tell anybody I told you this, but you can do this:

@annotatemethod { @SuppressWarnings("all") }

and then alter Java.stg so that it references

<actions.annotatemethod>

right before the method definition. Bob's your uncle, and you have  
annotations.

ANTLR's output template mechanism allows you to name any action you  
want and then reference it from the output templates.

Ter

On Aug 1, 2009, at 1:32 PM, Sam Barnett-Cormack wrote:

> Hey all,
>
> similar to previous discussions of doc-comments reaching the generated
> classes, it'd be *really* nice if it were possible to annotate the
> generated classes. Specifically, adding @SuppressWarnings("all") would
> be lovely, as the generated code produces so many warnings (dead code,
> unused local variables, unused imports...).
>
> If there were just something, akin to @header, that appeared between  
> the
> antlr-generated imports and the actual class, that would do the  
> trick -
> for doc-comments (of the class) and for annotations.
>
> Just a thought.
>
> -- 
> Sam Barnett-Cormack
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list