diff --git a/src/Doc/System/Scala.thy b/src/Doc/System/Scala.thy --- a/src/Doc/System/Scala.thy +++ b/src/Doc/System/Scala.thy @@ -1,125 +1,133 @@ (*:maxLineLen=78:*) theory Scala imports Base begin chapter \Isabelle/Scala development tools\ text \ Isabelle/ML and Isabelle/Scala are the two main language environments for Isabelle tool implementations. There are some basic command-line tools to work with the underlying Java Virtual Machine, the Scala toplevel and compiler. Note that Isabelle/jEdit @{cite "isabelle-jedit"} provides a Scala Console for interactive experimentation within the running application. \ section \Java Runtime Environment within Isabelle \label{sec:tool-java}\ text \ The @{tool_def java} tool is a direct wrapper for the Java Runtime Environment, within the regular Isabelle settings environment (\secref{sec:settings}). The command line arguments are that of the underlying Java version. It is run in \<^verbatim>\-server\ mode if possible, to improve performance (at the cost of extra startup time). The \<^verbatim>\java\ executable is the one within @{setting ISABELLE_JDK_HOME}, according to the standard directory layout for official JDK distributions. The class loader is augmented such that the name space of \<^verbatim>\Isabelle/Pure.jar\ is available, which is the main Isabelle/Scala module. \ section \Scala toplevel \label{sec:tool-scala}\ text \ The @{tool_def scala} tool is a direct wrapper for the Scala toplevel; see also @{tool java} above. The command line arguments are that of the - underlying Scala version. + underlying Scala version. This allows to interact with Isabelle/Scala in TTY + mode. An alternative is to use the \<^verbatim>\Console/Scala\ plugin of Isabelle/jEdit + @{cite "isabelle-jedit"}. +\ - This allows to interact with Isabelle/Scala in TTY mode like this: - @{verbatim [display] -\isabelle scala -scala> isabelle.Isabelle_System.getenv("ISABELLE_HOME") -scala> val options = isabelle.Options.init() -scala> options.bool("browser_info") -scala> options.string("document")\} +subsubsection \Example\ + +text \ + Explore the Isabelle system environment in Scala: + @{scala [display] +\import isabelle._ + +val isabelle_home = Isabelle_System.getenv("ISABELLE_HOME") + +val options = Options.init() +options.bool("browser_info") +options.string("document")\} \ section \Scala compiler \label{sec:tool-scalac}\ text \ The @{tool_def scalac} tool is a direct wrapper for the Scala compiler; see also @{tool scala} above. The command line arguments are that of the underlying Scala version. This allows to compile further Scala modules, depending on existing Isabelle/Scala functionality. The resulting class or jar files can be added to the Java classpath using the \<^verbatim>\classpath\ Bash function that is provided by the Isabelle process environment. Thus add-on components can register themselves in a modular manner, see also \secref{sec:components}. Note that jEdit @{cite "isabelle-jedit"} has its own mechanisms for adding plugin components, which needs special attention since it overrides the standard Java class loader. \ section \Scala script wrapper\ text \ The executable @{executable "$ISABELLE_HOME/bin/isabelle_scala_script"} allows to run Isabelle/Scala source files stand-alone programs, by using a suitable ``hash-bang'' line and executable file permissions. For example: @{verbatim [display] \#!/usr/bin/env isabelle_scala_script val options = isabelle.Options.init() Console.println("browser_info = " + options.bool("browser_info")) Console.println("document = " + options.string("document"))\} This assumes that the executable may be found via the @{setting PATH} from the process environment: this is the case when Isabelle settings are active, e.g.\ in the context of the main Isabelle tool wrapper \secref{sec:isabelle-tool}. Alternatively, the full \<^file>\$ISABELLE_HOME/bin/isabelle_scala_script\ may be specified in expanded form. \ section \Project setup for common Scala IDEs\ text \ The @{tool_def scala_project} tool creates a project configuration for Isabelle/Scala/jEdit: @{verbatim [display] \Usage: isabelle scala_project [OPTIONS] PROJECT_DIR Options are: -L make symlinks to original scala files Setup Gradle project for Isabelle/Scala/jEdit --- to support Scala IDEs such as IntelliJ IDEA.\} The generated configuration is for Gradle\<^footnote>\\<^url>\https://gradle.org\\, but the main purpose is to import it into common Scala IDEs, such as IntelliJ IDEA\<^footnote>\\<^url>\https://www.jetbrains.com/idea\\. This allows to explore the sources with static analysis and other hints in real-time. The specified project directory must not exist yet. The generated files refer to physical file-system locations, using the path notation of the underlying OS platform. Thus the project needs to be recreated whenever the Isabelle installation is changed or moved. \<^medskip> By default, Scala sources are \<^emph>\copied\ from the Isabelle distribution and editing them within the IDE has no permanent effect. Option \<^verbatim>\-L\ produces \<^emph>\symlinks\ to the original files: this allows to develop Isabelle/Scala/jEdit within an external Scala IDE. Note that building the result always requires \<^verbatim>\isabelle jedit -b\ on the command-line. \ end