The Scala support for NetBeans will provide an integrated development environment for building, running, testing, and debugging Scala applications.
Lexical scanning and syntax parsing are done using Schliemann by defining a Scala LL(K) NBS file. The editor will know about Scala's traits/objects/classes, variables, functions, types, prefix/infix/postfix operators, and these elements will be properly highlighted.
This identifies function calls and parameters, local/global/instance variables, and unused variables.
The navigator displays the structure of the file, from Trait/Object/Class down to individual functions, fields. Double-clicking on an element in the navigator window warps to its source in the editor.
Traits/Objects/Classes, functions and block statements are foldable.
The Scala parser is running in the background when the user stops typing, and provides error messages as error annotations. On a successful parse, the parse tree is used to drive additional features.
Placing the caret on an element (such as a local variable, instance variable, global variable, function call, or class reference) will highlight all other references as well as definition of the current symbol.
Right click on an element and choose Go-To-Declaration will warp to the declaration for the element, if possible. (Note, it will work right for local variables, but for functions and such it needs to include the type inference prototype as well as some other facilities for finding references in the builtin libraries, or, remote source files.)
This feature is also available via editor hyperlinks - hold the Control key and as you drag the mouse over the source, identifiers are highlighted as hyperlinks. Clicking on a hyperlink will warp to its source if possible.
Renaming a local variable or function is done in place and all references are updated on the fly. To invoke, press the keybinding Ctrl+R.
Some basic code completion is provided. When you hit Ctrl-Space, completion is provided for local variables in the current context, as well as function names, class names and constants in the same file.
In addition, various Scala builtins such as keywords and predefined constants are provided.
This is an area where further research is going to yield some improvements using Type inference etc.
Code completion also provides help in specific contexts. For example, if you invoke code completion after the "new" keyword it lists all local and imported Classes.
There are more scenarios; for example, invoking code completion after a "def" keyword will only list inherited methods from the superclasses, and so on.
Pressing Return to create a new line causes the new line to be indented appropriately, e.g. same line as the previous line, or further indented when a new block is establishes, e.g. in an if statement, case statement, etc.
Reformat will reindent the source code.
The editor automatically highlights matching parentheses, braces, brackets, string delimiters, etc. In addition, as you're editing, the editor tries to automatically insert (and remove) matching delimiters automatically. For example, if you type "{", the editor modifies the document to contain "{|}" The important part here is that while you're editing, the file stays valid such that code completion will work etc.
Scala files are recognized in the file system, assigned some default actions, etc.
JUnit tests or Scala based unit test will be supported. There is a new unit test template. And when executing unit tests failures are linked to the editor source.
You can open up an interactive Scala shell session from the Windows menu. The shell window let you interact with Scala directly. Use arrow keys for command history etc.
Debugging Scala will be invoked when you press the "Debug" button.
NetBeans' project Schliemann has a built-in, near full-featured scanning and parser. With a bit more enhancements, such as state stack and lookahead features for NBS, it can reach the same level of JavaCC. I'll follow the latest process of Schiliemann project.
Editing features will be based on project Schliemann. By defining a LL(K) NBS file for Scala tokens and grammar, we can get most basic editing features working. There will be some necessary enhancements of Schliemann modules, such as a refined formatter, better integration to external semantic analyzer etc. I'll work with the modules owner to get Schliemann more featured, flexible and stable.
Go-To-Declaration/Hyperlinks for remote variables and remote functions, Smart-Completion features will be base on a Semantic/Type-Inference analyzer, this analyzer is the most difficult and time-consumer part of whole project. By visiting the AST tree, we should get all semantic definitions, usages, and their contexts. Their types should also be inferred on the meantime. All these semantic information will be indexed in Lucene documents for further using.
Project support module will be based on current j2se project support of NetBeans, thus Scala project can support mixing Scala/Java source files. This feature will track the newest Java Project Common API.
Debugger modules will be based on current JPDA modules of NetBeans.
To hook mouse clicking to adding/removing breakpoints, should implement and register Scala's MIME type related "GlyphGutterActions" in layer.xml, so, org.netbeans.modules.editor.impl.GlyphGutterActionsProvider#getGlyphGutterActions(String mimeType) can lookup this action. GlyphGutterActionsProvider#getGlyphGutterActions will be invoked by org.netbeans.editor.GlyphGutter#GutterMouseListener#mouseClicked.
To get debugger recognizing source file's structure and context, should implement org.netbeans.spi.debugger.jpda.EditorContext.
All deliverables such as Installable modules, Source code, User guides will be available corresponding to each time line at:
To implement this feature, the Scala editing and project support should cooperate with existing Java features of NetBeans, such as querying the index of Java platform.
Right-click on a symbol and choose Find-Usages (or use the keyboard shortcut). In the Find usages dialog user can also find subtypes of the class rather than usages
Due to the time frame, refactoring cross mixed Java source file may not be supported, this leaves more research area to enhance in the future.