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.
IProposalConflictHelper.NullHelper
Constructor and Description |
---|
AntlrProposalConflictHelper() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
equalTokenSequence(org.antlr.runtime.TokenSource first,
org.antlr.runtime.TokenSource second) |
boolean |
existsConflict(java.lang.String lastCompleteText,
java.lang.String proposal,
ContentAssistContext context)
Returns
false if the proposal would corrupt the previous
input. |
org.antlr.runtime.TokenSource |
getCombinedLexer() |
org.antlr.runtime.TokenSource |
getLastCompleteLexer() |
org.antlr.runtime.TokenSource |
getProposalLexer() |
protected void |
initTokenSource(java.lang.String text,
org.antlr.runtime.TokenSource tokenSource,
ContentAssistContext context) |
protected void |
initTokenSources(java.lang.String lastCompleteText,
java.lang.String proposal,
ContentAssistContext context) |
void |
setCombinedLexer(Lexer combinedLexer) |
void |
setLastCompleteLexer(Lexer lastCompleteLexer) |
void |
setProposalLexer(Lexer proposalLexer) |
existsConflict, existsConflict
public boolean existsConflict(java.lang.String lastCompleteText, java.lang.String proposal, ContentAssistContext context)
ProposalConflictHelper
false
if the proposal would corrupt the previous
input.existsConflict
in class ProposalConflictHelper
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
.false
if the proposal would corrupt the current input.protected boolean equalTokenSequence(org.antlr.runtime.TokenSource first, org.antlr.runtime.TokenSource second)
protected void initTokenSources(java.lang.String lastCompleteText, java.lang.String proposal, ContentAssistContext context)
protected void initTokenSource(java.lang.String text, org.antlr.runtime.TokenSource tokenSource, ContentAssistContext context)
public org.antlr.runtime.TokenSource getProposalLexer()
public void setProposalLexer(Lexer proposalLexer)
public org.antlr.runtime.TokenSource getCombinedLexer()
public void setCombinedLexer(Lexer combinedLexer)
public void setLastCompleteLexer(Lexer lastCompleteLexer)
public org.antlr.runtime.TokenSource getLastCompleteLexer()