Posts for the month of April 2008

Scala for NetBeans Screenshot#10: Working on Auto-Completion for Java

I've done some hacking work to get Java classes to be completion enabled, but it's not full functional. Any way, it's a good start point for auto-completion for Scala plugins, I hope to get more type inference work to be finished, and finally support both Scala/Java classes smart-completion.

Click on the picture to enlarge it

nn

nn

Scala for NetBeans Screenshot#9: Working on Auto-Completion

With the indexed cache of project's Class/Trait/Object, and Scala standard library's source files, the auto-completion is a bit smarter now. If the val/var is defined with type, the auto-completion can know which methods will be suggested. (Not work for java classes yet)

To get this working, you should follow these steps:

  • Update to newest Scala plugins (Editing version 1.0.21.1)
  • Delete the old-cache files which are located at your NetBeans's configuration directory (for example, .netbeans/dev/var/cache).
  • Download Scala standard library's source file, unzip them to $SCALA_HOME/src, per sub-folder per source jar file

Click on the picture to enlarge it

nn

New Scala Plugins for NetBeans are Available for Public Test, and Fortress, Erlang

>>> Updated Apr 22
Due to the incompatibly changes of NetBeans underlaying modules, Scala plugins can not be installed/updated on NetBeans 6.1 any more, you should get the latest nightly build to play with Scala plugins.
===

>>> Updated Apr 19

  • Fixed some broken syntax
  • Fixed NPE caused by brace completion
  • Fixed indentation of case class/object
  • Added formatting options ("Preference" -> "Scala" -> "Formatting")
Please update your Scala Editing plugin to version 1.0.19 which will be available after NetBeans hudson building.
===

The new written Scala plugins for NetBeans are available for public test now, which can be installed on NetBeans 6.1 RC, and latest NetBeans nightly build. To get start, please visit http://wiki.netbeans.org/Scala

The following features are ready for test:

  • Syntax highlighting
  • Auto-indentation
  • Brace completion
  • Formatter
  • Outline navigator
  • Occurrences mark for local variables and functions
  • Instance rename for local variables and functions
  • Go-to-declaration for local variables and functions
  • Scala project
  • Basic debugger

And with known issues:

  • Auto-completion it not fully supported yet and not smart
  • There is no parsing errors recovering yet
  • Semantic errors are not checked on editing, but will be noticed when you build project
  • Due to the un-consistent of Scala's grammar reference document, there may be some syntax broken issues

BTW, Fortress editing plugin is also available on "Last Development Build" update center, see the installation part of http://wiki.netbeans.org/Scala to get it installed. It's a very alpha stage plugin.

And, Erlang plugins are also available from "Last Development Build" update center too, that is, you can install and use Erlang plugins with Ruby, Scala, JavaScript on the same NetBeans IDE (6.1 RC or nightly build). Thanks to Tor's work, the indexing performance has been improved a lot.

Erlang plugin will be rewritten in the near future too.

Scala for NetBeans Screenshot#8: Working on Indexer

I've done some basic indexer code, that is, all source files under a project will be parsed, analyzed, then indexed (class/object/trait, functions, fields etc). But it's just a start, before I finished type inference, if you press CTRL+SPACE to invoke completion, there are a lot of indexed Class/Object/Trait/Function will be roughly shown on you :-), it's not smart, it's more like a puzzle, you should decide which one is applicable by yourself. But you can get a view of the coming completion feature.

Click on the picture to enlarge it

nn

Progress of Scala for NetBeans - with a New Written Lexer and Parser

According to this post:

I talked to Jetbrains about this, and they told me that they stopped working on the Scala plugin for the time being, because - demand for Groovy/Ruby was higher - the language was moving too fast - Scala is a terribly difficult language for compiler/tool writers, and the only good way to analyze Scala programs might be through the official compiler, which didn't yet support this

It's true that "Scala is a terribly difficult language for compiler/tool writers", but I'm trying to bypass "the only good way to analyze Scala programs might be through the official compiler"

Before rewriting Scala for NetBeans, I considered some parser choices, one was Scala's native compiler, which is good for compiling/building Scala project, but not suitable for Editor. And JavaCC, ANTLR, which may be good enough, but it's not natural to express Scala's grammar.

Then I found Rats! which is used by Fortress, a very very clean, powerful parser generator. After couple of days working, I got an incremental lexer for Scala, and a parser for Scala that with Scala's grammar being naturally expressed (the grammar definition is ParserScala.rats). The benefit of a complete controllable parser is that I can now do some type inference and wholly semantic analysis freely and immediately.

Another progress is that I've decoupled the Scala project's dependency on Java.source's classpath in NetBeans, instead, GSF's classpath is used in Scala project module now. That means, I can begin the indexer for Scala's standard library and project source files.

The next steps will be type inference; smart completion with type inferred information; indexer for later refectory and usages searching; parsing error recover etc.

nn