Community
Participate
Working Groups
For debugging purpose, it is useful to have a toString() method. What would you like to see inside this toString() method? Something very verbose? Simply the class name + getStartPosition() and getLength()? Don't hesitate to provide examples of what you expect.
i would something close to what a pretty printer output would be (without all the super-smart formating, of course) so, for an InfixExpression 3 + 3 it'd be: 3 + 3 positions are less interesting - i can look them up in the nodes. btw, the internal ast nodes have useful info in toString - something like that would do
Dumping the entire tree in a node seems excessive. On some nodes, these strings will be many KB long. I have a hard time believing that that would be useful for users debugging AST programs. (It is also likely to be mistaken for and used as a means for serializing AST.) For debug purposes, something that fits on a reasonable length line (<150 chars) is more appropriate.
I agree that pretty printing is not the right thing to do. I propose something like this: - expression: pretty print - statement: pretty print - blocks [0] statement type (for example VariableDeclarationStatement) [1] statment type (for example Expression) ... - method declaration: the signature - type declaration: the signature ...
Is this ok for everybody? If yes, I start to implement the Dirk's suggestion.
methods are typically both not-all-too-long and interesting same for blocks so, my suggestion is: - expression: pretty print - statement: pretty print - blocks: pretty print - method declaration: pretty print - type declaration: signature + list of method signatures - compilation unit: signature + list of types ...
Jim made some changes in this area. Don't hesitate to suggest improvements. Fixed and released in HEAD.