@Override public ImmutableList<Note> analyzeFile( final ShipshapeContext shipshapeContext, final JavaCompilationDetails compilationDetails, final CompilationUnitTree file, String path) throws AnalyzerException { final ImmutableList.Builder<Note> notes = new ImmutableList.Builder<>(); // Don't run error-prone if the compilation failed in any way. if (compilationDetails.hasCompileErrors() || compilationDetails.inBadCompilationState()) { return ImmutableList.of(); } // TODO(ciera): Create an EnabledPredicate that uses a configuration file // and push that change upstream to errorprone. Scanner scanner = new ErrorProneScanner(ErrorProneScanner.EnabledPredicate.DEFAULT_CHECKS); JavacTask javacTask = compilationDetails.getJavac(); Context context = ((JavacTaskImpl) javacTask).getContext(); JCCompilationUnit compilationUnit = (JCCompilationUnit) file; CharSequence source = null; try { source = file.getSourceFile().getCharContent(false); } catch (IOException e) { logger.severe(e, "Unable to read source file " + path, shipshapeContext, CATEGORY); } NoteAdapter adapter = new NoteAdapter( notes, path, compilationUnit, shipshapeContext, source, compilationDetails.getEncoding()); scanner.scan(file, new VisitorState(context, adapter)); return notes.build(); }
public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) { this(kind, unit.getSourceFile(), unit, clazz); }
public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); }