Groovy Enhancement Proposal |
Number: |
GEP-5 |
Title: |
File extension dependent AST transformations |
Version: |
1 |
Type: |
Feature |
Status: |
Draft |
Leader: |
Alex Tkachman |
Created: |
2010-02-26 |
Last modification: |
2010-02-26 |
AST transformations is powerful tool for creating DSLs. Two ways to define AST transformations exist today - via annotation and global transformation, which apply to everything. This proposal introduce new type - transformations, which apply only to source files with given extension.
Such approach gives possibility to have better and unified way to organize code base containing groovy based DSLs.
There are two problems to be addressed
Interesting that first problem doesn't require any specific handling at all. Global AST transformation can use name of SourceUnit to filter what files to process.
For second problem file META-INF/services/org.codehaus.groovy.transform.ASTTransformation where global AST transformations normally defined can be used. To keep things backward compatible following syntax is suggested
#files:<ext1>,<ext2>...
The main benefit of using configuration files are