June 18th, 2007

JavaScript plugin for jEdit

The JavaScript plugin embeds the Rhino JavaScript implementation into jEdit to provide syntax checking, scope checking, and more.

Latest - Download version 0.4.2 JavaScript.jar
Download version 0.3: JavaScript_0.3.jar
Grab the source from http://skrul.com/svn/javascript/trunk

For help installing the plugin, see the jEdit plugin installation documentation.

Features (0.4.2)

  • Supports JavaScript embedded in XML files (XHTML, XUL, XBL)
  • Support for jEdit 4.3

Features (0.3):

  • Syntax checking
  • Scope checking
  • Structure browsing

Using the Plugin

After installing the plugin, the SideKick plugin will have two new parsers available to it — “skrul-javascript” and “skrul-xml-javascript”. The former is for files that contain only JavaScript, the latter is for XML files with embedded JavaScript. Note that SideKick already has a built-in “javascript” parser that gets automatically selected when you open a JavaScript file. You can configure SideKick to always use the “skrul-javascript” parser by setting the options at Plugins menu -> Options -> SideKick -> Parsers.

Editing XML documents with embedded JavaScript

. After opening an XHTML, XUL, or XBL file, you will have to switch the parser to “skrul-xml-javascript” to activate the plugin for these files. You can permanently associate the parser with these file types in the Sidekick plugin options.

Configuring Scope Check:

You may import external global names into your buffer to prevent the scope checker from flagging names that exist in the target environment. There are two ways to do this. The first way is by configuring the plugin options (Plugins menu -> Plugins Options -> JavaScript -> Scope Check). Here you can import predefined name lists or specify a list of external JavaScript files to extract the global names from. These settings will apply to all JavaScript buffers.

The predefined name lists are:

Description Name View
Combined DOM Window domwindow domwindow.js
Internet Explorer DOM Window iedomwindow iedomwindow.js
Mozilla DOM Window mozdomwindow mozdomwindow.js
Mozilla Chrome Window chromewindow chromewindow.js
Mozilla Component mozscript mozscript.js
XPCShell xpcshell xpcshell.js
Prototype prototype prototype.js
Dojo dojo dojo.js

You may also specify these settings on a per-buffer basis by including a mode line at the top of your JavaScript file. (Note that this is not currently supported in XML files.) The line must begin and end with the delimiter “-*-” and contains a semicolon separated list of setting names, followed by a colon, followed by a comma separated list of values. For example:


// -*- js-standard: domwindow,dojo; js-import: globalscript.js; js-var:GlobalClass, global_fn; -*-

Possible setting names are

js-standard
A list of the name of one or more of the predefined global name sets defined in the table above
js-import
One or more files to import into the global scope. The path to the file may be absolute or relative. Relative paths are evaluated from the directory that contains the file in the buffer
js-var
One or more names to include into the global scope
js-preproc
Overrides the global setting for handling preprocessor tokens embedded in the JavaScript file. Possible values are: true, false

Requirements for 0.4.x:

  • jEdit version 4.3
  • Java 1.5
  • The SideKick and ErrorList plugins must already be installed

Requirements for 0.3:

  • jEdit version 4.2
  • Java 1.4
  • The SideKick and ErrorList plugins must already be installed

Limitations:

  • Sharp variables are not supported (as Rhino does not support them)

Screenshots: