use of com.sun.tools.javac.parser.Parser in project lombok by rzwitserloot.
the class CommentCollectingParserFactory method setInCompiler.
public static void setInCompiler(JavaCompiler compiler, Context context) {
context.put(CommentCollectingParserFactory.key(), (Parser.Factory) null);
Field field;
try {
field = JavaCompiler.class.getDeclaredField("parserFactory");
field.setAccessible(true);
field.set(compiler, new CommentCollectingParserFactory(context));
} catch (Exception e) {
throw new IllegalStateException("Could not set comment sensitive parser in the compiler", e);
}
}
use of com.sun.tools.javac.parser.Parser in project lombok by rzwitserloot.
the class CommentCollectingParserFactory method newParser.
public Parser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) {
ScannerFactory scannerFactory = ScannerFactory.instance(context);
Lexer lexer = scannerFactory.newScanner(input, true);
Object x = new CommentCollectingParser(this, lexer, true, keepLineMap);
return (Parser) x;
// CCP is based on a stub which extends nothing, but at runtime the stub is replaced with either
//javac6's EndPosParser which extends Parser, or javac7's EndPosParser which implements Parser.
//Either way this will work out.
}
use of com.sun.tools.javac.parser.Parser in project ceylon-compiler by ceylon.
the class JavacTaskImpl method parseType.
/**
* For internal use only. This method will be
* removed without warning.
*/
public Type parseType(String expr, TypeElement scope) {
if (expr == null || expr.equals(""))
throw new IllegalArgumentException();
compiler = JavaCompiler.instance(context);
JavaFileObject prev = compiler.log.useSource(null);
ParserFactory parserFactory = ParserFactory.instance(context);
Attr attr = Attr.instance(context);
try {
CharBuffer buf = CharBuffer.wrap((expr + "