Class AntlrProposalConflictHelper
- java.lang.Object
-
- org.eclipse.xtext.ide.editor.contentassist.ProposalConflictHelper
-
- org.eclipse.xtext.ide.editor.contentassist.antlr.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, sinceMyIdSomethingElsewould be consumed as a single ID by the lexer, the proposalSomethingElseis invalid.- Since:
- 2.10
- Noreference:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.xtext.ide.editor.contentassist.IProposalConflictHelper
IProposalConflictHelper.NullHelper
-
-
Constructor Summary
Constructors Constructor Description AntlrProposalConflictHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanequalTokenSequence(org.antlr.runtime.TokenSource first, org.antlr.runtime.TokenSource second)booleanexistsConflict(java.lang.String lastCompleteText, java.lang.String proposal, ContentAssistContext context)Returnsfalseif the proposal would corrupt the previous input.org.antlr.runtime.TokenSourcegetCombinedLexer()org.antlr.runtime.TokenSourcegetLastCompleteLexer()org.antlr.runtime.TokenSourcegetProposalLexer()protected voidinitTokenSource(java.lang.String text, org.antlr.runtime.TokenSource tokenSource, ContentAssistContext context)protected voidinitTokenSources(java.lang.String lastCompleteText, java.lang.String proposal, ContentAssistContext context)voidsetCombinedLexer(org.eclipse.xtext.parser.antlr.Lexer combinedLexer)voidsetLastCompleteLexer(org.eclipse.xtext.parser.antlr.Lexer lastCompleteLexer)voidsetProposalLexer(org.eclipse.xtext.parser.antlr.Lexer proposalLexer)-
Methods inherited from class org.eclipse.xtext.ide.editor.contentassist.ProposalConflictHelper
existsConflict, existsConflict
-
-
-
-
Method Detail
-
existsConflict
public boolean existsConflict(java.lang.String lastCompleteText, java.lang.String proposal, ContentAssistContext context)Description copied from class:ProposalConflictHelperReturnsfalseif the proposal would corrupt the previous input.- Specified by:
existsConflictin classProposalConflictHelper- Parameters:
lastCompleteText- the previous sibling in the input source. Is nevernullbut may be empty. However, the implementation ofProposalConflictHelper.existsConflict(INode, int, String, ContentAssistContext)will not pass empty strings by default but returnfalseinstead.proposal- a possible proposal string. Is nevernull.context- the current content assist context. Is nevernull.- Returns:
falseif 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()
-
-