Using ASTTransformation in Groovy to build an AST like structure for all connected devices

Given a groovy source code as an input, is it possible to create a graph-like or AST representing the overall flow structure representing what event is triggered and due to which action and what is the changed state of that device?
Is there a tool or any method available to do this?

Kinda like this? Cause this is from Core.

Is this a tool that parses the source code and converts it into this structure?
I want to be able to convert it into a representative structure from the source code itself.