Created
July 16, 2018 12:30
-
-
Save olegchir/8142d2830570fda45e81d64edcbbfca6 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
//До 2.5 приходилось писать так: | |
def clazz = new MethodCallExpression(new VariableExpression("this"), "getClass", EMPTY_ARGUMENTS) | |
def body = new ExpressionStatement(new MethodCallExpression(clazz, "getName", EMPTY_ARGUMENTS)) | |
classNode.addMethod('getDescription', ACC_PUBLIC, STRING_TYPE, EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, body) | |
//После 2.5 первые две строчки превращаются в такое: | |
def body = macro(true) { | |
getClass().name | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment