Optimization: check for setting before initiating background action and checking if Lombok library exists

GitOrigin-RevId: 7338ae8b498eb527b1e305597080f753258136c2
This commit is contained in:
Dmitry Jemerov
2022-01-07 17:57:09 +01:00
committed by intellij-monorepo-bot
parent 41b59c8dcb
commit 6cec315ce2

View File

@@ -32,31 +32,33 @@ public class LombokProjectValidatorActivity implements StartupActivity.DumbAware
final MessageBusConnection connection = project.getMessageBus().connect();
connection.subscribe(BuildManagerListener.TOPIC, new LombokBuildManagerListener());
ReadAction.nonBlocking(() -> {
if (project.isDisposed()) return null;
if (ProjectSettings.isEnabled(project, ProjectSettings.IS_LOMBOK_VERSION_CHECK_ENABLED, false)) {
ReadAction.nonBlocking(() -> {
if (project.isDisposed()) return null;
final boolean hasLombokLibrary = LombokLibraryUtil.hasLombokLibrary(project);
final boolean hasLombokLibrary = LombokLibraryUtil.hasLombokLibrary(project);
// If dependency is present and out of date notification setting is enabled (defaults to disabled)
if (hasLombokLibrary && ProjectSettings.isEnabled(project, ProjectSettings.IS_LOMBOK_VERSION_CHECK_ENABLED, false)) {
String lombokVersion = LombokLibraryUtil.getLombokVersionCached(project);
// If dependency is present and out of date notification setting is enabled (defaults to disabled)
if (hasLombokLibrary) {
String lombokVersion = LombokLibraryUtil.getLombokVersionCached(project);
if (StringUtil.isNotEmpty(lombokVersion) && Version.isLessThan(lombokVersion, Version.LAST_LOMBOK_VERSION)) {
return getNotificationGroup().createNotification(
LombokBundle.message("config.warn.dependency.outdated.title"),
LombokBundle.message("config.warn.dependency.outdated.message", project.getName(), lombokVersion, Version.LAST_LOMBOK_VERSION),
NotificationType.WARNING);
if (StringUtil.isNotEmpty(lombokVersion) && Version.isLessThan(lombokVersion, Version.LAST_LOMBOK_VERSION)) {
return getNotificationGroup().createNotification(
LombokBundle.message("config.warn.dependency.outdated.title"),
LombokBundle.message("config.warn.dependency.outdated.message", project.getName(), lombokVersion, Version.LAST_LOMBOK_VERSION),
NotificationType.WARNING);
}
}
}
return null;
}).expireWith(LombokPluginDisposable.getInstance(project))
.coalesceBy(project, LombokProjectValidatorActivity.class)
.finishOnUiThread(ModalityState.NON_MODAL, notification -> {
if (notification != null) {
notification.setListener(NotificationListener.URL_OPENING_LISTENER).notify(project);
Disposer.register(LombokPluginDisposable.getInstance(project), notification::expire);
}
}).submit(AppExecutorUtil.getAppExecutorService());
return null;
}).expireWith(LombokPluginDisposable.getInstance(project))
.coalesceBy(project, LombokProjectValidatorActivity.class)
.finishOnUiThread(ModalityState.NON_MODAL, notification -> {
if (notification != null) {
notification.setListener(NotificationListener.URL_OPENING_LISTENER).notify(project);
Disposer.register(LombokPluginDisposable.getInstance(project), notification::expire);
}
}).submit(AppExecutorUtil.getAppExecutorService());
}
}
@NotNull