Placeholder for a proposal.

Some notes from discussion w/ jlahoda:

for Java lang scripting, use ClassPath with IDE modules
registration in SFS / Lookup.default & memory leaks, unloading
DoS defense
 editor hints
 macros: loops, counters, special editor actions like Find
 lexer w/ token ID (e.g. "block comm") vs. category ("comm"),
  flyweight tokens store offset in seq, start+len, subtokens
 use Quick Search for unusual actions
  (where to get code name vs. display name? code completion?)
 dynamic abbreviations
 editor hints could be run project-wide with a trigger (e.g. distinctive FQN or identifier)
 simplified pattern syntax for tree matches, e.g. "($type) getCookie($type.class)"
 debugger breakpoints
 code completion, e.g. on String's in a certain method or XML elements,
  returning matches on prefix + callback for HTML docs
 setEmbedding to create nested token stream under some conditions,
  e.g. to colorize Java or HTML in Java (string/comment), XML, ...
 hyperlink providers
 refactoring plugin (FU, rename, delete)
 scriptable code folds?
exceptions from script -> OW

How to create, edit, run, and install scripts

New project type, "IDE Scripting Project".

No associated build system; very simple metadata, just a properties file. Metadata can have display name, list of module deps, maybe more. Probably no need for deps on other projects; deps on Java code done better by creating a NB module for that code, and deps on other script code probably overkill (TBD).

Simple dir containing at least init.* for some scripting extension, e.g. init.groovy if using Groovy. Intention is that init.* will be loaded & run at startup if installed.

Other files can be created, which can be loaded eagerly or lazily. New File offers appropriate script file types. Might also by default create scratch.* for playing with things.

All NB environmental objects are in a namespace starting from a global singleton named netbeans (compare to window or document for JavaScript in a web browser). An SPI allows required modules to offer various objects inside that namespace. For example, netbeans.layers would be a low-level object offering r/w access to the system filesystem; netbeans.menus would be a higher-level object offering methods such as addSimpleMenuItem (with menu folder, position, ID, label, callback). Code completion (if available) knows about these objects.

Code completion for script files also offers whatever Java classes are available given the declared module deps, so you can use random NB APIs directly. Of course Java platform APIs are available too.

Run File loads and runs one script file. Run loads and runs init.*. Should be some context menu item in the editor to eval the selection. In all cases, stdio is redirected to a "scripting" tab in the Output Window. Exceptions from script also go to OW, hyperlinked if possible back to script & Java sources.

Project context menu item "Install" (or "Uninstall") first locates or creates startup.* script (of same extension as project init script) in NetBeans system filesystem under Scripts/ (so effectively in $userdir/config/Scripts/). Looks for an existing call to load the project's init script by absolute path, using the appropriate idiom for the language. If not found, labeled "Install" and inserts a call; if found, labeled "Uninstall" and removes it. In either case, opens startup script in editor and sets caret to inserted/removed load function location.

User can, if desired, make some other customizations there and save. Any known load calls are hyperlinked: clicking opens the corresponding project, if packaged in a project, else just the bare file, if not.

Optional - project context menu item "Package" creates an NBM of the script. TBD how it is registered in the IDE, and how recipients can choose to customize it. Or could just create a ZIP of the project, which could be unpacked and registered by someone else. (New Project wiz for scripting projects could offer to take such a ZIP, or a bare script file, or a URL to either a ZIP or a bare file, to be downloaded somewhere.)

Alternate project recognition: any dir containing a *.nbscript.* (analogous to *.user.js in GreaseMonkey). This script would then contain metadata in special comments. Advantage that a script would then be fully self-contained.

Prototype impl

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo