Class FoldParserManager

  • All Implemented Interfaces:
    SyntaxConstants

    public final class FoldParserManager
    extends java.lang.Object
    implements SyntaxConstants
    Manages fold parsers. Instances of RSyntaxTextArea call into this class to retrieve fold parsers for whatever language they're editing. Folks implementing custom languages can add a FoldParser implementation for their language to this manager and it will be used by RSTA.
    Version:
    1.0
    • Field Detail

      • foldParserMap

        private java.util.Map<java.lang.String,​FoldParser> foldParserMap
        Map from syntax styles to fold parsers.
    • Constructor Detail

      • FoldParserManager

        private FoldParserManager()
        Private constructor to prevent instantiation.
    • Method Detail

      • addFoldParserMapping

        public void addFoldParserMapping​(java.lang.String syntaxStyle,
                                         FoldParser parser)
        Adds a mapping from a syntax style to a fold parser. The parser specified will be shared among all RSTA instances editing that language, so it should be stateless (which should not be difficult for a fold parser). You can also override the fold parser for built-in languages, such as SYNTAX_STYLE_JAVA, with your own parser implementations.
        Parameters:
        syntaxStyle - The syntax style.
        parser - The parser.
        See Also:
        SyntaxConstants
      • createFoldParserMap

        private java.util.Map<java.lang.String,​FoldParser> createFoldParserMap()
        Creates the syntax style-to-fold parser mapping for built-in languages.
        Returns:
        The style-to-fold parser mapping.
      • get

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

        public FoldParser getFoldParser​(java.lang.String syntaxStyle)
        Returns a fold parser to use for an editor highlighting code of a specific language.
        Parameters:
        syntaxStyle - A value from SyntaxConstants, such as SYNTAX_STYLE_JAVA.
        Returns:
        A fold parser to use, or null if none is registered for the language.