myJSEditor - Embeddable JavaScript Editor for Eclipse
myJSEditor is a plug-in to for JavaScript editing. There are several JavaScript
editors out there for Eclipse. The main usage for the MyJSEditor is its ability
to embed it into other products and projects easily. It is built purposely to
easily add your own JavaScript objects and be able to code complete and
highlight these.
The plug-in is also made specifically to work well with the
Rhino JavaScript Engine,
but it should be compatible with any Ecma262 compliant JavaScript engines. If
someone makes their own Rhino object model for their own embedded scripting
language, it can easily be plugged into the myJSEditor plug-in, and you can get a very nice and fancy editor for your
embedded scripting.
Currently, the Rhino version supported is up to Rhino 1.5R5. Rhino 1.5R6 adds
the The ECMA-357 (XML for JavaScript), which is
currently not supported by this plug-in.

An example of myJavaScript Syntax Highlighting
The project is divided into two main parts. One is the parser and syntax tree
building part. This is separated out into its own standalone jar so people can
do, for example, simple refactor jobs on the server side in a client/server
environment.
The plug-in got several features for generic JavaScript editing:
- Syntax Highlighting: It highlights keywords, strings, blocks,
comments etc. (new 0.9.0: marking deprecated methods, Rhino
static methods and LiveConnect classes).
- Code Completion: For known objects, it will show available
methods and properties available. It will also know about variables and
functions defined in the script itself, and suggest those if appropriate. (new
0.9.0: Type guessing. Depending on what you assign a variable to,
the parser guesses based on the expression what the current type of the
variable is. This makes it possible to auto complete on variables that
haven't been cast).
- Casting: Since JavaScript is type-less (variables have no types),
there is an optional syntax to allow the user to tell what type a variable
is. This is done by a "cast-comment" which looks like this
/*: String :*/. This tells the
system that this variable is of type String and it will then be able to give
code completion hints when this variable is used.
- Error reporting: Reports on various syntax errors but also on
things like 'a property is used as a method' which would normally only be
caught runtime.
In addition, the widget is specifically built to also be used as controls on
any composite. So if your system got properties to some editable object that
allows for JavaScript, you can get the exact same features here as in a normal
JavaScript editor. For more information on the extensibility, look at the
technical documentation.

JavaScript editor widgets as part of a property screen
The parser system has the following features:
- Parsing JavaScripts: It builds a list of tokens (compatible with
the Rhino engine). (new 0.9.0: Incremental parsing increases performance on
large scripts exponentially)
- Syntax tree: From the token list, it builds a syntax tree
specifically built for UI editing to figure out, for example, what variables
are created where and which keywords are allowed when.
- Type Guessing: As of 0.9.0, the parses is able to guess the type
of JavaScript variables from what their assigned to. So if a variable isn't
cast to a particular type, the parser will guess and still give code
completion and highlight help.
- API: It has a simple API to tell things like "Where are the
function 'substring' on the object 'String' used in this script". This could
be useful for code refactoring.
Outstanding Features planned for 1.0 :
- Rhino 1.6: Rhino 1.6 includes the
ECMA-357 standard which defines XML for JavaScript. This would require a
whole new parser.
- Bugfixes.
|