Class AbstractTokenHighlighting

  • Direct Known Subclasses:
    QlInBslTokenHighlighting

    public abstract class AbstractTokenHighlighting
    extends Object
    Abstract class for highlighting one xtext language in string literals of other xtext language
    • Field Detail

      • startPos

        protected int startPos
      • tokens

        protected org.antlr.runtime.TokenStream tokens
    • Constructor Detail

      • AbstractTokenHighlighting

        public AbstractTokenHighlighting()
        Empty constructor
      • AbstractTokenHighlighting

        public AbstractTokenHighlighting​(String text,
                                         int startPos)
        Constructor
        Parameters:
        text - highlighting text. Can't be null
        startPos - the beginning position of highlighting text
    • Method Detail

      • getSourceText

        public String getSourceText()
        Gets source text
        Returns:
        source text, can't be null
      • updateSourceData

        public void updateSourceData​(String text,
                                     int startPos)
        Updates highlighting text
        Parameters:
        text - highlighting text. Can't be null
        startPos - the beginning position of highlighting text
      • startHighlighting

        public int startHighlighting​(org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor highlightingAcceptor,
                                     String defaultColorId)
        Starts highlighting calculation
        Parameters:
        highlightingAcceptor - IHighlightedPositionAcceptor from any xtext language
        defaultColorId - default color id for highlighting common tokens, can't be null
        Returns:
        number of highlighting tokens
      • getActualTokenStream

        protected abstract org.eclipse.xtext.parser.antlr.XtextTokenStream getActualTokenStream​(String text)
        Initialize token stream - creates TokenStream for highlighting language
        Parameters:
        text - initial text for highlighting tokens
        Returns:
        created TokenStream, can't be null
      • getDiscardTokenTypes

        protected abstract int[] getDiscardTokenTypes()
        Gets discard token types
        Returns:
        array of discard token types or empty array
      • getColorIdByTokenType

        protected abstract String getColorIdByTokenType​(int type,
                                                        String defaultColorId)
        Get color id for highlighting token by its type
        Parameters:
        type - type of the token
        defaultColorId - default color id, can't be null
        Returns:
        color id by type, can't be null