mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-253063 get run configuration language in background thread
GitOrigin-RevId: 3f4c5e898637d22c2201c6d193ed91b7204e4bd0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
56ab37534b
commit
bf2efd5ab6
+32
-18
@@ -11,14 +11,17 @@ import com.intellij.execution.target.TargetEnvironmentConfiguration;
|
||||
import com.intellij.execution.target.TargetEnvironmentType;
|
||||
import com.intellij.execution.target.TargetEnvironmentsManager;
|
||||
import com.intellij.internal.statistic.IdeActivity;
|
||||
import com.intellij.internal.statistic.eventLog.FeatureUsageData;
|
||||
import com.intellij.internal.statistic.eventLog.events.*;
|
||||
import com.intellij.internal.statistic.eventLog.validator.ValidationResultType;
|
||||
import com.intellij.internal.statistic.eventLog.validator.rules.EventContext;
|
||||
import com.intellij.internal.statistic.eventLog.validator.rules.impl.CustomValidationRule;
|
||||
import com.intellij.internal.statistic.utils.PluginInfo;
|
||||
import com.intellij.internal.statistic.utils.PluginInfoDetectorKt;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.concurrency.NonUrgentExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -38,27 +41,38 @@ public final class RunConfigurationUsageTriggerCollector {
|
||||
@NotNull ConfigurationFactory factory,
|
||||
@NotNull Executor executor,
|
||||
@Nullable RunConfiguration runConfiguration) {
|
||||
return new IdeActivity(project, GROUP).startedWithDataAsync(data -> {
|
||||
return ReadAction.nonBlocking(() -> buildContext(project, factory, executor, runConfiguration, data))
|
||||
.expireWith(project)
|
||||
.submit(NonUrgentExecutor.getInstance());
|
||||
});
|
||||
}
|
||||
|
||||
private static @NotNull FeatureUsageData buildContext(@NotNull Project project,
|
||||
@NotNull ConfigurationFactory factory,
|
||||
@NotNull Executor executor,
|
||||
@Nullable RunConfiguration runConfiguration,
|
||||
@NotNull FeatureUsageData data) {
|
||||
final ConfigurationType configurationType = factory.getType();
|
||||
return new IdeActivity(project, GROUP).startedWithData(data -> {
|
||||
List<EventPair> eventPairs = createFeatureUsageData(configurationType, factory);
|
||||
ExecutorGroup<?> group = ExecutorGroup.getGroupIfProxy(executor);
|
||||
eventPairs.add(EXECUTOR.with(group != null ? group.getId() : executor.getId()));
|
||||
if (runConfiguration instanceof FusAwareRunConfiguration) {
|
||||
List<EventPair<?>> additionalData = ((FusAwareRunConfiguration)runConfiguration).getAdditionalUsageData();
|
||||
ObjectEventData objectEventData = new ObjectEventData(additionalData);
|
||||
eventPairs.add(ADDITIONAL_FIELD.with(objectEventData));
|
||||
}
|
||||
if (runConfiguration instanceof TargetEnvironmentAwareRunProfile) {
|
||||
String defaultTargetName = ((TargetEnvironmentAwareRunProfile)runConfiguration).getDefaultTargetName();
|
||||
if (defaultTargetName != null) {
|
||||
TargetEnvironmentConfiguration target = TargetEnvironmentsManager.getInstance(project).getTargets().findByName(defaultTargetName);
|
||||
if (target != null) {
|
||||
eventPairs.add(TARGET.with(target.getTypeId()));
|
||||
}
|
||||
List<EventPair> eventPairs = createFeatureUsageData(configurationType, factory);
|
||||
ExecutorGroup<?> group = ExecutorGroup.getGroupIfProxy(executor);
|
||||
eventPairs.add(EXECUTOR.with(group != null ? group.getId() : executor.getId()));
|
||||
if (runConfiguration instanceof FusAwareRunConfiguration) {
|
||||
List<EventPair<?>> additionalData = ((FusAwareRunConfiguration)runConfiguration).getAdditionalUsageData();
|
||||
ObjectEventData objectEventData = new ObjectEventData(additionalData);
|
||||
eventPairs.add(ADDITIONAL_FIELD.with(objectEventData));
|
||||
}
|
||||
if (runConfiguration instanceof TargetEnvironmentAwareRunProfile) {
|
||||
String defaultTargetName = ((TargetEnvironmentAwareRunProfile)runConfiguration).getDefaultTargetName();
|
||||
if (defaultTargetName != null) {
|
||||
TargetEnvironmentConfiguration target = TargetEnvironmentsManager.getInstance(project).getTargets().findByName(defaultTargetName);
|
||||
if (target != null) {
|
||||
eventPairs.add(TARGET.with(target.getTypeId()));
|
||||
}
|
||||
}
|
||||
eventPairs.forEach(pair -> pair.addData(data));
|
||||
});
|
||||
}
|
||||
eventPairs.forEach(pair -> pair.addData(data));
|
||||
return data;
|
||||
}
|
||||
|
||||
public static class RunConfigurationExecutorUtilValidator extends CustomValidationRule {
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.util.TimeoutUtil
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.concurrency.Promise
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.function.Consumer
|
||||
|
||||
@@ -44,6 +45,17 @@ class IdeActivity @JvmOverloads constructor(private val projectOrNullForApplicat
|
||||
return this
|
||||
}
|
||||
|
||||
fun startedWithDataAsync(dataSupplier: (FeatureUsageData) -> Promise<FeatureUsageData>): IdeActivity {
|
||||
if (!LOG.assertTrue(state == State.NOT_STARTED, state.name)) return this
|
||||
state = State.STARTED
|
||||
startedTimestamp = System.nanoTime()
|
||||
|
||||
dataSupplier(createDataWithActivityId()).then { data ->
|
||||
FUCounterUsageLogger.getInstance().logEvent(projectOrNullForApplication, group, appendActivityName(STARTED_EVENT_ID), data)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
fun stageStarted(stageName: String): IdeActivity {
|
||||
if (!LOG.assertTrue(state == State.STARTED, state.name)) return this
|
||||
|
||||
|
||||
Reference in New Issue
Block a user