Search in sources :

Example 1 with OperationDescriptor

use of com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor in project intellij-community by JetBrains.

the class GradleProgressEventConverter method convert.

@NotNull
public static ExternalSystemTaskNotificationEvent convert(ExternalSystemTaskId id, ProgressEvent event) {
    final InternalOperationDescriptor internalDesc = event.getDescriptor() instanceof DefaultOperationDescriptor ? ((DefaultOperationDescriptor) event.getDescriptor()).getInternalOperationDescriptor() : null;
    final String eventId = internalDesc == null ? event.getDescriptor().getDisplayName() : internalDesc.getId().toString();
    final String parentEventId;
    if (event.getDescriptor().getParent() == null) {
        parentEventId = null;
    } else {
        parentEventId = internalDesc == null ? event.getDescriptor().getParent().getDisplayName() : internalDesc.getParentId().toString();
    }
    final String description = event.getDescriptor().getName();
    if (event instanceof StartEvent) {
        final OperationDescriptor descriptor = convert(event.getDescriptor(), event.getEventTime());
        return new ExternalSystemTaskExecutionEvent(id, new ExternalSystemStartEventImpl<>(eventId, parentEventId, descriptor));
    } else if (event instanceof FinishEvent) {
        final OperationDescriptor descriptor = convert(event.getDescriptor(), event.getEventTime());
        return new ExternalSystemTaskExecutionEvent(id, new ExternalSystemFinishEventImpl<>(eventId, parentEventId, descriptor, convert(((FinishEvent) event).getResult())));
    } else if (event instanceof TaskProgressEvent) {
        final OperationDescriptor descriptor = convert(event.getDescriptor(), event.getEventTime());
        return new ExternalSystemTaskExecutionEvent(id, new BaseExternalSystemProgressEvent<>(eventId, parentEventId, descriptor));
    } else {
        return new ExternalSystemTaskNotificationEvent(id, description);
    }
}
Also used : InternalOperationDescriptor(org.gradle.tooling.internal.protocol.events.InternalOperationDescriptor) OperationDescriptor(com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor) DefaultOperationDescriptor(org.gradle.tooling.events.internal.DefaultOperationDescriptor) TaskOperationDescriptor(org.gradle.tooling.events.task.TaskOperationDescriptor) JvmTestOperationDescriptor(org.gradle.tooling.events.test.JvmTestOperationDescriptor) InternalOperationDescriptor(org.gradle.tooling.internal.protocol.events.InternalOperationDescriptor) DefaultOperationDescriptor(org.gradle.tooling.events.internal.DefaultOperationDescriptor) ExternalSystemTaskNotificationEvent(com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationEvent) TaskProgressEvent(org.gradle.tooling.events.task.TaskProgressEvent) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ExternalSystemTaskNotificationEvent (com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationEvent)1 OperationDescriptor (com.intellij.openapi.externalSystem.model.task.event.OperationDescriptor)1 DefaultOperationDescriptor (org.gradle.tooling.events.internal.DefaultOperationDescriptor)1 TaskOperationDescriptor (org.gradle.tooling.events.task.TaskOperationDescriptor)1 TaskProgressEvent (org.gradle.tooling.events.task.TaskProgressEvent)1 JvmTestOperationDescriptor (org.gradle.tooling.events.test.JvmTestOperationDescriptor)1 InternalOperationDescriptor (org.gradle.tooling.internal.protocol.events.InternalOperationDescriptor)1 NotNull (org.jetbrains.annotations.NotNull)1