redhat-developer/intellij-common

Provide ContentFactory instance across breaking API change in IC-2023.1

Closed this issue · 0 comments

is a dependency for redhat-developer/intellij-kubernetes#576

ContentFactory add a static .getInstance() and deprecated the static SERVICE inner class in IC-2022.1:

commit 0a202057ead0ab65380e6efb06867a9df62f4ccf
Author: Daniil Ovchinnikov <daniil.ovchinnikov@jetbrains.com>
Date:   Tue May 17 19:55:40 2022 +0200

    deprecate `ContentFactory$SERVICE`

    GitOrigin-RevId: 4419508a657adf8e6b830190078539d1f7d144c3

diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java
index 3d7e2de5567d..49fc44820bf0 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java
@@ -58,7 +58,7 @@ final class ProblemsViewImpl extends ProblemsView {
         });
         Disposer.register(toolWindow.getDisposable(), panel);

-        Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
+        Content content = ContentFactory.getInstance().createContent(panel, "", false);
         content.setHelpId("reference.problems.tool.window");
         toolWindow.getContentManager().addContent(content);

diff --git a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerMessagesService.java b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerMessagesService.java
index 6ab8179d2e9d..e1340737f339 100644
--- a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerMessagesService.java
+++ b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerMessagesService.java
@@ -272,7 +272,7 @@ public final class CompilerMessagesService implements BuildViewService {

     MessageView messageView = MessageView.SERVICE.getInstance(myProject);
     messageView.runWhenInitialized(() -> {
-      Content content = ContentFactory.SERVICE.getInstance().createContent(component, myContentName, true);
+      Content content = ContentFactory.getInstance().createContent(component, myContentName, true);
       content.setHelpId(HelpID.COMPILER);
       CONTENT_ID_KEY.set(content, myContentId);
       SESSION_ID_KEY.set(content, sessionId);

IC-2023.1 now marked ContentFactory.SERVICEto be removed. We support IC-2021.1+ and thus need a way to get the ContentFactory instance that works pre-IC-2023.1 and post-IC-2023.1.