Scala68v1

Scala Plugins for NetBeans 6.8 v1.x (RC2b)

Contents


New & Noteworthy

  • Fixed: Error and warning markers on Windows
  • Fixed: Go-To-Source on Windows
  • Fixed: Go-To-Source across dependent Maven projects.
  • Use dependencies aware scalac task instead of fsc for default Scala project
  • Much more responsive when typing and for code-completion
  • More refactoring: find usages, rename across opened projects
  • Breakpoint works everywhere
  • Better supporting for mixed Java/Scala project in both direction (Java is visible in Scala and vice versa)
  • Better integration with NetBeans maven plugin
  • Better code completion even for implicit methods (in most cases)
  • Better indentation and formatter for unfinished line after if, else, =, for, while, do etc
  • Better syntax highlighting for val/var, lazy val, implicit call, byname param, abstract method etc
  • Mark of implemented/overridden methods, click on mark will jump to super definition
  • Go to type ("Ctrl+O")
  • Select parts of code, press {, [, (, ", ` will add/replace surrounding pair, press ~ will remove them. Specially, press / will block-comment it
  • Reset Scala interactive parser when necessary, for instance: dependent libs changed (Right click on source, choose "Reset Scala Parser" in pop-up menu)
  • Output highlighted code to html ([File] -> [PrintToHTML...]) (Can be then copied/pasted to Word, PowerPoint, Keynote etc. See example)
  • Some basic hints, for instance: fixing import, unused imports
  • Code template now works, check or add your own via [Options/Preferences] -> [Editor] -> [Code Templates] -> [Scala]
  • Fixed breakpoint issue under Windows

Install with NetBeans 6.8

  1. Download and install Scala-2.8.0 RC! runtime via http://www.scala-lang.org/downloads
    • Note for Windows user: do not install Scala runtime under path/directory with embed space.
  2. Set $SCALA_HOME environment variable to point to the installed Scala runtime path. Add $SCALA_HOME/bin to PATH environment variable.
    • Note for Mac OS user: $SCALA_HOME environment variable may not be visible for Applications/NetBeans, see [1]
    • Note for Linux user: if your $SCALA_HOME environment variable is not visible for NetBeans, see [2]
  3. Get the NetBeans 6.8 from: http://netbeans.org/downloads/index.html
  4. If you have previous NetBeans installed:
    • Remove $UserHome/.netbeans/6.7 or rename it to $UserHome/.netbeans/back6.7
    • Remove $UserHome/.netbeans/6.8 or rename it to $UserHome/.netbeans/back6.8
    • Answering "No" to the question of "Importing old configuration of ..." if it shows
  5. Get the Scala plugins binary from: http://sourceforge.net/projects/erlybird/files/nb-scala/6.8v1.1.0rc2b/
  6. Unzip Scala plugin binary to somewhere
  7. 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.
  8. Edit $NetBeansInstallationPath/etc/netbeans.conf
    • You may need to increase maximum heap memory size etc, for instance: -J-Xmx1024m -J-XX:MaxPermSize=500m
    • remove "-J-ea" if there is one to avoid AssertionError window popup

Old Projects Created Before 6.8v1.1.0beta Should Modify Their Project Properties

All projects created via "File" | "New Project" before nb-scala-6.8v1.1.0beta should add or change following lines in "nbproject/project.properties"

scalac.compilerargs=
scalac.deprecation=no
scalac.unchecked=no

Tips

Reset Scala parser when necessary

Sometimes, the dependent project is rebuilt or newly added, or the dependent jars are changes, the editor may not recognize these changes and shows error messages, you can right-click on source file, choose "Reset Scala Parser" in the popped menu, then switch to another editor window, and go back.

Could not connect to compilation daemon

If you encounter "... Could not connect to compilation daemon.", try to run "fsc -reset" under a command/terminal window. (From v1.1.0, "fsc" is not support any more, please use dependencyfile setting instead)

How to Set Path to Scala Runtime Library

Each release of Scala plugin may support several scalac compatible Scala runtime libraries. For ant based project, the building process always use the Scala runtime library under $SCALA_HOME. For Maven based project, it always use the Scala runtime library configured in pom.xml.

How to Set Building Heap Size

For ant based project, set something like:

ANT_OPTS=ANT_OPTS='-Xmx1024m -XX:MaxPermSize=512m'

For Maven based project, you need to set the jvmArgs for maven-scala-plugin in your pom.xml file

                <configuration>
                    <jvmArgs>
                        <jvmArg>-Xms64m</jvmArg>
                        <jvmArg>-Xmx1024m</jvmArg>
                    </jvmArgs>
                    <scalaVersion>${scala.version}</scalaVersion>
                    <args>
                        <arg>-target:jvm-1.5</arg>
                        <arg>-make:transitivenocp</arg>
                        <arg>-dependencyfile</arg>
                        <arg>${project.build.directory}/.scala_dependencies</arg>
                    </args>
                </configuration>

Current Code Template

NetBeans supports custom code template, you can check or add via [Options/Preferences] -> [Editor] -> [Code Templates] -> [Scala]

To invoke, just type the abbreviation, for example, "ca", then press "Tab" key.

The followings are predefined:

<codetemplates>
  <codetemplate abbreviation="ex">
    <code>extends </code>
  </codetemplate>
  <codetemplate abbreviation="re">
    <code>return </code>
  </codetemplate>
  <codetemplate abbreviation="ma">
    <code>match {</code>
  </codetemplate>
  <codetemplate abbreviation="pr">
    <code>private </code>
  </codetemplate>
  <codetemplate abbreviation="ov">
    <code>override </code>
  </codetemplate>
  <codetemplate abbreviation="sy">
    <code>synchronized </code>
  </codetemplate>

  <codetemplate abbreviation="th">
    <code>
      <![CDATA[@throws(classOf[${cursor}])]]>
    </code>
  </codetemplate>

  <codetemplate abbreviation="iff">
    <code>
      <![CDATA[if (${cursor}) else]]>
    </code>
  </codetemplate>

  <codetemplate abbreviation="ca">
    <code>
      <![CDATA[case ${cursor} =>]]>
    </code>
  </codetemplate>

  <codetemplate abbreviation="bcom">
    <code>
      <![CDATA[/*${selection}*/]]>
    </code>
  </codetemplate>

  <codetemplate abbreviation="fcom">
    <code>
      <![CDATA[// <editor-fold defaultstate="collapsed" desc="${comment}">
${selection}${cursor}// </editor-fold>
]]>
    </code>
  </codetemplate>

</codetemplates>

For Windows user

please do not create projects under directory that contains space. Otherwise you may encounter something like (WIll try to fix it in next release):

init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\myuser\My Documents\NetBeansProjects\ScalaApplication1\build\classes
C:\Documents and Settings\myuser\My Documents\NetBeansProjects\ScalaApplication1\nbproject\build-impl.xml:403:
The following error occurred while executing this line:
C:\Documents and Settings\myuser\My Documents\NetBeansProjects\ScalaApplication1\nbproject\build-impl.xml:236:
don't know what to do with and
BUILD FAILED (total time: 0 seconds)
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