Giter Site home page Giter Site logo

scala-worksheet's Introduction

Scala Worksheet plugin for Eclipse

A simple worksheet implementation for Scala IDE. It is a glorified editor, with the option of evaluating the script and placing the results of each expression in a comment on the same line.

There are 5 Eclipse plugins:

  • the plugin itself
  • the plugin.tests fragment
  • the plugin's runtime library (needed for producing the worksheet's output)
  • an Eclipse feature
  • an Eclipse source feature
  • an Eclipse update-site

The projects can readily be imported inside Eclipse. Additionally, you have maven pom files based on Tycho, enabling command line builds.

Download:

Build

Simply run the ./build.sh script.

The worksheet build is based on plugin-profiles and can be built against several versions of the IDE, Eclipse and Scala compiler.

Launching the build.sh script will exand to the following Maven command:

mvn -Peclipse-indigo,scala-2.10.x,scala-ide-stable clean install

You can choose a different profile for any of the three axis: eclipse platform, Scala version and Scala IDE stream. Read here for more details.

scala-worksheet's People

Contributors

amirsh avatar dotta avatar dragos avatar huitseeker avatar kiritsuku avatar megri avatar nadavwr avatar skyluc avatar ukstv avatar wpopielarski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scala-worksheet's Issues

Ask for build before evalute

If the project is not up to date, evaluating the worksheet may trigger compilation errors. On the other hand, the worksheet may not depend on any types in the project, so it would be ok to evaluate.

Ask the user!

Instrumented sources should not be stored in Eclipse installation

Currently, the $instrumented.scala sources are stored in the Eclipse installation, i.e. inside Eclipse.app/Contents/MacOS/. Not really the ideal place ;-)

Also, the binaries are placed in the project's binary folder. I think what we can do is creating a .instrumented/src and .instrumented/bin in the project's root and store sources and binaries for the worksheet there.

Report build errors in the Eclipse Problems View

Evaluating the following snippet won't work because it contains a compilation error. However, no error is reported in the editor because unimplemented abstract methods are only checked during refcheck phase, which is not run by the presentation compiler.

object Main {
  abstract class A {
    def foo: Unit
  }
  class B extends A

  new B
}

What we need to do is pass an instance of BuildReporter to the Global use to compile the worksheets, so that build errors are always reported in the Problems View.

Scala 2.9 support

After chatting with Lukas and Josh, it looks like 2.9 support is extremely important for the worksheet.

'askReload' using a Document Listener

Right now we do askReload on document reconciliation, which is pooling changes the moment the user stops typing for a few milliseconds.

This has the advantage of not generating useless work, but if the user is very fast, he can ask for completions before the reconciler has kicked in. This means that ASTs are out of date, and completion will return, say, scope completion instead of members (because the old AST does not have the 'Select' node yet).

We should move it on a document listener, and askReload on each key stroke. This is what is done in the Scala IDE. It is wasteful most of the times, so a better solution would be to do askReload before computing completions, but that runs into misterious race conditions. Should investigate further.

Add a local hyperlink detector

The Scala IDE hyperlink detector assumes a JDT compilation unit, so it won't find targets of hyperlinks in the same file.

We need to add another hyperlink detector that uses only symbol.pos to find the declaration.

Force reconciliation when the editor is open

Right now, the reconciler does not run before the first change is made. This can be fixed by calling forceReconciling when the editor is open.

The JavaReconciler registers a part listener and calls forceReconciling when the editor is open or activated.

Use Platform JVM launchers to evaluate

Currently we run java, but a proper evaluation engine should use launchers to:

  • use the per project/workspace configured JRE
  • allow cancellation
  • eventually allow debugging

Expose content formatter

It's hooked in the SourceViewerConfiguration, but for some reason there's no menu or action exposed.

Smart padding when pasting code

Right, when pasting multiline code, the padding between the code and the evaluation result is adjusted. But it is not done when pasting a simple string without new line.

From

prinln("hello")        //> hello

Pasting world result in

println("hello world")        //> hello

It should become

println("hello world")  //> hello

Comment selected line action

It would be nice if we could have the following shortcuts for commenting/uncommenting selected lines in the worksheet

ctrl + / to comment  
ctrl + \ to uncomment

Hook reconciler

Enable the reconciler to show error as you type in the Script editor.

Hyperlinking not working sometimes

Every now and then, hyperlinking fails inside the presentation compiler, inside getLinkPos. This needs to be debugged. It fails consistently, and I noticed that it's the overloading 'resolution' that fails. The code looks like this:

      parseAndEnter(unit)
      val pre = adaptToNewRunMap(ThisType(sym.owner))
      val newsym = pre.typeSymbol.info.decl(sym.name) filter { alt =>
        sym.isType || {
          try {
            val tp1 = pre.memberType(alt) onTypeError NoType
            val tp2 = adaptToNewRunMap(sym.tpe) substSym (originalTypeParams, sym.owner.typeParams)
            matchesType(tp1, tp2, false)
          }
          catch {
          ...

It finds the symbol, and it get's into val tp1 = .., and there it fails. I am trying to hyperlink to List.max which is inside IterableLike, which has a type parameter. Editing a bit the file brings it back to normal, but when it is in a bad mood, it's consistently failing until editing.

Add hyperlinking

Allow hyperlinking in the editor. Hook with the sdt.core engine.

Rebuild up to a line

Hook the support already existing for evaluating up to a given line in the source file.

Wrong source instrumentation generation

For the following worksheet source

object M {}

generates the followin (wrong) instrumented code

import scala.runtime.WorksheetSupport._; def main(args: Array[String])=$execute{}object M {
}

This bug is extremely annoying if you run the evaluation on save, as a build error will be reported right after a worksheet is created (Re #3 and #6)

Allow to evaluate single expression

Would be nice to allow to evaluate one single expression instead of the whole source file. Even more, we could run the evaluation automatically, that would be very nice indeed. I wonder if this sort of behavior could be implemented via the scala.tools.reflect.ToolBox class.

Graceful failure on forward references

The following won't compile

def foo = bar
val bar = 1

The reason is that the whole code is put in a block, where forward references to vals are not allowed. So this is not a bug but something expected.

When this happens, we should fail gracefully and provide the user with some more meaningful information than "error during evaluation".

Lock editor during evaluation

While the evaluation engine is working, the user may edit the file. Hoever, when evaluation is back, we'll replace the editor contents with the results.

Lock the editor while evaluating!

Unify classpath handling

Compiling and running the worksheet should use the same classpath.

  • compiling may use the build manager (has to be investigated if feasible -- don't want to keep analysis artifacts from the worksheet into the project build)
  • the classloader used for running should be configured with the same classpath as the compilation classpath

Add Evaluate Sheet command

Add a command that evaluates the current contents of a Script file and replaces it with the output of the evaluation. Currently, that's the same source augmented with comments that give the result for each expression.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.