Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 440822

Summary: [formatter] Single line comment inside annotation is wrongly formatted
Product: [Eclipse Project] JDT Reporter: Holger Klene <h.klene>
Component: CoreAssignee: Mateusz Matela <mateusz.matela>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, jarthana, mateusz.matela
Version: 4.5   
Target Milestone: 4.11 M1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
zipped workspace none

Description Holger Klene CLA 2014-07-30 18:12:22 EDT
Created attachment 245561 [details]
zipped workspace

As mentioned in bug 440630 issue 4 The line marked A in CountingComparator jumps back and forth on every save. Just add a space or a newline somewhere and press Ctrl+S.

- The comment A is indented to 4 spaces
- The comment A starts at column 0

I'll attach a workspace to demonstrate the issue.
The code formatter settings are exported as xml in the workspace.

Version eclipse-SDK-N20140728-2000-linux-gtk-x86_64.tar.gz
Version: Mars (4.5)
Build id: N20140728-2000
JDT 3.11.0.N20140728-2000
Comment 1 Dani Megert CLA 2014-07-31 07:39:30 EDT
Besides the fact that it should not toggle, what would you expect as the correct result? Currently the formatter based on your profile and the indenter disagree on the correct solution.
Comment 2 Holger Klene CLA 2014-07-31 08:56:33 EDT
If I can choose, I'd like it to be indented to 4 spaces :-)

This would be consistent with commenting out more DefaultLocations as in:

@NonNullByDefault({
    DefaultLocation.ARRAY_CONTENTS,
    DefaultLocation.FIELD,
    DefaultLocation.PARAMETER,
    // DefaultLocation.RETURN_TYPE, // B
    DefaultLocation.TYPE_ARGUMENT,
    DefaultLocation.TYPE_BOUND,
    // DefaultLocation.TYPE_PARAMETER, // A
})

Where B does not toggle in my setup and stays indented.
Comment 3 Dani Megert CLA 2014-07-31 10:11:52 EDT
(In reply to Holger Klene from comment #2)
> If I can choose, I'd like it to be indented to 4 spaces :-)

I assume there's no way to tweak the formatter profile so that it happens?
Comment 4 Holger Klene CLA 2014-07-31 11:45:21 EDT
I can switch off additional save action > Code Organizing > Correct Indentation
Or I can tell the Formatter Comments > Never indent line comments on first column

Both will leave the comment alone in column 0.
Comment 5 Dani Megert CLA 2014-08-05 09:31:16 EDT
Fixing the formatter will fix this problem.
Comment 6 Eclipse Genie CLA 2019-01-02 13:50:19 EST
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 7 Mateusz Matela CLA 2019-01-03 16:34:52 EST
This problem no longer occurs after the formatter redesign.

*** This bug has been marked as a duplicate of bug 303519 ***
Comment 8 Jay Arthanareeswaran CLA 2019-01-08 09:06:04 EST
Verified for 4.11 M1 using build I20190107-2050.