Groovy for Domain-specific Languages - Second Edition
Power Groovy DSL Features [ 178 ] Coming back to our markup processing, the next line of code is in the context of a closure wit ...
Chapter 7 [ 179 ] then: """<root> <level1> <level2> </level2> </level1> </root>""" == output ...
Power Groovy DSL Features [ 180 ] Replacing methods The technique that we use to add a method can also be used to replace an exi ...
Chapter 7 [ 181 ] when: BusinessService.isRemoteServiceLive() then: thrown NullPointerException when: BusinessService.metaClass. ...
Power Groovy DSL Features [ 182 ] then: cust.idForFirstName() == "fred" cust.idForSurname() == "flintstone" cust.idForStreet() = ...
Chapter 7 [ 183 ] When we are overloading subsequent methods with different signatures, we can make use of the append operator & ...
Power Groovy DSL Features [ 184 ] Summary We have covered a lot of ground in this chapter. We have now covered most of the impor ...
[ 185 ] AST Transformations In this chapter, we will take a look at Groovy abstract syntax tree (AST) transformations. AST trans ...
AST Transformations [ 186 ] What is an AST The acronym AST is shorthand for the abstract syntax tree. During the compilation pro ...
Chapter 8 [ 187 ] Compiler phases As the compiler works through the different phases, it adds detail to the AST. In all the exam ...
AST Transformations [ 188 ] Conversion: In this phase, the token tree is converted into an AST. This is the very first time tha ...
Chapter 8 [ 189 ] Local AST transformations When discussing AST transformations in Groovy, we refer to local and global AST tran ...
AST Transformations [ 190 ] So we are expecting a new method to be added that prints the expected string. Not very useful for no ...
Chapter 8 [ 191 ] @GroovyASTTransformation (phase = CompilePhase.SEMANTIC_ANALYSIS) class PrettyBasicASTTransformation implement ...
AST Transformations [ 192 ] This is not really what we want yet for a proper PrettyPrint transformation, but it is a fully funct ...
Chapter 8 [ 193 ] null, methodStatement ) classNode.addMethod(methodNode) } } The main difference you will notice here is the us ...
AST Transformations [ 194 ] if (!(nodes[0] instanceof AnnotationNode)) return if (!nodes[1] && !(nodes[1] instanceof Cla ...
Chapter 8 [ 195 ] This is sort of what we are trying to do with our pretty print AST transformation. AST transformations happen ...
AST Transformations [ 196 ] Here, we create a class node for PrettyAwesomeTrait using the ClassHelper class. We don't want to ad ...
Chapter 8 [ 197 ] Global AST transformations Next, we will look at a global AST transformation. Unlike the local transformations ...
«
6
7
8
9
10
11
12
13
14
15
»
Free download pdf