Search in sources :

Example 1 with ParserFactory

use of org.eclipse.ceylon.langtools.tools.javac.parser.ParserFactory in project ceylon by eclipse.

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 + "\u0000").toCharArray(), 0, expr.length());
        Parser parser = parserFactory.newParser(buf, false, false, false);
        JCTree tree = parser.parseType();
        return attr.attribType(tree, (Symbol.TypeSymbol) scope);
    } finally {
        compiler.log.useSource(prev);
    }
}
Also used : Symbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol) CharBuffer(java.nio.CharBuffer) JCTree(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree) ParserFactory(org.eclipse.ceylon.langtools.tools.javac.parser.ParserFactory) Parser(org.eclipse.ceylon.langtools.tools.javac.parser.Parser)

Aggregations

CharBuffer (java.nio.CharBuffer)1 Symbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol)1 Parser (org.eclipse.ceylon.langtools.tools.javac.parser.Parser)1 ParserFactory (org.eclipse.ceylon.langtools.tools.javac.parser.ParserFactory)1 JCTree (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree)1