groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shil Sinha <>
Subject Re: AST transformation to modify variable names
Date Wed, 29 Jul 2015 19:59:27 GMT
Have you looked at VariableAccessReplacer and its related classes
in org.codehaus.groovy.transform.tailrec? They might not fit your use case
as is, but you could probably modify them to do what you want.

On Wed, Jul 29, 2015 at 4:40 AM, Wolfgang Pedot <>

> Hello,
> I have the following Scenario:
> OSGI-based application with embedded GroovyScriptEngines, lots of
> small(ish) scripts which use variables from the Binding.
> All those Binding-Variables are written in uppercase (like constants) to
> distinguish them from locally used variables in the script.
> While looking into recent increases in compile-time for the scripts I
> learned that those uppercase variable names are part of the problem because
> they cause a lot of undesired class-lookups.
> Modifying all the existing scripts would be a giant pain so I thought
> there might be a way to do this using an AST transformation, what I would
> like to do is something like adding a lower-case prefix to all
> uppercase-variables but I cant seem to find the right angle.
> Any hints/ideas? Most of the variable-names are known, but some are not.
> regards
> Wolfgang Pedot

View raw message