First Experimental Scala Supporting for NetBeans is Available

>>> Updated Dec 23: There is an updated Editing module at:
http://sourceforge.net/project/showfiles.php?group_id=192439&package_id=256544&release_id=563760

CHANGELOG:

  • "{" of class/object/trait declarations can be put on new line
  • Some broken syntax fixed.

========

Features:

  • Syntax checking, highlighting, code folding, navigator, basic indent
  • Interactive Scala shell. [Windows] -> [Interactive Scala Shell]
  • Basic Scala project management with file locator for compile Errors
Notes:

  • Requires NetBeans 6.0 Release
  • Don't forget to set your SCALA_HOME environment first, or append "-J-Dscala.home=scalahomepath" to the end of "netbeans_default_options" in your netbeans.conf file, where, "scalahomepath" is your Scala home's absolute path. For example: /Users/dcaoyuan/apps/scala/share/scala/
    The netbeans.conf is located at "pathToNetBeansInstallationDirectory/etc", in Mac OSX, it could be:
    /Applications/NetBeans/NetBeans 6.0.app/Contents/Resources/NetBeans/etc

Know Issues:

  • Embedded /* */ comment is not supported yet.
  • Do not write old-style ForComprehension "for (val i <- ...)", instead, use "for(i <- ...)". Please see Scala Spec 2.6.0+
  • Do not put infix/postfix operator at the beginning of new line even in a parenthesis expression
  • When "<" is an operator, put a space after "<" to identify it from a xml element

Download:

  • http://sourceforge.net/project/showfiles.php?group_id=192439&package_id=256544

Installation:

  1. Upzip to some where, there will be several *.nbm files
  2. Run NetBeans, install these *.nbm files via [Tools] -> [Plugins] -> "Downloaded"

Comments

1. Michael Nischt -- 2007-12-21 08:00

Is it already christmas? :-)

Few things: Installation worked well. Compilation also, but I could figure out how to run (a single object). Points 1+2 in your list seemed to work well for the Main object example - didn't test more complex things yet. Ah and "format" screws things up as now.

Anyway great work so far!

If you're interested, I will try it with some scala projects of mine next days and report how's going..

2. Caoyuan -- 2007-12-21 08:00

Yeah, it's Christmas, that's why I rush it out. :-)

To run a project, you may need to set the main class some where, maybe in nbproject/private/private.properties

Anyway, it's ant based project, take a look at build.xml and build-impl.xml may be helpful.

I'll take a look too when I have time.

Thanks Michael, please tell me all bugs.

3. Michael Nischt -- 2007-12-21 08:00

After using it for some hours, my impression is that the module quite usable already!

And thanks for the tip to run a single file. I added the following to the ant file and it works fine:

<property name="run.class" value="mypackage.MyMainObject?"/>

Btw. <a href=" http://gestalt.monoid.net/stuffu/scala-nb/errors.zip" target="errors">here</a> are five examples breaking the syntax highlighting. More to follow soon :-)

4. David Pollak -- 2007-12-21 08:00

I'm trying to use the new plugin... however... I get the following error when trying to compile: Could not load definitions from resource scala/tools/ant/antlib.xml. It could not be found.

I've scanned my entire system and do not have the antlib.xml file.

dpp@think:~/netbeans-6.0$ find / -name antlib.xml 2> /dev/null dpp@think:~/netbeans-6.0$

How do I proceed?

5. Caoyuan -- 2007-12-21 08:00

It seems the SCALA_HOME is not set properly. The antlib.xml is packaged in a jar under ...../scala/share/scala/lib.

The SCALA_HOME should be set to reach: ...../scala/share/scala, which has sub-dir as: bin, lib, doc etc.

6. Caoyuan -- 2007-12-21 08:00

BTW, I'm writing a module to manage scala platforms, which will verify the scala_home directory, and, may support more one scala installations (such as 2.6.2, 2.5.0 etc).

7. Caoyuan -- 2007-12-21 08:00

Micheal,

Thanks for the error cases, I'll try to solve them.

8. Kevin Kleinfelter -- 2007-12-22 08:00

Setting SCALA_HOME appears to not work with Windows Netbeans 6.0 final.

I've got SCALA_HOME=C:\scala in my environment. I've confirmed it by starting a Command prompt and typing "set". Yet I still get the scala/tools/ant/antlib.xml error.

However, adding -J-Dscala.home=C:\scala to the end of the netbeans_default_options string in C:\Program Files\NetBeans 6.0\etc\netbeans.conf resolves the problem.

I don't speak ant, but I'm betting that the following snippet from build-impl.xml doesn't behave as expected in some cases:

<condition property="scala.home" value="$">

<isset property="env.SCALA_HOME"/>

</condition>

9. Nazar -- 2007-12-24 08:00

Hello Caoyuan,

as David reported earlier he was compiling sources of netbeans himself when got "Could not load definitions from resource scala/tools/ant/antlib.xml." Same sort of errors I have experienced when compiled modules under cvs/languages/scala. As I figured out modules in netbeans platform are organized into clusters. Scala support is declared in "experimental" cluster which isn't guaranteed to compile. I think it'll be useful if you provide steps on how to check out, configure clusters and compile minimal netbeans platform with scala support. Thanks

10. Nazar -- 2007-12-24 08:00

Here's the output of an error

[nbmerge] Failed to build target: all-languages/scala/core

BUILD FAILED C:\netbeans\nbbuild\build.xml:1216: The following error occurred while executing

this line:

C:\netbeans\nbbuild\build.xml:688: The following error occurred while executing this line: C:\netbeans\nbbuild\build.xml:683: The following error occurred while executing this line: C:\netbeans\nbbuild\build.xml:733: The following error occurred while executing this line: C:\netbeans\nbbuild\templates\projectized.xml:87: No dependent module org.netbea ns.modules.projectapi

Total time: 33 minutes 49 seconds

11. Caoyuan -- 2007-12-24 08:00

Nazar,

Here's my steps to compile scala modules under NetBeans cvs tree:

1. Checkout NetBeans cvs trunk: CVSROOT=:pserver:dcaoyuan@cvs.netbeans.org:/cvs export CVSROOT cvs login cvs checkout nbbuild ant -f nbbuild/build.xml checkout

2. cd nbbuild, ant build

3. Run NetBeans 6.0, open scala projects;

4. Right click on project node, choose build or create NBM.

BTW, after you re-build all scala modules, you can also run CVSed NetBeans directly via run icon.

12. jartur -- 2007-12-25 08:00

Ah, that's great. Do you accept contributors? I've been working on Scala for NB for some time in the past. And I'd like to resume this work & it'd be great to work on improving your module.

13. Caoyuan -- 2007-12-25 08:00

jartur,

I commit directly to NetBeans CVS tree now. For more information, please check  http://www.netbeans.org/community/contribute/

But at the beginning, you can mail your ideas or patches or code to me.

For my experiences on language supporting for NetBeans, the most difficult parts are type inference when do semantic analyze, and, debugging.

14. ed1t -- 2007-12-26 08:00

Hi,

I have installed the scala plugin and have added -J-Dscala.home=scalahomepath to my netbeans-default as mentioned and i also have environment variable SCALA_HOME pointing to ..../scala/share/scala but i get the same error...

/Users/dj/NetBeansProjects/ScalaApplication2/nbproject/build-impl.xml:25: You must set SCALA_HOME or environment property or scala.home

property in nbproject/private/private.properties to point to Scala installation directory.

BUILD FAILED (total time: 0 seconds)

anybody why this is happening? I am OS X 10.5

15. Caoyuan -- 2007-12-27 08:00

ed1t,

Did you added: -J-Dscala.home=..../scala/share/scala ?