Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 404986

Summary: [dom ast] Add a debug option to verify proper nesting of ASTNodes
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Markus Keller <markus.kell.r>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: anchakrk, jarthana, manoj.palat, markus.kell.r, srikanth_sankaran
Version: 4.3   
Target Milestone: 4.3 M7   
Hardware: All   
OS: All   
Whiteboard:

Description Markus Keller CLA 2013-04-05 07:03:44 EDT
Add a debug option to verify proper nesting of ASTNodes according to ASTParser#setKind(int):

 * Source ranges nest properly: the source range for a child is always
 * within the source range of its parent, and the source ranges of sibling
 * nodes never overlap.

This should avoid issues like bug 404489 and bug 391894 comment 4 in the future.
Comment 1 Markus Keller CLA 2013-04-05 08:07:50 EDT
I've implemented two debug options to enable this verification:

# Reports bad node nesting in DOM AST
org.eclipse.jdt.core/debug/dom/ast=false

# Throws an exception in case of bad node nesting in DOM AST
org.eclipse.jdt.core/debug/dom/ast/throw=false

The first option just writes issues to the log
 -> suitable for daily use in main and runtime workbench

The second option throws an exception when bad source ranges are found
 -> suitable for JUnit test runs (so that the test goes red)


SourceRangeVerifier#checkChild(..) stops verification when malformed or recovered nodes are encountered. We do accept some strangeness in this case.


Released to master with http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=11bdf7ee83fa535bb4e922a4f202eec91a5eb529
Comment 2 Markus Keller CLA 2013-04-05 08:09:34 EDT
Forgot to mention that I also fixed two cases of bad property ordering in AnnotationTypeMemberDeclaration and DoStatement.
Comment 3 ANIRBAN CHAKRABORTY CLA 2013-05-01 03:21:49 EDT
Verified for 4.3 M7 build I20130428-2000.


Saw the following in the .options file:

# Reports bad node nesting in DOM AST
org.eclipse.jdt.core/debug/dom/ast=false

# Throws an exception in case of bad node nesting in DOM AST
org.eclipse.jdt.core/debug/dom/ast/throw=false