Bug 457748 - "Add Javadoc Comment" should ignore current line indentation
Summary: "Add Javadoc Comment" should ignore current line indentation
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.3.2   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-16 14:13 EST by Andy Lowry CLA
Modified: 2023-03-30 19:42 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Lowry CLA 2015-01-16 14:13:48 EST
I commonly experience this annoyance: 

I want to add a javadoc comment to some member of a class - field, method, embedded class, whatever. So I position myself on the line where the member is declared and hit Alt-Shift-J to insert the appropriate template. But nothing seems to happen.

That's when I realize that eclipse went and added a class-level javadoc comment near the top of the file, which is not at all what I wanted. Of course I can easily undo that change, but even that's annoying because after undo I find myself positioned at the point where the spurious comment was just removed. So I have to again position myself where I really want to be working.

I understand that eclipse uses my insertion point to figure out where I am in the code structure, and then chooses where to add the javadoc accordingly. But I think its decision in this instance is wrong - or at least very unintuitive. If I'm on the line where a new member declaration begins, that member should be the target of the javadoc.

I think this could be addressed quite easily by ignoring any line indentation that surrounds or immediately follows the insertion point.
Comment 1 Noopur Gupta CLA 2015-01-21 01:13:16 EST
(In reply to Andy Lowry from comment #0)
> I want to add a javadoc comment to some member of a class - field, method,
> embedded class, whatever. So I position myself on the line where the member
> is declared and hit Alt-Shift-J to insert the appropriate template.

If you place the caret anywhere at the line where a member is declared and press Alt-Shift-J, it adds the Javadoc comment to the member correctly. 
("|" represents the caret):

public class C {

	|void m1(boolean b) {
		return;
	}

}

Only if you place the caret at an empty line, the Javadoc comment is added to the class.
Comment 2 Andy Lowry CLA 2015-01-21 07:54:32 EST
My apologies... I omitted a crucial point in my write-up.

The behavior I described occurs if I am in front of or anywhere inside the line's indentation. Hence my proposed solution that Eclipse should ignore indentation when choosing what sort of javadoc to produce.
Comment 3 Dani Megert CLA 2015-01-27 12:05:44 EST
(In reply to Andy Lowry from comment #2)
> My apologies... I omitted a crucial point in my write-up.
> 
> The behavior I described occurs if I am in front of or anywhere inside the
> line's indentation. Hence my proposed solution that Eclipse should ignore
> indentation when choosing what sort of javadoc to produce.

Yes, we could be more tolerant here.
Comment 4 Eclipse Genie CLA 2019-04-10 19:56:23 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 Eclipse Genie CLA 2021-04-01 00:25:07 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 6 Eclipse Genie CLA 2023-03-30 19:42:07 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.