Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343951 - Clean-up creates bad diff (for SVN, CVS, etc.)
Summary: Clean-up creates bad diff (for SVN, CVS, etc.)
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-27 09:13 EDT by Sven Köhler CLA
Modified: 2020-03-21 19:25 EDT (History)
1 user (show)

See Also:


Attachments
copy it to EclipseCleanup.java, run the cleanup wizard, and observe the diff (155 bytes, application/vnd.lotus-organizer)
2011-04-27 09:33 EDT, Sven Köhler CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Köhler CLA 2011-04-27 09:13:31 EDT
Build Identifier: 

Hi,

imagine some source, that is badly indented. That is, before "public void someMethod()" there is not only a \t, but 4 spaces or a mixture of 3 spaces and a \t.

As it happens, someMethod() overrides some method from the super-class, but the @Override annotation is missing. Hence, I execute the cleanup wizard. Afterwards, I look at the output of "svn diff".

I observe, that according to svn diff, that the whitespace in front of @Override matches the white space that was in front of the method declaration. But the indention of the method declaration has now changed. In result, the diff shows the line with the method declaration as changed.

IMHO, this is clearly a misconception on Eclipse's side. I often find that Eclipse doesn't do well with improperly indented code. However, this is especially annoying, since I create a large changeset when clearly I should be adding some lines. And I clearly don't want to do it manually.

So please enhance the piece of code which is responsible for this.


Reproducible: Always
Comment 1 Sven Köhler CLA 2011-04-27 09:33:40 EDT
Created attachment 194152 [details]
copy it to EclipseCleanup.java, run the cleanup wizard, and observe the diff

The diff is

--- EclipseCleanup.java.org	2011-04-27 15:31:30.313115221 +0200
+++ EclipseCleanup.java	2011-04-27 15:31:36.261916231 +0200
@@ -8,7 +8,8 @@
 }
 
 class Test2 extends Test1 {
-  	public void someMethod()
+  	@Override
+	public void someMethod()
 	{
 		// nothing
 	}


Instead of

--- EclipseCleanup.java.org	2011-04-27 15:31:30.313115221 +0200
+++ EclipseCleanup.java	2011-04-27 15:31:36.261916231 +0200
@@ -8,7 +8,8 @@
 }
 
 class Test2 extends Test1 {
+  	@Override
   	public void someMethod()
 	{
 		// nothing
 	}
Comment 2 Olivier Thomann CLA 2011-04-27 09:57:38 EDT
We preserve the indentation of the line before the method declaration in front of the @Override annotation. Then we insert an indentation after the annotation.
Are you expecting that we preserve the indentation before the method declaration when we insert the indentation after the annotation ?
Comment 3 Sven Köhler CLA 2011-04-27 10:02:39 EDT
(In reply to comment #2)
> We preserve the indentation of the line before the method declaration in front
> of the @Override annotation. Then we insert an indentation after the
> annotation.
> Are you expecting that we preserve the indentation before the method
> declaration when we insert the indentation after the annotation ?

Yes, it sounds like what I expect.
Comment 4 Eclipse Genie CLA 2020-03-21 19:25:51 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.