Bug 38447 - AST: Source ranges with missing bracket
Summary: AST: Source ranges with missing bracket
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-05 04:25 EDT by Martin Aeschlimann CLA
Modified: 2003-07-16 05:35 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2003-06-05 04:25:26 EDT
20030604

1. Create a project with the JUnit source
2. In 'ResultPrinter' remove the closing bracket of the constructor. Note: The
outliner still shows to structure of the CU
3. Select the constructor in the outliner
4. press delete: This removes almost the whole CU

Either the AST get's as good as the reconciler in recovering or we could update
the AST positions with the JAVAElement position when we detect errors in the AST
Comment 1 Martin Aeschlimann CLA 2003-06-05 12:18:51 EDT
The AST contains all elements even the bracket is missing!
Unfortunatly the length of the constructor node is too large.

Moving to JCore to ask if it would be possible to get more valid ranges (e.g.
like the Java elements). Currently the ranges are overlapping.
Comment 2 Olivier Thomann CLA 2003-06-10 10:38:44 EDT
Could you please provide the exact test case? What I tried works fine.
Comment 3 Martin Aeschlimann CLA 2003-06-11 03:46:34 EDT
added ASTRewritingMethodDeclTest.testBUG_38447
Comment 4 Olivier Thomann CLA 2003-06-11 11:05:11 EDT
I looked at your test case. You cannot expect the comments to be part of the
foo1 declaration. If the last comment is a javadoc comment instead of a block
comment, then it will be included in the foo1 declaration. Otherwise these
comments are not attached to a particular node.
I fixed the code to stop the declaration of foo on the opening brace '{'. In
case of a syntax error, it is much more difficult to get the right positions. I
don't remember that we ever garantee any "reliable" positions in case of a
syntax error.
Comment 5 Martin Aeschlimann CLA 2003-06-11 11:29:26 EDT
Don't care about the comment. The problem reported is that the range of foo is 
covering the other methods. If the range now ends on { that's great.
Comment 6 Olivier Thomann CLA 2003-06-11 12:05:12 EDT
Fixed and released in HEAD contents.
Regression tests added.
Comment 7 David Audel CLA 2003-07-16 05:35:52 EDT
Verified.