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 Oct 3, 2023
1 parent 3ecfd95 commit 8deb2dd
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ 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 @@ -102,6 +102,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 @@ -141,6 +142,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 @@ -416,7 +416,7 @@ public void onFailure(@NotNull ExternalSystemTaskId id, @NotNull Exception e) {
var externalSystemName = externalSystemId.getReadableName();
var title = ExternalSystemBundle.message("notification.project.refresh.fail.title", externalSystemName, projectName);
var dataContext = BuildConsoleUtils.getDataContext(id, syncViewManager);
var eventResult = createFailureResult(title, e, externalSystemId, project, dataContext);
var eventResult = createFailureResult(title, e, externalSystemId, project, externalProjectPath, dataContext);
return new FinishBuildEventImpl(id, null, eventTime, eventMessage, eventResult);
});
processHandler.notifyProcessTerminated(1);
Expand Down Expand Up @@ -585,7 +585,7 @@ private static void handleSyncResult(
var systemName = externalSystemId.getReadableName();
var projectName = resolveProjectTask.getProjectName();
var title = ExternalSystemBundle.message("notification.project.refresh.fail.title", systemName, projectName);
var eventResult = createFailureResult(title, t, externalSystemId, project, DataContext.EMPTY_CONTEXT);
var eventResult = createFailureResult(title, t, externalSystemId, project, externalProjectPath, DataContext.EMPTY_CONTEXT);
return new FinishBuildEventImpl(taskId, null, eventTime, eventMessage, eventResult);
});
}
Expand Down Expand Up @@ -699,9 +699,10 @@ public static void markModuleAsMaven(@NotNull Module module, @Nullable String mo
@NotNull Throwable exception,
@NotNull ProjectSystemId externalSystemId,
@NotNull Project project,
@NotNull String externalProjectPath,
@NotNull DataContext dataContext) {
var notificationManager = ExternalSystemNotificationManager.getInstance(project);
var notificationData = notificationManager.createNotification(title, exception, externalSystemId, project, dataContext);
var notificationData = 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 8deb2dd

Please sign in to comment.