Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Java formatter
Java formatter [message #248133] Wed, 26 September 2007 11:00 Go to next message
Eclipse UserFriend
Hi there,

I'm having the problem that the formatter puts our code in a format that
causes checkstyle warnings which we would like to avoid.

The problem is with the following code:

public static SOAP getSoap()
{
if (Soap == null) { throw new IllegalStateException("Soap==null. "
+ "InitUtils.init() was not called or failed"); }
return Soap;
}

If I put the closing brace of the if clause into a new line, the formatter
puts it to the now place, at the end of its body. I have taken a look on
various options in the formatter but could not find any that would prevent
this. Do you know any?

- Gergely
Re: Java formatter [message #248206 is a reply to message #248133] Thu, 27 September 2007 10:49 Go to previous messageGo to next message
Eclipse UserFriend
Gergely Buday wrote:

> Hi there,
> I'm having the problem that the formatter puts our code in a format
> that causes checkstyle warnings which we would like to avoid.
> The problem is with the following code:
>
> public static SOAP getSoap()
> {
> if (Soap == null) { throw new IllegalStateException("Soap==null. "
> + "InitUtils.init() was not called or failed"); }
> return Soap;
> }
>
> If I put the closing brace of the if clause into a new line, the
> formatter puts it to the now place, at the end of its body.

If I format that code with default formatter settings (out of the box) I
get:
public static SOAP getSoap() {
if (Soap == null) {
throw new IllegalStateException("Soap==null. "
+ "InitUtils.init() was not called or failed");
}
return Soap;
}

So what's the problem?

Dani

> I have taken a look on various options in the formatter but could not
> find any that would prevent this. Do you know any?
>
> - Gergely
>
Re: Java formatter [message #248216 is a reply to message #248133] Thu, 27 September 2007 13:34 Go to previous message
Eclipse UserFriend
Gergely Buday a écrit :
> I'm having the problem that the formatter puts our code in a format that
> causes checkstyle warnings which we would like to avoid.
> The problem is with the following code:
> public static SOAP getSoap()
> {
> if (Soap == null) { throw new IllegalStateException("Soap==null. "
> + "InitUtils.init() was not called or failed"); }
> return Soap;
> }
> If I put the closing brace of the if clause into a new line, the
> formatter puts it to the now place, at the end of its body. I have taken
> a look on various options in the formatter but could not find any that
> would prevent this. Do you know any?
Did you try to change the brace setting for block to "Next line"?
--
Olivier
Previous Topic:Example of org.eclipse.ui.editors.templates extension point?
Next Topic:Question on Marker use (APT vs. JavaModel)
Goto Forum:
  


Current Time: Mon May 12 19:14:51 EDT 2025

Powered by FUDForum. Page generated in 0.03876 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top