From fb737d1fd42e91959bae81dbaa7be53f8d4ff9da Mon Sep 17 00:00:00 2001 From: "Alexander.Glukhov" Date: Thu, 18 Jul 2024 10:26:30 +0200 Subject: [PATCH] [external system api][IJPL-158355] progress event api: converted `ExternalSystemProgressEvent` to Kotlin GitOrigin-RevId: 99de1dbb062fb9fa64de6cc856d08a694d969b12 --- .../api-dump-unreviewed.txt | 35 ++++---- .../task/event/ExternalSystemFinishEvent.java | 40 ---------- .../event/ExternalSystemMessageEvent.java | 56 ------------- .../event/ExternalSystemProgressEvent.java | 65 --------------- .../task/event/ExternalSystemStartEvent.java | 28 ------- .../task/event/ExternalSystemStatusEvent.java | 79 ------------------- .../model/task/event/progressEvent.kt | 76 ++++++++++++++++++ ...ernalSystemTaskProgressIndicatorUpdater.kt | 6 +- 8 files changed, 97 insertions(+), 288 deletions(-) delete mode 100644 platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemFinishEvent.java delete mode 100644 platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemMessageEvent.java delete mode 100644 platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemProgressEvent.java delete mode 100644 platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemStartEvent.java delete mode 100644 platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemStatusEvent.java create mode 100644 platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/progressEvent.kt diff --git a/platform/external-system-api/api-dump-unreviewed.txt b/platform/external-system-api/api-dump-unreviewed.txt index 17e734f6862c..68ce94b2d0e0 100644 --- a/platform/external-system-api/api-dump-unreviewed.txt +++ b/platform/external-system-api/api-dump-unreviewed.txt @@ -897,36 +897,37 @@ f:com.intellij.openapi.externalSystem.model.task.TaskData - com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationEvent - (com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId,com.intellij.build.events.BuildEvent):V - getBuildEvent():com.intellij.build.events.BuildEvent -c:com.intellij.openapi.externalSystem.model.task.event.ExternalSystemFinishEvent +f:com.intellij.openapi.externalSystem.model.task.event.ExternalSystemFinishEvent - com.intellij.openapi.externalSystem.model.task.event.ExternalSystemProgressEvent - (java.lang.String,java.lang.String,com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor,com.intellij.openapi.externalSystem.model.task.event.OperationResult):V -- getOperationResult():com.intellij.openapi.externalSystem.model.task.event.OperationResult -c:com.intellij.openapi.externalSystem.model.task.event.ExternalSystemMessageEvent +- f:getOperationResult():com.intellij.openapi.externalSystem.model.task.event.OperationResult +f:com.intellij.openapi.externalSystem.model.task.event.ExternalSystemMessageEvent - com.intellij.openapi.externalSystem.model.task.event.ExternalSystemProgressEvent - (java.lang.String,java.lang.String,com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor,java.lang.String):V - (java.lang.String,java.lang.String,com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor,Z,java.lang.String,java.lang.String):V -- getDescription():java.lang.String -- getMessage():java.lang.String -- isStdOut():Z +- f:getDescription():java.lang.String +- f:getMessage():java.lang.String +- f:isStdOut():Z c:com.intellij.openapi.externalSystem.model.task.event.ExternalSystemProgressEvent - java.io.Serializable - (java.lang.String,java.lang.String,com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor):V -- getDescriptor():com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor -- getDisplayName():java.lang.String -- getEventId():java.lang.String -- getEventTime():J -- getParentEventId():java.lang.String -c:com.intellij.openapi.externalSystem.model.task.event.ExternalSystemStartEvent +- f:getDescriptor():com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor +- f:getDisplayName():java.lang.String +- f:getEventId():java.lang.String +- f:getEventTime():J +- f:getParentEventId():java.lang.String +f:com.intellij.openapi.externalSystem.model.task.event.ExternalSystemStartEvent - com.intellij.openapi.externalSystem.model.task.event.ExternalSystemProgressEvent - (java.lang.String,java.lang.String,com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor):V -c:com.intellij.openapi.externalSystem.model.task.event.ExternalSystemStatusEvent +f:com.intellij.openapi.externalSystem.model.task.event.ExternalSystemStatusEvent - com.intellij.openapi.externalSystem.model.task.event.ExternalSystemProgressEvent - (java.lang.String,java.lang.String,com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor,J,J,java.lang.String):V - (java.lang.String,java.lang.String,com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor,J,J,java.lang.String,java.lang.String):V -- getDescription():java.lang.String -- getProgress():J -- getTotal():J -- getUnit():java.lang.String +- b:(java.lang.String,java.lang.String,com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor,J,J,java.lang.String,java.lang.String,I,kotlin.jvm.internal.DefaultConstructorMarker):V +- f:getDescription():java.lang.String +- f:getProgress():J +- f:getTotal():J +- f:getUnit():java.lang.String c:com.intellij.openapi.externalSystem.model.task.event.ExternalSystemTaskExecutionEvent - com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationEvent - (com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId,com.intellij.openapi.externalSystem.model.task.event.ExternalSystemProgressEvent):V diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemFinishEvent.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemFinishEvent.java deleted file mode 100644 index 3ebcff6c2afc..000000000000 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemFinishEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.task.event; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Vladislav.Soroka - */ -public class ExternalSystemFinishEvent extends ExternalSystemProgressEvent { - - @NotNull - private final OperationResult myResult; - - public ExternalSystemFinishEvent(@NotNull String eventId, - @Nullable String parentEventId, - @NotNull T descriptor, - @NotNull OperationResult result) { - super(eventId, parentEventId, descriptor); - myResult = result; - } - - public OperationResult getOperationResult() { - return myResult; - } -} diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemMessageEvent.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemMessageEvent.java deleted file mode 100644 index 49d66387c37c..000000000000 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemMessageEvent.java +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package com.intellij.openapi.externalSystem.model.task.event; - -import com.intellij.openapi.util.NlsSafe; -import org.jetbrains.annotations.Nls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * An event with textual description. - * @param - */ -public class ExternalSystemMessageEvent extends ExternalSystemProgressEvent { - - private final boolean myStdOut; - private final @Nullable @Nls String myMessage; - private final @Nullable String myDescription; - - public ExternalSystemMessageEvent( - @NotNull String eventId, - @Nullable String parentEventId, - @NotNull T descriptor, - boolean isStdOut, - @Nullable @Nls String message, - @Nullable String description - ) { - super(eventId, parentEventId, descriptor); - myStdOut = isStdOut; - myMessage = message; - myDescription = description; - } - - public ExternalSystemMessageEvent(@NotNull String eventId, - @Nullable String parentEventId, - @NotNull T descriptor, - @Nullable @NlsSafe String description) { - this(eventId, parentEventId, descriptor, true, description, description); - } - - public boolean isStdOut() { - return myStdOut; - } - - public @Nullable String getMessage() { - return myMessage; - } - - /** - * Textual description of the event. - * - * @return arbitrary additional information about status update - */ - public @Nullable String getDescription() { - return myDescription; - } -} diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemProgressEvent.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemProgressEvent.java deleted file mode 100644 index 4358a67e097a..000000000000 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemProgressEvent.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.task.event; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.Serializable; - -/** - * @author Vladislav.Soroka - */ -public class ExternalSystemProgressEvent implements Serializable { - - private static final long serialVersionUID = 1L; - - @NotNull private final String myEventId; - @NotNull private final T myDescriptor; - @Nullable private final String myParentEventId; - - public ExternalSystemProgressEvent(@NotNull String eventId, - @Nullable String parentEventId, - @NotNull T descriptor) { - myEventId = eventId; - myDescriptor = descriptor; - myParentEventId = parentEventId; - } - - @NotNull - public String getEventId() { - return myEventId; - } - - @Nullable - public String getParentEventId() { - return myParentEventId; - } - - @NotNull - public T getDescriptor() { - return myDescriptor; - } - - @NotNull - public String getDisplayName() { - return myDescriptor.getDisplayName(); - } - - public long getEventTime() { - return myDescriptor.getEventTime(); - } -} diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemStartEvent.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemStartEvent.java deleted file mode 100644 index 251418b3ec62..000000000000 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemStartEvent.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.task.event; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Vladislav.Soroka - */ -public class ExternalSystemStartEvent extends ExternalSystemProgressEvent { - public ExternalSystemStartEvent(@NotNull String eventId, @Nullable String parentEventId, @NotNull T descriptor) { - super(eventId, parentEventId, descriptor); - } -} diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemStatusEvent.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemStatusEvent.java deleted file mode 100644 index cb6baaff2d26..000000000000 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/ExternalSystemStatusEvent.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.externalSystem.model.task.event; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * An event that informs about an interim result of the operation. - * - * @author Vladislav.Soroka - */ -public class ExternalSystemStatusEvent extends ExternalSystemProgressEvent { - - private final long myTotal; - private final long myProgress; - private final String myUnit; - @Nullable - private final String myDescription; - - public ExternalSystemStatusEvent(@NotNull String eventId, @Nullable String parentEventId, @NotNull T descriptor, - long total, long progress, String unit) { - this(eventId, parentEventId, descriptor, total, progress, unit, null); - } - - public ExternalSystemStatusEvent(@NotNull String eventId, @Nullable String parentEventId, @NotNull T descriptor, - long total, long progress, String unit, @Nullable String description) { - super(eventId, parentEventId, descriptor); - myTotal = total; - myProgress = progress; - myUnit = unit; - myDescription = description; - } - - /** - * The amount of work already performed by the build operation. - * - * @return The amount of performed work - */ - public long getProgress() { - return myProgress; - } - - /** - * The total amount of work that the build operation is in the progress of performing, or -1 if not known. - * - * @return The total amount of work, or -1 if not known. - */ - public long getTotal() { - return myTotal; - } - - /** - * The measure used to express the amount of work. - * - * @return The measure used to express the amount of work. - */ - public String getUnit() { - return myUnit; - } - - @Nullable - public String getDescription() { - return myDescription; - } -} diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/progressEvent.kt b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/progressEvent.kt new file mode 100644 index 000000000000..eb4c85f7f62f --- /dev/null +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/task/event/progressEvent.kt @@ -0,0 +1,76 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.openapi.externalSystem.model.task.event + +import com.intellij.openapi.util.NlsSafe +import org.jetbrains.annotations.Nls +import java.io.Serializable + +open class ExternalSystemProgressEvent( + val eventId: String, + val parentEventId: String?, + val descriptor: T, +) : Serializable { + + val displayName: String + get() = descriptor.displayName + + val eventTime: Long + get() = descriptor.eventTime +} + +class ExternalSystemStartEvent( + eventId: String, + parentEventId: String?, + descriptor: T, +) : ExternalSystemProgressEvent(eventId = eventId, parentEventId = parentEventId, descriptor = descriptor) + +class ExternalSystemFinishEvent( + eventId: String, + parentEventId: String?, + descriptor: T, + val operationResult: OperationResult, +) : ExternalSystemProgressEvent(eventId = eventId, parentEventId = parentEventId, descriptor = descriptor) + +/** + * An event with textual description. + * + * @property description Textual description of the event. Arbitrary additional information about status update. + */ +class ExternalSystemMessageEvent( + eventId: String, + parentEventId: String?, + descriptor: T, + val isStdOut: Boolean, + val message: @Nls String?, + val description: String?, +) : ExternalSystemProgressEvent(eventId = eventId, parentEventId = parentEventId, descriptor = descriptor) { + + constructor( + eventId: String, + parentEventId: String?, + descriptor: T, + description: @NlsSafe String?, + ) : this(eventId = eventId, + parentEventId = parentEventId, + descriptor = descriptor, + isStdOut = true, + message = description, + description = description) +} + +/** + * An event that informs about an interim result of the operation. + * + * @property total The total amount of work that the build operation is in the progress of performing, or -1 if not known. + * @property progress The amount of work already performed by the build operation. + * @property unit The measure used to express the amount of work. + */ +class ExternalSystemStatusEvent @JvmOverloads constructor( + eventId: String, + parentEventId: String?, + descriptor: T, + val total: Long, + val progress: Long, + val unit: String, + val description: String? = null, +) : ExternalSystemProgressEvent(eventId = eventId, parentEventId = parentEventId, descriptor = descriptor) diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemTaskProgressIndicatorUpdater.kt b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemTaskProgressIndicatorUpdater.kt index 475d64cad692..3a864c6ab761 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemTaskProgressIndicatorUpdater.kt +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemTaskProgressIndicatorUpdater.kt @@ -53,9 +53,9 @@ abstract class ExternalSystemTaskProgressIndicatorUpdater { } event is ExternalSystemTaskExecutionEvent && event.progressEvent is ExternalSystemStatusEvent<*> -> { val progressEvent = event.progressEvent as ExternalSystemStatusEvent<*> - total = progressEvent.getTotal() - progress = progressEvent.getProgress() - unit = progressEvent.getUnit() + total = progressEvent.total + progress = progressEvent.progress + unit = progressEvent.unit } else -> return }