Etichettato: javascript

Eclipse and his quite zombie/nazi JavaScript Validator

Since when I’ve begun to code in Java (in 2005) I’ve tried many IDEs, but the best is still probably Eclipse. Sadly enough, it’s the best but not that good in every aspect. Sometimes you spend whole days trying to just make something work: while you’re doing everything right, he’s trolling you not really doing something at some point; so the hard part is finding out what it is and then doing it manually.

The issues and solutions I’m going to list apply to Indigo SR1, but probably to many other versions (from the beginning until the end of times, as we are used to with Eclipse). Solutions are mainly from other people, go see the linked threads and posts for credits. I just wanted to have them all in the same place.

Issues with Eclipse, chapter 1: JavaScript Validator

1) Sometimes a NullPointerException pops up (constantly, at every build) saying “Errors running builder ‘JavaScript Validator’ on project ‘${project}’. java.lang.NullPointerException”.

The solution, as you can read here and in many other places, is to open project properties (this is a project-only option) and disable (or remove altogether if it’s not enough) Builders -> JavaScript Validator.

2) Errors on JavaScript files sometimes are reported (as the usual little red icon) on the project tree, even though you have solved them in the source files and even after a full rebuild or a manual “Validate”; sometimes Eclipse continues to report them at the very same line of the opened file, even though the error is not there anymore.

The causes can be many (one of them is “have you messed with it too much?”), and getting rid of this may be done the taliban or the diplomatic way. The diplomatic way to clear the report of a non-existent JavaScript error is to find it in the “Problems” tab and deleting it. If it works, good for you. The taliban way is to blow up the folder

${workspace}/.metadata/.plugins/org.eclipse.core.resources/.projects/${project}

as suggested here. In this way you’re clearing a cache for project metadata (has it errors? are all changes committed to the repository? and so on), and in order to regenerate it you have to close and reopen the project.

3) Sometimes you just want to ignore JavaScript errors because you don’t care.

You can try to disable them for a single project (but don’t assume it will work): Properties -> Validation, check Enable project specific settings, disable Client-side JavaScript Validator, for Manual (when you right-click on the file and choose “Validate”, should be harmless if you don’t use it) and/or Build (validation on *every* build).

Or you can disable them for the entire workspace: Preferences -> Validation, disable Allow projects to override these preference settings (hope it works), disable Client-side JavaScript Validator in the same way as above.

Be aware that even if you disabled the validator you can still have caching issues as described in 2).

Is the Validator still running? You may have to open your .project file and remove the <buildCommand> XML block containing <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>, and <nature>org.eclipse.wst.jsdt.core.jsNature</nature>, as described here (yes, it’s an old issue). Close and reopen your project.

Still issues? Maybe the solution proposed in this comment (same thread on stackoverflow) will work for you: Preferences -> JavaScript -> Editor, disable “Report problems as you type”.

4) In a Dynamic Web Project with many files (hundreds, both .java and .js), the time required to open for the first time (since Eclipse startup) the project tree is about 1 minute.

Having disabled JavaScript Validation (in some or all of the many horrible ways listed above), it takes about 1 second, so I guess it’s related.

Annunci