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:
- 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
- Alphabetic
- By Inheritance
- CompilerControl
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Type Members
- case class AskDocCommentItem(sym: Global.Symbol, source: SourceFile, site: Global.Symbol, fragments: List[(Global.Symbol, SourceFile)], response: Global.Response[(String, String, Global.Position)]) extends Global.WorkItem with Product with Serializable
- case class AskLinkPosItem(sym: Global.Symbol, source: SourceFile, response: Global.Response[Global.Position]) extends Global.WorkItem with Product with Serializable
- case class AskLoadedTypedItem(source: SourceFile, keepLoaded: Boolean, response: Global.Response[Global.Tree]) extends Global.WorkItem with Product with Serializable
- case class AskParsedEnteredItem(source: SourceFile, keepLoaded: Boolean, response: Global.Response[Global.Tree]) extends Global.WorkItem with Product with Serializable
- case class AskScopeCompletionItem(pos: Global.Position, response: Global.Response[List[Global.Member]]) extends Global.WorkItem with Product with Serializable
- class AskToDoFirstItem extends Global.WorkItem
- case class AskTypeAtItem(pos: Global.Position, response: Global.Response[Global.Tree]) extends Global.WorkItem with Product with Serializable
- case class AskTypeCompletionItem(pos: Global.Position, response: Global.Response[List[Global.Member]]) extends Global.WorkItem with Product with Serializable
- case class AskTypeItem(source: SourceFile, forceReload: Boolean, response: Global.Response[Global.Tree]) extends Global.WorkItem with Product with Serializable
- case class FilesDeletedItem(sources: List[SourceFile], response: Global.Response[Unit]) extends Global.WorkItem with Product with Serializable
- abstract class Member extends AnyRef
Info given for every member found by completion
- class NoWorkScheduler extends WorkScheduler
A do-nothing work scheduler that responds immediately with MissingResponse.
A do-nothing work scheduler that responds immediately with MissingResponse.
Used during compiler shutdown.
- case class ReloadItem(sources: List[SourceFile], response: Global.Response[Unit]) extends Global.WorkItem with Product with Serializable
- type Response[T] = interactive.Response[T]
- case class ScopeMember(sym: Global.Symbol, tpe: Global.Type, accessible: Boolean, viaImport: Global.Tree, aliasInfo: Option[Global.ScopeMember] = None) extends Global.Member with Product with Serializable
- case class TypeMember(sym: Global.Symbol, tpe: Global.Type, accessible: Boolean, inherited: Boolean, viaView: Global.Symbol, aliasInfo: Option[Global.ScopeMember] = None) extends Global.Member with Product with Serializable
- abstract class WorkItem extends () => Unit
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- Implicit
- This member is added by an implicit conversion from CompilerControl toany2stringadd[CompilerControl] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
- def ->[B](y: B): (CompilerControl, B)
- Implicit
- This member is added by an implicit conversion from CompilerControl toArrowAssoc[CompilerControl] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def ask[A](op: () => A): A
Asks for a computation to be done quickly on the presentation compiler thread
- def askDocComment(sym: Global.Symbol, source: SourceFile, site: Global.Symbol, fragments: List[(Global.Symbol, SourceFile)], response: Global.Response[(String, String, Global.Position)]): Unit
Sets sync var
response
to doc comment information for a given symbol.Sets sync var
response
to doc comment information for a given symbol.- sym
The symbol whose doc comment should be retrieved (might come from a classfile)
- source
The source file that's supposed to contain the definition
- site
The symbol where 'sym' is observed
- fragments
All symbols that can contribute to the generated documentation together with their source files.
- response
A response that will be set to the following: If
source
contains a definition of a given symbol that has a doc comment, the (expanded, raw, position) triplet for a comment, otherwise ("", "", NoPosition). Note: This operation does not automatically load sources that are not yet loaded.
- def askFilesDeleted(sources: List[SourceFile], response: Global.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. - def askForResponse[A](op: () => A): Global.Response[A]
Asks for a computation to be done on presentation compiler thread, returning a response with the result or an exception
- def askLinkPos(sym: Global.Symbol, source: SourceFile, response: Global.Response[Global.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 loadsource
. Ifsource
is unloaded, it stays that way.
- final def askLoadedTyped(source: SourceFile, response: Global.Response[Global.Tree]): Unit
- def askLoadedTyped(source: SourceFile, keepLoaded: Boolean, response: Global.Response[Global.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.
- keepLoaded
Whether to keep that file in the PC if it was not loaded before. If the file is already loaded, this flag is ignored.
- response
The response, which is set to the fully attributed tree of
source
. If the unit corresponding tosource
has been removed in the meantime the a NoSuchUnitError is raised in the response.
- def askParsedEntered(source: SourceFile, keepLoaded: Boolean, response: Global.Response[Global.Tree]): Unit
Set sync var
response
to the parse tree ofsource
with all top-level symbols entered.Set sync var
response
to the parse tree ofsource
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 isfalse
the operation is run at low priority, only after everything is brought up to date in a regular type checker run.- response
The response.
- def askReload(sources: List[SourceFile], response: Global.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. - def askReset(): Unit
Cancels current compiler run and start a fresh one where everything will be re-typechecked (but not re-loaded).
- def askScopeCompletion(pos: Global.Position, response: Global.Response[List[Global.Member]]): Unit
Sets sync var
response
to list of members that are visible as members of the scope enclosingpos
.Sets sync var
response
to list of members that are visible as members of the scope enclosingpos
.- Note
Pre-condition: source is loaded
- def askShutdown(): Unit
Tells the compile server to shutdown, and not to restart again
- def askStructure(keepSrcLoaded: Boolean)(source: SourceFile, response: Global.Response[Global.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.
- 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.
- def askTypeAt(pos: Global.Position, response: Global.Response[Global.Tree]): Unit
Sets sync var
response
to the smallest fully attributed tree that encloses positionpos
.Sets sync var
response
to the smallest fully attributed tree that encloses positionpos
. Note: Unlike for most other ask... operations, the source file belonging topos
needs not be loaded. - def askTypeCompletion(pos: Global.Position, response: Global.Response[List[Global.Member]]): Unit
Sets sync var
response
to list of members that are visible as members of the tree enclosingpos
, possibly reachable by an implicit.Sets sync var
response
to list of members that are visible as members of the tree enclosingpos
, possibly reachable by an implicit.- Note
Pre-condition: source is loaded
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def doLocateContext(pos: Global.Position): Global.Context
Returns the smallest context that contains given
pos
, throws FatalError if none exists. - def ensuring(cond: (CompilerControl) => Boolean, msg: => Any): CompilerControl
- Implicit
- This member is added by an implicit conversion from CompilerControl toEnsuring[CompilerControl] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: (CompilerControl) => Boolean): CompilerControl
- Implicit
- This member is added by an implicit conversion from CompilerControl toEnsuring[CompilerControl] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean, msg: => Any): CompilerControl
- Implicit
- This member is added by an implicit conversion from CompilerControl toEnsuring[CompilerControl] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean): CompilerControl
- Implicit
- This member is added by an implicit conversion from CompilerControl toEnsuring[CompilerControl] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getUnitOf(s: SourceFile): Option[Global.RichCompilationUnit]
Return the compilation unit attached to a source file, or None if source is not loaded.
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def locateContext(pos: Global.Position): Option[Global.Context]
Locates smallest context that encloses position as an optional value.
- def locateTree(pos: Global.Position): Global.Tree
Locate smallest tree that encloses position
Locate smallest tree that encloses position
- Note
Pre-condition: Position must be loaded
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def onCompilerThread: Boolean
- def onUnitOf[T](source: SourceFile)(op: (Global.RichCompilationUnit) => T): T
Run operation
op
on a compilation unit associated with givensource
.Run operation
op
on a compilation unit associated with givensource
. If source has a loaded compilation unit, this one is passed toop
. Otherwise a new compilation unit is created, but not added to the set of loaded units. - def parseTree(source: SourceFile): Global.Tree
Returns parse tree for source
source
.Returns parse tree for source
source
. No symbols are entered. Syntax errors are reported.This method is thread-safe and as such can safely run outside of the presentation compiler thread.
- def recentlyDeleted(): List[Global.Symbol]
Returns the top level classes and objects that were deleted in the editor since last time recentlyDeleted() was called.
- def removeUnitOf(s: SourceFile): Option[Global.RichCompilationUnit]
Removes the CompilationUnit corresponding to the given SourceFile from consideration for recompilation.
- val 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]
- Annotations
- @volatile()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Deprecated Value Members
- def askDocComment(sym: Global.Symbol, site: Global.Symbol, source: SourceFile, response: Global.Response[(String, String, Global.Position)]): Unit
- Annotations
- @deprecated
- Deprecated
(Since version 2.10.2) Use method that accepts fragments
- def askType(source: SourceFile, forceReload: Boolean, response: Global.Response[Global.Tree]): Unit
Sets sync var
response
to the fully attributed & typechecked tree contained insource
.Sets sync var
response
to the fully attributed & typechecked tree contained insource
.- Annotations
- @deprecated
- Deprecated
(Since version 2.10.1) Use
askLoadedTyped
instead to avoid race conditions in the typechecker- Note
Pre-condition:
,source
needs to be loaded.Deprecated because of race conditions in the typechecker when the background compiler is interrupted while typing the same
source
.- See also
scala/bug#6578
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from CompilerControl toStringFormat[CompilerControl] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.12.16) Use
formatString.format(value)
instead ofvalue.formatted(formatString)
, or use thef""
string interpolator. In Java 15 and later,formatted
resolves to the new method in String which has reversed parameters.
- def →[B](y: B): (CompilerControl, B)
- Implicit
- This member is added by an implicit conversion from CompilerControl toArrowAssoc[CompilerControl] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.
The Scala compiler and reflection APIs.