dotty.tools.repl

Members list

Type members

Classlikes

class AbstractFileClassLoader(val root: AbstractFile, parent: ClassLoader) extends ClassLoader

Attributes

Supertypes
class ClassLoader
class Object
trait Matchable
class Any
case class AmbiguousCommand(cmd: String, matchingCommands: List[String]) extends Command

An ambiguous prefix that matches multiple commands

An ambiguous prefix that matches multiple commands

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Command
trait ParseResult
class Object
trait Matchable
class Any
Show all

A phase that collects user defined top level imports.

A phase that collects user defined top level imports.

These imports must be collected as typed trees and therefore after Typer.

Attributes

Supertypes
class Phase
class Object
trait Matchable
class Any
sealed trait Command extends ParseResult

A command is on the format:

A command is on the format:

:commandName <optional arguments...>

The Command trait denotes these commands

Attributes

Supertypes
trait ParseResult
class Object
trait Matchable
class Any
Known subtypes
class DocOf
object Help.type
object Imports.type
class Load
object Quit.type
class Reset
class Settings
class TypeOf
Show all
case class DocOf(expr: String) extends Command

A command that is used to display the documentation associated with the given expression.

A command that is used to display the documentation associated with the given expression.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Command
trait ParseResult
class Object
trait Matchable
class Any
Show all
object DocOf

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
DocOf.type
case object Help extends Command

:help shows the different commands implemented by the Dotty repl

:help shows the different commands implemented by the Dotty repl

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Command
trait ParseResult
class Object
trait Matchable
class Any
Show all
Self type
Help.type
case object Imports extends Command

:imports lists the imports that have been explicitly imported during the session

:imports lists the imports that have been explicitly imported during the session

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Command
trait ParseResult
class Object
trait Matchable
class Any
Show all
Self type
Imports.type
class JLineTerminal extends Closeable

Attributes

Supertypes
trait Closeable
class Object
trait Matchable
class Any
case class Load(path: String) extends Command

:load <path> interprets a scala file as if entered line-by-line into the REPL

:load <path> interprets a scala file as if entered line-by-line into the REPL

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Command
trait ParseResult
class Object
trait Matchable
class Any
Show all
object Load

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Load.type
object Main

Main entry point to the REPL

Main entry point to the REPL

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Main.type
case object Newline extends ParseResult

Parsed result is simply a newline

Parsed result is simply a newline

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait ParseResult
class Object
trait Matchable
class Any
Show all
Self type
Newline.type
sealed trait ParseResult

A parsing result from string input

A parsing result from string input

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Command
class DocOf
object Help.type
object Imports.type
class Load
object Quit.type
class Reset
class Settings
class TypeOf
object Newline.type
class Parsed
object SigKill.type
class SyntaxErrors
Show all
object ParseResult

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
case class Parsed(source: SourceFile, trees: List[Tree], reporter: StoreReporter) extends ParseResult

An error free parsing resulting in a list of untyped trees

An error free parsing resulting in a list of untyped trees

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait ParseResult
class Object
trait Matchable
class Any
Show all
class Parser extends Phase

A placeholder phase that receives parse trees..

A placeholder phase that receives parse trees..

It is called "parser" for the convenience of collective muscle memory.

This enables -Vprint:parser.

Attributes

Supertypes
class Phase
class Object
trait Matchable
class Any
case object Quit extends Command

:quit exits the repl

:quit exits the repl

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Command
trait ParseResult
class Object
trait Matchable
class Any
Show all
Self type
Quit.type
object Rendering

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Rendering.type
object ReplCommand extends CompilerCommand

Attributes

Supertypes
trait CliCommand
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
class ReplCompiler extends Compiler

This subclass of Compiler is adapted for use in the REPL.

This subclass of Compiler is adapted for use in the REPL.

  • compiles parsed expression in the current REPL state:
    • adds the appropriate imports in scope
    • wraps expressions into a dummy object
  • provides utility to query the type of an expression
  • provides utility to query the documentation of an expression

Attributes

Companion
object
Supertypes
class Compiler
class Object
trait Matchable
class Any
object ReplCompiler

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
class ReplDriver(settings: Array[String], out: PrintStream, classLoader: Option[ClassLoader]) extends Driver

Main REPL instance, orchestrating input, compilation and presentation

Main REPL instance, orchestrating input, compilation and presentation

Attributes

Supertypes
class Driver
class Object
trait Matchable
class Any
class ReplPhase extends Phase

A phase that assembles wrapped parse trees from user input.

A phase that assembles wrapped parse trees from user input.

Ths ReplState attachment indicates Repl wrapping is required.

This enables -Vprint:repl so that users can see how their code snippet was wrapped.

Attributes

Supertypes
class Phase
class Object
trait Matchable
class Any
case class Reset(arg: String) extends Command

Reset the session to the initial state from when the repl program was started

Reset the session to the initial state from when the repl program was started

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Command
trait ParseResult
class Object
trait Matchable
class Any
Show all
object Reset

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Reset.type
class ScriptEngine extends AbstractScriptEngine

A JSR 223 (Scripting API) compatible wrapper around the REPL for improved interoperability with software that supports it.

A JSR 223 (Scripting API) compatible wrapper around the REPL for improved interoperability with software that supports it.

It works by instantiating a new script engine through the script engine manager. The script engine provides a eval method to evaluate scripts in string form. Example use:

val m = new javax.script.ScriptEngineManager() val e = m.getEngineByName("scala") println(e.eval("42"))

Attributes

Companion
object
Supertypes
class AbstractScriptEngine
trait ScriptEngine
class Object
trait Matchable
class Any
object ScriptEngine

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
case class Settings(arg: String) extends Command

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Command
trait ParseResult
class Object
trait Matchable
class Any
Show all
object Settings

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Settings.type
case object SigKill extends ParseResult

ctrl-c obtained from input string

ctrl-c obtained from input string

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait ParseResult
class Object
trait Matchable
class Any
Show all
Self type
SigKill.type
case class State(objectIndex: Int, valIndex: Int, imports: Map[Int, List[Import]], invalidObjectIndexes: Set[Int], context: Context)

The state of the REPL contains necessary bindings instead of having to have mutation

The state of the REPL contains necessary bindings instead of having to have mutation

The compiler in the REPL needs to do some wrapping in order to compile valid code. This wrapping occurs when a single MemberDef that cannot be top-level needs to be compiled. In order to do this, we need some unique identifier for each of these wrappers. That identifier is objectIndex.

Free expressions such as 1 + 1 needs to have an assignment in order to be of use. These expressions are therefore given a identifier on the format resX where X starts at 0 and each new expression that needs an identifier is given the increment of the old identifier. This identifier is valIndex.

Value parameters

context

the latest compiler context

imports

a map from object index to the list of user defined imports

invalidObjectIndexes

the set of object indexes that failed to initialize

objectIndex

the index of the next wrapper

valIndex

the index of next value binding for free expressions

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class SyntaxErrors(sourceCode: String, errors: List[Diagnostic], trees: List[Tree]) extends ParseResult

A parsing result containing syntax errors

A parsing result containing syntax errors

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait ParseResult
class Object
trait Matchable
class Any
Show all
case class TypeOf(expr: String) extends Command

To find out the type of an expression you may simply do:

To find out the type of an expression you may simply do:

scala> :type (1 * 54).toString
String

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Command
trait ParseResult
class Object
trait Matchable
class Any
Show all
object TypeOf

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
TypeOf.type
case class UnknownCommand(cmd: String) extends Command

An unknown command that will not be handled by the REPL

An unknown command that will not be handled by the REPL

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Command
trait ParseResult
class Object
trait Matchable
class Any
Show all
object results

Contains the different data and type structures used to model results in the REPL

Contains the different data and type structures used to model results in the REPL

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
results.type