Bug 11067 - Adding useful toString() method for each new DOM/AST nodes
Summary: Adding useful toString() method for each new DOM/AST nodes
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: Other other
: P3 minor (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-08 17:12 EST by Olivier Thomann CLA
Modified: 2002-03-13 11:22 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2002-03-08 17:12:20 EST
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.
Comment 1 Adam Kiezun CLA 2002-03-09 18:53:50 EST
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
Comment 2 Jim des Rivieres CLA 2002-03-11 09:39:06 EST
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.
Comment 3 Dirk Baeumer CLA 2002-03-11 09:56:25 EST
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
...


Comment 4 Olivier Thomann CLA 2002-03-11 12:32:43 EST
Is this ok for everybody? If yes, I start to implement the Dirk's suggestion.
Comment 5 Adam Kiezun CLA 2002-03-11 12:45:33 EST
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
...
Comment 6 Olivier Thomann CLA 2002-03-12 16:22:47 EST
Jim made some changes in this area. Don't hesitate to suggest improvements.
Fixed and released 
in HEAD.