org.eclipse.xtext.conversion.impl
Class AbstractIDValueConverter
java.lang.Object
org.eclipse.xtext.conversion.impl.AbstractValueConverter<T>
org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter<java.lang.String>
org.eclipse.xtext.conversion.impl.AbstractIDValueConverter
- All Implemented Interfaces:
- IValueConverter<java.lang.String>, IValueConverter.RuleSpecific
- Direct Known Subclasses:
- IDValueConverter, IgnoreCaseIDValueConverter
public abstract class AbstractIDValueConverter
- extends AbstractLexerBasedConverter<java.lang.String>
Abstract implementation of a value converter that escapes a string
based on a set of values. The strategy to compute this values and how the
the string is found in this set is the responsibility of the concrete
implementation. A common use-case is to collect the keywords in a grammar
and match the string against these keywords or to use some ignore-case matching
algorithm against the list of normalized keywords.
- Author:
- Sebastian Zarnekow - Initial contribution and API
Methods inherited from class org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter |
assertTokens, createTokenTypeMismatchException, getLexer, getLexerProvider, getRule, getRuleName, getRuleName, getTokenDefMap, getTokenDefProvider, getTokenSource, setLexerProvider, setRule, setTokenDefProvider, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractIDValueConverter
protected AbstractIDValueConverter()
computeValuesToEscape
protected abstract java.util.Set<java.lang.String> computeValuesToEscape(Grammar grammar)
getValuesToEscape
protected java.util.Set<java.lang.String> getValuesToEscape()
mustEscape
protected abstract boolean mustEscape(java.lang.String value)
toEscapedString
protected java.lang.String toEscapedString(java.lang.String value)
- Overrides:
toEscapedString
in class AbstractLexerBasedConverter<java.lang.String>
assertValidValue
protected void assertValidValue(java.lang.String value)
- Overrides:
assertValidValue
in class AbstractLexerBasedConverter<java.lang.String>
createTokenContentMismatchException
protected ValueConverterException createTokenContentMismatchException(java.lang.String value,
java.lang.String escapedString,
org.antlr.runtime.Token token)
- Overrides:
createTokenContentMismatchException
in class AbstractLexerBasedConverter<java.lang.String>
getInvalidCharactersMessage
protected java.lang.String getInvalidCharactersMessage(java.lang.String value,
java.util.Set<java.lang.Character> invalidChars)
collectInvalidCharacters
protected java.util.Set<java.lang.Character> collectInvalidCharacters(java.lang.String value)
toValue
public java.lang.String toValue(java.lang.String string,
INode node)
- Description copied from interface:
IValueConverter
Creates a value from the given input. The input is conformant
to a data type or terminal rule.
The given string
or node
may be null but not both of them.
- Parameters:
string
- the string that was inferred from the node. Usually the node's text
but may be reduced to the parts of the node that are not
hidden
.node
- the parsed node including hidden parts.
- Returns:
- the new value or
null
.
getGrammarAccess
protected IGrammarAccess getGrammarAccess()
setGrammarAccess
public void setGrammarAccess(IGrammarAccess grammarAccess)