Scala for Netbeans Beta Is Ready, Working with NetBeans 6.5 Beta
>>> Updated Aug 15:
For Windows Vista users:
There is a known bug #135547 that may have been fixed in trunk but not for NetBeans 6.5 Beta, which causes exception of "NullPointerException at org.openide.filesystems.FileUtil.normalizeFileOnWindows" when create Scala project. If you are Vista user and like to have a try on Scala plugins, you may need to download a recent nightly build version of NetBeans. Since I have none Vista environment, I'm not sure about above message.
======
I'm pleased to announce that the first beta of Scala for NetBeans is released, followed NetBeans 6.5 beta releasing. The availability and installation instructions can be found at http://wiki.netbeans.org/Scala.
Features:
- Full featured Scala editor
- syntax and semantic coloring
- outline navigator
- code folding
- mark occurrences
- go to declaration
- instant rename
- indentation
- formatting
- pair matching
- error annotations
- code completion
- Project management (build/run/debug project)
- Debugger
- Interactive console
- JUnit integration
- Maven integration (works with Lift Web Framework)
There are some known issues. Bug reports are welcome.
Installation on NetBeans 6.5 beta:
- Get the NetBeans 6.5 beta or later version from: http://download.netbeans.org/netbeans/6.5/beta/
- Get the Scala plugins beta binary from: http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=11854
- Unzip Scala plugin binary to somewhere
- Open NetBeans, go to "Tools" -> "Plugins", click on "Downloaded" tab title, click on "Add Plugins..." button, choose the directory where the Scala plugins are unzipped, select all listed *.nbm files, following the instructions. Restart IDE.
Posted at 01:53AM Aug 14, 2008 by dcaoyuan in NetBeans | Comments[11]
Run/Debug Lift Web App Using Scala/Maven Plugin for NetBeans
I'm a newbie to Maven, so I encountered some issues when run/debug Lift apps. The following are tips that I got, it may not be perfect, but at least work.
1. When pom.xml is changed, and classes not found errors happen on editor, you can close and reopen the project
This is a known issue, that I didn't refresh compiling context when pom.xml changed, thus the classpath dependency may be not refreshed at once, I'll fix this issue in the near future.2. Run project by external Maven instead of embedded Maven of NetBeans plugin
I encountered "java.lang.NoClassDefFoundError org/codehaus/plexus/util/DirectoryScanner" when use embedded NetBeans Maven plugin (3.1.3) when invoke "Run" project, but fortunately, you can custom the binding actions in NetBeans Maven. The steps are:- Right click project node, choose "Properties"
- Click on "Actions" in left-pane, choose "Use external Maven for build execution", and "set external Maven home"
- Choose "Run project" in right-pane, input "jetty:run"
- Choose "Debug project" in right-pane, input "jetty:run"
3. How to debug project
I'm a bit stupid here, since I don't like to change MAVEN_OPTS frequently. So I choose to do:
$ cd $MAVEN_HOME$/bin $ cp mvn mvn.run $ cp mvnDebug mvn
Then I invoke "Debug" action from NetBeans toolbar, and get NetBeans' output window saying:
WARNING: You are running Maven builds externally, some UI functionality will not be available. Executing:/Users/dcaoyuan/apps/apache-maven-2.0.9/bin/mvn jetty:run Preparing to Execute Maven in Debug Mode Listening for transport dt_socket at address: 8000
Open menu "Debug" -> "Attach Debugger...", in the popped window, for "Port:", input "8000". Everything goes smoothly then. You add/remove breakpoints just as you are doing for a regular Scala project.
Of course, if you want to turn back to "Run" from "Debug", you have to "cp mvn.run mvn" back.
Anybody can give me hints on how to get this setting simple? in NetBeans Maven plugin.
Here's a snapshot: (click to enlarge it)
Posted at 03:10PM Jul 29, 2008 by dcaoyuan in NetBeans | Comments[2]
Scala, NetBeans, Maven, and yes, Lift now
Per recent changes, Scala for NetBeans can live with Maven for NetBeans, and yes, Lift web framework.
The Maven for NetBeans has done an excellent work for Maven's project integration, with proper classpath supporting and indexing. So the Scala editor is well aware of auto-completion, types etc.
Here's a snapshot: (click to enlarge it)
To get above features, you have to download the latest NetBeans daily build, then install Scala's plugins and Maven plugins.
For Scala plugins, see http://wiki.netbeans.org/Scala; For Maven plugins, see http://wiki.netbeans.org/MavenBestPractices.
Posted at 08:18PM Jul 28, 2008 by dcaoyuan in NetBeans | Comments[2]
Implementation of Scala for NetBeans based on GSF
The Scala for NetBeans is under pre-beta stage, other than bug-fixes, I'm preparing some documentations for it too. If you are interested in how to write language supporting under GSF's framework, you can take a look at this working documentation.
Implementation of Scala for NetBeans
And also:
Proposal of Scala for NetBeans
Progressing of Scala for NetBeans
Posted at 10:54AM Jul 26, 2008 by dcaoyuan in NetBeans | Comments[1]
Scala for NetBeans Screenshot#12: JUnit integration
There is a Scala JUnit Test template in Scala for NetBeans now, you can create Scala JUnit testing and run testing, see testing result.
Here is an example test file:
/*
* DogTest.scala
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package scalajunit
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.Assert._
class DogTest {
@Before
def setUp() = {
}
@After
def tearDown() = {
}
@Test
def testHello() = {
val dog = new Dog()
dog.talk("Mr. Foo")
assert(true)
}
@Test
def testAdding() = {
assertEquals(4, 2 + 3)
}
}
To get JUnit working, upgrade to Scala Project Module version 1.2.14, and re-create a new project for exist old project (if there has been one). Under the "Test Packages", create your testing packages, right click on package node, select create "Scala JUnit Test".
To run tests, right-click on project node, choose "Test".
And also, the beta-release is feature frozen, I'll concentrate on bug-fixes in next 1-2 weeks, and get it ready for public release as beta.
Posted at 05:50PM Jul 25, 2008 by dcaoyuan in NetBeans |
Employ Scala's Native Compiler in Scala for NetBeans
>>> Updated 3 hours later Fixed document displaying and go to declaration for Java element. Please update to Scala Editing version 1.1.4 ======
Well, it's a fairly long time after I latest blog about Scala for NetBeans. I was busy on several things, and can only work on this project on my spare time.
The good news is that I've integrated Scala's native compiler into this handy plugin, it means that the error messages shown in the editor will be the same as building now. And, the auto-completion feature is totally rewritten too, which also use AST tree that was created by Scala's native compiler to get all the candidate content assistant items.
The only problem is that the Java's document comments and offset to be go to when press CTRL + Click does not work properly yet, I have several way to resolve it, but I'm looking for a best way.
Another exciting news is that I've been invited to join NetBeans Dream Team, and of course, I accepted this invitation.
I'm planning to get Scala plugin for NetBeans to beta release in August, which will be compatible with NetBeans 6.5
Posted at 12:07PM Jul 15, 2008 by dcaoyuan in NetBeans | Comments[8]
Parsing Performance of Scala for NetBeans
I'm re-considering the indexing mechanism of Scala for NetBeans. The indexing is used to store meta-info of parsed templates/methods etc, for auto-completion and document/source offsets searching. Currently, the parsing phases include lexer, syntax and semantic analysis, not include type inference and type check.
With a basic performance testing on all Scala standard library and liftweb's library, the maxima parsing time seems less than 1s, the average parsing time is around 0.2s, not bad.
So, this may let the indexing feature a lot simple, I can store classes/objects/traits' meta-info only, instead of including their type parameters and their members (fields/methods, scoped importing etc), these additional information can be got via re-parsing the source file or querying the class file.
Posted at 08:30PM Jun 10, 2008 by dcaoyuan in NetBeans |
Bundled Latest Scala Runtime to Scala for NetBeans
I just bundled latest Scala runtime to Scala for NetBeans, the version is 2.7.1.final, this brings two things:
First, you do not need to set SCALA_HOME any more to get whole plugins working. But, you can still set SCALA_HOME to specifying the target Scala version, if so, you should also need to download and unzip source jars to $SCALA_HOME/src;
Second, I'll begin to write some code in Scala instead of Java for Scala plugins. I can evaluate the features of Scala plugins in daily work, find and fix more bugs of plugins.
Posted at 08:54AM May 27, 2008 by dcaoyuan in NetBeans | Comments[9]
Scala for NetBeans Screenshot#12: Better Completion with More Types Inferred
>>> Updated May 11
Mostly, infix expressions can be type inferred now. CTRL+Click on infix op name, it will bring you to declaration (since 1.0.29.0)
===
Well, the type inference work is not so easy (with performance in mind), but anyway, I've got a bit more progress, at least, the chained member call can now be correctly inferred in a lot of cases. It's some level as Tor's JavaScript for NetBeans now.
First, let's create a val "node", which is a "scala.xml.Node"
Then, input '.' to invoke completion, as I know which type is of "node", the proposal items look good.
I choose "descendant" function (which returns a "List"), and input '.' again, we can see the proposal items look still good.
These features also work on Java's class.
Known issues:
- It seems the indexing/scanning for Scala standard library source will perform twice when you first installed Scala plugins
- The type inference is not consistence yet, so don't be strange for the strange behavior sometimes
Again, don't forget to download scala standard library's source jars and unzip to $SCALA_HOME/src, per sub-folder per jar
Posted at 10:45AM May 09, 2008 by dcaoyuan in NetBeans | Comments[6]
Scala for NetBeans Screenshot#11: Go to Remote Declaration and Doc Tooltip
Two crazy days of my spare time, I was coding between sleeping and eating, with a lot of cups of coffee. Now Scala plugins support Go-To remote declarations (CTRL + Click on var/function name), and when you put cursor on the identifier name with CTRL pressed, or under auto-completion, the doc will also be shown as tooltip.
These features work for Java classes too with a bit poor performance, I'll fix it later (fixed).
Not all identifiers have been type inferred, so these features are not applicable for all identifiers.
Please update to Scala Editing module as version 1.0.26.xxx when it's available, which is the only stable one these days. Remember to unzip Scala lib's source under $SCALA_HOME/src
Posted at 12:04AM May 03, 2008 by dcaoyuan in NetBeans | Comments[8]
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
Posted at 08:09PM Apr 29, 2008 by dcaoyuan in NetBeans | Comments[3]
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
Posted at 07:40PM Apr 25, 2008 by dcaoyuan in NetBeans | Comments[4]
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")
===
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.
Posted at 09:21AM Apr 18, 2008 by dcaoyuan in NetBeans | Comments[13]
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
Posted at 03:08PM Apr 14, 2008 by dcaoyuan in NetBeans | Comments[4]
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.
Posted at 07:20AM Apr 13, 2008 by dcaoyuan in NetBeans | Comments[4]













