JSP EL (Expression Language) causing problems in Eclipse - eclipse

My system: Ubuntu 9.10. Eclipse 3.5.1 with Java EE 1.2.1 (manual install - NOT from synaptic). Web Developer Tools 3.1.1
I've recently adopted someone else's code (a Dynamic Web Project), and run into lots of errors, warnings and incorrect syntax highlighting in Eclipse. I've narrowed it down to these 4 lines of code (create a new Dynamic Web Project, and then a new JSP page, and put this in the body):
${(1<2)? "" : "no"}
<%for (int i = 0; i < 5; i++) {%>
<div>${5}</div>
<%}%>
Errors / Warnings / Incorrect syntax highlighting
line1: yellow warning line under '<': Invalid character used in text string
(${(1<2)? "yes" : "no"}).
line2: red error line under 'f':
Multiple annotations found at this line: 1) Syntax error, insert "Finally" to complete TryStatement. 2) Syntax error, insert "}" to complete ClassBody
line2: red error line under ')': Syntax error on token ")", try expected after this token
line3: yellow warning line under 'div': No end tag (/div).
line3: yellow warning line under '<' of closing div: Multiple annotations
found at this line: 1) Invalid character used in text string (${5} <%}%>). 2) Invalid character used in text string (${5} <%}%>).
line3: '/div' is black and purple (for scriptlet code?) instead of green for HTML code
line4: The opening and closing scriplet tags '<%' and '%>' are black instead of orange
The page works as expected in a browser: you get '5' five times. If you change the empty quotes on line 1 to "yes" then save, close the file in the editor, r click it in the project explorer > validate, then re-open it: all errors / warnings / incorrect syntax highlighting disappear, except the first one (invalid character). This is incredibly irritating. Any thoughts would be greatly appreciated.

Eclipse WTP is great, but exactly this problem is an epic fail in Eclipse WTP for me as well. They seem to be working on that, but until then I just disable/set-to-ignore all of the validation related to this stuff in the workspace preferences through Web > JSP Files > Validation > scroll list to very bottom and set all EL validation settings to Ignore. Also in the main Validation preference uncheck all checkboxes related to JSP. This however doesn't seem to remove every warning/error, but it at least minimizes the annoyance.
IntelliJ IDEA handles JSP/EL validation much better.
To me, the symptoms make me think that WTP is using regexp instead of a stackbased parser to validate HTML/JSP/EL. This is a big no-no in case of structured markup.

Related

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

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?

Disable real-time error and warning check in Eclipse

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.

Unexpected 'INDENT' in CoffeeScript Example Code

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

Using eclipse on Mac OSX, I get random invisible character \160 . Why?

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.

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