In some malformed MethodDeclaration,it's Block is null [message #250568] |
Thu, 10 January 2008 09:56  |
Eclipse User |
|
|
|
Originally posted by: supgenius.hotmail.com
It is use org.eclipse.jdt.core.dom. I use 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 ' is not follow syntax.
example: System.out.println('a);
System.out.println(''a);
3.The statement is begin with number+e .
example: 9eSystem.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.
Are these situation kind of bugs? need to report?
|
|
|
Re: In some malformed MethodDeclaration,it's Block is null [message #251153 is a reply to message #250568] |
Thu, 31 January 2008 08:17  |
Eclipse User |
|
|
|
On Thu, 10 Jan 2008 14:56:58 +0000, Eric wrote:
> It is use org.eclipse.jdt.core.dom. I use 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 ' is not follow syntax.
> example: System.out.println('a);
> System.out.println(''a);
>
> 3.The statement is begin with number+e .
> example: 9eSystem.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.
> Are these situation kind of bugs? need to report?
From the javadoc of ASTParser#setStatementRecovery, I read that the
compiler (conditionally) 'tries to create statement nodes for code
containing syntax errors', which commits to little in case of syntax
errors indeed. You may want to browse the bugzilla system and check if
others have raised similar concerns, and what resulted from that. But my
take would be that the statement recovery works in best effort.
|
|
|
Powered by
FUDForum. Page generated in 0.04267 seconds