Class LanguageSupportFactory

  • All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.util.EventListener

    public final class LanguageSupportFactory
    extends java.lang.Object
    implements java.beans.PropertyChangeListener
    Provides language support (code completion, etc.) for programming languages in RSyntaxTextArea. Different languages may have varying levels of "support."
    Version:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static LanguageSupportFactory INSTANCE  
      private static java.lang.String LANGUAGE_SUPPORT_PROPERTY
      Client property set on RSyntaxTextAreas that points to the current language support for that text area.
      private java.util.Map<java.lang.String,​LanguageSupport> styleToSupport
      Maps syntax styles to language supports for them.
      private java.util.Map<java.lang.String,​java.lang.String> styleToSupportClass
      Maps styles to class-names-for-language-supports; this way we can lazily create the LanguageSupports when necessary.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private LanguageSupportFactory()
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addLanguageSupport​(java.lang.String style, java.lang.String lsClassName)
      Adds language support for a language.
      private void createSupportMap()
      Creates the mapping of syntax styles to language supports.
      static LanguageSupportFactory get()
      Returns the singleton instance of this class.
      LanguageSupport getSupportFor​(java.lang.String style)
      Returns the language support for a programming language.
      private void installSupport​(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
      Installs language support on an RSTA depending on its syntax style.
      void propertyChange​(java.beans.PropertyChangeEvent e)
      Listens for RSyntaxTextAreas to change what language they're highlighting, so language support can be updated appropriately.
      void register​(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
      Registers an RSyntaxTextArea to receive language support.
      private void uninstallSupport​(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
      Uninstalls the language support on an RSyntaxTextArea, if any.
      void unregister​(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
      Un-registers an RSyntaxTextArea.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • styleToSupportClass

        private java.util.Map<java.lang.String,​java.lang.String> styleToSupportClass
        Maps styles to class-names-for-language-supports; this way we can lazily create the LanguageSupports when necessary.
      • styleToSupport

        private java.util.Map<java.lang.String,​LanguageSupport> styleToSupport
        Maps syntax styles to language supports for them.
      • LANGUAGE_SUPPORT_PROPERTY

        private static final java.lang.String LANGUAGE_SUPPORT_PROPERTY
        Client property set on RSyntaxTextAreas that points to the current language support for that text area.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LanguageSupportFactory

        private LanguageSupportFactory()
        Constructor.
    • Method Detail

      • addLanguageSupport

        public void addLanguageSupport​(java.lang.String style,
                                       java.lang.String lsClassName)
        Adds language support for a language. This is a hook for applications using this library to add language support for custom languages.
        Parameters:
        style - The language to add support for. This should be one of the values defined in SyntaxConstants. Any previous language support for this language is removed.
        lsClassName - The class name of the LanguageSupport.
      • createSupportMap

        private void createSupportMap()
        Creates the mapping of syntax styles to language supports.
      • get

        public static LanguageSupportFactory get()
        Returns the singleton instance of this class.
        Returns:
        The singleton instance.
      • getSupportFor

        public LanguageSupport getSupportFor​(java.lang.String style)
        Returns the language support for a programming language.
        Parameters:
        style - The language. This should be one of the constants defined in SyntaxConstants.
        Returns:
        The language support, or null if none is registered for the language specified.
      • installSupport

        private void installSupport​(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
        Installs language support on an RSTA depending on its syntax style.
        Parameters:
        textArea - The text area to install language support on.
        See Also:
        uninstallSupport(RSyntaxTextArea)
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent e)
        Listens for RSyntaxTextAreas to change what language they're highlighting, so language support can be updated appropriately.
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
        Parameters:
        e - The event.
      • register

        public void register​(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
        Registers an RSyntaxTextArea to receive language support. The text area will get support for the currently highlighted language, and if it changes what language it is highlighting, the support will change as appropriate.
        Parameters:
        textArea - The text area to register.
      • uninstallSupport

        private void uninstallSupport​(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
        Uninstalls the language support on an RSyntaxTextArea, if any.
        Parameters:
        textArea - The text area.
        See Also:
        installSupport(RSyntaxTextArea)
      • unregister

        public void unregister​(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
        Un-registers an RSyntaxTextArea. This removes any language support on it.
        Parameters:
        textArea - The text area.
        See Also:
        register(RSyntaxTextArea)