Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazily load plugin checks when running auto-patching #4467

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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