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?
I find it distracting that Eclipse checks the code for errors and warnings during typing. Is it possible to change this behavior, so that it only checks when I'm done writing a line?
If you were talking about java code, the checkbox can be found via 'Preferences - Java - Editor' -> 'Report problems as you type'.
String tmp = // no syntax error here
String tmp = ; // line end -> syntax error
For other editors use 'General - Editors - Structured Text Editors'-> 'Report problems as you type'. It's not necessary to deactivate 'build automatically'.
I don't think it's possible to change it to compile after each line. But you can turn automatic compilation off altogether in the menu Project->Build Automatically.
As I was playing around for the first time with CoffeeScript, I ran in to a problem. In order to debug my problem, I tried replacing my whole file with one of the example bits of code from the coffee script site:
kids =
brother:
name: "Max"
age: 11
sister:
name: "Ida"
age: 9
However, when I try to compile that code, I get:
Error: In coffee/main.coffee, Parse error on line 3: Unexpected 'INDENT'
at Object.parseError (/usr/lib/coffeescript/parser.js:501:11)
at Object.parse (/usr/lib/coffeescript/parser.js:573:32)
at Object.compile (/usr/lib/coffeescript/coffee-script.js:23:22)
at /usr/lib/coffeescript/command.js:99:27
at /usr/lib/coffeescript/command.js:72:28
at fs:84:13
at node.js:773:9
In coffee/main.coffee, Parse error on line 3: Unexpected 'INDENT'
Since this is code from the CoffeeScript site, I assume the code itself isn't the problem. However, the compiler also seems to be working properly; if I compile:
a = 2
it generates a file with:
(function(){
var a;
a = 2;
})();
as expected. So in other words, the code is good, the compiler is good, and yet somehow I'm getting this Unexpected 'IDENT' error ... can anyone help me understand what is going on?
I am pretty sure this is a tabs-vs-spaces issue. Tell your editor not to convert spaces to tabs if it does that. Also, go through your code with the cursor and make sure it doesn't jump over blank areas.
The issue is that while normal editors see a tab as equivalent to two or four spaces, coffeescript sees it as one space, so the indentation gets messed up.
If this all doesn't help, make sure you have a recent coffeescript version, e.g. 1.1.0 or newer.
If you are using a JetBrains IDE (IntelliJ, PHPStorm, etc) the change of setting that worked for me is:
File > Settings > Project Settings > Code Style > CoffeeScript > Tabs
and Indents
Tick "Use tab character" & "Smart tabs"
Code is fine. Make sure you haven't messed up the whitespace (strange control chars showing as blanks, tabs or similar).
If you have the same problem, but your indentation is okay,
then you must be suffering from bug 2868.
Basically, the error is misleading. Check for indentation
errors in the required files.
When in Atom you can automatically convert tabs to spaces:
Packages > Whitespace > Convert Tabs to Spaces
You can resolve this two ways
1. IF using webstorm File->Default Settings as said above
2. Other workaround, is to use a different editor like Sublime, there u can press enter on earlier line and it will auto tab it for you with spaces
I'm using Eclipse on Mac OSX and I randomly get character \160 (whatever that is) instead of a whitespace in my code.
From time to time when I compile I get this error:
java:74: illegal character: \160
if (c == '*' ||?c == '/')
when my code in Eclipse actually looks like:
if (c == '*' || c == '/')
This is annoying and usually resolved by deleting the supposed invisible ? and pressing spacebar once again in the editor.
I'm curious as to why this happens if anybody has an idea.
as #Hanynowsky mention it is related to a different encoding between the source you copied and the one from your file. I have not found any way to automatically removed the bogus mismatching characters, but you can actually see them in eclipse if you enable the editor to show whitespaces.
For doing that:
set Eclipse to "show whitespace characters" (option under Preferences -> General -> Editors -> Text Editors)
the bogus \160 character will appear as " ." even if your other spaces will appear as ".". So you just need to delete the " ." occurrences and you are good!
When you copy / paste a code from a website page into your IDE editor, you might get this error as the copied code has invisible unknown characters, usually white spaces.
Unfortunately I do not know of any solution bar to remove and re-ident every white spaces between your code's identifiers.
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