Class AntlrProposalConflictHelper

  • All Implemented Interfaces:
    IProposalConflictHelper

    public class AntlrProposalConflictHelper
    extends ProposalConflictHelper

    An implementation that relies on the lexer to detect proposals that conflict with the input in the document.

    A proposal is considered to be conflicting if the lexer would not produce two distinct tokens for the previous sibling and the proposal itself but consume parts of the proposal as part of the first token. Example:

     === Grammar:
      MyParserRule: name=ID other=[MyParserRule];
     === Input:
      MyId|
     

    where | denotes the cursor position. A valid follow token for the parser is the ID of the cross reference. However, since MyIdSomethingElse would be consumed as a single ID by the lexer, the proposal SomethingElse is invalid.

    Since:
    2.10
    Noreference:
    • Constructor Detail

      • AntlrProposalConflictHelper

        public AntlrProposalConflictHelper()
    • Method Detail

      • existsConflict

        public boolean existsConflict​(java.lang.String lastCompleteText,
                                      java.lang.String proposal,
                                      ContentAssistContext context)
        Description copied from class: ProposalConflictHelper
        Returns false if the proposal would corrupt the previous input.
        Specified by:
        existsConflict in class ProposalConflictHelper
        Parameters:
        lastCompleteText - the previous sibling in the input source. Is never null but may be empty. However, the implementation of ProposalConflictHelper.existsConflict(INode, int, String, ContentAssistContext) will not pass empty strings by default but return false instead.
        proposal - a possible proposal string. Is never null.
        context - the current content assist context. Is never null.
        Returns:
        false if the proposal would corrupt the current input.
      • equalTokenSequence

        protected boolean equalTokenSequence​(org.antlr.runtime.TokenSource first,
                                             org.antlr.runtime.TokenSource second)
      • initTokenSources

        protected void initTokenSources​(java.lang.String lastCompleteText,
                                        java.lang.String proposal,
                                        ContentAssistContext context)
      • initTokenSource

        protected void initTokenSource​(java.lang.String text,
                                       org.antlr.runtime.TokenSource tokenSource,
                                       ContentAssistContext context)
      • getProposalLexer

        public org.antlr.runtime.TokenSource getProposalLexer()
      • setProposalLexer

        public void setProposalLexer​(org.eclipse.xtext.parser.antlr.Lexer proposalLexer)
      • getCombinedLexer

        public org.antlr.runtime.TokenSource getCombinedLexer()
      • setCombinedLexer

        public void setCombinedLexer​(org.eclipse.xtext.parser.antlr.Lexer combinedLexer)
      • setLastCompleteLexer

        public void setLastCompleteLexer​(org.eclipse.xtext.parser.antlr.Lexer lastCompleteLexer)
      • getLastCompleteLexer

        public org.antlr.runtime.TokenSource getLastCompleteLexer()