Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » In some malformed MethodDeclaration,it's Block is null
In some malformed MethodDeclaration,it's Block is null [message #250568] Thu, 10 January 2008 09:56 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Are unit tests for Eclipse refactorings visible / available?
Next Topic:IProgressMonitor for a build
Goto Forum:
  


Current Time: Sat Apr 26 11:37:54 EDT 2025

Powered by FUDForum. Page generated in 0.04267 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top