Bug 69349 - [DOM/AST] Wrong end position for method declaration
Summary: [DOM/AST] Wrong end position for method declaration
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-06 06:03 EDT by Frederic Fusier CLA
Modified: 2005-01-11 11:03 EST (History)
0 users

See Also:


Attachments
Patch to apply on HEAD (1.04 KB, patch)
2004-07-06 10:30 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2004-07-06 06:03:22 EDT
Using HEAD stream...

In following example:
public class Test {
	public String foo(){
		return "";} //$NON-NLS-1$
}

the end position of MethodDeclaration for foo is on ';' character in source
although its body correctly ends at '}' character.

This is really anoying as method declaration ends before its body child...
One impact of this is that trailing comment can be associated neither to the
method declaration nor to the body.

Note that it works with 3.0 => seems to be a regression while merging JDK_1_5
stream. Looking at code, ASTConverter.retrieveRightBraceOrSemiColonPosition(int,
int) method now returns now scanner.currentPosition-1 instead of previously
scanner.currentPosition when brace is found.

Note also that method declaration end position is correct with following example:
public class Test {
	public String foo(){
		return "";
	} //$NON-NLS-1$
}
Comment 1 Olivier Thomann CLA 2004-07-06 09:43:47 EDT
I will investigate.
Comment 2 Olivier Thomann CLA 2004-07-06 10:29:27 EDT
I think that retrieveRightBraceOrSemiColonPosition should be called with bodyEnd
+ 1 instead of bodyEnd for the first argument. Otherwise the ; is found and its
position is returned.
Comment 3 Olivier Thomann CLA 2004-07-06 10:30:02 EDT
Created attachment 12982 [details]
Patch to apply on HEAD

Let me know what you think. All tests passed with this patch.
Comment 4 Olivier Thomann CLA 2004-07-06 21:07:04 EDT
Fixed and released in HEAD.
Regression tests added.