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

Bug 407260

Summary: [formatting] wrong placement of curly braces if method has throws declaration in own line
Product: [Eclipse Project] JDT Reporter: Ulrich Scholz <d7>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: jarthana
Version: 4.2.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug
Attachments:
Description Flags
desktop recording showing the formatting problem
none
Eclipse formatter settings showing the problem none

Description Ulrich Scholz CLA 2013-05-06 05:14:26 EDT
Currently, if a method has a throws declaration in its own line, formatting places the curly braces of a method at the column given by the throws statement.  Instead, they should always be placed at the column given by the method declaration.

correct:

public void foo()
    throws Exception
{
   if(true)
   { 
      bar();
   }
}

not correct (as done today):

public void foo()
    throws Exception
    {
   if(true)
   {
      bar()
   }
    }
Comment 1 Jay Arthanareeswaran CLA 2013-05-06 06:10:55 EDT
I don't see this problem. Did you try out the following formatter options:

Braces -> Method Declaration = Next line
Line Wrapping -> Method Declarations:Throws Clause = Wrap ... ?
Comment 2 Ulrich Scholz CLA 2013-05-06 07:15:45 EDT
That is exactly my setting (Wrap where necessary).

The preview shows the formatted code correctly.  But if I apply formatting on a full method that has a throws clause, it if formatted incorrectly.  If you want, I will attach a desktop recording to show you.
Comment 3 Ulrich Scholz CLA 2013-05-06 07:16:31 EDT
Created attachment 230507 [details]
desktop recording showing the formatting problem
Comment 4 Jay Arthanareeswaran CLA 2013-05-07 00:57:22 EDT
I see this behavior 'only' when the Braces option for Method declaration is set to "Next line indented" and not otherwise. Can you check what you have set?
Comment 5 Ulrich Scholz CLA 2013-05-07 03:27:52 EDT
On my site, the braces option for Method declaration is set to 'Next line', not to 'Next line indented"

Is there a way to attach all my settings at once?
Comment 6 Jay Arthanareeswaran CLA 2013-05-07 04:09:25 EDT
(In reply to comment #5)
> On my site, the braces option for Method declaration is set to 'Next line',
> not to 'Next line indented"
> 
> Is there a way to attach all my settings at once?

I don't think the other settings should affect this. For the formatter settings, you can just export and share it.
Comment 7 Ulrich Scholz CLA 2013-05-07 04:31:46 EDT
Created attachment 230568 [details]
Eclipse formatter settings showing the problem
Comment 8 Jay Arthanareeswaran CLA 2013-05-07 05:01:32 EDT
I can't reproduce this even with the given formatter setting. May be I should have said this earlier: can you try with one of the recent Kepler builds? I can't imagine what else (apart from the formatter prefs) could cause this.
Comment 9 Ulrich Scholz CLA 2013-05-15 03:09:04 EDT
unfortunately, I'm bound to my company-provided Eclipse version and am unable to install a different one.
Comment 10 Eclipse Genie CLA 2020-02-22 07:13:09 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. 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.