Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Advanced (Unorthodox?) Formatting in Eclipse(Source Code Formatting)
Advanced (Unorthodox?) Formatting in Eclipse [message #766649] Fri, 16 December 2011 07:36 Go to next message
David Illescas is currently offline David Illescas
Messages: 1
Registered: December 2011
Junior Member
Hello.

Although I am a newcomer to this forum I am not a newcomer to Eclipse. I have, however, failed to make use of its powerful source code formatting features because, well, the way I format my code is rather idiosyncratic.

Consider the following snippet:

package source;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class 
HelloWorld 
extends SomeClass
implements SomeInterface
{
	/**
	 * @param args
	 */
	public static void 
	main
	(String[] args) 
	{
		System.out.println
		("Hello World from Java 1.7");
		@SuppressWarnings("unused")
		List<Integer> complicated_object =
			new LinkedList<Integer>( Arrays.asList(new Integer[]{5,6,7,8,9}) );

		printMessage("four");
	}

	private static void 
	printMessage
	(String string) 
	{
		
		switch(string){
			case("one"):
				System.out.println(1);
				break;
			case("two"):
				System.out.println(2);
				break;
			default:
				System.out.println(	
					"You entered some other number, and yes, I know this" +
					"\"error\" message could be more helpful."
				);
				break;
		}
	}
}



As you can see there are a number of odd things happening above, and I am not sure that the range of settings on the source code formatter permits my code to look this way(I could be mistaken about this). For instance, I break the linked list declaration at the assignment operator; I also put the class name on its own line, and the method name on its own line; I put short argument lists on the same line as the method name, medium length argument lists on their own line, and multi-line argument lists using a traditional function brace arrangement.

I am wondering if anyone knows of any "low-level" interface for configuring the source code formatter, so that the formatting and clean-up can be made completely consistent and automatic.

Thank you.

[Updated on: Fri, 16 December 2011 08:15]

Report message to a moderator

Re: Advanced (Unorthodox?) Formatting in Eclipse [message #766989 is a reply to message #766649] Fri, 16 December 2011 19:58 Go to previous message
Deepak Azad is currently offline Deepak Azad
Messages: 545
Registered: July 2009
Senior Member
Nope, you cannot set the formatter to place method arguments on a new line.

--
Deepak Azad
http://wiki.eclipse.org/JDT/FAQ
Previous Topic:Finding class declarations in workspace
Next Topic:Special Characters not displayed in text editor
Goto Forum:
  


Current Time: Wed Oct 01 00:15:39 GMT 2014

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

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