Skip to content

Commit

Permalink
Lazily load plugin checks when running auto-patching
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Jul 15, 2024
1 parent 8f9e7da commit 728e3f9
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ public static ErrorProneAnalyzer createAnalyzer(
refactoringCollection[0] = RefactoringCollection.refactor(epOptions.patchingOptions(), context);

// Refaster refactorer or using builtin checks
CodeTransformer codeTransformer =
Supplier<CodeTransformer> codeTransformer =
epOptions
.patchingOptions()
.customRefactorer()
.or(
() -> {
Suppliers.memoize(() -> {
ScannerSupplier toUse = ErrorPronePlugins.loadPlugins(scannerSupplier, context);
ImmutableSet<String> namedCheckers = epOptions.patchingOptions().namedCheckers();
if (!namedCheckers.isEmpty()) {
Expand All @@ -86,8 +86,7 @@ public static ErrorProneAnalyzer createAnalyzer(
toUse = toUse.applyOverrides(epOptions);
}
return ErrorProneScannerTransformer.create(toUse.get());
})
.get();
}));

return createWithCustomDescriptionListener(
codeTransformer, epOptions, context, refactoringCollection[0]);
Expand Down Expand Up @@ -160,12 +159,12 @@ private static Supplier<CodeTransformer> scansPlugins(
}

static ErrorProneAnalyzer createWithCustomDescriptionListener(
CodeTransformer codeTransformer,
Supplier<CodeTransformer> codeTransformer,
ErrorProneOptions errorProneOptions,
Context context,
DescriptionListener.Factory descriptionListenerFactory) {
return new ErrorProneAnalyzer(
Suppliers.ofInstance(codeTransformer),
codeTransformer,
errorProneOptions,
context,
descriptionListenerFactory);
Expand Down

0 comments on commit 728e3f9

Please sign in to comment.