Package org.fife.rsta.ac.js
Class JavaScriptLanguageSupport
- java.lang.Object
-
- org.fife.rsta.ac.AbstractLanguageSupport
-
- org.fife.rsta.ac.js.JavaScriptLanguageSupport
-
- All Implemented Interfaces:
LanguageSupport
public class JavaScriptLanguageSupport extends AbstractLanguageSupport
Language support for JavaScript. This requires Rhino, which is included with this library.- Version:
- 1.0
- See Also:
JavaScriptOutlineTree
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classJavaScriptLanguageSupport.DeepestScopeVisitorprivate static classJavaScriptLanguageSupport.InfoManages information about the parsing/auto-completion for a single text area.private classJavaScriptLanguageSupport.JavaScriptAutoCompletionA hack ofAutoCompletionthat forces the parser to re-parse the document when the user presses Ctrl+space.private classJavaScriptLanguageSupport.ListenerListens for various events in a text area editing Java (in particular, caret events, so we can track the "active" code block).
-
Field Summary
Fields Modifier and Type Field Description private booleanclientprivate java.io.FiledefaultJshintrcprivate JsErrorParsererrorParserprivate JarManagerjarManagerprivate intlanguageVersionprivate JavaScriptParserparserprivate java.util.Map<JavaScriptParser,JavaScriptLanguageSupport.Info>parserToInfoMapMapsJavaScriptParsers toInfoinstances about them.private static java.lang.StringPROPERTY_LISTENERClient property installed on text areas that points to a listener.private JavaScriptCompletionProviderproviderprivate booleanstrictModeprivate booleanxmlAvailable-
Fields inherited from interface org.fife.rsta.ac.LanguageSupport
PROPERTY_LANGUAGE_PARSER
-
-
Constructor Summary
Constructors Constructor Description JavaScriptLanguageSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected JarManagercreateJarManager()Creates a jar manager instance for used in JS language support.protected JavaScriptCompletionProvidercreateJavaScriptCompletionProvider()Creates the provider to use for an RSTA instance editing JavaScript.java.io.FilegetDefaultJsHintRCFile()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.JsErrorParsergetErrorParser()Returns the engine to use for checking for syntax errors in JavaScript files.JarManagergetJarManager()JavaScriptParsergetJavaScriptParser()intgetJsHintIndent()intgetLanguageVersion()Sets the JS version to use when parsing the code.JavaScriptParsergetParser(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.booleanisStrictMode()Returns whether strict mode (more warnings are detected) is enabled.booleanisXmlAvailable()Returns whether E4X is supported in parsed JavaScript.protected voidreparseDocument(int offset)voidsetClient(boolean client)Set whether the JavaScript support supports client/browser objects.booleansetDefaultJsHintRCFile(java.io.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(java.lang.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 org.fife.rsta.ac.AbstractLanguageSupport
createAutoCompletion, createDefaultCompletionCellRenderer, getAutoActivationDelay, getAutoCompletionFor, getDefaultCompletionCellRenderer, getShowDescWindow, getTextAreas, installImpl, isAutoActivationEnabled, isAutoCompleteEnabled, isParameterAssistanceEnabled, setAutoActivationDelay, setAutoActivationEnabled, setAutoCompleteEnabled, setDefaultCompletionCellRenderer, setParameterAssistanceEnabled, setShowDescWindow, uninstallImpl
-
-
-
-
Field Detail
-
parserToInfoMap
private java.util.Map<JavaScriptParser,JavaScriptLanguageSupport.Info> parserToInfoMap
MapsJavaScriptParsers toInfoinstances about them.
-
jarManager
private JarManager jarManager
-
xmlAvailable
private boolean xmlAvailable
-
client
private boolean client
-
strictMode
private boolean strictMode
-
languageVersion
private int languageVersion
-
errorParser
private JsErrorParser errorParser
-
parser
private JavaScriptParser parser
-
provider
private JavaScriptCompletionProvider provider
-
defaultJshintrc
private java.io.File defaultJshintrc
-
PROPERTY_LISTENER
private static final java.lang.String PROPERTY_LISTENER
Client property installed on text areas that points to a listener.- See Also:
- Constant Field Values
-
-
Method Detail
-
createJarManager
protected JarManager createJarManager()
Creates a jar manager instance for used in JS language support.- Returns:
- The jar manager instance.
-
setECMAVersion
public void setECMAVersion(java.lang.String version, JarManager jarManager)
-
createJavaScriptCompletionProvider
protected JavaScriptCompletionProvider createJavaScriptCompletionProvider()
Creates the provider to use for an RSTA instance editing JavaScript. Subclasses can override to return custom subclasses ofJavaScriptCompletionProvider.- Returns:
- The provider.
-
getDefaultJsHintRCFile
public java.io.File 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:
setErrorParser(JsErrorParser)
-
getErrorParser
public JsErrorParser 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:
setErrorParser(JsErrorParser)
-
getJarManager
public JarManager getJarManager()
-
getJavaScriptParser
public JavaScriptParser 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:
setLanguageVersion(int)
-
getParser
public JavaScriptParser getParser(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
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:
LanguageSupport.uninstall(RSyntaxTextArea)
-
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:
setStrictMode(boolean)
-
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:
setXmlAvailable(boolean)
-
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:
setClient(boolean)
-
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:
isClient()
-
setDefaultJsHintRCFile
public boolean setDefaultJsHintRCFile(java.io.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. 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:
getDefaultJsHintRCFile(),setErrorParser(JsErrorParser)
-
setErrorParser
public boolean setErrorParser(JsErrorParser errorParser)
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:
getErrorParser()
-
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:
getLanguageVersion()
-
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:
isStrictMode()
-
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:
isXmlAvailable()
-
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:
LanguageSupport.install(RSyntaxTextArea)
-
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.
-
-