Search in sources :

Example 1 with FixingErrorManager

use of com.google.javascript.refactoring.FixingErrorManager in project closure-compiler by google.

the class Linter method fix.

/**
 * @return Whether any fixes were applied.
 */
private static boolean fix(String filename, ImmutableSet<DiagnosticType> unfixableErrors) throws IOException {
    Compiler compiler = new Compiler(System.out);
    FixingErrorManager errorManager = new FixingErrorManager(unfixableErrors);
    compiler.setErrorManager(errorManager);
    errorManager.setCompiler(compiler);
    lint(Paths.get(filename), compiler);
    Collection<SuggestedFix> fixes = errorManager.getAllFixes();
    if (!fixes.isEmpty()) {
        ApplySuggestedFixes.applySuggestedFixesToFiles(fixes);
        return true;
    }
    return false;
}
Also used : SuggestedFix(com.google.javascript.refactoring.SuggestedFix) FixingErrorManager(com.google.javascript.refactoring.FixingErrorManager)

Aggregations

FixingErrorManager (com.google.javascript.refactoring.FixingErrorManager)1 SuggestedFix (com.google.javascript.refactoring.SuggestedFix)1