Bug 10984 - DOM/AST: CU with syntax errors
Summary: DOM/AST: CU with syntax errors
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-07 13:59 EST by Dirk Baeumer CLA
Modified: 2002-03-11 13:59 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2002-03-07 13:59:56 EST
Build 20020305

For the CU

package errors_in;

public class A_test800 {
	public void fails() {
		foo()
	}
	public void foo() {
		foo();
	}
}

the block for the method foo has the positions [-1, 0]. Although the CU has 
compiler errors in method fails I don't understand why the positions of the 
method foo's block are incorrect. The method foo itself has positions but I 
didn't check if they are valid
Comment 1 Olivier Thomann CLA 2002-03-07 14:40:44 EST
I could not reproduce that specific problem, but I found another bug for the 
length of the method declaration.For the 'foo' method, you won't be able to 
retrieve the statements. No statements are built if there is a syntax error in 
the source. We agreed that the AST tree might be incomplete in case of syntax 
error in the source.
Fixed and released in HEAD.
Comment 2 Dirk Baeumer CLA 2002-03-08 02:56:56 EST
I hope this is a typo <g>. You wrote:

For the 'foo' method, you won't be able to retrieve the statements. No 
statements are built if there is a syntax error in  the source. 

The method foo doesn't have any errors. Only the method fails does. What is the 
rational behind not having nodes for method foo.

And can you please outline in which situations the AST tree is corrent even if 
the CU has errors.
Comment 3 Olivier Thomann CLA 2002-03-08 09:42:51 EST
No this problem is closed.
When a syntax error occurs in the code, the parser retrieves only headers 
(method, fields, initializers, member classes). So in your example, the two 
methods 'foo' and 'fails' won't have any statement, because of the syntax error 
in 'fails'. It is like that. Syntax errors are the worst errors for the parser.
I closed this PR as the initial problem is fixed.
Comment 4 Olivier Thomann CLA 2002-03-08 11:24:41 EST
The second method should have its statements.
Comment 5 Olivier Thomann CLA 2002-03-08 11:49:26 EST
In order to be able to retrieve statements for the second method, I have to do a dietParse followed 
by a getMethodBodies instead of a full parse.
Comment 6 Olivier Thomann CLA 2002-03-11 13:59:37 EST
Now the second method contains its statements even if the first method contains a syntax error. 
This change requires latest changes in the parser, compiler, error reporting.
Fixed and 
released in HEAD.