Correctly configuring Eclipse for non-web JavaScript development - javascript

Recently I've needed to write a small utility for Acrobat in its JavaScript.
Because the editor in Acrobat is pretty limited, I've installed the latest release of Eclipse IDE for JavaScript and Web Developers (Neon). It should already include the latest JSDT 2.0.
However, I've been surprised, that Eclipse's JavaScript editor does not correctly parse even simple common JavaScript patterns, like namespaces, modules, single global variable, etc. Also code folding is missing, except the very first function.
I do not expect to debug Acrobat's JavaScript code in Eclipse, but I wanted to have a smart JavaScript editor and also projects, where I could gather a few non-JavaScript resources. Some automation possibilities would be also nice, of course.
I've played with Eclipse preferences a lot and I've also searched on Internet, but I was not able to find anything really helpful.
Have I missed something in Eclipse configuration or is it really wasting of time and I should use something else?
For small projects a free IDE would be preferable, but also reasonably priced commercial products would be acceptable.
A configuration solution in Eclipse would be the most welcome, of course.
Thanks a lot for your help.

The support for newer Javascript Syntax is very bad in Eclipse (Bug).
You can use Tern.js it has a good ES5 and ES6 support.
But for Javascript development there are a lot of much better editors like Webstorm, VisualStudio, Sublime out there. You'll like more!

From my experience with Acrobat JavaScript, and the Acroforms technology (which you use when you work in PDF), there are not that many advantages you get from an IDE.
In fact, for my work (which IS extensive), a good text editor, with quote and parentheses balancing, maybe even auto-indent, and basic JavaScript code coloring is pretty much sufficient. I personally do write the scripts in BBEdit, and then copy/paste them into the Acrobat JavaScript editor window.
Keep in mind that JavaScripts in Acrobat/PDF are generally quite short, because they do not have to deal with DOM overhead, and because the field event sequence is quite structured (and it is really important to understand this sequence… more important than fancy JavaScript constructs). You also have to be aware that the JavaScript core implementation in Acrobat is relatively old (recently, they did upgrade it, but if your forms/applications are for the general public, you can't rely on them having the very newest version of Acrobat/Reader).

Related

javascript code formatting in eclipse doesn't work

javascript code formatting doesn't work at all in eclipse under xubuntu.
Same problems with auto-completion and with validation.
I tried different way to install Eclipse and its different plugins nodeclipse, tern, jsdt ...
I tried to open file with different editors.
I tried to change formatting profile.
But everywere everything just doesn't work.
It perfectly works for C/C++. But javascript not. It look like something generally wrong with my eclipse+javascript+node.js environment. But what?
Did you try JSDT pluging?
https://eclipse.org/webtools/jsdt/
It adds a JavaScript project type and perspective to the Eclipse Workbench as well as a number of views, editors, wizards, and builders.
The Eclipse "JavaScript Editor" (from JSDT) always had some issues.
Formatting does work, but can break under some circumstances.
The JavaScript-Plugin in Eclipse is buggy and evil since a few years.
Quota from: Auto-formatting of JavaScript code in Eclipse
This is not just my opinion, this has been going on for years as the Eclipse community had a hard time catching up with the Java/JavaEE evolutions (and C/C++ and ...) in parallel to all the JavaScript changes.
I do not blame them as this is all for free !
The Eclipse JavaScript Editor (JSDT one) can 'choke' on various keywords for example: myObject.import(xyz); will break it (on some versions at least) due to the import keyword.
Sometimes I also noticed that some types of calculations involving divisions and many brackets broke the formatter. Autocompletion also has many issues, support is far from that of Java or C/C++.
It can also get slow due to code folding, but that can be disabled in Editor/Folding and spell checking which can also be disabled.
Eclipse Wild Web Developer
With the latest Eclipse releases since 2019 / 2020 you can use Eclipse Wild Web Developer (Red Hat is the main contributor):
Info
Install or here Github
Background:
Because of technical reasons (reimplementation of parsers mostly) and
strategical priorities (Java EE), Eclipse IDE and the WebTools project
have hard time catching up with innovation in the front-end Web
development world. As a result, several editors for typical web
languages (CSS, HTML, JavaScript...) shipped in the Simultaneous
Release are of low quality compared to the state of the domain and
competiting IDEs.
Yes we noticed ^^
Eclipse Wild Web Developer integrates existing artifacts like TextMate
grammars and Language Servers to provide a rich development experience
to Web developers using typical programming languages for the Web
(CSS, HTML, JSon, JavaScript, TypeScript...).
Eclipse Wild Web Developer is about integrating existing technologies
for those languages more than creating more specific language
smartness.
That is a wise decision.
This reminds me of Unity vs Gnome in Ubuntu ... or various browsers ending up using Chromium. Maintaining your own stuff and keeping the pace is hard.

Javascript plugin for Eclipse?

I am very happy with Eclipse and don't want to change my IDE, but find the pre-bundled Eclipse plugin for JavaScript too difficult to work with.
Too many of the features that I got used to developing Java (not JavaScript) in Eclipse seem to be missing or incomplete, such as an intelligent code analysis, smart refactorings, a truly language-related (not full-text) reference search, class inheritance trees, etc.
Any suggestions for alternative Eclipse plugins for JavaScript development?
Admittedly, it is a lot more difficult to analyze JavaScript code (compared to Java) not only for a plugin but also for any human programmer, because JavaScript comes with fewer structural elements, and because there are so many different ways to do common things like inheritance or modularization. But there's got to be something, right?
As Nodeclipse lead, I am always looking for what is available in Eclipse ecosystem.
JavaScript support is Eclipse JSDT project.
It gives Editor, and JSDoc support.
For ES5 support, JSDT validation is to be disabled and JSHint-Eclipse used.
Also there is new Tern-IDE plugins, that gives hints and go to definition by using Tern.js.
The same author leads AngularJS plugin
All mention plugins can be got via Enide Studio 2014 (installed as plugins or downloaded as stand-alone product).
Nodeclipse site has even more links,
and I am inviting to collaborate on the JavaScript tools on GitHub
There are also JSON Editor and Json Tools.
Unfortunately VJET is no longer continued as there is no backing company now.
All effort are community driven. The simplest contribution is reporting bug or taking own issue to research and share.
Any suggestions for alternative Eclipse plugins for JavaScript development?
No alternative plugins, just get more of them.
The VJET plugin seems to provide better JavaScript support, although I haven't tested it very extensively.
http://eclipse.org/vjet/
For necessary code hygiene I recommend to use JSHint (a sane version of JSLint).
http://marketplace.eclipse.org/content/jshint-eclipse
Both are installable through the built-in Eclipse Marketplace.
The popular Aptana IDE, which is based on Eclipse, is also available as plugin, but I haven't tested it as plugin.
http://www.aptana.com/products/studio3/download
My personal opinion: Eclipse has outdated syntax validators (no ECMAScript 5 support) and non of the plugins can fix that. The problem is known for years (Bug Report), but nothing is done about it. Code completion seems to be a lot better in the WebStorm IDE or Sublime Text with certain plugins. Right now, I'm quite happy using Eclipse for my backend Java stuff and WebStorm for the frontend code for the same project.
A. In the Eclipse world...in my opinion... the best JavaScript support is currently given by Eclipse Orion, a web based variant of Eclipse:
https://orionhub.org
Orion applies tern.js to get JavaScript features like highlighting and completion:
Eclipse orion code completion
The JavaScript library tern.js seems to be up to date:
https://github.com/ternjs/tern
And it is applied by several Source Code Editor plugins:
https://ternjs.net/#plugins
B. On the other hand, all JavaScript plugins for Eclipse seem to be outdated.
See for example
http://www.eclipse.org/webtools/development/news/main.php (last updated 2016)
The Eclipse Plugin for tern.js seems to be out of date, too:
https://marketplace.eclipse.org/content/tern-eclipse-ide
I was not able to install it on the current Eclipse version Photon.
Also see https://github.com/angelozerr/tern.java/issues/463
C. If you are open for a commercial JavaScript editor, try to use WebStorm, als already suggested by Tilman.
If there is a good Eclipse based JavaScript solution, that I am not aware of and that is able to compete with the features of WebStorm, please let me know.

Autoformat Javascript in Netbeans IDE

Are there any known Plugins or ways to properly autoformat Javascript in Netbeans IDE?
EDIT 9/15/2012
After looking into this further, I have found that the javascript module is being rewritten already(much needed). You can finally find formatting options for javascript. It's available in the netbeans nightly builds. Good luck all.
http://bits.netbeans.org/download/trunk/nightly/
I have released a pretty simple JS formatter that uses JSBeautify and runs in Rhino.
http://plugins.netbeans.org/plugin/43263/jsbeautify
You have to use an alternate key for now. I'm working on modifying the Javascript language in Netbeans to possibly release something better, later on(either as a plugin or patch). I'm still familiarizing myself with the way things are happening in Netbeans.
There have been talks for years to add more formatting options for Javascript in Netbeans. Nothing has surfaced. I'm going to propose that the Javascript language leverage JSBeautify(running in Rhino) to provide formatting, rather then implementing new features in Java. This simplifies the formatting process, plus the JSBeautify community is very large and it's actively developed.

Is there a good javascript plugin for visual studio?

I think that Visual Studio's biggest let down is the Javascript editor. I have been told to use Aptana as an editor for my javascript files, but I would prefer to stick with visual studio if possible.
I have read other similar plugin posts, but none focus specifically on Javascript.
VS2010 may offer some improvements, but will they be up to Apatana standards? I have briefly tested the beta, but I'm not overly impressed.
Is there anything out there that will bring Javascript closer to c# development? Considering the wide spread use of Javascript I think there must be something....... I hope! :)
Many thanks in advance... this is something that has always bugged me!
There's a couple recent plugins that may be helpful :
From Microsoft :
JScript Editor Extensions
Brace Matching
Outlining / Cold-folding
Current Word Highlighting
IntelliSense Doc-Comments Support
JSEnhancements
Outlining and matching braces highlighting
(I wouldn't think installing both of these is a good idea - and the Microsoft plugin has more features so try that one first)
VS is a pretty good IDE (especially when coupled with Resharper) but not so hot with Javascript. The debugger is good and there's the JSLint plugin but other than that I'm not sure. Aptana (based on Eclipse) is an excellent javascript IDE but it doesn't like it much when the javascript is embedded in aspx files (unless they updated the support recently). So far I'm not sure there's an ideal .net platform IDE for both client and server side stuff just yet.
Update: Resharper 6 added pretty good JavaScript support - so now I'd recommend that combination if you're doing a lot of debugging across client and server at the same time. If you're focussing on pure client code then I find WebStorm to be an excellent JavaScript/HTML IDE - even better than Aptana.
I'd really like to recommend Webstorm. It does not! treat your JS as text files.
Its a full blown JS editor and has become my favourite JS editor working in parallel with VS to handle my server side stuff.
WS has actual object intellisense across JS files. That means when I press . (dot) it shows me the functions on that objects, even if its located physically in another file.
It will recognize my objects (or their type if you will) created in other JS files referred to in the file I'm working on.
I have 'Find usages' on JS functions
I have 'find all references' on JS object / function / class / variable or whatever you want to search on. In the end its all objects but Webstorm knows this.
If I change the short/cut to F12, I can press F12 on my function call and it will jump to the implementation of that JS functon. Even if its located in another file.
Ofc. you have code folding and colouring, extract method and other neat code re factoring, overview creating tools.
Oh. And by the way.
I'd like to kill off a rumour going around in the cloud on forums I come across from time to time, looking for better ways to handle JS.
reSharper DO NOT SUPPORT JAVASCRIPT! A little piece of me dies every time I read some guy repeating what he saw on the reSharper site. It may have a some poor intellisense and some low level syntax check, but that has nothing to do with support.
Notepad++ supports JS better than VS in my opinion.
Münster
Don't forget to grab Chirpy to handle minifying your scripts in VS.
If you use Visual Studio, add the
/// <reference path="myOtherJsFile.js" />
directive at top of your js files and install Web Essentials you get pretty decent (but not perfect) intellisense, go to definition by using F12 and find all references (sort of..) by using SHIFT+F12

What would be a good browser-independent JavaScript programming environment?

My team's current project involves re-writing retrieval libraries in JavaScript. We are basically looking for a setup which enables us to apply test-driven development methods.
So far we plan to use Vim to write the code, no fancy IDE. For generating output we would use Spidermonkey's shell environment. JSLint could serve as a moderate syntax checking tool.
The essential question remains: How do you develop JavaScript (browser-independent) programs?
If we are already on the right track, then maybe you can supply us with a few tips and tricks.
You can test your code in Spidermonkey or Rhino (an older JS interpreter in Java), but you won't really know which browsers it works in until you test your scripts in them!
I agree with the earlier poster, using a browser-independent library like jQuery is probably a good idea.
I have not used Spidermonkey, but I know Rhino has a good debugging GUI, allowing the usual: setting breakpoints, watches, and stepping through code.
Only testing you'll make your JavaScript code browser-independent.
If you have the chance to rewrite it all, you might consider jQuery.
It's essentially browser agnostic. Or at least it requires much less object sniffing than plain javascript.
Yes,I'm using the same environment to develop standalone JS apps (vim + SpiderMonkey). I only would add up, that I've made small in-browser IDE for reading/writing/launching JS scripts on the server-side. Sometimes it's very helpful. Also, I'm looking for using WXJavascript project, which seems to be very promising.

Categories

Resources