Search in sources :

Example 66 with JavacTask

use of com.sun.source.util.JavacTask in project ceylon by eclipse.

the class T6199075 method compileAndCheck.

void compileAndCheck(VarargsMethod m1, VarargsMethod m2, TypeKind actual, ArgumentsArity argsArity) throws Exception {
    final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    JavaSource source = new JavaSource(m1, m2, actual, argsArity);
    ErrorChecker ec = new ErrorChecker();
    JavacTask ct = (JavacTask) tool.getTask(null, fm, ec, null, null, Arrays.asList(source));
    ct.generate();
    check(source, ec, m1, m2, actual, argsArity);
}
Also used : JavaCompiler(javax.tools.JavaCompiler) JavacTask(com.sun.source.util.JavacTask)

Example 67 with JavacTask

use of com.sun.source.util.JavacTask in project ceylon by eclipse.

the class T7042566 method compileAndCheck.

void compileAndCheck() throws Exception {
    final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    JavaSource source = new JavaSource();
    ErrorChecker ec = new ErrorChecker();
    JavacTask ct = (JavacTask) tool.getTask(null, fm, ec, null, null, Arrays.asList(source));
    ct.call();
    check(source, ec);
}
Also used : JavaCompiler(javax.tools.JavaCompiler) JavacTask(com.sun.source.util.JavacTask)

Example 68 with JavacTask

use of com.sun.source.util.JavacTask in project ceylon by eclipse.

the class T7043922 method compileAndCheck.

void compileAndCheck() throws Exception {
    JavaSource source = new JavaSource();
    ErrorChecker ec = new ErrorChecker();
    JavacTask ct = (JavacTask) tool.getTask(null, fm, ec, null, null, Arrays.asList(source));
    ct.analyze();
    if (ec.errorFound) {
        throw new Error("invalid diagnostics for source:\n" + source.getCharContent(true) + "\nCompiler diagnostics:\n" + ec.printDiags());
    }
}
Also used : JavacTask(com.sun.source.util.JavacTask)

Example 69 with JavacTask

use of com.sun.source.util.JavacTask in project ceylon by eclipse.

the class Warn4 method test.

static void test(SourceLevel sourceLevel, TrustMe trustMe, SuppressLevel suppressLevelClient, SuppressLevel suppressLevelDecl, ModifierKind modKind, Signature vararg_meth, Signature client_meth) throws Exception {
    final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    JavaSource source = new JavaSource(trustMe, suppressLevelClient, suppressLevelDecl, modKind, vararg_meth, client_meth);
    DiagnosticChecker dc = new DiagnosticChecker();
    JavacTask ct = (JavacTask) tool.getTask(null, fm, dc, Arrays.asList("-Xlint:unchecked", "-source", sourceLevel.sourceKey), null, Arrays.asList(source));
    // to get mandatory notes
    ct.generate();
    check(dc.warnings, sourceLevel, new boolean[] { vararg_meth.giveUnchecked(client_meth), vararg_meth.giveVarargs(client_meth) }, source, trustMe, suppressLevelClient, suppressLevelDecl, modKind);
}
Also used : JavaCompiler(javax.tools.JavaCompiler) JavacTask(com.sun.source.util.JavacTask)

Example 70 with JavacTask

use of com.sun.source.util.JavacTask in project ceylon by eclipse.

the class Warn5 method test.

static void test(SourceLevel sourceLevel, XlintOption xlint, TrustMe trustMe, SuppressLevel suppressLevel, ModifierKind modKind, MethodKind methKind, SignatureKind sig, BodyKind body) throws Exception {
    final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    JavaSource source = new JavaSource(trustMe, suppressLevel, modKind, methKind, sig, body);
    DiagnosticChecker dc = new DiagnosticChecker();
    JavacTask ct = (JavacTask) tool.getTask(null, fm, dc, Arrays.asList(xlint.getXlintOption(), "-source", sourceLevel.sourceKey), null, Arrays.asList(source));
    ct.analyze();
    check(sourceLevel, dc, source, xlint, trustMe, suppressLevel, modKind, methKind, sig, body);
}
Also used : JavaCompiler(javax.tools.JavaCompiler) JavacTask(com.sun.source.util.JavacTask)

Aggregations

JavacTask (com.sun.source.util.JavacTask)97 JavaCompiler (javax.tools.JavaCompiler)45 JavaFileObject (javax.tools.JavaFileObject)27 JavacTool (com.sun.tools.javac.api.JavacTool)24 CompilationUnitTree (com.sun.source.tree.CompilationUnitTree)23 StandardJavaFileManager (javax.tools.StandardJavaFileManager)17 SimpleJavaFileObject (javax.tools.SimpleJavaFileObject)16 IOException (java.io.IOException)14 DiagnosticCollector (javax.tools.DiagnosticCollector)13 File (java.io.File)12 StringWriter (java.io.StringWriter)12 Context (com.sun.tools.javac.util.Context)11 PrintWriter (java.io.PrintWriter)11 JavacFileManager (com.sun.tools.javac.file.JavacFileManager)9 Path (java.nio.file.Path)8 ArrayList (java.util.ArrayList)8 JCCompilationUnit (com.sun.tools.javac.tree.JCTree.JCCompilationUnit)7 Diagnostic (javax.tools.Diagnostic)7 ClassTree (com.sun.source.tree.ClassTree)6 Trees (com.sun.source.util.Trees)6