scala.tools.nsc.interactive

CompilerControl

trait CompilerControl extends AnyRef

Interface of interactive compiler to a client such as an IDE The model the presentation compiler consists of the following parts:

unitOfFile: The map from sourcefiles to loaded units. A sourcefile/unit is loaded if it occurs in that map.

manipulated by: removeUnitOf, reloadSources.

A call to reloadSources will add the given sources to the loaded units, and start a new background compiler pass to compile all loaded units (with the indicated sources first). Each background compiler pass has its own typer run. The background compiler thread can be interrupted each time an AST node is completely typechecked in the following ways:

  1. by a new call to reloadSources. This starts a new background compiler pass with a new typer run. 2. by a call to askTypeTree. This starts a new typer run if the forceReload parameter = true 3. by a call to askTypeAt, askTypeCompletion, askScopeCompletion, askToDoFirst, askLinkPos, askLastType. 4. by raising an exception in the scheduler. 5. by passing a high-priority action wrapped in ask { ... }.

Actions under 1-3 can themselves be interrupted if they involve typechecking AST nodes. High-priority actions under 5 cannot; they always run to completion. So these high-priority actions should to be short.

Normally, an interrupted action continues after the interrupting action is finished. However, if the interrupting action created a new typer run, the interrupted action is aborted. If there's an outstanding response, it will be set to a Right value with a FreshRunReq exception.

Self Type
Global
Source
CompilerControl.scala
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. CompilerControl
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Type Members

  1. case class AskLinkPosItem(sym: Symbol, source: SourceFile, response: Response[Position]) extends WorkItem with Product with Serializable

  2. case class AskLoadedTypedItem(source: SourceFile, response: Response[Tree]) extends WorkItem with Product with Serializable

  3. case class AskParsedEnteredItem(source: SourceFile, keepLoaded: Boolean, response: Response[Tree]) extends WorkItem with Product with Serializable

  4. case class AskScopeCompletionItem(pos: Position, response: Response[List[Member]]) extends WorkItem with Product with Serializable

  5. class AskToDoFirstItem extends WorkItem

  6. case class AskTypeAtItem(pos: Position, response: Response[Tree]) extends WorkItem with Product with Serializable

  7. case class AskTypeCompletionItem(pos: Position, response: Response[List[Member]]) extends WorkItem with Product with Serializable

  8. case class AskTypeItem(source: SourceFile, forceReload: Boolean, response: Response[Tree]) extends WorkItem with Product with Serializable

  9. case class FilesDeletedItem(sources: List[SourceFile], response: Response[Unit]) extends WorkItem with Product with Serializable

  10. abstract class Member extends AnyRef

    Info given for every member found by completion

  11. class NoWorkScheduler extends WorkScheduler

    A do-nothing work scheduler that responds immediately with MissingResponse.

  12. case class ReloadItem(sources: List[SourceFile], response: Response[Unit]) extends WorkItem with Product with Serializable

  13. type Response[T] = Response[T]

  14. case class ScopeMember(sym: Symbol, tpe: Type, accessible: Boolean, viaImport: Tree) extends Member with Product with Serializable

  15. case class TypeMember(sym: Symbol, tpe: Type, accessible: Boolean, inherited: Boolean, viaView: Symbol) extends Member with Product with Serializable

  16. abstract class WorkItem extends () ⇒ Unit

  17. case class AskInstrumentedItem(source: SourceFile, line: Int, response: Response[(String, Array[Char])]) extends WorkItem with Product with Serializable

    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) SI-6458: Instrumentation logic will be moved out of the compiler.

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def ask[A](op: () ⇒ A): A

    Asks for a computation to be done quickly on the presentation compiler thread

  8. def askFilesDeleted(sources: List[SourceFile], response: Response[Unit]): Unit

    Removes source files and toplevel symbols, and issues a new typer run.

    Removes source files and toplevel symbols, and issues a new typer run. Returns () to syncvar response on completion.

  9. def askForResponse[A](op: () ⇒ A): Response[A]

    Asks for a computation to be done on presentation compiler thread, returning a response with the result or an exception

  10. def askLinkPos(sym: Symbol, source: SourceFile, response: Response[Position]): Unit

    Sets sync var response to the position of the definition of the given link in the given sourcefile.

    Sets sync var response to the position of the definition of the given link in the given sourcefile.

    sym

    The symbol referenced by the link (might come from a classfile)

    source

    The source file that's supposed to contain the definition

    response

    A response that will be set to the following: If source contains a definition that is referenced by the given link the position of that definition, otherwise NoPosition. Note: This operation does not automatically load source. If source is unloaded, it stays that way.

  11. def askLoadedTyped(source: SourceFile, response: Response[Tree]): Unit

    If source is not yet loaded, loads it, and starts a new run, otherwise continues with current pass.

    If source is not yet loaded, loads it, and starts a new run, otherwise continues with current pass. Waits until source is fully type checked and returns body in response.

    source

    The source file that needs to be fully typed.

    response

    The response, which is set to the fully attributed tree of source. If the unit corresponding to source has been removed in the meantime the a NoSuchUnitError is raised in the response.

  12. def askParsedEntered(source: SourceFile, keepLoaded: Boolean, response: Response[Tree]): Unit

    Set sync var response to the parse tree of source with all top-level symbols entered.

    Set sync var response to the parse tree of source with all top-level symbols entered.

    source

    The source file to be analyzed

    keepLoaded

    If set to true, source file will be kept as a loaded unit afterwards. If keepLoaded is false the operation is run at low priority, only after everything is brought up to date in a regular type checker run.

    response

    The response.

  13. def askReload(sources: List[SourceFile], response: Response[Unit]): Unit

    Makes sure a set of compilation units is loaded and parsed.

    Makes sure a set of compilation units is loaded and parsed. Returns () to syncvar response on completion. Afterwards a new background compiler run is started with the given sources at the head of the list of to-be-compiled sources.

  14. def askReset(): Unit

    Cancels current compiler run and start a fresh one where everything will be re-typechecked (but not re-loaded).

  15. def askScopeCompletion(pos: Position, response: Response[List[Member]]): Unit

    Sets sync var response' to list of members that are visible as members of the scope enclosing pos.

  16. def askShutdown(): Unit

    Tells the compile server to shutdown, and not to restart again

  17. def askStructure(keepSrcLoaded: Boolean)(source: SourceFile, response: Response[Tree]): Unit

    If source if not yet loaded, get an outline view with askParseEntered.

    If source if not yet loaded, get an outline view with askParseEntered. If source is loaded, wait for it to be typechecked. In both cases, set response to parsed (and possibly typechecked) tree.

    keepSrcLoaded

    If set to true, source file will be kept as a loaded unit afterwards.

  18. def askToDoFirst(source: SourceFile): Unit

    Asks to do unit corresponding to given source file on present and subsequent type checking passes.

    Asks to do unit corresponding to given source file on present and subsequent type checking passes. If the file is in the 'crashedFiles' ignore list it is removed and typechecked normally.

  19. def askType(source: SourceFile, forceReload: Boolean, response: Response[Tree]): Unit

    Sets sync var response to the fully attributed & typechecked tree contained in source.

  20. def askTypeAt(pos: Position, response: Response[Tree]): Unit

    Sets sync var response to the smallest fully attributed tree that encloses position pos.

    Sets sync var response to the smallest fully attributed tree that encloses position pos. Note: Unlike for most other ask... operations, the source file belonging to pos needs not be be loaded.

  21. def askTypeCompletion(pos: Position, response: Response[List[Member]]): Unit

    Sets sync var response' to list of members that are visible as members of the tree enclosing pos, possibly reachable by an implicit.

  22. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  23. def doLocateContext(pos: Position): Context

    Returns the smallest context that contains given pos, throws FatalError if none exists.

  24. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  25. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  26. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  27. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  28. def getUnitOf(s: SourceFile): Option[RichCompilationUnit]

    Return the compilation unit attached to a source file, or None if source is not loaded.

  29. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  30. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  31. def locateContext(pos: Position): Option[Context]

    Locates smallest context that encloses position as an optional value.

  32. def locateTree(pos: Position): Tree

    Locate smallest tree that encloses position

  33. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  34. final def notify(): Unit

    Definition Classes
    AnyRef
  35. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  36. def onCompilerThread: Boolean

  37. def onUnitOf[T](source: SourceFile)(op: (RichCompilationUnit) ⇒ T): T

    Run operation op on a compilation unit associated with given source.

    Run operation op on a compilation unit associated with given source. If source has a loaded compilation unit, this one is passed to op. Otherwise a new compilation unit is created, but not added to the set of loaded units.

  38. def parseTree(source: SourceFile): Tree

    Returns parse tree for source source.

    Returns parse tree for source source. No symbols are entered. Syntax errors are reported. Can be called asynchronously from presentation compiler.

  39. def recentlyDeleted(): List[Symbol]

    Returns the top level classes and objects that were deleted in the editor since last time recentlyDeleted() was called.

  40. def removeUnitOf(s: SourceFile): Option[RichCompilationUnit]

    Removes the CompilationUnit corresponding to the given SourceFile from consideration for recompilation.

  41. var scheduler: WorkScheduler

    The scheduler by which client and compiler communicate Must be initialized before starting compilerRunner

    The scheduler by which client and compiler communicate Must be initialized before starting compilerRunner

    Attributes
    protected[interactive]
  42. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  43. def toString(): String

    Definition Classes
    AnyRef → Any
  44. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  45. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  46. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Deprecated Value Members

  1. def askInstrumented(source: SourceFile, line: Int, response: Response[(String, Array[Char])]): Unit

    Set sync var response to a pair consisting of

    Set sync var response to a pair consisting of

    • the fully qualified name of the first top-level object definition in the file. or "" if there are no object definitions.
    • the text of the instrumented program which, when run, prints its output and all defined values in a comment column.
    source

    The source file to be analyzed

    response

    The response.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) SI-6458: Instrumentation logic will be moved out of the compiler.

  2. def askParse(source: SourceFile, response: Response[Tree]): Unit

    Annotations
    @deprecated
    Deprecated

    (Since version 2.9.0) use parseTree(source) instead

  3. def unitOf(pos: Position): RichCompilationUnit

    The compilation unit corresponding to a position

    The compilation unit corresponding to a position

    Annotations
    @deprecated
    Deprecated

    (Since version 2.9.0) use getUnitOf(pos.source) or onUnitOf(pos.source) instead

  4. def unitOf(s: SourceFile): RichCompilationUnit

    The compilation unit corresponding to a source file if it does not yet exist create a new one atomically Note: We want to get roid of this operation as it messes compiler invariants.

    The compilation unit corresponding to a source file if it does not yet exist create a new one atomically Note: We want to get roid of this operation as it messes compiler invariants.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.9.0) use getUnitOf(s) or onUnitOf(s) instead

Inherited from AnyRef

Inherited from Any