scala-ide/scala-ide — pull request #829 by Kwestor (2014-10-09 14:59:48+00:00)
Title: Expression evaluator for Scala IDE

Expression evaluator for Scala IDE

Implementation of expression evaluator and conditional breakpoints based on JDI.

Conditional breakpoints could be set in standard Eclipse debug window, for expression evaluator there is separate view. Both work with "new Scala" debug launcher.

Both allows user to evaluate any Scala expression in context of some breakpoint during debug. Expression is transformed in multiple phases and evaluated using calls to remote debugged machine and result is fetched back to the user.

Because of complexity of Scala language, implementation details of JVM platform and necessity for manual evaluation not all Scala features are supported yet.

Short list of implemented and missing features:

- [x] evaluating expressions on chosen frame,
- [x] different views for evaluator, with history of evaluated expressions,
- [x] tree view with result of evaluation, with logical structure for collections,
- [x] access to all values visible from breakpoint (both locally and globally) with exception of access modifiers (see below),
- [x] limited support for control structures: for now `if/else`, `while` and `do/while`,
- [x] limited support for varargs (see below),
- [x] support for implicits,
- [x] support for `this`,
- [x] support for number, tuple, unit and null literals,
- [x] support for creating new instances,
- [x] limited support for lambdas (you need to specify types of arguments),
- [x] conditional breakpoints,
- [ ] extracting generic types from source,
- [ ] support for `Array.apply` and rich operations on arrays (needs generics),
- [ ] fix method resolution when using overloaded varargs (needs generics),
- [ ] fix resolution of overloaded local values,
- [ ] fix `this` when breakpoint is in lambda (right now it points to lambda),
- [ ] support for accessing Java static fields and methods,
- [ ] support for accessing objects nested in classes,
- [ ] support for nested lambdas,
- [ ] support for partial functions with more than one parameter,
- [ ] support for accessing methods and fields with access modifiers (this need changes in scala `Toolbox`),
- [ ] support for setting local variables,
- [ ] support for `isInstanceOf` and `asInstanceOf`,
- [ ] support for `for` comprehensions (needs generics),
- [ ] support for `try` and `throw`,
- [ ] support for `scala.Dynamic`,
- [ ] support for varargs in constructors,
- [ ] undo and redo in expression view,
- [ ] support for float literals (for some reason `1.0f` becomes `1.0` after parsing),
- [ ] fix some compiler issues with lambda compilation.

Fix #1000682

Co-authored-by:
- Paweł Batko (@pbatko)
- Piotr Kukiełka (@pkukielka)
- Jerzy Müller (@Kwestor)
- Michał Pociecha (@mpociecha)
- Krzysztof Romanowski (@romanowski)

For all the help thanks to:
- Iulian Dragoș (@dragos)
- Eugene Burmako (@xeno-by)
- Grzegorz Kossakowski (@gkossakowski)

Lastly, the below disclaimer is required by the lawyers:

THE FOLLOWING DISCLAIMER APPLIES TO ALL SOFTWARE CODE AND OTHER MATERIALS CONTRIBUTED IN CONNECTION WITH THIS SOFTWARE:
THIS SOFTWARE IS LICENSED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY OF NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THIS SOFTWARE MAY BE REDISTRIBUTED TO OTHERS ONLY BY EFFECTIVELY USING THIS OR ANOTHER EQUIVALENT DISCLAIMER IN ADDITION TO ANY OTHER REQUIRED LICENSE TERMS.
ONLY THE SOFTWARE CODE AND OTHER MATERIALS CONTRIBUTED IN CONNECTION WITH THIS SOFTWARE, IF ANY, THAT ARE ATTACHED TO (OR OTHERWISE ACCOMPANY) THIS SUBMISSION (AND ORDINARY COURSE CONTRIBUTIONS OF FUTURES PATCHES THERETO) ARE TO BE CONSIDERED A CONTRIBUTION. NO OTHER SOFTWARE CODE OR MATERIALS ARE A CONTRIBUTION.