diff --git a/src/main/java/io/openliberty/tools/intellij/actions/LibertyGeneralAction.java b/src/main/java/io/openliberty/tools/intellij/actions/LibertyGeneralAction.java index 220060613..122eae30f 100644 --- a/src/main/java/io/openliberty/tools/intellij/actions/LibertyGeneralAction.java +++ b/src/main/java/io/openliberty/tools/intellij/actions/LibertyGeneralAction.java @@ -10,7 +10,6 @@ package io.openliberty.tools.intellij.actions; import com.intellij.notification.Notification; -import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; import com.intellij.notification.Notifications; import com.intellij.openapi.actionSystem.ActionUpdateThread; @@ -157,11 +156,9 @@ protected final String[] toProjectNamesTooltips(@NotNull List lis * @param errMsg */ protected void notifyError(String errMsg, Project project) { - Notification notif = new Notification(Constants.LIBERTY_DEV_DASHBOARD_ID, errMsg, NotificationType.WARNING) - .setTitle(LocalizedResourceUtil.getMessage("liberty.action.cannot.start")) - .setIcon(LibertyPluginIcons.libertyIcon) - .setSubtitle("") - .setListener(NotificationListener.URL_OPENING_LISTENER); + Notification notif = new Notification(Constants.LIBERTY_DEV_DASHBOARD_ID, + LocalizedResourceUtil.getMessage("liberty.action.cannot.start"), errMsg, NotificationType.WARNING); + notif.setIcon(LibertyPluginIcons.libertyIcon); Notifications.Bus.notify(notif, project); } diff --git a/src/main/java/io/openliberty/tools/intellij/actions/ViewIntegrationTestReport.java b/src/main/java/io/openliberty/tools/intellij/actions/ViewIntegrationTestReport.java index b3a8c9e88..2a091530f 100644 --- a/src/main/java/io/openliberty/tools/intellij/actions/ViewIntegrationTestReport.java +++ b/src/main/java/io/openliberty/tools/intellij/actions/ViewIntegrationTestReport.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2023 IBM Corporation. + * Copyright (c) 2020, 2024 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -11,7 +11,6 @@ import com.intellij.ide.BrowserUtil; import com.intellij.notification.Notification; -import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; import com.intellij.notification.Notifications; import com.intellij.openapi.project.Project; @@ -54,13 +53,12 @@ protected void executeLibertyAction(LibertyModule libertyModule) { if (failsafeReportVirtualFile == null || !failsafeReportVirtualFile.exists()) { - Notification notif = new Notification(Constants.LIBERTY_DEV_DASHBOARD_ID - , LibertyPluginIcons.libertyIcon - , LocalizedResourceUtil.getMessage("integration.test.report.does.not.exist.notification.title") - , "" - , LocalizedResourceUtil.getMessage("test.report.does.not.exist", failsafeReportFile.getAbsolutePath()) - , NotificationType.ERROR - , NotificationListener.URL_OPENING_LISTENER); + Notification notif = new Notification(Constants.LIBERTY_DEV_DASHBOARD_ID, + LocalizedResourceUtil.getMessage("integration.test.report.does.not.exist.notification.title"), + LocalizedResourceUtil.getMessage("test.report.does.not.exist", failsafeReportFile.getAbsolutePath()), + NotificationType.ERROR); + notif.setIcon(LibertyPluginIcons.libertyIcon); + Notifications.Bus.notify(notif, project); LOGGER.debug("Integration test report does not exist at : " + failsafeReportFile.getAbsolutePath()); return; diff --git a/src/main/java/io/openliberty/tools/intellij/actions/ViewTestReport.java b/src/main/java/io/openliberty/tools/intellij/actions/ViewTestReport.java index 862a3298c..2c01a88bb 100644 --- a/src/main/java/io/openliberty/tools/intellij/actions/ViewTestReport.java +++ b/src/main/java/io/openliberty/tools/intellij/actions/ViewTestReport.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2023 IBM Corporation. + * Copyright (c) 2020, 2024 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -11,7 +11,6 @@ import com.intellij.ide.BrowserUtil; import com.intellij.notification.Notification; -import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; import com.intellij.notification.Notifications; import com.intellij.openapi.project.Project; @@ -86,13 +85,12 @@ protected void executeLibertyAction(LibertyModule libertyModule) { VirtualFile testReportVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(testReportFile); if (testReportVirtualFile == null || !testReportVirtualFile.exists()) { - Notification notif = new Notification(Constants.LIBERTY_DEV_DASHBOARD_ID - , LibertyPluginIcons.libertyIcon - , LocalizedResourceUtil.getMessage("gradle.test.report.does.not.exist") - , "" - , LocalizedResourceUtil.getMessage("test.report.does.not.exist", testReportFile.getAbsolutePath()) - , NotificationType.ERROR - , NotificationListener.URL_OPENING_LISTENER); + Notification notif = new Notification(Constants.LIBERTY_DEV_DASHBOARD_ID, + LocalizedResourceUtil.getMessage("gradle.test.report.does.not.exist"), + LocalizedResourceUtil.getMessage("test.report.does.not.exist", testReportFile.getAbsolutePath()), + NotificationType.ERROR); + notif.setIcon(LibertyPluginIcons.libertyIcon); + Notifications.Bus.notify(notif, project); LOGGER.debug("Gradle test report does not exist at : " + testReportFile.getAbsolutePath()); return; diff --git a/src/main/java/io/openliberty/tools/intellij/actions/ViewUnitTestReport.java b/src/main/java/io/openliberty/tools/intellij/actions/ViewUnitTestReport.java index daff96ff1..604a925fa 100644 --- a/src/main/java/io/openliberty/tools/intellij/actions/ViewUnitTestReport.java +++ b/src/main/java/io/openliberty/tools/intellij/actions/ViewUnitTestReport.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2022 IBM Corporation. + * Copyright (c) 2020, 2024 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -11,7 +11,6 @@ import com.intellij.ide.BrowserUtil; import com.intellij.notification.Notification; -import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; import com.intellij.notification.Notifications; import com.intellij.openapi.project.Project; @@ -53,13 +52,12 @@ protected void executeLibertyAction(LibertyModule libertyModule) { VirtualFile surefireReportVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(surefireReportFile); if (surefireReportVirtualFile == null || !surefireReportVirtualFile.exists()) { - Notification notif = new Notification(Constants.LIBERTY_DEV_DASHBOARD_ID - , LibertyPluginIcons.libertyIcon - , LocalizedResourceUtil.getMessage("unit.test.report.does.not.exist") - , "" - , LocalizedResourceUtil.getMessage("test.report.does.not.exist", surefireReportFile.getAbsolutePath()) - , NotificationType.ERROR - , NotificationListener.URL_OPENING_LISTENER); + Notification notif = new Notification(Constants.LIBERTY_DEV_DASHBOARD_ID, + LocalizedResourceUtil.getMessage("unit.test.report.does.not.exist"), + LocalizedResourceUtil.getMessage("test.report.does.not.exist", surefireReportFile.getAbsolutePath()), + NotificationType.ERROR); + notif.setIcon(LibertyPluginIcons.libertyIcon); + Notifications.Bus.notify(notif, project); LOGGER.debug("Unit test report does not exist at : " + surefireReportFile.getAbsolutePath()); return; diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4mp/MicroProfileDeploymentSupport.java b/src/main/java/io/openliberty/tools/intellij/lsp4mp/MicroProfileDeploymentSupport.java index 4217a2cd4..ea21d0f56 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4mp/MicroProfileDeploymentSupport.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4mp/MicroProfileDeploymentSupport.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 Red Hat, Inc. + * Copyright (c) 2023, 2024 Red Hat, Inc. * Distributed under license by Red Hat, Inc. All rights reserved. * This program is made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, @@ -11,7 +11,6 @@ package io.openliberty.tools.intellij.lsp4mp; import com.intellij.openapi.Disposable; -import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; @@ -38,7 +37,7 @@ public class MicroProfileDeploymentSupport implements ClasspathResourceChangedMa private final Project project; public static MicroProfileDeploymentSupport getInstance(Project project) { - return ServiceManager.getService(project, MicroProfileDeploymentSupport.class); + return project.getService(MicroProfileDeploymentSupport.class); } public MicroProfileDeploymentSupport(Project project) { diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4mp/MicroProfileProjectService.java b/src/main/java/io/openliberty/tools/intellij/lsp4mp/MicroProfileProjectService.java index 363ba9f26..525c6e48c 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4mp/MicroProfileProjectService.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4mp/MicroProfileProjectService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020 Red Hat, Inc. + * Copyright (c) 2020, 2024 Red Hat, Inc. * Distributed under license by Red Hat, Inc. All rights reserved. * This program is made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, @@ -10,7 +10,6 @@ ******************************************************************************/ package io.openliberty.tools.intellij.lsp4mp; -import com.intellij.ProjectTopics; import com.intellij.json.JsonFileType; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; @@ -90,7 +89,7 @@ public MicroProfileProjectService(Project project) { LibraryTablesRegistrar.getInstance().getLibraryTable(project).addListener(this, project); connection = ApplicationManager.getApplication().getMessageBus().connect(project); connection.subscribe(VirtualFileManager.VFS_CHANGES, this); - project.getMessageBus().connect().subscribe(ProjectTopics.MODULES, this); + project.getMessageBus().connect().subscribe(ModuleListener.TOPIC, this); } private void handleLibraryUpdate(Library library) { diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/classpath/ClasspathResourceChangedManager.java b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/classpath/ClasspathResourceChangedManager.java index 53bc520ea..0e7fbb387 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/classpath/ClasspathResourceChangedManager.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/classpath/ClasspathResourceChangedManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 Red Hat Inc. and others. + * Copyright (c) 2023, 2024 Red Hat Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -13,11 +13,10 @@ *******************************************************************************/ package io.openliberty.tools.intellij.lsp4mp4ij.classpath; -import com.intellij.ProjectTopics; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.ModuleListener; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar; import com.intellij.openapi.util.Pair; @@ -27,8 +26,6 @@ import com.intellij.util.messages.MessageBusConnection; import com.intellij.util.messages.Topic; -import java.util.ArrayList; -import java.util.List; import java.util.Set; /** @@ -57,7 +54,7 @@ public class ClasspathResourceChangedManager implements Disposable { private final ClasspathResourceChangedListener listener; public static ClasspathResourceChangedManager getInstance(Project project) { - return ServiceManager.getService(project, ClasspathResourceChangedManager.class); + return project.getService(ClasspathResourceChangedManager.class); } public interface Listener { @@ -80,7 +77,7 @@ public ClasspathResourceChangedManager(Project project) { // Track update of Psi Java, properties files PsiManager.getInstance(project).addPsiTreeChangeListener(listener, project); // Track modules changes - projectConnection.subscribe(ProjectTopics.MODULES, listener); + projectConnection.subscribe(ModuleListener.TOPIC, listener); // Track delete, create, update of file appConnection = ApplicationManager.getApplication().getMessageBus().connect(project); appConnection.subscribe(VirtualFileManager.VFS_CHANGES, listener); diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/PropertiesManagerForJava.java b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/PropertiesManagerForJava.java index fdc1a7e87..e056415b7 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/PropertiesManagerForJava.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/PropertiesManagerForJava.java @@ -192,7 +192,7 @@ private void collectDefinition(String uri, PsiFile typeRoot, PsiElement hyperlin // Collect all adapted definition participant JavaDefinitionContext context = new JavaDefinitionContext(uri, typeRoot, utils, module, hyperlinkedElement, hyperlinkedPosition); - List definitions = IJavaDefinitionParticipant.EP_NAME.extensions() + List definitions = IJavaDefinitionParticipant.EP_NAME.getExtensionList().stream() .filter(definition -> definition.isAdaptedForDefinition(context)) .collect(Collectors.toList()); if (definitions.isEmpty()) { @@ -326,7 +326,7 @@ private void collectHover(String uri, PsiFile typeRoot, PsiElement hoverElement, // Collect all adapted hover participant JavaHoverContext context = new JavaHoverContext(uri, typeRoot, utils, module, hoverElement, hoverPosition, documentFormat, surroundEqualsWithSpaces); - List definitions = IJavaHoverParticipant.EP_NAME.extensions() + List definitions = IJavaHoverParticipant.EP_NAME.getExtensionList().stream() .filter(definition -> definition.isAdaptedForHover(context)).collect(Collectors.toList()); if (definitions.isEmpty()) { return; diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/java/completion/CompletionHandler.java b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/java/completion/CompletionHandler.java index b6a6a0ab7..0ab4707f8 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/java/completion/CompletionHandler.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/java/completion/CompletionHandler.java @@ -72,7 +72,7 @@ public CompletionList completion(MicroProfileJavaCompletionParams params, IPsiUt List completionItems = new ArrayList<>(); JavaCompletionContext completionContext = new JavaCompletionContext(uri, typeRoot, utils, module, completionOffset); - List completions = JavaCompletionDefinition.EP_NAME.extensions() + List completions = JavaCompletionDefinition.EP_NAME.getExtensionList().stream() .filter(definition -> group.equals(definition.getGroup())) .filter(completion -> completion.isAdaptedForCompletion(completionContext)) .collect(Collectors.toList()); diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/java/diagnostics/DiagnosticsHandler.java b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/java/diagnostics/DiagnosticsHandler.java index 68e1e25e9..df494a993 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/java/diagnostics/DiagnosticsHandler.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/java/diagnostics/DiagnosticsHandler.java @@ -72,7 +72,7 @@ private void collectDiagnostics(String uri, IPsiUtils utils, DocumentFormat docu DumbService.getInstance(module.getProject()).runReadActionInSmartMode(() -> { // Collect all adapted diagnostic definitions JavaDiagnosticsContext context = new JavaDiagnosticsContext(uri, typeRoot, utils, module, documentFormat, settings); - List definitions = JavaDiagnosticsDefinition.EP_NAME.extensions() + List definitions = JavaDiagnosticsDefinition.EP_NAME.getExtensionList().stream() .filter(definition -> group.equals(definition.getGroup())) .filter(definition -> definition.isAdaptedForDiagnostics(context)) .collect(Collectors.toList()); diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/project/PsiMicroProfileProjectManager.java b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/project/PsiMicroProfileProjectManager.java index a1002f2f7..f3e9b57e0 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/project/PsiMicroProfileProjectManager.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/project/PsiMicroProfileProjectManager.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2020 Red Hat Inc. and others. +* Copyright (c) 2020, 2024 Red Hat Inc. and others. * All rights reserved. This program and the accompanying materials * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-v20.html @@ -9,7 +9,6 @@ *******************************************************************************/ package io.openliberty.tools.intellij.lsp4mp4ij.psi.core.project; -import com.intellij.ProjectTopics; import com.intellij.openapi.Disposable; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; @@ -86,7 +85,7 @@ private PsiMicroProfileProjectManager(Project project) { microprofileProjectListener = new MicroProfileProjectListener(); connection = project.getMessageBus().connect(project); connection.subscribe(ClasspathResourceChangedManager.TOPIC, microprofileProjectListener); - connection.subscribe(ProjectTopics.MODULES, microprofileProjectListener); + connection.subscribe(ModuleListener.TOPIC, microprofileProjectListener); } public PsiMicroProfileProject getMicroProfileProject(Module project) { diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/internal/core/java/codeaction/CodeActionHandler.java b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/internal/core/java/codeaction/CodeActionHandler.java index 758333bfa..b926b21e9 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/internal/core/java/codeaction/CodeActionHandler.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/internal/core/java/codeaction/CodeActionHandler.java @@ -98,7 +98,7 @@ public List codeAction(MicroProfileJavaCodeActionParams pa // Loop for each code action kinds to process the proper code actions for (String codeActionKind : codeActionKinds) { // Get list of code action definition for the given kind - List codeActionDefinitions = JavaCodeActionDefinition.EP.extensions() + List codeActionDefinitions = JavaCodeActionDefinition.EP.getExtensionList().stream() .filter(definition -> group.equals(definition.getGroup())) .filter(definition -> definition.isAdaptedForCodeAction(context)) .filter(definition -> codeActionKind.equals(definition.getKind())) @@ -204,7 +204,7 @@ public CodeAction resolveCodeAction(CodeAction unresolved, IPsiUtils utils) { start, end - start, utils, params, unresolved); context.setASTRoot(getASTRoot(unit)); - IJavaCodeActionParticipant participant = JavaCodeActionDefinition.EP.extensions() + IJavaCodeActionParticipant participant = JavaCodeActionDefinition.EP.getExtensionList().stream() .filter(definition -> unresolved.getKind().startsWith(definition.getKind())) .filter(definition -> group.equals(definition.getGroup())) .filter(definition -> participantId.equals(definition.getParticipantId())) diff --git a/src/main/java/io/openliberty/tools/intellij/util/JavaVersionUtil.java b/src/main/java/io/openliberty/tools/intellij/util/JavaVersionUtil.java index 58426dc87..6dcc5c1dd 100644 --- a/src/main/java/io/openliberty/tools/intellij/util/JavaVersionUtil.java +++ b/src/main/java/io/openliberty/tools/intellij/util/JavaVersionUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 IBM Corporation. + * Copyright (c) 2023, 2024 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -10,7 +10,6 @@ package io.openliberty.tools.intellij.util; import com.intellij.notification.Notification; -import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; import com.intellij.notification.Notifications; import com.intellij.openapi.project.Project; @@ -55,11 +54,11 @@ public static boolean isJavaHomeValid(String javaHome, String serverType) { } private static void notifyError(String errMsg, Project project) { - Notification notif = new Notification(Constants.LIBERTY_DEV_DASHBOARD_ID, errMsg, NotificationType.WARNING) - .setTitle(LocalizedResourceUtil.getMessage("java.runtime.error.message")) - .setIcon(LibertyPluginIcons.libertyIcon) - .setSubtitle("") - .setListener(NotificationListener.URL_OPENING_LISTENER); + + Notification notif = new Notification(Constants.LIBERTY_DEV_DASHBOARD_ID, + LocalizedResourceUtil.getMessage("java.runtime.error.message"), + errMsg, NotificationType.WARNING); + notif.setIcon(LibertyPluginIcons.libertyIcon); Notifications.Bus.notify(notif, project); }