Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » formatting project code using existing template(code formatting, template, )
formatting project code using existing template [message #731084] Thu, 29 September 2011 22:08 Go to next message
Lewis John is currently offline Lewis JohnFriend
Messages: 7
Registered: September 2011
Location: Stanford
Junior Member

Hi,

We have an existing code format file (please see attached) which we wish to utilise on a planned release of our development trunk. I am completely unfamiliar with the process of formatting a codebase based upon the xml configuration therefore can anyone provide guidance as to best practice?

Thank you in advance for any direction/suggestions

Lewis
Re: formatting project code using existing template [message #731099 is a reply to message #731084] Thu, 29 September 2011 23:58 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 29-Sep-11 16:08, Lewis John wrote:
> Hi,
>
> We have an existing code format file (please see attached) which we wish to utilise on a planned release of our development trunk. I am completely unfamiliar with the process of formatting a codebase based upon the xml configuration therefore can anyone provide guidance as to best practice?
>
> Thank you in advance for any direction/suggestions
>
> Lewis
>

I hope I am answering the question you're asking.

:-)

Go to Window -> Preferences -> Java -> Code Style -> Formatter. There,
you'll probably see (because you've likely not changed it) that the code
formatter you're using is the default shipped with Eclipse.

If you click the Edit button, you'll be able to change a lot about how
things are done. For instance, by working with the braces, you can
change from using Kernel Normal Form (KNF) to, say, Allman indentation
(as used by ANSI and ISO).

And you can dramatically affect the way other things are physically
formatted not only as you type in code, but also as a result of
selecting code and doing Source -> Format in the editor.

You can save your changes under a different name by giving your new
format a name and clicking on the Export... button. This saves your
changes in a file containing the stuff you pasted into your post (that
I'm answering).

Conversely, when you create a new Eclipse workspace, you can go to
Window -> Preferences -> Java -> Code Style -> Formatter and click the
Import... button, navigate to that file you saved and thereby substitute
it for Eclipse's default format. Obviously, you can save that file and
distribute it.

That's how I use it. There may be more intelligent ways of distributing,
injecting it into new workspaces or even Eclipse installations, but I
don't know about those.

Hope this helps.

Russ
Re: formatting project code using existing template [message #731222 is a reply to message #731099] Fri, 30 September 2011 10:13 Go to previous messageGo to next message
Lewis John is currently offline Lewis JohnFriend
Messages: 7
Registered: September 2011
Location: Stanford
Junior Member

This is excellent Russ, thank you for your explanation it is greatly appreciated

Lewis
Re: formatting project code using existing template [message #742685 is a reply to message #731099] Thu, 20 October 2011 18:25 Go to previous message
Lewis John is currently offline Lewis JohnFriend
Messages: 7
Registered: September 2011
Location: Stanford
Junior Member

Hi Russ (or anyone else for that matter),

Were finally ready to roll a RC and this 'blocker' issue is giving me some headaches. I've followed your instructions to the dot and even after I save the project, the formatting doesn't seem to remain. Can you explain why after I have formatted the codebase using my custom template, the changes are not made outside the eclipse instance?

In an attempt to crack this one myself, I've run the eclipse code formatter application from the command line as follows
{code}
eclipse -application org.eclipse.jdt.core.JavaCodeFormatter -config ~/ASF/trunk/eclipse-codeformat.xml -verbose ~/ASF/trunk
{code}

This uses my template and formats the codebase, however I'm getting lots and lots of skipped log messages. I found a web blog entry by peter freese on this topic a closely linked post by operational dynamics here [2], these are great, but I'm still getting the following output, even after adding the Java 1.5 compiler targets.
{code}
The Eclipse formatter failed to format /home/lewis/ASF/trunk/src/java/org/apache/nutch/tools/FreeGenerator.java. Skip the file.
Formatting: /home/lewis/ASF/trunk/src/java/org/apache/nutch/tools/DmozParser.java
The Eclipse formatter failed to format /home/lewis/ASF/trunk/src/java/org/apache/nutch/tools/DmozParser.java. Skip the file.
Formatting: /home/lewis/ASF/trunk/src/java/org/apache/nutch/tools/Benchmark.java
The Eclipse formatter failed to format /home/lewis/ASF/trunk/src/java/org/apache/nutch/tools/Benchmark.java. Skip the file.
Formatting: /home/lewis/ASF/trunk/src/java/org/apache/nutch/tools/CrawlDBScanner.java
The Eclipse formatter failed to format /home/lewis/ASF/trunk/src/java/org/apache/nutch/tools/CrawlDBScanner.java. Skip the file.
{code}

Any help with this one would be greatly appreciated. Kind regards

Lewis
Previous Topic:BW TIFF images status
Next Topic:JSF proble with #{..}
Goto Forum:
  


Current Time: Tue Mar 19 05:38:35 GMT 2024

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

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

Back to the top