Bug 67077 - [typing] "Add Javadoc" adds (duplicate) Javadoc to the wrong element
Summary: [typing] "Add Javadoc" adds (duplicate) Javadoc to the wrong element
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Jeff Johnston CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-14 14:41 EDT by Michael Valenta CLA
Modified: 2024-05-14 07:13 EDT (History)
1 user (show)

See Also:


Attachments
Java file (996 bytes, text/plain)
2004-06-14 14:42 EDT, Michael Valenta CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Valenta CLA 2004-06-14 14:41:38 EDT
I added the following method to a class.

    public boolean hi(String there) {
        return false;
    }

I then selected all three lines (entirely) andd chose Source>Add Javadoc. A
javadoc entry was added to the class instead of the method. I actually did this
several times before I realized what was happening so I ended up with several
class comments all of which were identical.

I then selected just the method name and performed the operation and it worked
as expected. I then selected all three lines of the method and performed the
action again and this time it added the javadoc to the method (resulting in 2
identical javadoc comments.

There are two problems to consider here:

1) Selecting the method in its entirety should have added the javadoc to the
method and not the class. 

2) Would it be possible to detect the fact that the comment being added is
identical to the existing comment and warn the user. It may even be benefitial
to warn the user even if the comment differs from the existing comment.

I will attach the file that resulted in this behavior
Comment 1 Michael Valenta CLA 2004-06-14 14:42:34 EDT
Created attachment 12064 [details]
Java file
Comment 2 Dirk Baeumer CLA 2004-06-14 17:54:08 EDT
Regarding issue 2: bug 30153 is requesting this feature.

Issue 1: we try to find the enclosing element of the current selection and add 
Javadoc to this one. Since for the Java model a method start with the 
visibility modifier and ends with } a "line" selection covering the method is 
considered to be covered by the Type. We should be smarter here and should 
ignore white spaces
Comment 3 Eclipse Genie CLA 2020-05-25 15:02:31 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Eclipse Genie CLA 2022-05-18 14:53:16 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 Jeff Johnston CLA 2022-05-24 15:36:01 EDT
Still occurs in 4.24 M3
Comment 6 Eclipse Genie CLA 2024-05-14 07:13:20 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.