joshua-decoder / joshua

Joshua Statistical Machine Translation Toolkit
http://joshua-decoder.org/
121 stars 56 forks source link

Add Eclipse codeformatter #222

Closed lewismc closed 9 years ago

lewismc commented 9 years ago

Hi Folks, Please see the following PR for addressing the Eclipse codeformatting request. The aim here is to implement a very easy solution to addressing the Joshua code formatting requirements. The lines which ensure that the requested formatting is adhered to are

<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="100"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>

The remaining rules are for decoration. We use these over on the Apache Nutch project.

mjpost commented 9 years ago

There are already some files under .settings/ that contain this information; can you use those files? How can Eclipse be made to load them automatically when importing the project?

lewismc commented 9 years ago

Hi @mjpost

There are already some files under .settings/ that contain this information; can you use those files?

They should be deleted as they were autogenerated at some stage in the past.

How can Eclipse be made to load them automatically when importing the project?

The easy peasy solution is to do

cd $JOSHUA_HOME
ant eclipse

Open Eclipse

File --> Import --> Existing Projects into Workspace

This will import the Java project, then simply do

Eclipse --> Preferences --> Java --> Code Style --> Formatter --> Configure Project Specific Settings --> Select Joshua project --> Import --> Navigate to the eclipse formatter.xml file
lewismc commented 9 years ago

Maybe we could add the above to the documentation page?

mjpost commented 9 years ago

Drat — What I was hoping was that importing the project would also import the project settings, such as coding conventions. It seems like there must be a way to do this! But I can't seem to find anything googling.