Bug 215137 - [AST]Some malformed MethodDeclaration, their Block is null, but they actually have Block
Summary: [AST]Some malformed MethodDeclaration, their Block is null, but they actually...
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M6   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-13 03:15 EST by supgenius CLA
Modified: 2008-03-25 11:06 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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