Class DefaultScriptLanguage
java.lang.Object
qupath.lib.scripting.languages.ScriptLanguage
qupath.lib.gui.scripting.languages.DefaultScriptLanguage
- All Implemented Interfaces:
ExecutableLanguage
- Direct Known Subclasses:
GroovyLanguage
Default implementation for a
ScriptLanguage
, based on a ScriptEngine
.- Since:
- v0.4.0
- Author:
- Melvin Gelbard, Pete Bankhead
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
Interface defining how the import statements should be generated for the language. -
Field Summary
Modifier and TypeFieldDescriptionprotected static final DefaultScriptLanguage.ImportStatementGenerator
Java-like import statementsprotected static final DefaultScriptLanguage.ImportStatementGenerator
Pythonic import statements -
Constructor Summary
ConstructorDescriptionDefaultScriptLanguage
(String name, Collection<String> exts, ScriptAutoCompletor completor) Constructor for aExecutableLanguage
.DefaultScriptLanguage
(ScriptEngineFactory factory) Constructor for aExecutableLanguage
based on aScriptEngineFactory
. -
Method Summary
Modifier and TypeMethodDescriptionprotected ScriptContext
createContext
(ScriptParameters params) Create aScriptContext
containing information from theScriptParameters
.execute
(ScriptParameters params) Execute the given script String.Get theScriptAutoCompletor
object that takes care of this language's auto-completion.protected ScriptAutoCompletor
getDefaultAutoCompletor
(String languageName) Default method to get a suitable auto completor for the given language name.protected String
getImportStatements
(Collection<Class<?>> classes) Get the import statements as a String, to add at the beginning of the executed script.getStaticImportStatements
(Collection<Class<?>> classes) Get the static import statements as a String, to add at the beginning of the executed script.protected String
tryToInterpretMessage
(Throwable cause, int line, boolean defaultImportsAvailable) Methods inherited from class qupath.lib.scripting.languages.ScriptLanguage
getExtensions, getName, toString
-
Field Details
-
JAVA_IMPORTER
Java-like import statements -
PYTHON_IMPORTER
Pythonic import statements
-
-
Constructor Details
-
DefaultScriptLanguage
Constructor for aExecutableLanguage
based on aScriptEngineFactory
.Note: the scriptEngine is not stored within this class. It is always fetched via
ScriptLanguageProvider
.- Parameters:
factory
-
-
DefaultScriptLanguage
Constructor for aExecutableLanguage
.Note: the scriptEngine is not stored within this class. It is always fetched via
ScriptLanguageProvider
.- Parameters:
name
- the language nameexts
- the possible extensions for this languagecompletor
- the auto-completion object for this language
-
-
Method Details
-
getDefaultAutoCompletor
Default method to get a suitable auto completor for the given language name.- Parameters:
languageName
-- Returns:
-
execute
Description copied from interface:ExecutableLanguage
Execute the given script String.- Specified by:
execute
in interfaceExecutableLanguage
- Parameters:
params
-- Returns:
- Throws:
ScriptException
-
tryToInterpretMessage
-
getDefaultScriptName
-
createContext
Create aScriptContext
containing information from theScriptParameters
.- Parameters:
params
-- Returns:
-
getAutoCompletor
Description copied from class:ScriptLanguage
Get theScriptAutoCompletor
object that takes care of this language's auto-completion.Can return
null
if the script editor should not handle auto-completion for this language.- Overrides:
getAutoCompletor
in classScriptLanguage
- Returns:
- auto-completor
-
getImportStatements
Get the import statements as a String, to add at the beginning of the executed script.- Parameters:
classes
- a collection of the classes to import- Returns:
- import string
-
getStaticImportStatements
Get the static import statements as a String, to add at the beginning of the executed script.- Parameters:
classes
- a collection of classes to import as static classes- Returns:
- import string
-
getImportStatementGenerator
Get anDefaultScriptLanguage.ImportStatementGenerator
. This attempts to make an educated guess, returning JAVA_IMPORTER or PYTHON_IMPORTER based on the name- Returns:
-