Class XmlLanguageSupport

All Implemented Interfaces:
LanguageSupport

public class XmlLanguageSupport extends AbstractMarkupLanguageSupport
Language support for XML. Currently supported features include:
  • Squiggle underlining of basic XML structure errors.
  • Usage of XmlOutlineTree, a tree view modeling the XML in the RSyntaxTextArea.
Possible future features include:
  • DTD/Schema validation.
  • Code completion based off of other tags in the XML.
  • Code completion based off of the relevant DTD or schema.
Version:
1.0
See Also:
  • Field Details

    • provider

      private XmlCompletionProvider provider
      The shared completion provider instance for all XML editors.
    • showSyntaxErrors

      private boolean showSyntaxErrors
      Whether syntax errors are squiggle-underlined in the editor.
  • Constructor Details

    • XmlLanguageSupport

      public XmlLanguageSupport()
      Constructor.
  • Method Details

    • createDefaultCompletionCellRenderer

      protected ListCellRenderer<Object> createDefaultCompletionCellRenderer()
      Creates the default cell renderer to use when none is specified. Subclasses can override this method if there is a "better" default renderer for a specific language.
      Overrides:
      createDefaultCompletionCellRenderer in class AbstractLanguageSupport
      Returns:
      The default renderer for the completion list.
    • getProvider

      private XmlCompletionProvider getProvider()
      Lazily creates the shared completion provider instance for XML.
      Returns:
      The completion provider.
    • getParser

      public XmlParser getParser(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
      Returns the XML parser running on a text area with this XML language support installed.
      Parameters:
      textArea - The text area.
      Returns:
      The XML parser. This will be null if the text area does not have this XmlLanguageSupport installed.
    • getShowSyntaxErrors

      public boolean getShowSyntaxErrors()
      Returns whether syntax errors are squiggle-underlined in the editor.
      Returns:
      Whether errors are squiggle-underlined.
      See Also:
    • install

      public void install(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
      Installs this support.
      Parameters:
      textArea - The text area to install onto.
      See Also:
    • installKeyboardShortcuts

      protected void installKeyboardShortcuts(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
      Installs extra keyboard shortcuts supported by this language support. The default implementation maps an action to automatically add closing tags when '>' is pressed; subclasses can override and add additional shortcuts if desired.

      Subclasses should call this method in their LanguageSupport.install(RSyntaxTextArea) methods.

      Overrides:
      installKeyboardShortcuts in class AbstractMarkupLanguageSupport
      Parameters:
      textArea - The text area to install the shortcuts into.
      See Also:
    • setShowSyntaxErrors

      public void setShowSyntaxErrors(boolean show)
      Sets whether syntax errors are squiggle-underlined in the editor.
      Parameters:
      show - Whether syntax errors are squiggle-underlined.
      See Also:
    • shouldAutoCloseTag

      protected boolean shouldAutoCloseTag(String tag)
      Subclasses should override this method to return whether a specified tag should have its closing tag auto-inserted.
      Specified by:
      shouldAutoCloseTag in class AbstractMarkupLanguageSupport
      Parameters:
      tag - The name of the tag to check.
      Returns:
      Whether the tag should have its closing tag auto-inserted.
    • uninstall

      public void uninstall(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
      Uninstalls this support.
      Parameters:
      textArea - The text area to uninstall from.
      See Also:
    • uninstallKeyboardShortcuts

      protected void uninstallKeyboardShortcuts(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
      Uninstalls any keyboard shortcuts specific to this language support.

      Subclasses should call this method in their LanguageSupport.uninstall(RSyntaxTextArea) methods.

      Overrides:
      uninstallKeyboardShortcuts in class AbstractMarkupLanguageSupport
      Parameters:
      textArea - The text area to uninstall the actions from.
      See Also: