CompilerBase

trait CompilerBase[N, T <: N, C <: Config] extends ServerWithConfig[N, T, C]

Trait to provide basic functionality for a compiler-like program constructed from phases, including profiling and timing support. N is the syntax tree node type used by this compiler. T is the type of the syntax tree communicated from the parser to the main processing of the compiler. C is the type of the configuration.

Trait to provide basic functionality for a compiler-like program constructed from phases, including profiling and timing support. N is the syntax tree node type used by this compiler. T is the type of the syntax tree communicated from the parser to the main processing of the compiler. C is the type of the configuration.

trait ServerWithConfig[N, T, C]
class Object
trait Matchable
class Any
trait CompilerWithConfig[N, T, C]
trait Compiler[N, T]

Type members

Classlikes

case class TreeAction(name: String, uri: String, from: N, to: String)

A representation of a simple named code action that replaces a tree node with other text.

A representation of a simple named code action that replaces a tree node with other text.

Inherited classlikes

case class RangePair(sstart: Int, send: Int, tstart: Int, tend: Int)
Inherited from
ServerWithConfig

Value members

Abstract methods

def createConfig(args: Seq[String]): C

Create the configuration for a particular run of the compiler. Override this if you have a custom configuration for your compiler.

Create the configuration for a particular run of the compiler. Override this if you have a custom configuration for your compiler.

def format(ast: T): Document

Format an abstract syntax tree for printing. Default: return an empty document.

Format an abstract syntax tree for printing. Default: return an empty document.

def makeast(source: Source, config: C): Either[T, Messages]

Make the contents of the given source, returning the AST wrapped in Left. Return Right with messages if an AST cannot be made. config provides access to all aspects of the configuration.

Make the contents of the given source, returning the AST wrapped in Left. Return Right with messages if an AST cannot be made. config provides access to all aspects of the configuration.

def name: String

The name of the language that this compiler processes. The best choice is the extension used for files containing this language.

The name of the language that this compiler processes. The best choice is the extension used for files containing this language.

def process(source: Source, ast: T, config: C): Unit

Function to process the input that was parsed. source is the input text processed by the compiler. ast is the abstract syntax tree produced by the parser from that text. config provides access to all aspects of the configuration.

Function to process the input that was parsed. source is the input text processed by the compiler. ast is the abstract syntax tree produced by the parser from that text. config provides access to all aspects of the configuration.

Concrete methods

def clearSemanticMessages(source: Source, config: C): Unit

Clear any previously reported semantic messages. By default, do nothing.

Clear any previously reported semantic messages. By default, do nothing.

def clearSyntacticMessages(source: Source, config: C): Unit

Clear any previously reported semantic messages. By default, clear the servers's source and sourcetree products.

Clear any previously reported semantic messages. By default, clear the servers's source and sourcetree products.

def compileFile(filename: String, config: C, encoding: String): Unit

Compile input from a file. The character encoding of the file is given by the encoding argument (default: UTF-8).

Compile input from a file. The character encoding of the file is given by the encoding argument (default: UTF-8).

def compileFiles(config: C): Unit

Compile the files one by one.

Compile the files one by one.

def compileSource(source: Source, config: C): Unit

Compile the given source by using makeast to turn its contents into an abstract syntax tree and then by process which conducts arbitrary processing on the AST. If makeast produces messages, report them.

Compile the given source by using makeast to turn its contents into an abstract syntax tree and then by process which conducts arbitrary processing on the AST. If makeast produces messages, report them.

def compileString(name: String, input: String, config: C): Unit

Compile input from a string.

Compile input from a string.

def createAndInitConfig(args: Seq[String]): Either[String, C]

Create and initialise the configuration for a particular run of the compiler. Default: call createConfig and then initialise the resulting configuration. Returns either the created configuration or an error message describing why the configuration couldn't be created.

Create and initialise the configuration for a particular run of the compiler. Default: call createConfig and then initialise the resulting configuration. Returns either the created configuration or an error message describing why the configuration couldn't be created.

def driver(args: Seq[String]): Unit

Command-line driver for this compiler. First, use the argument list to create a configuration for this execution. Then, use the configuration to run the file compilation in the appropriate way.

Command-line driver for this compiler. First, use the argument list to create a configuration for this execution. Then, use the configuration to run the file compilation in the appropriate way.

def getCodeActions(position: Position): Option[Vector[TreeAction]]

Return applicable code actions for the given position (if any). Each action is in terms of an old tree node and a new node that replaces it. Default is to return no actions.

Return applicable code actions for the given position (if any). Each action is in terms of an old tree node and a new node that replaces it. Default is to return no actions.

def getDefinition(position: Position): Option[N]

Return the corresponding definition node for the given position (if any). Default is to never return anything.

Return the corresponding definition node for the given position (if any). Default is to never return anything.

def getFormatted(source: Source): Option[String]

Return a formatted version of the whole of the given source. By default, return None meaning there is no formatter.

Return a formatted version of the whole of the given source. By default, return None meaning there is no formatter.

def getHover(position: Position): Option[String]

Return markdown hover markup for the given position (if any). Default is to never return anything.

Return markdown hover markup for the given position (if any). Default is to never return anything.

def getReferences(position: Position, includeDecl: Boolean): Option[Vector[N]]

Return the corresponding reference nodes (uses) of the symbol at the given position (if any). If includeDecl is true, also include the declaration of the symbol. Default is to never return anything.

Return the corresponding reference nodes (uses) of the symbol at the given position (if any). If includeDecl is true, also include the declaration of the symbol. Default is to never return anything.

def getSymbols(source: Source): Option[Vector[DocumentSymbol]]

Return the symbols frmo a compilation unit. Default is to return no symbols.

Return the symbols frmo a compilation unit. Default is to return no symbols.

def main(args: Array[String]): Unit

The entry point for this compiler.

The entry point for this compiler.

def publishSourceProduct(source: Source, document: => Document): Unit
def publishSourceTreeProduct(source: Source, document: => Document): Unit
def report(source: Source, messages: Messages, config: C): Unit

Output the messages in order of position to the configuration's output.

Output the messages in order of position to the configuration's output.

def run(config: C): Unit

Run the compiler given a configuration.

Run the compiler given a configuration.

Inherited methods

def clearDiagnostics(name: String): Unit
Inherited from
ServerWithConfig
def connect(aClient: Client): Unit
Inherited from
ServerWithConfig
def convertPosition(optPos: Option[Position]): Position
Inherited from
ServerWithConfig
def convertRange(optStart: Option[Position], optFinish: Option[Position]): Range
Inherited from
ServerWithConfig
def convertSeverity(severity: Severity): DiagnosticSeverity
Inherited from
ServerWithConfig
def launch(config: C): Unit
Inherited from
ServerWithConfig
def locationOfNode(node: N): Location
Inherited from
ServerWithConfig
def logMessage(msg: String): Unit
Inherited from
ServerWithConfig
def messageToDiagnostic(message: Message): Diagnostic
Inherited from
ServerWithConfig
def pairsToMap(pairs: List[RangePair], key: RangePair => OffsetRange, value: RangePair => OffsetRange): Array[RangeEntry]
Inherited from
ServerWithConfig
def positionOfStartFinish(optStart: Option[Position], optFinish: Option[Position]): Option[(Int, Int)]
Inherited from
ServerWithConfig
def positionsOfDocument(document: Document): List[RangePair]
Inherited from
ServerWithConfig
def publishDiagnostics(name: String, diagnostics: Vector[Diagnostic]): Unit
Inherited from
ServerWithConfig
def publishMessages(messages: Messages): Unit
Inherited from
ServerWithConfig
def publishProduct(source: Source, name: String, language: String, document: Document, append: Boolean): Unit
Inherited from
ServerWithConfig
def publishProductStr(source: Source, name: String, language: String, message: String, append: Boolean): Unit
Inherited from
ServerWithConfig
def rangeOfNode(node: N): Range
Inherited from
ServerWithConfig
def registerCapability(id: String, method: String, options: Object): Unit
Inherited from
ServerWithConfig
def setSettings(settings: Object): Unit
Inherited from
ServerWithConfig
def setSettings(settings: JsonObject): Unit
Inherited from
ServerWithConfig
def setting[V](key: String, get: JsonElement => V, default: V): V
Inherited from
ServerWithConfig
def settingArray(key: String, default: JsonArray): JsonArray
Inherited from
ServerWithConfig
def settingBool(key: String, default: Boolean): Boolean
Inherited from
ServerWithConfig
def settingInt(key: String, default: Int): Int
Inherited from
ServerWithConfig
def settingStr(key: String, default: String): String
Inherited from
ServerWithConfig
def settings(): JsonObject
Inherited from
ServerWithConfig
def showMessage(tipe: MessageType, msg: String): Unit
Inherited from
ServerWithConfig
def sortBySourceRangeSize(pairs: Array[RangeEntry]): Array[RangeEntry]
Inherited from
ServerWithConfig

Concrete fields

val messaging: Messaging

The messaging facilitiy used by this compiler.

The messaging facilitiy used by this compiler.

val positions: Positions

The position store used by this compiler.

The position store used by this compiler.

val sources: Map[String, Source]

The sources previously used by the semantic analysis phase of this compiler, indexed by source name.

The sources previously used by the semantic analysis phase of this compiler, indexed by source name.