Comments (4)
what sorting?
Is it something that does not happen in Eclipse? :)
from eclipsecodeformatter.
Could you add screenshots?
from eclipsecodeformatter.
Sorry, by "sorting", I meant the "Rearrange Entries" option for the "Reformat Code" operation.
And this may be the key. I did a little more testing in Eclipse and IntelliJ, and I think what I have observed may actually be standard Eclipse behavior. In my previous Eclipse life, I used the "Clean Up" operation primarily, which included Sorting as well as my Formatter configuration. That was clouding the issue for me.
In short, I think this is "working as designed". :)
But, so you can see what I was talking about, here is a simple example. Paste this into IntelliJ:
package formatter.example;
public class Foo {
private static final String VAR1_LABEL = "var1";
private static final String VAR2_LABEL = "var2";
private final int _var1;
private final int _var2;
public Foo(final int var1, final int var2) {
_var1 = var1;
_var2 = var2;
}
@Override
public String toString() {
return VAR1_LABEL + "=" + _var1 + ", " + VAR2_LABEL + "=" + _var2;
}
}
In your imported formatting configuration file, ensure you have blank_lines_before_field = 0, and number_of_empty_lines_to_preserve = 1.
Then Code->Reformat Code.
Note that the blank lines above the fields were not removed.
Cut the _var2 declaration line and paste it below the constructor. Then run Code->Reformat Code and be sure to select the "Rearrange entries" option before clicking Run.
Assuming you have some amount of field rearrangement configured, _var2 will likely end up below _var1. Note that there is no space above the declaration of _var2. It will look like this:
package formatter.example;
public class Foo {
private static final String VAR1_LABEL = "var1";
private static final String VAR2_LABEL = "var2";
private final int _var1;
private final int _var2;
public Foo(final int var1, final int var2) {
_var1 = var1;
_var2 = var2;
}
@Override
public String toString() {
return VAR1_LABEL + "=" + _var1 + ", " + VAR2_LABEL + "=" + _var2;
}
}
from eclipsecodeformatter.
I see, IntelliJ rearranger makes it without the blank line (because Blank Lines | Around field = 0) and Eclipse formatter does not insert the blank line either because of blank_lines_before_field=0.
from eclipsecodeformatter.
Related Issues (20)
- Formatter not working anymore with newest IDEA version. HOT 6
- Imports have an empty line between packages HOT 2
- Missing space before instanceof operator HOT 3
- Support loading XML configuration from JAR HOT 1
- Support disable modules in project
- Resolve project specific config can not find configuration file HOT 1
- Document is locked by write PSI operations during Replace in files
- Error logged by IDEA
- Eclipse Correct Indentation leads to different result
- Document version of bundled eclipse used by this plugin
- Newest Eclipse version is not compatible with EclipseCodeFormatter
- Failed to format with Adapter for Eclipse Code Formatter. Formatter config file not resolved. HOT 13
- @formatter:off is not working HOT 3
- Absolute Path to config file gets replaced with relative path using variable $PROJECT_DIR$ rendering settings unusable for a global central settings location HOT 7
- error failed to format with Adapter for Eclipse Code Formatter. Configured settings file does not exist, path="" HOT 3
- IconDeferrerImpl.clearCache IllegalStateException HOT 7
- Incompatible with IDEA2023.3.1 HOT 1
- Upgrade bundled eclipse to 2023-12 (4.30) HOT 3
- Code formatting before committing is not working in the newer version of IntelliJ IDEA
- EclipseCodeStyleManager not honoring plugin listeners HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eclipsecodeformatter.