-
/codeformatter
- This folder contains the company’s code formatter XML files for Eclipse IDE.
Note
|
For IntelliJ IDEA usage, there exists a plugin that can utilize the Eclipse formatter: https://plugins.jetbrains.com/plugin/6546-eclipse-code-formatter |
The file originates from the default settings of Eclipse, with a few modifications.
To see the differences easily, you can create a new formatter within Eclipse based on the default Eclipse settings, then export it. Next, take your own formatter, which might have been created in an older version of Eclipse, import it, and export it again. This way, the older formatter will be updated with any new rules introduced in Eclipse.
Setting identifier |
Default value |
Used value |
From version file |
Explanation |
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter |
do not insert |
insert |
v15 |
? |
org.eclipse.jdt.core.formatter.comment.indent_root_tags |
false |
true |
v15 |
? |
org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position |
true |
false |
v15 |
? |
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing |
do not insert |
insert |
v15 |
Adds an empty line at the end of every file (solves numerous issues) |
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column |
false |
true |
v15 |
? |
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant |
49(*1) |
0 |
v15 |
? |
org.eclipse.jdt.core.formatter.alignment_for_enum_constants |
16 (*1) |
0 |
v15 |
? |
org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped |
true |
false |
v15 |
? |
org.eclipse.jdt.core.formatter.comment.line_length |
80 |
150 |
v15 |
150 character line wrapping for comments |
org.eclipse.jdt.core.formatter.use_on_off_tags |
true |
false |
v15 |
Disable toggling the formatter in the code |
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments |
do not insert |
insert |
v15 |
? |
org.eclipse.jdt.core.formatter.alignment_for_assertion_message |
16 (*1) |
0 |
v15 |
? |
org.eclipse.jdt.core.formatter.comment.indent_parameter_description |
false |
true |
v15 |
? |
org.eclipse.jdt.core.formatter.tabulation.char |
tab |
space |
v15 |
Replace tabs with 4 spaces |
org.eclipse.jdt.core.formatter.lineSplit |
120 |
150 |
v15 |
Line wrapping at 150 characters |
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation |
0 (*1) |
16 |
v16 |
The annotation wrapping is not handled correctly; specifically, it is currently disabled by default |
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation |
16 |
80 |
0.2.0 |
Chain method calls (fluent API) should be placed on new lines for each method if they exceed the allowed maximum line length |
org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line |
- |
true |
0.2.0 |
Chain method calls (fluent API) should be placed on new lines for each method if they exceed the allowed maximum line length |
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call |
16 |
48 |
0.2.0 |
Parameter lists should be placed on new lines if they exceed the allowed maximum line length |
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression |
16 |
48 |
0.2.0 |
Parameter lists should be placed on new lines if they exceed the allowed maximum line length |
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation |
16 |
48 |
0.2.0 |
Parameter lists should be placed on new lines if they exceed the allowed maximum line length |
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression |
16 |
48 |
0.2.0 |
Parameter lists should be placed on new lines if they exceed the allowed maximum line length |
-
Tab <→ 4 space
-
We use tabs for indentation
-
Maximum line length is 150 characters
-
Default namespace abbreviation: xsd
1) File menu /Settings… Plugins (Tip: Typing in the search field above the left-hand tree filters the left-hand tree):
2) In the tree, after clicking on 'Plugins', 'Marketplace' appears on the right-hand side. Begin typing 'Eclipse Code Formatter' in the right-hand search field and install it.
3) Download the code formatting rules, which can be found in the /codeformatter/eclipse directory of this repository.
4) Start typing 'Eclipse Code Formatter' above the left-hand tree. Select it. On the right-hand side, the settings should look something like this (version and local machine dependent):
5) "*" Exclude imports:
Settings > Editor > Code Style > Java > Imports > Class count to use import with '' → 100
Settings > Editor > Code Style > Java > Imports > Names count to use static import with '' → 100
6) Tip: What conflicts: The 'Settings > Editor > General > Auto Import > Optimize imports on the fly' setting. This conflicts with Eclipse Code Formatter, resulting in imports being formatted twice, with IntelliJ IDEA’s own formatting taking precedence.
Therefore, if using auto-import, adjust 'Settings > Editor > Code Style > Java > Imports > Import layout' section as follows: import static all other imports; blank line; import java.; blank line; import javax.; blank line; import jakarta.; blank line; import org.; blank line; import all other
Similar to the example below (with 'jakarta' missing there).
When modifying old code, tabs and spaces may be mixed on the same line. Therefore, it’s advisable to enable showing whitespace characters as well.
Copyright © 2023 i-Cell Mobilsoft Zrt.