Skip to content

Commit

Permalink
Expose externalProjectPath on ExternalSystemNotificationExtension.cus…
Browse files Browse the repository at this point in the history
…tomize()
  • Loading branch information
vmadalin committed Sep 5, 2023
1 parent 98408a4 commit ebc1939
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,29 @@ 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);

/**
* Allows to customize external system processing notification.
* @deprecated Use {@link #customize(NotificationData, Project, String, Throwable)} instead
* @param notificationData notification data
* @param project target ide project
* @param error error occurred during external system processing
*/
@Deprecated
default void customize(@NotNull NotificationData notificationData,
@NotNull Project project,
@Nullable Throwable error) {
}

/**
* Allows to determine internal errors comes from external system which might be confusing for IDE users.
* Such errors shouldn't be shown to the end user on UI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -140,6 +141,7 @@ public ExternalSystemNotificationManager(final @NotNull Project project) {
if (!externalSystemId.equals(targetExternalSystemId) && !targetExternalSystemId.equals(ProjectSystemId.IDE)) {
continue;
}
extension.customize(notificationData, project, externalProjectPath, error);
extension.customize(notificationData, project, error);
}
return notificationData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));

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

0 comments on commit ebc1939

Please sign in to comment.