org.eclipse.xtext.ui.editor.contentassist.antlr
Class AntlrProposalConflictHelper
java.lang.Object
org.eclipse.xtext.ui.editor.contentassist.ProposalConflictHelper
org.eclipse.xtext.ui.editor.contentassist.antlr.AntlrProposalConflictHelper
- All Implemented Interfaces:
- IProposalConflictHelper
- Direct Known Subclasses:
- AbstractTemplateProposalConflictHelper
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.
- Author:
- Sebastian Zarnekow - Initial contribution and API
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AntlrProposalConflictHelper
public AntlrProposalConflictHelper()
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(Lexer proposalLexer)
getCombinedLexer
public org.antlr.runtime.TokenSource getCombinedLexer()
setCombinedLexer
public void setCombinedLexer(Lexer combinedLexer)
setLastCompleteLexer
public void setLastCompleteLexer(Lexer lastCompleteLexer)
getLastCompleteLexer
public org.antlr.runtime.TokenSource getLastCompleteLexer()