Java 8 DiagnosticCollector - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DiagnosticCollector class.

This code example shows how to use the following methods:report
import javax.tools.DiagnosticCollector; 
 
public class T6452876 { 
    public static void main(String... args) { 
        try { 
            new DiagnosticCollector<Object>().report(null); 
        } catch (NullPointerException npe) { 
            return; 
        } 
        throw new AssertionError("Expected NPE not thrown"); 
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDiagnostics
        "  @NotAutoAnnotation Empty notNewEmpty() {}", 
        "}" 
    ); 
    JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
    DiagnosticCollector<JavaFileObject> diagnosticCollector =
        new DiagnosticCollector<JavaFileObject>();
    JavaCompiler.CompilationTask compilationTask = javaCompiler.getTask(
        (Writer) null, (JavaFileManager) null, diagnosticCollector, (Iterable<String>) null,
        (Iterable<String>) null, ImmutableList.of(erroneousJavaFileObject));
    compilationTask.setProcessors(ImmutableList.of(new AutoAnnotationProcessor()));
    boolean result = compilationTask.call();
    assertThat(result).isFalse();
    List<Diagnostic<? extends JavaFileObject>> diagnostics = diagnosticCollector.getDiagnostics();
    assertThat(diagnostics).isNotEmpty();
    assertThat(diagnostics.get(0).getMessage(null)).contains("NotAutoAnnotation");
    assertThat(diagnostics.get(0).getMessage(null)).doesNotContain("static");
  } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    } 
 
    public Class compile(JavaSource javaSource) {
        try { 
 
            final DiagnosticCollector<JavaFileObject> errs = new DiagnosticCollector<JavaFileObject>();
            JdkCompileTask compileTask = new JdkCompileTask(new JdkCompilerClassLoader(this.getClass().getClassLoader()),
                options);
            String fullName = javaSource.getPackageName() + "." + javaSource.getClassName();
            Class newClass = compileTask.compile(fullName, javaSource.getSource(), errs);
            return newClass;
        } catch (JdkCompileException ex) {
            DiagnosticCollector<JavaFileObject> diagnostics = ex.getDiagnostics();
            throw new CompileExprException("compile error, source : \n" + javaSource + ", "
                                           + diagnostics.getDiagnostics(), ex);
        } catch (Exception ex) {
            throw new CompileExprException("compile error, source : \n" + javaSource, ex);
        } 
 
    } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:report
import javax.tools.DiagnosticCollector; 
 
public class T6452876 { 
    public static void main(String... args) { 
        try { 
            new DiagnosticCollector<Object>().report(null); 
        } catch (NullPointerException npe) { 
            return; 
        } 
        throw new AssertionError("Expected NPE not thrown"); 
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
				new CompilerTestHelper( ToolProvider.getSystemJavaCompiler() );
	} 
 
	@BeforeMethod 
	public void setUpDiagnostics() { 
		diagnostics = new DiagnosticCollector<JavaFileObject>();
	} 
 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    this.outputRoot = new File(workingDirectory, "output");
    this.outputRoot.mkdir();
    this.localTempDir = new File(workingDirectory, "temp");
    this.localTempDir.mkdir();
    this.compiler = ToolProvider.getSystemJavaCompiler();
    this.diagnostics = new DiagnosticCollector<JavaFileObject>();
    this.fileManager = compiler.getStandardFileManager(diagnostics, null, null);
 
    try { 
      // Define the output locations 
      fileManager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(outputRoot));
      fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, Arrays.asList(outputRoot));
    } catch (IOException e) {
      throw new UndeclaredThrowableException(e);
    } 
  } 
 
  /** 
   * Deletes this java project by deleting the working directory. 
   */ 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        compiler = getCompiler();
        if (compiler == null) {
            throw new JavaDynamicException("Compiler not found"); 
        } 
 
        diagnostics = new DiagnosticCollector<JavaFileObject>();
 
        StandardJavaFileManager standardFileManager = compiler
                .getStandardFileManager(diagnostics, null, null);
        javaDynamicManager = new JavaDynamicManager(standardFileManager);
    } 
     
    /** 
     * Gets the compiler. 
     * 
     * @return the compiler 
     */ 
    public JavaCompiler getCompiler() {
        return ToolProvider.getSystemJavaCompiler();
    } 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    public CompileResult compileEx(JavaSource javaSource) {
        compileCount.incrementAndGet();
        long startTimeMillis = System.nanoTime();
 
        try { 
            final DiagnosticCollector<JavaFileObject> errs = new DiagnosticCollector<JavaFileObject>();
 
            JdkCompileTask<Expr> compileTask = new JdkCompileTask<Expr>(classLoader, options);
 
            String fullName = javaSource.getPackageName() + "." + javaSource.getClassName();
 
            CompileResult result = compileTask.compile(fullName, javaSource.getSource(), errs);
 
            return result;
        } catch (JdkCompileException ex) {
            DiagnosticCollector<JavaFileObject> diagnostics = ex.getDiagnostics();
 
            throw new CompileExprException("compile error, source : \n" + javaSource + ", "
                                           + diagnostics.getDiagnostics(), ex);
        } catch (Exception ex) {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
public class MemoryFileManager extends ForwardingJavaFileManager<StandardJavaFileManager> {
	public Map<String, Output> map = new HashMap<String, Output>();
 
	MemoryFileManager(JavaCompiler compiler) {
		super(compiler.getStandardFileManager(new DiagnosticCollector<JavaFileObject>(), null, null));
	} 
 
	@Override 
	public Output getJavaFileForOutput(Location location, String name, Kind kind, FileObject source) {
		//System.out.println("getJavaFileForOutput called with "+name); 
		Output mc = new Output(name, kind);
		this.map.put(name, mc);
		return mc;
	} 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
See Code Examples for Java 8 DiagnosticCollector Methods: