To use the Scala Plugin, switch to the Scala perspective (Window/Open Perspective/Other/Scala).
In this perspective, the following wizards are available in your File/New menu:
- Scala Project: creates an empty Scala project with a source directory called "src."
- Scala Package: creates an empty Scala package in the selected project's source directory.
- Scala Class/Object/Trait/Application: creates a top-level Scala class or object in a new source file of the selected package.
Note that the use of these wizards is optional and an entire Scala source
tree can be copied into the "src" directory of a project. If you do this, ensure
that the paths of the source files only include their packages relative from the "src" directory,
and remember to manually "refresh" (F5 or File/Refresh) the "src" directory after the copy is completed.
Building
Any Scala source file that exists in the source directory will be compiled when the project is built.
If "Project/Build Automatically" is enabled, Scala source files will be recompiled whenever they are saved.
Alternatively, otherwise, Scala source files are recompiled when "Project/Build Project" and "Project/Build All" are selected.
By default, class files are saved in the project's "bin" directory. "Project/Clean" will delete all classfiles in
the bin directory, as well as get rid of all project error markers. As in the Java development tool, compilation errors
will appear as markers and as rows in the "Problems" view.
Editing
The Scala plugin enhances the editing of Scala source files with compilation information.
This information is continuously updated during editng.
The following editing services are supported:
- Hover Help: when the mouse pointer hovers over an identifier, the Scala editor will display
the type of the identifier as well as any available Scala or Java documentation.
- Hyperlink Navigation: holding down the control/command key and clicking on an identifier will reveal
the identifier's definition in a Scala or Java editor. Goto declaration (usually F5) can be used to go to the identifier's definition from the keyboard.
- Content Assist: holding control/command and typing space will popup a list of identifiers that can be
used in the current editing context. Content assist resolves any identifier in an editor buffer, but does not resolve keywords.
For example, typing control-space after "to" in "list.to" will replace "to" with "toString",
which is the only list method that begins with "to."
Compilation information is also used to implement syntax coloring. The coloring scheme used to highlight a file
can be configured at "Window/Preferences/Scala/Editor."
Running
Given an object that extends "scala.Application", the object can be executed as an application inside Eclipse.
To do this, select the "Run/Run..." menu option, select the "Scala Application" option, enter the name of the
project that includes the executable object in the "Project" field, and type the package-qualified name of the
object in the "Scala application object" field.
Although the Scala application can be executed inside Eclipse's debugger, debugging of a Scala application
is not supported yet (i.e., there is no way to step through code in Scala files). Alternatively, you can
use an Interpreter shell to evaluate Scala expressions that can access Scala code in your project.
Debugging
You can also debug a running Scala application. To do this, select the "Run/Debug..." menu item and choose the
Scala application you want to debug. The following debugging services are supported:
- Breakpoints: double-click the left ruler on the line where you want to stop the program execution. Alternatively,
you can use the "Run/Toggle line breakpoint" menu item. When the program execution will be stopped at a breakpoint,
Eclipse will switch to the Debug perspective wich will allow you to step the execution, view call stack and variables
values.
- Hot Code Replace: while debugging a program you can modify it and the running program will be updated automatically.
If the modifications are too important, Eclipse will notify you. Welcome to powerful debugging!