Skip to content

Commit

Permalink
Merge pull request OpenLiberty#875 from aparnamichael/issue847_Deprec…
Browse files Browse the repository at this point in the history
…ated_API_usage

Issue 847 deprecated api usage
  • Loading branch information
aparnamichael authored Aug 5, 2024
2 parents 6982994 + 2fd30e4 commit c672d2b
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -157,11 +156,9 @@ protected final String[] toProjectNamesTooltips(@NotNull List<LibertyModule> 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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IJavaDefinitionParticipant> definitions = IJavaDefinitionParticipant.EP_NAME.extensions()
List<IJavaDefinitionParticipant> definitions = IJavaDefinitionParticipant.EP_NAME.getExtensionList().stream()
.filter(definition -> definition.isAdaptedForDefinition(context))
.collect(Collectors.toList());
if (definitions.isEmpty()) {
Expand Down Expand Up @@ -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<IJavaHoverParticipant> definitions = IJavaHoverParticipant.EP_NAME.extensions()
List<IJavaHoverParticipant> definitions = IJavaHoverParticipant.EP_NAME.getExtensionList().stream()
.filter(definition -> definition.isAdaptedForHover(context)).collect(Collectors.toList());
if (definitions.isEmpty()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public CompletionList completion(MicroProfileJavaCompletionParams params, IPsiUt
List<CompletionItem> completionItems = new ArrayList<>();
JavaCompletionContext completionContext = new JavaCompletionContext(uri, typeRoot, utils, module, completionOffset);

List<JavaCompletionDefinition> completions = JavaCompletionDefinition.EP_NAME.extensions()
List<JavaCompletionDefinition> completions = JavaCompletionDefinition.EP_NAME.getExtensionList().stream()
.filter(definition -> group.equals(definition.getGroup()))
.filter(completion -> completion.isAdaptedForCompletion(completionContext))
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<JavaDiagnosticsDefinition> definitions = JavaDiagnosticsDefinition.EP_NAME.extensions()
List<JavaDiagnosticsDefinition> definitions = JavaDiagnosticsDefinition.EP_NAME.getExtensionList().stream()
.filter(definition -> group.equals(definition.getGroup()))
.filter(definition -> definition.isAdaptedForDiagnostics(context))
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public List<? extends CodeAction> 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<JavaCodeActionDefinition> codeActionDefinitions = JavaCodeActionDefinition.EP.extensions()
List<JavaCodeActionDefinition> codeActionDefinitions = JavaCodeActionDefinition.EP.getExtensionList().stream()
.filter(definition -> group.equals(definition.getGroup()))
.filter(definition -> definition.isAdaptedForCodeAction(context))
.filter(definition -> codeActionKind.equals(definition.getKind()))
Expand Down Expand Up @@ -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()))
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit c672d2b

Please sign in to comment.