Community
Participate
Working Groups
Created attachment 281437 [details] One example of wrong indentations added by the code formatter. I'm adjusting changes for bug 356832 and I've noticed very broken formatter behaviour. I don't know whether its a formatter problem or formatter settings problem, but I constantly have to undo the formatter changes because it keeps adding wrong indentations. The attached video "formatter_indentations.mp4" is only one example. So far I notice it for methods that have "throws ..." in their signature, but it may be in other cases as well.
I think the formatter does some wrong assumptions when formatting only parts of a method in org.eclipse.jgit (e.g. some method in FS.java). When I select the entire method and format the code with Ctrl+Shift+F, the indentations are fine. When I select only the body, the formatter adds wrong indentations.
Which package and version of Eclipse are you using ?
(In reply to Matthias Sohn from comment #2) > Which package and version of Eclipse are you using ? Eclipse SDK Version: 2020-03 (4.15) Build id: I20191228-1800
Another case, while I'm writing a test (with all the commits for bug 356832 and bug 552338): /* * Copyright (C) 2020, Simeon Andreev <simeon.danailov.andreev@gmail.com> * Copyright (C) 2020, Andre Bossert <andre.bossert@siemens.com> * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0 which is available at * https://www.eclipse.org/org/documents/edl-v10.php. * * SPDX-License-Identifier: BSD-3-Clause */ package org.eclipse.jgit.diffmergetool; import java.io.File; import org.eclipse.jgit.junit.RepositoryTestCase; import org.junit.Before; import org.junit.Test; /** * Testing external merge tool. */ public class ExternalMergeToolTest extends RepositoryTestCase { private MergeToolManager manager; @Before public void setup() throws Exception { super.setUp(); manager = new MergeToolManager(db); } @Test public void testExternalToolXYZ() throws Exception { File localFile = writeTrashFile("localFile", " line"); FileElement local = new FileElement(localFile.getAbsolutePath(), FileElement.Type.LOCAL); File remoteFile = writeTrashFile("remoteFile", "\tline"); FileElement remote = new FileElement(remoteFile.getAbsolutePath(), FileElement.Type.REMOTE); File mergedFile = writeTrashFile("mergeFile", ""); FileElement merged = new FileElement(mergedFile.getAbsolutePath(), FileElement.Type.MERGED); String mergeToolName = "kdiff3"; ExternalMergeTool tool = manager.getTool(mergeToolName); manager.merge(local, remote, merged, null, null, tool); } } String mergeToolName = "kdiff3"; This gets indentations to match the line above. I think we should move this to the formatter area; it really looks like the formatter indents based on the line above.
Created attachment 281500 [details] Example project to reproduce the problem with. Try to fix the indentation of line 9 in Test.java. I can reproduce fairly easy with the .settings from JGit "org.eclipse.jgit.test". See the project in the attached "TestEclipseFormatter.zip". Try to fix the indentation of line 9 in Test.java, observe that the formatter keeps pushing the line like this: public void veryLongMethodName(boolean b) throws IOException, IndexOutOfBoundsException { System.out.println("try to fix the indentation of THIS LINE"); // the indentation of this line is broken Instead of: public void veryLongMethodName(boolean b) throws IOException, IndexOutOfBoundsException { System.out.println("try to fix the indentation of THIS LINE"); In the example above, manually formatting the file (Ctrl+A select all, Ctrl+Shift+F format) fixes the indentation, but formatting on saving breaks the indentation again.
Created attachment 281501 [details] Example project to reproduce the problem with. Try to fix the indentation of line 9 in Test.java.
@Mateusz, I've quickly checked the git history, could it be, that changes for bug 250656 (commit ba73b313fde63d8ccedec4bd1f0dfefd65dc4e33) is the reason? Editing code in EGit / JGit is impossible with 4.15 M1.
(In reply to Andrey Loskutov from comment #7) > @Mateusz, I've quickly checked the git history, could it be, that changes > for bug 250656 (commit ba73b313fde63d8ccedec4bd1f0dfefd65dc4e33) is the > reason? Should be this one, yes. After I revert it, I no longer see the problem with the project in the attached "TestEclipseFormatter.zip".
(In reply to Simeon Andreev from comment #8) > (In reply to Andrey Loskutov from comment #7) > > @Mateusz, I've quickly checked the git history, could it be, that changes > > for bug 250656 (commit ba73b313fde63d8ccedec4bd1f0dfefd65dc4e33) is the > > reason? > > Should be this one, yes. After I revert it, I no longer see the problem with > the project in the attached "TestEclipseFormatter.zip". Thanks for validation! @Mateusz: assigning to you, it would be really helpful to fix this ASAP.
New Gerrit change created: https://git.eclipse.org/r/155951
Gerrit change https://git.eclipse.org/r/155951 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=d5bebfcd41e40e691236ae672f0c877a727409c1
*** Bug 559128 has been marked as a duplicate of this bug. ***
Verified with I20200115-1800. Thanks Mateusz for a fast fix!
*** Bug 559638 has been marked as a duplicate of this bug. ***