Bug 476636 - [typing] wrong indentation when breaking a line before method invocation
Summary: [typing] wrong indentation when breaking a line before method invocation
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.5   Edit
Hardware: All Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2015-09-04 07:08 EDT by Martin Lippert CLA
Modified: 2023-06-15 11:37 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Lippert CLA 2015-09-04 07:08:33 EDT
The formatter seems to put the wrong indentation into the code when function calls are wrapped at certain positions.

Example line:

	environment.getPropertySources().addLast(new MapPropertySource(CONFIG_SERVER_BOOTSTRAP, map));

when I break the line manually before ".addLast", the result is:

	environment.getPropertySources()
	.addLast(new MapPropertySource(CONFIG_SERVER_BOOTSTRAP, map));

where it should be:

	environment.getPropertySources()
			.addLast(new MapPropertySource(CONFIG_SERVER_BOOTSTRAP, map));

When I instead break the line manually before "new Map", the result is correct:

	environment.getPropertySources()
	.addLast(new MapPropertySource(CONFIG_SERVER_BOOTSTRAP, map));

	environment.getPropertySources().addLast(
			new MapPropertySource(CONFIG_SERVER_BOOTSTRAP, map));

The same problem happens with the "correct indentation" cleanup action (which is the real problem, since that is executed on save and destroys correct formatting in this case).
Comment 1 Mateusz Matela CLA 2015-10-17 20:28:49 EDT
(In reply to Martin Lippert from comment #0)
> The same problem happens with the "correct indentation" cleanup action

If it only happed with the cleanup action, I'd say it's a duplicate of bug 477476 (your report was first, but the other one somehow got more attention).
So how else does it occur? After pressing Ctrl+Shift+F? (I guess not, a bug like that would be a huge deal)
Comment 2 Mateusz Matela CLA 2015-11-07 10:46:38 EST
OK, I just realized it's about pressing Enter inside the code editor to add line break.
Java formatter is not invoked in this case, it's probably a jdt-text issue.
Comment 3 Dani Megert CLA 2015-12-01 05:54:02 EST
Noopur, please take a look.
Comment 4 Noopur Gupta CLA 2015-12-01 13:29:31 EST
It can be reproduced in Eclipse 3.8 also.
Comment 5 Eclipse Genie CLA 2019-06-07 13:33:42 EDT
New Gerrit change created: https://git.eclipse.org/r/143562
Comment 6 Lakshminarayana CLA 2019-06-07 13:37:10 EDT
(In reply to Eclipse Genie from comment #5)
> New Gerrit change created: https://git.eclipse.org/r/143562

Used simple indent for now. In the future, We may need to map with preferences for customizing.
Comment 7 Eclipse Genie CLA 2021-05-28 08:26:24 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.

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 8 Jeff Johnston CLA 2021-06-01 16:26:10 EDT
(In reply to Lakshminarayana from comment #6)
> (In reply to Eclipse Genie from comment #5)
> > New Gerrit change created: https://git.eclipse.org/r/143562
> 
> Used simple indent for now. In the future, We may need to map with
> preferences for customizing.

Hi Lakshminarayana,

I tried rebasing your patch above and it has a few test failures (2).  Are you interested in revisiting your patch and either changing the tests if needed or adding scenarios?  If yes, I can review and try to get this into 4.21.
Comment 9 Lakshminarayana CLA 2021-06-02 00:45:39 EDT
(In reply to Jeff Johnston from comment #8)
> (In reply to Lakshminarayana from comment #6)
> > (In reply to Eclipse Genie from comment #5)
> > > New Gerrit change created: https://git.eclipse.org/r/143562
> > 
> > Used simple indent for now. In the future, We may need to map with
> > preferences for customizing.
> 
> Hi Lakshminarayana,
> 
> I tried rebasing your patch above and it has a few test failures (2).  Are
> you interested in revisiting your patch and either changing the tests if
> needed or adding scenarios?  If yes, I can review and try to get this into
> 4.21.


Sure Jeff Johnston. I try to revisit the patch by this weekend.
When will be the 4.21 release?
Comment 10 Jeff Johnston CLA 2021-06-02 13:15:33 EDT
(In reply to Lakshminarayana from comment #9)
> (In reply to Jeff Johnston from comment #8)
> > (In reply to Lakshminarayana from comment #6)
> > > (In reply to Eclipse Genie from comment #5)
> > > > New Gerrit change created: https://git.eclipse.org/r/143562
> > > 
> > > Used simple indent for now. In the future, We may need to map with
> > > preferences for customizing.
> > 
> > Hi Lakshminarayana,
> > 
> > I tried rebasing your patch above and it has a few test failures (2).  Are
> > you interested in revisiting your patch and either changing the tests if
> > needed or adding scenarios?  If yes, I can review and try to get this into
> > 4.21.
> 
> 
> Sure Jeff Johnston. I try to revisit the patch by this weekend.
> When will be the 4.21 release?

Not for a while.  The 4.20 release is just releasing RC1 and will be GA on June 16th and then we will have 4.21 M1 three weeks after that, however, JDT gets M1 ready one week earlier than other components so make that two weeks after 2021-06 GA.
Comment 11 Eclipse Genie CLA 2023-06-15 11:37:05 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.

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.