mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[lombok] IDEA-267953 Suggest enabling of annotation processing instead of doing it silently automatically on every build
GitOrigin-RevId: 3bdbfec4ed5325e488046ed80c2a74d6a9217882
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cb65764a1f
commit
f13b33f07f
+38
-1
@@ -3,13 +3,23 @@ package de.plushnikov.intellij.plugin.activity;
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.CompilerConfigurationImpl;
|
||||
import com.intellij.compiler.server.BuildManagerListener;
|
||||
import com.intellij.notification.*;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import de.plushnikov.intellij.plugin.LombokBundle;
|
||||
import de.plushnikov.intellij.plugin.Version;
|
||||
import de.plushnikov.intellij.plugin.util.LombokLibraryUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.java.compiler.AnnotationProcessingConfiguration;
|
||||
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LombokBuildManagerListener implements BuildManagerListener {
|
||||
@@ -19,7 +29,7 @@ public class LombokBuildManagerListener implements BuildManagerListener {
|
||||
@NotNull UUID sessionId) {
|
||||
if (!hasAnnotationProcessorsEnabled(project) &&
|
||||
ReadAction.nonBlocking(() -> LombokLibraryUtil.hasLombokLibrary(project)).executeSynchronously()) {
|
||||
enableAnnotationProcessors(project);
|
||||
suggestEnableAnnotations(project);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,5 +47,32 @@ public class LombokBuildManagerListener implements BuildManagerListener {
|
||||
CompilerConfigurationImpl compilerConfiguration = getCompilerConfiguration(project);
|
||||
compilerConfiguration.getDefaultProcessorProfile().setEnabled(true);
|
||||
compilerConfiguration.getModuleProcessorProfiles().forEach(pp -> pp.setEnabled(true));
|
||||
|
||||
StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
|
||||
JBPopupFactory.getInstance()
|
||||
.createHtmlTextBalloonBuilder(
|
||||
LombokBundle.message("popup.content.java.annotation.processing.has.been.enabled"),
|
||||
MessageType.INFO,
|
||||
null
|
||||
)
|
||||
.setFadeoutTime(3000)
|
||||
.createBalloon()
|
||||
.show(RelativePoint.getNorthEastOf(statusBar.getComponent()), Balloon.Position.atRight);
|
||||
}
|
||||
|
||||
private static void suggestEnableAnnotations(Project project) {
|
||||
NotificationGroup notificationGroup = NotificationGroupManager.getInstance().getNotificationGroup(Version.PLUGIN_NAME);
|
||||
Notification notification =
|
||||
notificationGroup.createNotification(LombokBundle.message("config.warn.annotation-processing.disabled.title"),
|
||||
LombokBundle.message("config.warn.annotation-processing.disabled.message"),
|
||||
NotificationType.ERROR);
|
||||
notification.setListener((not, e) -> {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
enableAnnotationProcessors(project);
|
||||
not.expire();
|
||||
}
|
||||
});
|
||||
|
||||
Notifications.Bus.notify(notification, project);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ config.warn.dependency.outdated.message=<br>\
|
||||
Project "{0}" and Module "{1}" seem to have outdated lombok dependency added.<br>\
|
||||
Configured version "{2}", but there is at least version "{3}" already released<br>\
|
||||
<a href="https://projectlombok.org/download">Maybe you want to update?</a> <br>
|
||||
config.warn.annotation-processing.disabled.title=Lombok requires enabled annotation processing
|
||||
config.warn.annotation-processing.disabled.message=<br>\
|
||||
Do you want to enable annotation processors? <a href="enable">Enable</a><br>
|
||||
replace.with.annotations.lombok=Replace with annotations (Lombok)
|
||||
replace.0.with.explicit.type.lombok=Replace ''{0}'' with explicit type (Lombok)
|
||||
replace.explicit.type.with.0.lombok=Replace explicit type with ''{0}'' (Lombok)
|
||||
@@ -169,3 +172,4 @@ inspection.lombok.group.name.lombok=Lombok
|
||||
inspection.lombok.group.name.redundant.modifiers=Redundant modifiers
|
||||
inspection.lombok.group.name.redundant.definitions=Redundant definitions
|
||||
intention.category.lombok=Java/Lombok
|
||||
popup.content.java.annotation.processing.has.been.enabled=Java annotation processing has been enabled
|
||||
|
||||
Reference in New Issue
Block a user