Bug 52927 - [typing] Autogeneration of multiline-comment generates erranous source
Summary: [typing] Autogeneration of multiline-comment generates erranous source
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 2.1.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-24 08:24 EST by Gregor Rosenauer CLA
Modified: 2006-01-17 04:47 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gregor Rosenauer CLA 2004-02-24 08:24:06 EST
1. You have a single-line-comment "//" which you want to translate into a 
multiline-comment
2. You delete the second "/" and insert a "*"
3. press RETURN
4. a multiline-comment is generated, but the content of the original line is 
wrongly inserted past the comment-end-tag "*/", generating an error.

Solution: The original comment-content should be placed inside the 
multilnie-comment instead, inserting a new "* <original comment>"-line 
automatically.
Comment 1 Gregor Rosenauer CLA 2004-02-24 09:20:19 EST
sorry, I think I got the wrong component - Core seems more appropriate.
It would be very helpful for new Eclipse-bugreporters if the 
Component-description-page contained a short description of the component and 
what it is responsible for, sothat one can decide better where to put a new 
bugreport (like it is on Mozilla's bugzilla).
Comment 2 Dani Megert CLA 2004-02-24 10:24:56 EST
The component was correct.
Comment 3 Dani Megert CLA 2004-02-24 10:36:24 EST
we don't keep state i.e.
// + backspace + enter
is the same as if you type
/* + enter

We could be smart. I guess in 80% of the cases when we have
/* <caret> SOME TEXT
and press enter after <caret> we would expect
/*
 * <caret> SOME TEXT
Comment 4 Gregor Rosenauer CLA 2004-02-24 10:52:54 EST
Yes, this would be the expected behaviour and would not generate an error - 
currently the auto-formatting feature gets in my way and I have to work around 
it which is quite counter-productive;)

Do we want to be smart? I vote for yes;), if it's not too much work in this 
case...

Comment 5 Gregor Rosenauer CLA 2004-02-24 10:59:03 EST
And not to forget, the end-tag of the multiline-comment should be inserted as 
*last* line, not before the original content.
Additionally it would be nice if the caret was positioned into a new commented 
line inside the now multiline.comment, since this will be the desired behaviour 
in most cases I think.

So to summarise the steps, we would have 3 states:
(_ = caret)

1. // _old single-line comment
2. /*_old single-line comment
3. /*
    * old single-line comment
    * _
    */

IIRC this works similarly when generating javadoc-comments (by inserting an 
additional asterisk '*' after the comment-open-tag), where a new comment-line is 
created automatically and the caret is positioned there.