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:
  • Field Details

  • Constructor Details

    • JavaScriptLanguageSupport

      public JavaScriptLanguageSupport()
  • Method Details

    • createJarManager

      protected JarManager createJarManager()
      Creates a jar manager instance for used in JS language support.
      Returns:
      The jar manager instance.
    • setECMAVersion

      public void setECMAVersion(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 of JavaScriptCompletionProvider.
      Returns:
      The provider.
    • getDefaultJsHintRCFile

      public File getDefaultJsHintRCFile()
      Returns the location of the .jshintrc file 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 if getErrorParser() does not return JsErrorParser.JSHINT.
      Returns:
      The .jshintrc file, or null if none; in that case, the JsHint defaults will be used.
      See Also:
    • 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:
    • 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 to JsErrorParser.RHINO.
      Returns:
      The JS version. This should be one of the VERSION_xxx constants in Rhino's Context class. If this is set to a value unknown to Rhino, then Rhino's default value is used (VERSION_DEFAULT).
      See Also:
    • 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 null if the text area does not have this JavaScriptLanguageSupport installed.
    • install

      public void install(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
      Description copied from interface: LanguageSupport
      Installs 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 to JsErrorParser.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 to JsErrorParser.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 to JsErrorParser.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 to JsErrorParser.RHINO.
      Parameters:
      client - True if client mode is supported.
      See Also:
    • setDefaultJsHintRCFile

      public boolean setDefaultJsHintRCFile(File file)
      Sets the location of the .jshintrc file 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 if getErrorParser() does not return JsErrorParser.JSHINT.
      Parameters:
      file - The .jshintrc file, or null if 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

      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 be null.
      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 to JsErrorParser.RHINO.
      Parameters:
      languageVersion - The JS version. This should be one of the VERSION_xxx constants in Rhino's Context class. 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 to JsErrorParser.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 to JsErrorParser.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: LanguageSupport
      Uninstalls 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.