concept node in category groovy

This is an excerpt from Manning's book Groovy in Action, Second Edition.
As you can see, the code block, in the form of a closure, has access to a special variable called node, which corresponds to the annotated node. This allows you to write custom assertions on the AST itself! Writing CompilePhase.SEMANTIC_ANALYSIS means that the assertion will be executed after the semantic analysis phase has completed.
Because not all AST nodes accept annotations, in addition to the node variable, the code block gives access to a helper method called lookup. The role of this method is to search for a specific AST node starting from the annotated node. Let’s imagine that you want to perform an assertion on a for loop. As you cannot annotate the for loop directly, we’ll use the lookup method to find it, as shown in the following listing.
This technique, which uses a label as a marker, allows you to reach any AST node that is inside the scope of a node that can be annotated. Using @ASTTest, you’re now capable of testing the transformation during the compilation itself, which is a big plus over runtime checks.
It’s not surprising that XML elements are stored in nodes of type ELEMENT_NODE, but it’s surprising that attributes are also stored in node objects (of nodeType ATTRIBUTE_NODE). To make things even more complex, each value of an attribute is stored in an extra node object (with nodeType TEXT_NODE). This complexity is a large part of the reason why simpler APIs such as JDOM, dom4j, and XOM have become popular.
XmlParser uses the groovy.util.Node type and its GPath expressions result in lists of nodes. That makes working with XmlParser feel like there always is a tangible object representation of elements—something that we can inspect via toString, print, or change in place. Because GPath expressions return lists of such elements, we can apply all our knowledge of the list datatype (see section 4.2).