Bug 12540 - Code formatter should leave comments at end of line
Summary: Code formatter should leave comments at end of line
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-01 10:11 EST by Nick Edgar CLA
Modified: 2002-04-27 21:29 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Edgar CLA 2002-04-01 10:11:12 EST
Build 20020328

If a line containing a single line comment at the end of line is too long, the 
comment can end up on a separate line.
It should stay with the line, even if that makes the line too long.
The comment refers to the line, and should not stand alone.
This would also fix up some occurrences of the $NON-NLS$ tags getting divorced 
from the appropriate expression.
Comment 1 Erich Gamma CLA 2002-04-09 13:02:34 EDT
I'm strongly in favor of this idea, it would solve the NON-NLS tag problem 
nicely.
Comment 2 Philipe Mulet CLA 2002-04-09 13:08:43 EDT
This would rather mean that a line with a trailing comment cannot be split 
alltogether. 

This sounds quite doable, Olivier ?
Comment 3 Nick Edgar CLA 2002-04-09 16:44:05 EDT
This would still not address the problem of formatting the following:

   someObject.someMethod(
       "my.id", // $NON-NLS
       3);

However, I still think it would be an improvement.
For the case above, you could decide not to merge if there's an end of line 
comment.
Comment 4 Olivier Thomann CLA 2002-04-09 17:44:59 EDT
Don't know the side-effects yet. Need more investigation.
Comment 5 Olivier Thomann CLA 2002-04-24 18:44:52 EDT
The best I can do with the existing tool is not to format a line that contains a line comment. See 
14387 for examples.
Comment 6 Nick Edgar CLA 2002-04-25 09:35:48 EDT
This suits me.
Or, if we don't want to do this for all end of line comments, we could add a 
special case for $NON-NLS$ tags.
Comment 7 Olivier Thomann CLA 2002-04-25 15:00:04 EDT
I added a special case for $NON-NLS$ comment in the formatter. Lines containing such a comment are 
not formatted anymore. If this doesn't work as expected, reopen this PR.
Comment 8 Nick Edgar CLA 2002-04-27 21:29:03 EDT
Will try it out, thanks.