caduceus
caduceus

Reputation: 1828

Generate a default Eclipse formatting configuration file

Is there any way to generate a Java formatting configuration file without installing/upgrading Eclipse and exporting it?

I want a new default configuration file for each new version of Eclipse so I can see what changed/how our coding convention should be adapted. The class is org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants

https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjdt%2Fcore%2Fformatter%2FDefaultCodeFormatterConstants.html

Exporting Java formatting settings from a new installation of Eclipse results in an empty file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="22"/>

It should have all possible settings with their default values.

Upvotes: 0

Views: 284

Answers (1)

LMC
LMC

Reputation: 12662

Create a new profile from any of the built-ins and export profiles (all in one file). Built-ins are not exported but custom ones.

Preferences: Java -> Code Style -> Formatter

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="22">
    <profile kind="CodeFormatterProfile" name="export-test" version="22">
        <setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
        <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
        <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
        <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
        <setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
        <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
        ...

Regarding the question

Is there any way to generate a Java formatting configuration file without installing/upgrading Eclipse and exporting it?

I want a new default configuration file for each new version of Eclipse so I can see what changed/how our coding convention should be adapted.

Eclipse formatter code seems to have had a low volume of changes per year so it's probably better to look at git log first than exporting the settings and manually compare with previous.

Upvotes: 1

Related Questions