Last active
December 16, 2015 11:38
-
-
Save oehme/5428626 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExtractInterfaceProcessor extends AbstractClassProcessor { | |
override doRegisterGlobals(ClassDeclaration cls, RegisterGlobalsContext context) { | |
context.registerInterface(cls.qualifiedInterfaceName) | |
} | |
override doTransform(MutableClassDeclaration cls, extension TransformationContext context) { | |
findInterface(cls.qualifiedInterfaceName) => [ iface | | |
cls.declaredMethods.filter [ | |
visibility == Visibility::PUBLIC | |
static == false | |
].forEach [ method | | |
iface.addMethod(method.simpleName) [ extracted | | |
extracted.visibility = method.visibility | |
extracted.returnType = method.returnType | |
method.parameters.forEach[extracted.addParameter(simpleName, type)] | |
extracted.docComment = method.docComment | |
extracted.exceptions = method.exceptions | |
] | |
] | |
iface.addAnnotation(typeof(ImplementedBy).findTypeGlobally) => [ | |
set("value", cls.newTypeReference) | |
] | |
] | |
} | |
//def qualifiedInterfaceName() {} omitted | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment