From a075b779731e88f9e5404425cb039884799b3b00 Mon Sep 17 00:00:00 2001 From: Madalin Valceleanu Date: Wed, 10 May 2023 13:51:13 +0100 Subject: [PATCH] Expose externalProjectPath on ExternalSystemNotificationExtension.customize() --- .../service/execution/ExternalSystemRunnableState.java | 2 +- .../notification/ExternalSystemNotificationExtension.java | 8 +++++--- .../ExternalSystemNotificationExtensionImpl.java | 1 + .../notification/ExternalSystemNotificationManager.java | 3 ++- .../openapi/externalSystem/util/ExternalSystemUtil.java | 7 ++++--- .../service/notification/GradleNotificationExtension.java | 1 + 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunnableState.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunnableState.java index 39fc05175b4fe..d1fde57824a9c 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunnableState.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunnableState.java @@ -270,7 +270,7 @@ public void onTaskOutput(@NotNull ExternalSystemTaskId id, @NotNull String text, public void onFailure(@NotNull ExternalSystemTaskId id, @NotNull Exception e) { DataContext dataContext = BuildConsoleUtils.getDataContext(id, progressListener); FailureResult failureResult = ExternalSystemUtil.createFailureResult( - executionName + " " + BuildBundle.message("build.status.failed"), e, id.getProjectSystemId(), myProject, dataContext); + executionName + " " + BuildBundle.message("build.status.failed"), e, id.getProjectSystemId(), myProject, mySettings.getExternalProjectPath(), dataContext); eventDispatcher.onEvent(id, new FinishBuildEventImpl(id, null, System.currentTimeMillis(), BuildBundle.message("build.status.failed"), failureResult)); processHandler.notifyProcessTerminated(1); diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationExtension.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationExtension.java index c8e5146571fa4..226fbdb4d6bce 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationExtension.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationExtension.java @@ -36,12 +36,14 @@ public interface ExternalSystemNotificationExtension { /** * Allows to customize external system processing notification. * - * @param notificationData notification data - * @param project target ide project - * @param error error occurred during external system processing + * @param notificationData notification data + * @param project target ide project + * @param externalProjectPath path of the target external project + * @param error error occurred during external system processing */ void customize(@NotNull NotificationData notificationData, @NotNull Project project, + @NotNull String externalProjectPath, @Nullable Throwable error); /** diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationExtensionImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationExtensionImpl.java index 34ab26874d0b1..67291105bf21b 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationExtensionImpl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationExtensionImpl.java @@ -36,6 +36,7 @@ public ProjectSystemId getTargetExternalSystemId() { @Override public void customize(@NotNull NotificationData notification, @NotNull Project project, + @NotNull String externalProjectPath, @Nullable Throwable error) { if (error == null) return; Throwable unwrapped = RemoteUtil.unwrap(error); diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationManager.java index 2243bc71cadbe..d902b43ec968e 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationManager.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemNotificationManager.java @@ -101,6 +101,7 @@ public ExternalSystemNotificationManager(final @NotNull Project project) { @NotNull Throwable error, @NotNull ProjectSystemId externalSystemId, @NotNull Project project, + @NotNull String externalProjectPath, @NotNull DataContext dataContext) { if (isInternalError(error, externalSystemId)) { return null; @@ -140,7 +141,7 @@ public ExternalSystemNotificationManager(final @NotNull Project project) { if (!externalSystemId.equals(targetExternalSystemId) && !targetExternalSystemId.equals(ProjectSystemId.IDE)) { continue; } - extension.customize(notificationData, project, error); + extension.customize(notificationData, project, externalProjectPath, error); } return notificationData; } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java index 19e9b4d1e34de..3d8d82859bb0b 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java @@ -453,7 +453,7 @@ public void onFailure(@NotNull ExternalSystemTaskId id, @NotNull Exception e) { String title = ExternalSystemBundle.message("notification.project.refresh.fail.title", externalSystemId.getReadableName(), projectName); DataContext dataContext = BuildConsoleUtils.getDataContext(id, syncViewManager); - FailureResult failureResult = createFailureResult(title, e, externalSystemId, project, dataContext); + FailureResult failureResult = createFailureResult(title, e, externalSystemId, project, externalProjectPath, dataContext); finishSyncEventSupplier.set(() -> new FinishBuildEventImpl(id, null, System.currentTimeMillis(), BuildBundle.message("build.status.failed"), failureResult)); processHandler.notifyProcessTerminated(1); @@ -540,7 +540,7 @@ private void handExecutionResult(@NotNull ExternalSystemTaskActivator externalSy ExternalSystemTaskId id = resolveProjectTask.getId(); String title = ExternalSystemBundle.message("notification.project.refresh.fail.title", externalSystemId.getReadableName(), projectName); - FailureResult failureResult = createFailureResult(title, t, externalSystemId, project, DataContext.EMPTY_CONTEXT); + FailureResult failureResult = createFailureResult(title, t, externalSystemId, project, externalProjectPath, DataContext.EMPTY_CONTEXT); finishSyncEventSupplier.set(() -> new FinishBuildEventImpl(id, null, System.currentTimeMillis(), BuildBundle.message("build.status.failed"), failureResult)); @@ -703,10 +703,11 @@ public static void markModuleAsMaven(@NotNull Module module, boolean isMavenModu @NotNull Throwable exception, @NotNull ProjectSystemId externalSystemId, @NotNull Project project, + @NotNull String externalProjectPath, @NotNull DataContext dataContext) { ExternalSystemNotificationManager notificationManager = ExternalSystemNotificationManager.getInstance(project); NotificationData notificationData = - notificationManager.createNotification(title, exception, externalSystemId, project, dataContext); + notificationManager.createNotification(title, exception, externalSystemId, project, externalProjectPath, dataContext); if (notificationData == null) { return new FailureResultImpl(); } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/notification/GradleNotificationExtension.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/notification/GradleNotificationExtension.java index a7678e82fa80c..4a3eec24b55d0 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/notification/GradleNotificationExtension.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/notification/GradleNotificationExtension.java @@ -80,6 +80,7 @@ public boolean isInternalError(@NotNull Throwable error) { @Override public void customize(@NotNull NotificationData notification, @NotNull Project project, + @NotNull String externalProjectPath, @Nullable Throwable error) { if (error == null) return; Throwable unwrapped = RemoteUtil.unwrap(error);