Skip to content
Iulian Dragos edited this page Sep 4, 2012 · 15 revisions

Introduction

This Eclipse plugin allows experimentation with the Scala language in a new way. A worksheet is a Scala file that is evaluated on save, and the result of each expression is shown in a column to the right. Worksheets are like a REPL session on steroids, and enjoy 1st class editor support: completion, hyperlinking, interactive errors-as-you-type, auto-format, etc.

Installation

The Worksheet is published in the Scala IDE ecosystem and is installed through the normal Eclipse update mechanism. The worksheet depends on the Scala IDE being installed. Currently we only have nightly builds for the worksheet, and they depend on the Helium nightly.

Point your Eclipse installation to the desired update site and select Scala Worksheet from the list of installable software. Once the plug-in is installed, restart Eclipse.

Getting Started

Create your first worksheet but right-clicking on a Scala project and choosing New Scala Worksheet. Or, if you are a shortcut junkie, hit CMD-3, type Scala worksheet and hit enter when the correct command appears in the quick command window.

images/new-worksheet.png

Scala worksheets are normal Scala files, but instead of .scala, they end in .sc. An editor is open for the newly created worksheet, and notice that after a few moments a greeting is printed next to the first expression in your object.

images/greeting.png

Verbose output

You can start typing and notice that most features of the Scala editor are available. Whenever you save, the worksheet is re-evaluated and the results are printed in line with your program.

images/multi-line.png

If the output of a certain line is too long or does not fit on one line, the new lines are introduced as needed. There is a (configurable) maximum number of characters that are placed in the editor. If the program takes too long to execute, the editor adds a spinning line after 2 seconds. You can interrupt the evaluation at any point by typing any character or Esc.

images/verbose-output.png

Features

The current project is on the worksheet classpath. You can immediately start experimenting with your code, or dependent libraries. Make sure the project is built and there are no errors (the best is to enable Project/Build automatically).

images/project-classpath.png

You can configure how to highlight the results, and the cut-off value on the plug-in configuration page.

images/configuration.png

Editor

Most features of the Scala editor are available in the worksheet editor:

  • highlight errors as you type
  • code completion (including auto-import)
  • hyperlinking
  • code format (context menu, or Cmd-Shift-F)
  • code hovers
Clone this wiki locally