Class JavaScriptLanguageSupport
java.lang.Object
org.fife.rsta.ac.AbstractLanguageSupport
org.fife.rsta.ac.js.JavaScriptLanguageSupport
- All Implemented Interfaces:
LanguageSupport
Language support for JavaScript. This requires Rhino, which is included with
this library.
- Version:
- 1.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classManages information about the parsing/auto-completion for a single text area.private classA hack ofAutoCompletionthat forces the parser to re-parse the document when the user presses Ctrl+space.private classListens for various events in a text area editing Java (in particular, caret events, so we can track the "active" code block). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate Fileprivate JsErrorParserprivate JarManagerprivate intprivate JavaScriptParserMapsJavaScriptParsers toInfoinstances about them.private static final StringClient property installed on text areas that points to a listener.private JavaScriptCompletionProviderprivate booleanprivate booleanFields inherited from interface LanguageSupport
PROPERTY_LANGUAGE_PARSER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected JarManagerCreates a jar manager instance for used in JS language support.protected JavaScriptCompletionProviderCreates the provider to use for an RSTA instance editing JavaScript.Returns the location of the.jshintrcfile to use if using JsHint as your error parser, and no .jshintrc file is found in the current file's folder hierarchy.Returns the engine to use for checking for syntax errors in JavaScript files.intintSets the JS version to use when parsing the code.getParser(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea) Returns the JS parser running on a text area with this JavaScript language support installed.voidinstall(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea) Installs this support.private voidinstallKeyboardShortcuts(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea) Installs extra keyboard shortcuts supported by this language support.booleanisClient()Returns whether this JavaScript support supports client/browser objects.booleanReturns whether strict mode (more warnings are detected) is enabled.booleanReturns whether E4X is supported in parsed JavaScript.protected voidreparseDocument(int offset) voidsetClient(boolean client) Set whether the JavaScript support supports client/browser objects.booleansetDefaultJsHintRCFile(File file) Sets the location of the.jshintrcfile to use if using JsHint as your error parser, and no .jshintrc file is found in the current file's folder hierarchy.voidsetECMAVersion(String version, JarManager jarManager) booleansetErrorParser(JsErrorParser errorParser) Sets the engine to use for identifying syntax errors in JavaScript files.voidsetLanguageVersion(int languageVersion) Sets the JS version to use when parsing the code.booleansetStrictMode(boolean strict) Sets whether strict mode (more warnings are detected) is enabled.booleansetXmlAvailable(boolean available) Sets whether E4X is supported in parsed JavaScript.voiduninstall(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea) Uninstalls this support.private voiduninstallKeyboardShortcuts(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea) Uninstalls any keyboard shortcuts specific to this language support.Methods inherited from class AbstractLanguageSupport
createAutoCompletion, createDefaultCompletionCellRenderer, getAutoActivationDelay, getAutoCompletionFor, getDefaultCompletionCellRenderer, getShowDescWindow, getTextAreas, installImpl, isAutoActivationEnabled, isAutoCompleteEnabled, isParameterAssistanceEnabled, setAutoActivationDelay, setAutoActivationEnabled, setAutoCompleteEnabled, setDefaultCompletionCellRenderer, setParameterAssistanceEnabled, setShowDescWindow, uninstallImpl
-
Field Details
-
parserToInfoMap
MapsJavaScriptParsers toInfoinstances about them. -
jarManager
-
xmlAvailable
private boolean xmlAvailable -
client
private boolean client -
strictMode
private boolean strictMode -
languageVersion
private int languageVersion -
errorParser
-
parser
-
provider
-
defaultJshintrc
-
PROPERTY_LISTENER
Client property installed on text areas that points to a listener.- See Also:
-
-
Constructor Details
-
JavaScriptLanguageSupport
public JavaScriptLanguageSupport()
-
-
Method Details
-
createJarManager
Creates a jar manager instance for used in JS language support.- Returns:
- The jar manager instance.
-
setECMAVersion
-
createJavaScriptCompletionProvider
Creates the provider to use for an RSTA instance editing JavaScript. Subclasses can override to return custom subclasses ofJavaScriptCompletionProvider.- Returns:
- The provider.
-
getDefaultJsHintRCFile
Returns the location of the.jshintrcfile to use if using JsHint as your error parser, and no .jshintrc file is found in the current file's folder hierarchy. This property is ignored ifgetErrorParser()does not returnJsErrorParser.JSHINT.- Returns:
- The
.jshintrcfile, ornullif none; in that case, the JsHint defaults will be used. - See Also:
-
getErrorParser
Returns the engine to use for checking for syntax errors in JavaScript files. Note that regardless of the value specified to this method, Rhino is always used for code completion and the outline tree.- Returns:
- The engine.
- See Also:
-
getJarManager
-
getJavaScriptParser
-
getJsHintIndent
public int getJsHintIndent() -
getLanguageVersion
public int getLanguageVersion()Sets the JS version to use when parsing the code. This parameter is ignored if the error parser is set toJsErrorParser.RHINO.- Returns:
- The JS version. This should be one of the
VERSION_xxxconstants in Rhino'sContextclass. If this is set to a value unknown to Rhino, then Rhino's default value is used (VERSION_DEFAULT). - See Also:
-
getParser
Returns the JS parser running on a text area with this JavaScript language support installed.- Parameters:
textArea- The text area.- Returns:
- The JS parser. This will be
nullif the text area does not have thisJavaScriptLanguageSupportinstalled.
-
install
public void install(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea) Description copied from interface:LanguageSupportInstalls this support.- Parameters:
textArea- The text area to install onto.- See Also:
-
installKeyboardShortcuts
private void installKeyboardShortcuts(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea) Installs extra keyboard shortcuts supported by this language support.- Parameters:
textArea- The text area to install the shortcuts into.
-
isStrictMode
public boolean isStrictMode()Returns whether strict mode (more warnings are detected) is enabled. This parameter is ignored if the error parser is set toJsErrorParser.RHINO.- Returns:
- Whether strict mode is enabled.
- See Also:
-
isXmlAvailable
public boolean isXmlAvailable()Returns whether E4X is supported in parsed JavaScript. This parameter is ignored if the error parser is set toJsErrorParser.RHINO.- Returns:
- Whether E4X is supported.
- See Also:
-
isClient
public boolean isClient()Returns whether this JavaScript support supports client/browser objects. This parameter is ignored if the error parser is set toJsErrorParser.RHINO.- Returns:
- Whether the JavaScript support supports client/browser objects.
- See Also:
-
reparseDocument
protected void reparseDocument(int offset) -
setClient
public void setClient(boolean client) Set whether the JavaScript support supports client/browser objects. This parameter is ignored if the error parser is set toJsErrorParser.RHINO.- Parameters:
client- True if client mode is supported.- See Also:
-
setDefaultJsHintRCFile
Sets the location of the.jshintrcfile to use if using JsHint as your error parser, and no .jshintrc file is found in the current file's folder hierarchy. This property is ignored ifgetErrorParser()does not returnJsErrorParser.JSHINT.- Parameters:
file- The.jshintrcfile, ornullif none; in that case, the JsHint defaults will be used.- Returns:
- Whether the new .jshintrc file is different from the original one.
- See Also:
-
setErrorParser
Sets the engine to use for identifying syntax errors in JavaScript files. Note that regardless of the value specified to this method, Rhino is always used for code completion and the outline tree.- Parameters:
errorParser- The engine to use. This cannot benull.- Returns:
- Whether this was actually a new error parser.
- See Also:
-
setLanguageVersion
public void setLanguageVersion(int languageVersion) Sets the JS version to use when parsing the code. This parameter is ignored if the error parser is set toJsErrorParser.RHINO.- Parameters:
languageVersion- The JS version. This should be one of theVERSION_xxxconstants in Rhino'sContextclass. If this is set to a value less than zero, then ES6 is used (VERSION_ES6).- See Also:
-
setStrictMode
public boolean setStrictMode(boolean strict) Sets whether strict mode (more warnings are detected) is enabled. This parameter is ignored if the error parser is set toJsErrorParser.RHINO.- Parameters:
strict- Whether strict mode is enabled.- Returns:
- Whether a new value was actually set for this property.
- See Also:
-
setXmlAvailable
public boolean setXmlAvailable(boolean available) Sets whether E4X is supported in parsed JavaScript. This parameter is ignored if the error parser is set toJsErrorParser.RHINO.- Parameters:
available- Whether E4X is supported.- Returns:
- Whether a new value was actually set for this property.
- See Also:
-
uninstall
public void uninstall(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea) Description copied from interface:LanguageSupportUninstalls this support.- Parameters:
textArea- The text area to uninstall from.- See Also:
-
uninstallKeyboardShortcuts
private void uninstallKeyboardShortcuts(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea) Uninstalls any keyboard shortcuts specific to this language support.- Parameters:
textArea- The text area to uninstall the actions from.
-