Bug 69349

Summary: [DOM/AST] Wrong end position for method declaration
Product: [Eclipse Project] JDT Reporter: Frederic Fusier <frederic_fusier>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch to apply on HEAD none

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.