Community
Participate
Working Groups
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
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.
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.
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.
The second method should have its statements.
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.
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.