com.sun.tools.javac.parser.Lexer Java Examples

The following examples show how to use com.sun.tools.javac.parser.Lexer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Utilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static synchronized Parser newParser(Context ctx, NBParserFactory fac,
                                             Lexer S, boolean keepDocComments,
                                             boolean keepLineMap, CancelService cancelService,
                                             Names names) {
    try {
        if (parserClass == null) {
            Method switchBlockStatementGroup = JavacParser.class.getDeclaredMethod("switchBlockStatementGroup");
            Method delegate;
            if (switchBlockStatementGroup.getReturnType().equals(com.sun.tools.javac.util.List.class)) {
                delegate = JackpotJavacParser.class.getDeclaredMethod("switchBlockStatementGroupListImpl");
            } else {
                delegate = JackpotJavacParser.class.getDeclaredMethod("switchBlockStatementGroupImpl");
            }
            parserClass = load(new ByteBuddy()
                                .subclass(JackpotJavacParser.class)
                                .method(ElementMatchers.named("switchBlockStatementGroup")).intercept(MethodCall.invoke(delegate))
                                .make())
                        .getLoaded();
        }
        return (Parser) parserClass.getConstructor(Context.class, NBParserFactory.class, Lexer.class, boolean.class, boolean.class, CancelService.class, Names.class)
                .newInstance(ctx, fac, S, keepDocComments, keepLineMap, cancelService, names);
    } catch (ReflectiveOperationException ex) {
        throw new IllegalStateException(ex);
    }
}
 
Example #2
Source File: Utilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JackpotJavacParser(Context ctx, NBParserFactory fac,
                 Lexer S,
                 boolean keepDocComments,
                 boolean keepLineMap,
                 CancelService cancelService,
                 Names names) {
    super(fac, S, keepDocComments, keepLineMap, true, false, cancelService);
    this.ctx = ctx;
    this.make = com.sun.tools.javac.tree.TreeMaker.instance(ctx);
    this.dollar = names.fromString("$");
}
 
Example #3
Source File: ManParserFactory.java    From manifold with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
public JavacParser newParser( CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap, boolean parseModuleInfo )
{
  input = _preprocessor.process( _taskEvent.getSourceFile(), input );
  mapInput( _taskEvent.getSourceFile(), input );
  Lexer lexer = ((ScannerFactory)ReflectUtil.field( this, "scannerFactory" ).get()).newScanner(input, keepDocComments);
  return (JavacParser)ReflectUtil.constructor( "com.sun.tools.javac.parser.ManJavacParser",
    ParserFactory.class, Lexer.class, boolean.class, boolean.class, boolean.class, boolean.class )
    .newInstance( this, lexer, keepDocComments, keepLineMap, keepEndPos, parseModuleInfo );
}
 
Example #4
Source File: CommentCollectingParserFactory.java    From EasyMPermission with MIT License 5 votes vote down vote up
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.
}
 
Example #5
Source File: CommentCollectingParserFactory.java    From EasyMPermission with MIT License 5 votes vote down vote up
@Override public Parser newParser(Lexer S, boolean keepDocComments, boolean genEndPos) {
	Object x = new CommentCollectingParser(this, S, true);
	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.
}
 
Example #6
Source File: CommentCollectingParserFactory.java    From EasyMPermission with MIT License 5 votes vote down vote up
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.
}
 
Example #7
Source File: NBParserFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public JavacParser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap, boolean parseModuleInfo) {
    Lexer lexer = scannerFactory.newScanner(input, keepDocComments);
    return new NBJavacParser(this, lexer, keepDocComments, keepLineMap, keepEndPos, parseModuleInfo, cancelService);
}
 
Example #8
Source File: NBParserFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public NBJavacParser(NBParserFactory fac, Lexer S, boolean keepDocComments, boolean keepLineMap, boolean keepEndPos, boolean parseModuleInfo, CancelService cancelService) {
    super(fac, S, keepDocComments, keepLineMap, keepEndPos, parseModuleInfo);
    this.names = fac.names;
    this.cancelService = cancelService;
}
 
Example #9
Source File: NBParserFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private EndPosTableImpl(Lexer lexer, JavacParser parser, SimpleEndPosTable delegate) {
    super(parser);
    this.lexer = lexer;
    this.delegate = delegate;
}
 
Example #10
Source File: CommentCollectingParser.java    From EasyMPermission with MIT License 4 votes vote down vote up
protected CommentCollectingParser(ParserFactory fac, Lexer S,
		boolean keepDocComments, boolean keepLineMap, boolean keepEndPositions) {
	super(fac, S, keepDocComments, keepLineMap, keepEndPositions);
	lexer = S;
}
 
Example #11
Source File: CommentCollectingParser.java    From EasyMPermission with MIT License 4 votes vote down vote up
protected CommentCollectingParser(Parser.Factory fac, Lexer S, boolean keepDocComments) {
	super(fac, S, keepDocComments);
	lexer = S;
}
 
Example #12
Source File: CommentCollectingParser.java    From EasyMPermission with MIT License 4 votes vote down vote up
protected CommentCollectingParser(ParserFactory fac, Lexer S,
		boolean keepDocComments, boolean keepLineMap) {
	super(fac, S, keepDocComments, keepLineMap);
	lexer = S;
}