Bug 55221 - Bug in comment mapper: Grabs next node's Javadoc
Summary: Bug in comment mapper: Grabs next node's Javadoc
Status: VERIFIED 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.0 M8   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-18 09:51 EST by Martin Aeschlimann CLA
Modified: 2004-03-25 12:58 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 Martin Aeschlimann CLA 2004-03-18 09:51:16 EST
20040318

In the following code, the extended range of class A includes the Javadoc of
class Test1.

/**
 */
class A{
}/**
 */
class Test1{
}
Comment 1 Frederic Fusier CLA 2004-03-18 23:53:44 EST
Fixed.

Also similar problems, but different due to new line after/before trailing 
comment, were fixed:
public class B {
	public int bar() {
		int x=0;
		if (true) {
			x=1;
		} else {
			x=2;
		}
		return x;
	}
	/**
	 * This comment should not be attached to previous method body!
	 * @return int
	 */

	public int foo() { return 1; }
}
public class C {
	public int bar() {
		int x=0;
		if (true) {
			x=1;
		} else {
			x=2;
		}
		return x;
	} /**
	 * This comment should not be attached to previous method body!
	 * @return int
	 */

	public int foo() { return 1; }
}

And also:
public class D {
	/**
	 * Javadoc comment
	 */// Line comment
	boolean foo() { return false; }
}
In this case return_type 'boolean' start position was wrongly extended to line 
comment.

For class A, B and C, the javadoc was both attached to body of method bar and 
to method foo(). Fixed by verifying that trailing comment was not already a 
javadoc of a body declaration (here a method declaration).
For class D, we're wrongly looking if the start position of token preceeding 
trailing comment was on the same line. It was the end position that we must 
verify and not start position...

[jdt-core-internal]
All changes done in DefaultCommentMapper methods storeLeading/TrailingComments.

Test case added in jdt.core.test.dom.ASTConvertJavadocTests
Comment 2 Jerome Lanneluc CLA 2004-03-19 06:38:21 EST
With this change refactoring test SurroundWithTests.testOneLine() is failing. 
Undid the change for now.
Reopening to investigate.
Comment 3 Martin Aeschlimann CLA 2004-03-19 07:03:04 EST
That's a bug in our test. We change it to pass with the wrong behavior.
It's now correct again.
Comment 4 Frederic Fusier CLA 2004-03-19 09:33:48 EST
Fix released again in HEAD.
Comment 5 Jerome Lanneluc CLA 2004-03-25 12:58:53 EST
Verified in build I200403250800.