groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Smith <chrylis+gro...@gmail.com>
Subject Ordering of AST transformations
Date Wed, 20 Jan 2021 07:01:04 GMT
A longstanding shortcoming of the AST-transformation system is the
minimal guarantees provided when multiple ASTTs target the same area
of code. While comprehensive support for this seems like it would
require a redesign or at least major rework, I have a suggestion for a
small change that might get a large segment of use cases working.

I propose adding "order" directives to transforms akin to Spring's
@Ordered and @AutoConfigureBefore/After. The sole effect of these
directives would be to instruct the compiler to run identified
transformations in sorted sequence.

As a specific hands-on use case, there's been a feature request open
against Spock for 5 years to support stateful traits
(https://github.com/spockframework/spock/issues/83); the impediment is
that both Spock and traits are implemented as SEMANTIC_ANALYSIS ASTTs,
so that Spock doesn't see the trait fields with their @Shared
annotations when it runs.

Is something like this feasible, or does it conflict with existing
sequencing or traversal requirements inside the compiler processing?

Mime
View raw message