Somehow I seem doomed to be in a constant love/hate relationship with my IDE of choice. Nowadays that’s Eclipse. On one hand, I don’t want to do any Java development without the refactoring tools and source helpers that Eclipse provides, on the other hand I find myself in a constant battle with Eclipse bugs — and they’re not of the sporadic kind, the kind every software product has, but of the soul-crushing, repetitive and long-lasting kind. Whenever there’s a new Eclipse version, I secretly hope this one will remove some of them, but usually they just get more. Sometimes bugs disappear, usually when some component is completely rewritten, but it’s very rare.
Sometimes I am lucky though and discover a way around them by either being persistent enough or by finding just the right magic combination of search terms that point me to a solution. To end this blog post somewhat uplifting, here are two fixes I found recently.
The Workbench-locks-up-at-startup Bug
This one happens fairly often for me. On startup, eclipse will do nothing or just write something like “Initialize Java tooling.. 1%” and then just stop working. Since I use Ubuntu with Compiz, that will then turn desaturate the eclipse window to signal the app is no longer responding to any window messages. There seems to be no CPU activity and this all continues until I forcefully kill the eclipse process.
Solution (found on Stackoverflow)
Delete either .metadata\.plugins\org.eclipse.core.resources.projects\.markers.snap or .metadata\.plugins\org.eclipse.core.resources.projects\.snap (or both?)
Bug: “Link with Editor” does not work with Javascript files anymore
The Eclipse team keeps changing the javascript editor, usually for the worse. Where it once was a simple syntax-highlighting editor that was of no big help, but did not stand in your way, either, it now tries to help you writing Javascript without seeming to actually understand Javascript at times. For example, it complains when you write “var undefined;” which is perfectly valid JavaScript and useful, too. (“undefined” is not a keyword like “true” or “false” but just a special value. Every variable that gets declared but has no value internally has that special undefined value. Redefining undefined locally makes access to it faster because it is already found in the local scope and also enables Javascript compressing tools to shorten the variable name.
Eclipse also acts weird when you try to type stuff like
$(function() { });
or
(function() { })();
Eclipse reorders round and curly braces etc.
So my strategy with the new JavaScript editor was basically to switch off what I could and ignore or suffer through the rest. Until the “Link With Editor” Bug came up. I really like “Link with Editor”, because it lets me collapse my whole project tree and then open up those branches I’m actually working on currently — but suddenly, it no longer worked with .js Files (WTF!?)
Turns out Eclipse is again trying to be clever and now forces you to set up all your script folders to have your scripts then listed under “JavaScript Elements”, something I couldn’t manage to with my current project.And if you fail to do so, Eclipse punishes you by taking away “Link with Editor” from you.
Solution (found that one myself)
Either use the “package explorer” of the Java perspective, not the “project explorer” or in the project explorer, click on the small triangle that opens the “View Menu” and select “Customize View…”; and then on the second tab, disable “JavaScript Elements”. Now Eclipse will honor “Link with Editor” with .js files again.
edit: correct .snap path
April 16, 2010 at 12:53
Thanks a lot for solution for “Link with Editor” bug. It really helped me.
May 25, 2010 at 11:28
Thanks for the “Link with editor” solution once more..
December 2, 2010 at 17:51
For me it lost the link for Java files, so I tried your solution but removing the “Java Resources”. It looked ugly so I put them back, but hey! The linking was working again!
Whaddaya know.
September 14, 2012 at 10:35
I have a quite old eclipse, but it does everything i need, one thing didnt work “Link with editor” and javascript files. Googled it, found your very helpful article, boom my old eclipse is now perfect 🙂 . Many thanks.
April 18, 2013 at 21:38
This worked great for me on Eclipse Juno. Thanks for taking the time to do a write-up!
June 9, 2013 at 11:11
One more time, Thanks for ‘Link with editor’ solution.
Working fine with package explorer. I am using STS.