Eclipse is wrapping the lines even if I'm disabling the wrapping - eclipse

I'm using Eclipse 2022.12. For some months, when I'm formatting my Java code, Eclipse is wrapping even if I set the line width to 200 characters. I created a new profile starting from "Eclipse 2.1" and I have disabled the line wrapping by doing this:
But Eclipse is still formatting like that (after the first parentesis):
final List<GrantedAuthority> authorities = getAuthorities(
Arrays.asList(roleRepository.findByName("ROLE_USER")));
Is it normal (and how to fix it ?) or a bug?

Related

Is there a way to unwrap an already wrapped code in Intellij / Eclipse?

I have code that was formatted based on a wrap of 120 chars. I changed the setting to wrap it at 200 chars in IntelliJ CE. Running a reformat doesn't re-wrap the code as per 200 char limit. I am having to manually move the split lines up to a single line.
Example of existing code :
final MyOwnFactoryClass myOwnFactoryClass = new
MyOwnFactoryClass(myStringVar1 , myStringVar2,
myStringVar3);
How I want it to look
final MyOwnFactoryClass myOwnFactoryClass = new MyOwnFactoryClass(myStringVar1 , myStringVar2, myStringVar3);
Is there an easier way of doing this either in IntelliJ or Eclipse?
For those wondering why I need this, I have new code that I need to read through and it is extremely tough reading and interpreting in the 1st format. And no the company has no code standards so I won't be violating anything.
Would changes to plugins or settings be of use?
I found a way just by experimenting :) .
Intellij --> File --> Settings (Preferences for MacOS) --> Code Style --> Java --> Wrapping and Braces --> check all the align when multiline option in for all the blocks you want like for(), if(), while() etc. --> Apply --> run code format. and it should do the needful! :)
Aside from working with the automatic formatting, you can use the "Join Lines" action.
With the cursor on the first part of the line, select the action, either by name (using Cmd-Shift-A or double-shift) or with the keyboard shortcut Ctrl-Shift-J.

Is there any way to get such type of line wrapping in Eclipse?

Eclipse sure provides a lot of ways to customize code formatting, but I'm missing the one I'm used to. It is "when line exceeds maximum length, recursively wrap and indent each argument and put the closing parenthesis on a new line without additional indentation". Like this:
Horse samuel = new Horse(
9.1051,
Color.RED,
new Music(1),
new Music(
"frying pan",
Taste.SWEET,
Russian.HELICOPTER
),
State.ARIZONA
);
However it is not implemented in standard Eclipse formatting tools. Can I achieve this through some plugins? There is a 1.5 year old bug in Eclipse bug tracker, but it is unlikely to get any attention any time soon: https://bugs.eclipse.org/bugs/show_bug.cgi?id=370540
I think you are going to have to create a custom profile formatter in eclipse to get it to do this. Window -> Prefrences -> Java -> Code Style -> Formatter
Under the Line Wrapping tab is the option for line width = Maximum line width. I think thats as good as it gets without that bug fix.
Also, use the Line Wrapping policy = Wrap all elements, every element on a new line.
Thats as close as I could get it to do what you are asking.

eclipse auto formate : How to stop new line after dot of method call?

When I press Ctrl+Shift+F
This line:
A
winterwell.jtwitter.Status status = twitter.updateStatus(statuses[0]);
Is formatted like this
B
winterwell.jtwitter.Status status = twitter
.updateStatus(statuses[0]);
I want to keep it like in A.
That is occurring because of your Maximum line width setting. You might want to increase yours, or look at the other options available for wrapping.
Go to Window > Preferences... Java > Code Style > Formatter > Edit...
Maximum line width
In my case helped Eclipse restart after I realised setting Maximum line width to 500 didn't help :-D
.. probably some kind of bug of:
Eclipse Java EE IDE for Web Developers.
Version: Luna Service Release 2 (4.4.2)
Build id: 20150219-0600

Unable to change eclipse line length or comment line length

I've tried changing all of the line wrapping parameters, both increasing and decreasing the maximum line length for source and comments, as well as disabling comment formatting. However, I'm unable to affect the code formatter's line-splitting behavior. No matter what changes I make to the format, line splitting occurs at 120 characters for both comments and source code. I've also tried upgrading eclipse from 3.6 to 3.7.
Any ideas why this is happening?
Right-click on your project and go to Properties
Check if Java Code Style > Formatter > Enable project specific settings is checked
If so, check the Active profile
My guess is that there was a different Active profile selected than the one you were editing. Deleting the project and recreating it caused the project to return to the default code style profile, where Enable project specific settings is unchecked.
Did you change the lines width from :
Preferences > Java > Code Style > Formatter >> then editing the maximum line width ?

Getting netbeans more eclipse-y

I'm a long-time eclipse user looking to use netbeans now that I've tried netbeans out a bit. I mostly like what I see, except there's a few aesthetics missing. Anyone have ideas on if the following are available in NetBeans?:
Eclipse highlights modified & inserted lines in the left margin / gutter
Eclipse highlights the currently edited function in the left margin / gutter
Eclipse highlights TODO / FIXME comments in the right margin
For example:
alt text http://img507.imageshack.us/img507/5471/forso.png
... any ideas on how I can get Netbeans to do this sort if stuff ?
If your project is connected to source control netbeans will show added lines with a green block at the beginning of the line, modified lines with a blue block, and deleted lines with a red arrow. It also marks these in the right margin/gutter. This is based off of compared to last commit, not last save however.
As for the other two I could not find a way to implement them but I may just be missing something