use of com.sun.tools.javac.parser.ScannerFactory 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.ScannerFactory in project error-prone by google.
the class ErrorProneTokens method getTokens.
/** Returns the tokens for the given source text, including comments. */
public static ImmutableList<ErrorProneToken> getTokens(String source, Context context) {
if (source == null) {
return ImmutableList.of();
}
ScannerFactory fac = ScannerFactory.instance(context);
char[] buffer = source.toCharArray();
Scanner scanner = new AccessibleScanner(fac, new CommentSavingTokenizer(fac, buffer, buffer.length));
ImmutableList.Builder<ErrorProneToken> tokens = ImmutableList.builder();
do {
scanner.nextToken();
tokens.add(new ErrorProneToken(scanner.token()));
} while (scanner.token().kind != TokenKind.EOF);
return tokens.build();
}
use of com.sun.tools.javac.parser.ScannerFactory in project lombok by rzwitserloot.
the class CommentCollectingParserFactory method newParser.
public JavacParser 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, keepEndPos);
return (JavacParser) 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 javac8's JavacParser which implements Parser.
//Either way this will work out.
}
Aggregations