mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
IDEA-323982 add build originator to FUS statistics
GitOrigin-RevId: 9031c45010971a2e8cabc0d24a911e6fe6aa4ad8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1e4761a0a1
commit
4fd7ab1769
@@ -28,6 +28,7 @@ import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactsWorkspaceSettings;
|
||||
import com.intellij.task.ProjectTaskManager;
|
||||
import com.intellij.task.impl.ProjectTaskManagerImpl;
|
||||
import com.intellij.ui.popup.list.ListPopupImpl;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
@@ -117,6 +118,7 @@ public final class BuildArtifactAction extends DumbAwareAction {
|
||||
}
|
||||
|
||||
private static void doBuild(@NotNull Project project, final @NotNull List<ArtifactPopupItem> items, boolean rebuild) {
|
||||
ProjectTaskManagerImpl.putBuildOriginator(project, BuildArtifactAction.class);
|
||||
final Artifact[] artifacts = getArtifacts(items, project);
|
||||
if (rebuild) {
|
||||
ProjectTaskManager.getInstance(project).rebuild(artifacts);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2019 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.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.compiler.actions;
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
@@ -9,6 +9,7 @@ import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.task.impl.ProjectTaskManagerImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class CompileActionBase extends AnAction implements DumbAware {
|
||||
@@ -29,6 +30,7 @@ public abstract class CompileActionBase extends AnAction implements DumbAware {
|
||||
if (file != null && editor != null && !DumbService.getInstance(project).isDumb()) {
|
||||
DaemonCodeAnalyzer.getInstance(project).autoImportReferenceAtCursor(editor, file); //let autoimport complete
|
||||
}
|
||||
ProjectTaskManagerImpl.putBuildOriginator(project, this.getClass());
|
||||
doAction(e.getDataContext(), project);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.packaging.impl.run
|
||||
|
||||
import com.intellij.execution.BeforeRunTaskProvider
|
||||
@@ -86,6 +86,7 @@ abstract class BuildArtifactsBeforeRunTaskProviderBase<T : BuildArtifactsBeforeR
|
||||
val sessionId = ExecutionManagerImpl.EXECUTION_SESSION_ID_KEY.get(env)
|
||||
val projectTaskContext = ProjectTaskContext(sessionId)
|
||||
env.copyUserDataTo(projectTaskContext)
|
||||
ProjectTaskManagerImpl.putBuildOriginator(project, this.javaClass)
|
||||
val resultPromise = ProjectTaskManager.getInstance(project).run(projectTaskContext, artifactsBuildProjectTask)
|
||||
val taskResult = ProjectTaskManagerImpl.waitForPromise(resultPromise)
|
||||
return taskResult != null && !taskResult.isAborted && !taskResult.hasErrors()
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.task.*;
|
||||
import com.intellij.task.impl.ProjectTaskManagerImpl;
|
||||
import com.intellij.ui.UIBundle;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.FileCollectionFactory;
|
||||
@@ -276,12 +277,14 @@ public final class HotSwapUIImpl extends HotSwapUI {
|
||||
@Nullable HotSwapStatusListener callback) {
|
||||
dontAskHotswapAfterThisCompilation();
|
||||
if (compileBeforeHotswap) {
|
||||
ProjectTaskManager projectTaskManager = ProjectTaskManager.getInstance(session.getProject());
|
||||
Project project = session.getProject();
|
||||
ProjectTaskManagerImpl.putBuildOriginator(project, this.getClass());
|
||||
ProjectTaskManager projectTaskManager = ProjectTaskManager.getInstance(project);
|
||||
if (callback == null) {
|
||||
projectTaskManager.buildAllModules();
|
||||
}
|
||||
else {
|
||||
ProjectTask buildProjectTask = projectTaskManager.createAllModulesBuildTask(true, session.getProject());
|
||||
ProjectTask buildProjectTask = projectTaskManager.createAllModulesBuildTask(true, project);
|
||||
ProjectTaskContext context = new ProjectTaskContext(callback).withUserData(HOT_SWAP_CALLBACK_KEY, callback);
|
||||
projectTaskManager.run(context, buildProjectTask);
|
||||
}
|
||||
@@ -299,7 +302,9 @@ public final class HotSwapUIImpl extends HotSwapUI {
|
||||
@Override
|
||||
public void compileAndReload(@NotNull DebuggerSession session, VirtualFile @NotNull ... files) {
|
||||
dontAskHotswapAfterThisCompilation();
|
||||
ProjectTaskManager.getInstance(session.getProject()).compile(files);
|
||||
Project project = session.getProject();
|
||||
ProjectTaskManagerImpl.putBuildOriginator(project, this.getClass());
|
||||
ProjectTaskManager.getInstance(project).compile(files);
|
||||
// The control flow continues at MyCompilationStatusListener.finished.
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.task.ProjectTask;
|
||||
import com.intellij.task.ProjectTaskContext;
|
||||
import com.intellij.task.ProjectTaskManager;
|
||||
import com.intellij.task.impl.EmptyCompileScopeBuildTaskImpl;
|
||||
import com.intellij.task.impl.ProjectTaskManagerImpl;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -172,6 +173,7 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
|
||||
|
||||
}).expireWith(myProject).executeSynchronously();
|
||||
|
||||
ProjectTaskManagerImpl.putBuildOriginator(myProject, CompileStepBeforeRun.class);
|
||||
projectTaskManager.run(pair.first, pair.second).onSuccess(taskResult -> {
|
||||
if ((!taskResult.hasErrors() || ignoreErrors) && !taskResult.isAborted()) {
|
||||
result.set(Boolean.TRUE);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.performancePlugin;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -9,6 +10,7 @@ import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.task.ModuleBuildTask;
|
||||
import com.intellij.task.ProjectTaskManager;
|
||||
import com.intellij.task.impl.ProjectTaskManagerImpl;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.jetbrains.performancePlugin.PerformanceTestSpan;
|
||||
import com.jetbrains.performancePlugin.PerformanceTestingBundle;
|
||||
@@ -71,6 +73,7 @@ public class BuildCommand extends AbstractCommand {
|
||||
});
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
ProjectTaskManagerImpl.putBuildOriginator(project, this.getClass());
|
||||
ProjectTaskManager instance = ProjectTaskManager.getInstance(project);
|
||||
Promise<ProjectTaskManager.Result> promise = null;
|
||||
spanRef.set(span.startSpan());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.task.impl;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
@@ -17,6 +17,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.OrderEnumerator;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectModelBuildableElement;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -55,6 +56,8 @@ import static java.util.stream.Collectors.groupingBy;
|
||||
*/
|
||||
public final class ProjectTaskManagerImpl extends ProjectTaskManager {
|
||||
private static final Logger LOG = Logger.getInstance(ProjectTaskManager.class);
|
||||
private static final Key<String> BUILD_ORIGINATOR_KEY = Key.create("project task build originator");
|
||||
|
||||
private final ProjectTaskRunner myDummyTaskRunner = new DummyTaskRunner();
|
||||
private final ProjectTaskListener myEventPublisher;
|
||||
private final List<ProjectTaskManagerListener> myListeners = new CopyOnWriteArrayList<>();
|
||||
@@ -271,6 +274,11 @@ public final class ProjectTaskManagerImpl extends ProjectTaskManager {
|
||||
if (modules.get() > 0) {
|
||||
fields.add(MODULES.with(modules.get()));
|
||||
}
|
||||
String buildOriginator = BUILD_ORIGINATOR_KEY.get(myProject);
|
||||
if (buildOriginator != null) {
|
||||
myProject.putUserData(BUILD_ORIGINATOR_KEY, null);
|
||||
fields.add(BUILD_ORIGINATOR.with(buildOriginator));
|
||||
}
|
||||
return BUILD_ACTIVITY.started(myProject, () -> fields);
|
||||
}
|
||||
|
||||
@@ -306,6 +314,12 @@ public final class ProjectTaskManagerImpl extends ProjectTaskManager {
|
||||
visitTasks(projectTask instanceof ProjectTaskList ? (ProjectTaskList)projectTask : Collections.singleton(projectTask), taskClassifier);
|
||||
}
|
||||
|
||||
public static void putBuildOriginator(@Nullable Project project, @NotNull Class<?> clazz) {
|
||||
if (BUILD_ORIGINATOR_KEY.get(project) == null) {
|
||||
BUILD_ORIGINATOR_KEY.set(project, clazz.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static @Nullable <T> T waitForPromise(@NotNull Promise<T> promise) {
|
||||
while (true) {
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.task.impl
|
||||
|
||||
import com.intellij.internal.statistic.IdeActivityDefinition
|
||||
import com.intellij.internal.statistic.collectors.fus.ClassNameRuleValidator
|
||||
import com.intellij.internal.statistic.eventLog.EventLogGroup
|
||||
import com.intellij.internal.statistic.eventLog.events.BooleanEventField
|
||||
import com.intellij.internal.statistic.eventLog.events.EventFields
|
||||
import com.intellij.internal.statistic.eventLog.events.IntEventField
|
||||
import com.intellij.internal.statistic.eventLog.events.StringListEventField
|
||||
import com.intellij.internal.statistic.eventLog.events.*
|
||||
import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector
|
||||
|
||||
class ProjectTaskManagerStatisticsCollector : CounterUsagesCollector() {
|
||||
@@ -23,12 +20,15 @@ class ProjectTaskManagerStatisticsCollector : CounterUsagesCollector() {
|
||||
@JvmField
|
||||
val INCREMENTAL: BooleanEventField = EventFields.Boolean("incremental")
|
||||
|
||||
@JvmField
|
||||
val BUILD_ORIGINATOR: StringEventField = EventFields.StringValidatedByCustomRule("build_originator", ClassNameRuleValidator::class.java)
|
||||
|
||||
@JvmField
|
||||
val HAS_ERRORS: BooleanEventField = EventFields.Boolean("has_errors")
|
||||
|
||||
@JvmField
|
||||
val BUILD_ACTIVITY: IdeActivityDefinition = GROUP.registerIdeActivity(null,
|
||||
startEventAdditionalFields = arrayOf(TASK_RUNNER, EventFields.PluginInfo, MODULES, INCREMENTAL),
|
||||
startEventAdditionalFields = arrayOf(TASK_RUNNER, EventFields.PluginInfo, MODULES, INCREMENTAL, BUILD_ORIGINATOR),
|
||||
finishEventAdditionalFields = arrayOf(HAS_ERRORS))
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<orderEntry type="library" name="kotlin-stdlib" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core" />
|
||||
<orderEntry type="module" module-name="intellij.platform.vcs.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.builtInServer.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core.ui" />
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.smartUpdate
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.task.ProjectTaskManager
|
||||
import com.intellij.task.impl.ProjectTaskManagerImpl
|
||||
|
||||
const val BUILD_PROJECT = "build.project"
|
||||
|
||||
@@ -12,6 +13,7 @@ class BuildProjectStep: SmartUpdateStep {
|
||||
|
||||
override fun performUpdateStep(project: Project, e: AnActionEvent?, onSuccess: () -> Unit) {
|
||||
val start = System.currentTimeMillis()
|
||||
ProjectTaskManagerImpl.putBuildOriginator(project, this.javaClass)
|
||||
ProjectTaskManager.getInstance(project).buildAllModules().onSuccess {
|
||||
SmartUpdateUsagesCollector.logBuild(System.currentTimeMillis() - start, true)
|
||||
onSuccess.invoke()
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.warmup
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.task.ProjectTaskManager
|
||||
import com.intellij.task.impl.ProjectTaskManagerImpl
|
||||
import org.jetbrains.concurrency.asDeferred
|
||||
|
||||
internal class PlatformBuildWarmupSupport(val project: Project) : ProjectBuildWarmupSupport {
|
||||
@@ -13,6 +14,7 @@ internal class PlatformBuildWarmupSupport(val project: Project) : ProjectBuildWa
|
||||
}
|
||||
|
||||
override suspend fun buildProjectWithStatus(rebuild: Boolean): WarmupBuildStatus.InvocationStatus {
|
||||
ProjectTaskManagerImpl.putBuildOriginator(project, this.javaClass)
|
||||
val projectTaskManager = ProjectTaskManager.getInstance(project)
|
||||
|
||||
val result = (if (rebuild) projectTaskManager.rebuildAllModules() else projectTaskManager.buildAllModules()).asDeferred().await()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.coverage;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
@@ -58,6 +58,7 @@ import com.intellij.rt.coverage.data.JumpData;
|
||||
import com.intellij.rt.coverage.data.LineData;
|
||||
import com.intellij.rt.coverage.data.SwitchData;
|
||||
import com.intellij.task.ProjectTaskManager;
|
||||
import com.intellij.task.impl.ProjectTaskManagerImpl;
|
||||
import com.intellij.testIntegration.TestFramework;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import jetbrains.coverage.report.ReportGenerationFailedException;
|
||||
@@ -359,6 +360,7 @@ public class JavaCoverageEngine extends CoverageEngine {
|
||||
JavaCoverageBundle.message("project.class.files.are.out.of.date"),
|
||||
NotificationType.INFORMATION);
|
||||
notification.addAction(NotificationAction.createSimpleExpiring(JavaCoverageBundle.message("coverage.recompile"), () -> {
|
||||
ProjectTaskManagerImpl.putBuildOriginator(project, this.getClass());
|
||||
ProjectTaskManager taskManager = ProjectTaskManager.getInstance(project);
|
||||
Promise<ProjectTaskManager.Result> promise = taskManager.buildAllModules();
|
||||
promise.onSuccess(result -> ApplicationManager.getApplication().invokeLater(() -> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.scratch.actions
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.openapi.keymap.KeymapManager
|
||||
import com.intellij.openapi.keymap.KeymapUtil
|
||||
import com.intellij.openapi.project.DumbService
|
||||
import com.intellij.task.ProjectTaskManager
|
||||
import com.intellij.task.impl.ProjectTaskManagerImpl
|
||||
import org.jetbrains.kotlin.idea.KotlinJvmBundle
|
||||
import org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager
|
||||
import org.jetbrains.kotlin.idea.core.script.configuration.CompositeScriptConfigurationManager
|
||||
@@ -64,6 +65,7 @@ class RunScratchAction : ScratchAction(
|
||||
log.printDebugMessage("Run Action: module = ${module?.name}")
|
||||
|
||||
if (!isAutoRun && module != null && isMakeBeforeRun) {
|
||||
ProjectTaskManagerImpl.putBuildOriginator(project, this.javaClass)
|
||||
ProjectTaskManager.getInstance(project).build(module).onSuccess { executionResult ->
|
||||
if (executionResult.isAborted || executionResult.hasErrors()) {
|
||||
executor.errorOccurs(KotlinJvmBundle.message("there.were.compilation.errors.in.module.0", module.name))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.console
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.openapi.compiler.CompilerManager
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.task.ProjectTaskManager
|
||||
import com.intellij.task.impl.ProjectTaskManagerImpl
|
||||
|
||||
class ConsoleCompilerHelper(
|
||||
private val project: Project,
|
||||
@@ -25,6 +26,7 @@ class ConsoleCompilerHelper(
|
||||
|
||||
fun compileModule() {
|
||||
if (RunContentManager.getInstance(project).removeRunContent(executor, contentDescriptor)) {
|
||||
ProjectTaskManagerImpl.putBuildOriginator(project, this.javaClass)
|
||||
ProjectTaskManager.getInstance(project).build(module).onSuccess {
|
||||
if (!module.isDisposed) {
|
||||
KotlinConsoleKeeper.getInstance(project).run(module, previousCompilationFailed = it.hasErrors())
|
||||
|
||||
Reference in New Issue
Block a user