Bug 215137

Summary: [AST]Some malformed MethodDeclaration, their Block is null, but they actually have Block
Product: [Eclipse Project] JDT Reporter: supgenius <supgenius.tw>
Component: CoreAssignee: David Audel <david_audel>
Status: VERIFIED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: jerome_lanneluc, Olivier_Thomann
Version: 3.2.2   
Target Milestone: 3.4 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description supgenius CLA 2008-01-13 03:15:18 EST
Build ID: M20060629-1905

Steps To Reproduce:
I used ASTParser to parse a java file. When statements has some wrong syntax in a method,such as...

1.The statement has only one " .
  example: System.out.println("hello);

2.The statement has only one ' or a couple of ' are not follow syntax.
  example: System.out.println('a);
           System.out.println(''a);

3.The statement is begin with number+e .
  example: 7eSystem.out.println();

This method will be parsed a malformed MethodDeclaration object by ASTParser. I want to call MethodDeclaration.getBody() to get it's Block but return null. 

In other wrong syntax cases, they can still have Block. I know these all wrong syntax cases, but I have request to get their Blocks.

More information:
Comment 1 Olivier Thomann CLA 2008-01-14 10:00:49 EST
If you enable the statement recovery, you get a body, but it is empty.
Comment 2 supgenius CLA 2008-01-15 02:21:59 EST
(In reply to comment #1)
> If you enable the statement recovery, you get a body, but it is empty.

I set ASTParser.setStatementsRecovery(true), but the result was the same. It's seems that those three types of syntax error statement can not be recoverd.
Comment 3 David Audel CLA 2008-03-19 08:00:48 EDT
This bug is already fixed in the 3.4 stream.

I close this bug as WORKSFORME.

I added some regression tests:
  ASTConverterBugsTest#testBug215137a() -> testBug215137d()
Comment 4 Jerome Lanneluc CLA 2008-03-25 11:06:48 EDT
Verified for 3.4M6 using I20080325-0100