org.eclipse.xtext.parser.antlr
Class LexerProvider<T extends org.antlr.runtime.Lexer>
java.lang.Object
org.eclipse.xtext.parser.antlr.LexerProvider<T>
- All Implemented Interfaces:
- javax.inject.Provider<T>
public class LexerProvider<T extends org.antlr.runtime.Lexer>
- extends java.lang.Object
- implements com.google.inject.Provider<T>
A Guice provider implementation, that does not use the default constructor of
the lexer class, but call the other available constructor that takes a CharStream as argument.
This provider is a workaround for a bug in ANTLR that leads to partially initialized
Lexer instances. They may cause NullPointerExceptions in some rare situations, when
backtracking is involved.
- Author:
- Sebastian Zarnekow - Initial contribution and API
Method Summary |
static
|
create(java.lang.Class<T> clazz)
|
T |
get()
Creates a lexer instance via reflection. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LexerProvider
public LexerProvider(java.lang.Class<T> clazz)
create
public static <T extends org.antlr.runtime.Lexer> LexerProvider<T> create(java.lang.Class<T> clazz)
get
public T get()
- Creates a lexer instance via reflection. The object is not created with the default
constructor because it will not initialize the backtracking state of the lexer.
Instead, we pass
null
as CharStream argument.
- Specified by:
get
in interface javax.inject.Provider<T extends org.antlr.runtime.Lexer>