Bug 9790 - Add constructors from superclass inserts in wrong place
Summary: Add constructors from superclass inserts in wrong place
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P2 minor (vote)
Target Milestone: 2.0 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 11056 12710 (view as bug list)
Depends on:
Blocks: 9394
  Show dependency tree
 
Reported: 2002-02-13 16:42 EST by John Arthorne CLA
Modified: 2015-03-18 11:03 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2002-02-13 16:42:42 EST
Build 20020212

1) Start with following classes:

public class A {
  public A(String s) {}
  public void foo() {}
}
public class B {}

2) Open an editor on class B
3) In the content outline, select Override Methods -> foo
4) Now select "Add Constructors From Superclass"

The result is below.  The constructor gets inserted between the method comment 
and the method body.  This is probably because "Override Methods" creates 
non-javadoc method comments.

	/*
	 * @see A#foo()
	 */
	/**
	 * Constructor for B.
	 * @param s
	 */
	public B(String s) {
		super(s);
	}
	public void foo() {
		super.foo();
	}
}
Comment 1 Martin Aeschlimann CLA 2002-02-15 05:45:04 EST
JavaCore should extend the source range of the method to 
include preceding non-javadoc comments.
Comment 2 Philipe Mulet CLA 2002-02-15 06:06:48 EST
If using the new DOM ASTs, then this problem will go away.
Comment 3 Olivier Thomann CLA 2002-02-27 11:26:53 EST
A non-javadoc comment is never part of the method declaration. So I don't want to include it.
Comment 4 Philipe Mulet CLA 2002-03-26 17:59:48 EST
*** Bug 11056 has been marked as a duplicate of this bug. ***
Comment 5 Philipe Mulet CLA 2002-03-26 18:01:28 EST
Olivier - couldn't we simply include comments to Source methods (as consumed by 
the source element parser) ? This wouldn't affect the compiler behavior, only 
source element parsed code (i.e. java elements).
Comment 6 Olivier Thomann CLA 2002-03-27 08:49:48 EST
I can see how to locally change this behavior.
Comment 7 Olivier Thomann CLA 2002-03-27 10:59:01 EST
Do we want to do the same thing for line comments? I guess we want the declaration of a method to 
include only multiple line comments and javadoc comments.
Comment 8 John Arthorne CLA 2002-03-27 11:36:01 EST
While you're looking at this, here's another method declaration that shows up 
incorrectly in the method-level editor.  The convention of adding /*package*/ 
for default visibility does not work when there is also a javadoc comment:

/**
 * Sets the project for which this builder operates.  
 * @see #getProject
 */
/* package */ final void setProject(IProject value) {
	Assert.isTrue(project == null);
	project = value;
}
Comment 9 Olivier Thomann CLA 2002-03-27 12:02:23 EST
The javadoc comment has to be the last one before the method declaration if you 
want to be able to use tags such as @deprecated. If you want to add /* package 
*/ in front of your method declaration, then you lose the feature of javadoc 
tags. Is this ok for you?
Where did you find this convention using /* package */?
Comment 10 John Arthorne CLA 2002-03-27 12:53:05 EST
I don't know where/when the convention started, but it seems to be fairly 
common.  A quick look through the Eclipse src showed this convention is 
sometimes used in platform core, platform ui, jdt core and jdt ui.

I didn't know that non-javadoc comments could have any effect on the behaviour 
of the compiler!  If that behaviour is specified for javadoc, I guess people 
should really stop using this convention then.
Comment 11 Olivier Thomann CLA 2002-03-27 13:55:27 EST
For me this comment /* package */ add nothing. It is simply useless and can lead to bugs related to 
the fact that javadoc tags used in the javadoc comment preceeding this comment are ignored. I will 
fix the fact that non-javadoc comments are ignored before body declarations, but I won't change 
the fact that javadoc tags are considered only if the javadoc comment is located immediately 
before the body declaration (method, field, type, initializer).
Comment 12 Olivier Thomann CLA 2002-03-27 17:13:55 EST
Now we can properly delete methods and theirs comments even if the comment are not javadoc 
comments. Inserting new methods is done at the right location.
All problems related to this 
seem fixed.
If you notice strange behavior, don't hesitate to reopen this PR.
Fixed and 
released in HEAD.
Comment 13 Philipe Mulet CLA 2002-04-04 06:05:08 EST
*** Bug 12710 has been marked as a duplicate of this bug. ***