mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
FUS-412 vcs: update usages collectors by new guidelines
GitOrigin-RevId: b27a927773f81258e429bd33873c95b8038800d7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ffddba18a5
commit
6efa9d2bc0
+4
-2
@@ -96,8 +96,10 @@ class FeatureUsageData {
|
||||
return if (SystemInfo.isLinux) "Linux" else "Other"
|
||||
}
|
||||
|
||||
fun addPluginInfo(info: PluginInfo): FeatureUsageData {
|
||||
addPluginInfoTo(info, data)
|
||||
fun addPluginInfo(info: PluginInfo?): FeatureUsageData {
|
||||
info?.let {
|
||||
addPluginInfoTo(info, data)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
@@ -455,8 +455,7 @@
|
||||
<statistics.counterUsagesCollector groupId="new.project.wizard" version="1"/>
|
||||
|
||||
<statistics.projectUsagesCollector implementation="com.intellij.openapi.vcs.statistics.VcsOptionsUsagesCollector"/>
|
||||
<statistics.projectUsagesCollector implementation="com.intellij.openapi.vcs.statistics.VcsStatsUsagesCollector"/>
|
||||
<statistics.projectUsagesCollector implementation="com.intellij.openapi.vcs.statistics.VcsNamesUsagesCollector"/>
|
||||
<statistics.projectUsagesCollector implementation="com.intellij.openapi.vcs.statistics.VcsUsagesCollector"/>
|
||||
|
||||
<applicationInitializedListener implementation="com.intellij.openapi.application.Preloader"/>
|
||||
|
||||
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
// Copyright 2000-2018 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.vcs.statistics;
|
||||
|
||||
import com.intellij.internal.statistic.beans.UsageDescriptor;
|
||||
import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector;
|
||||
import com.intellij.internal.statistic.utils.PluginInfo;
|
||||
import com.intellij.internal.statistic.utils.PluginInfoDetectorKt;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class VcsNamesUsagesCollector extends ProjectUsagesCollector {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getGroupId() {
|
||||
return "vcs.names";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<UsageDescriptor> getUsages(@NotNull Project project) {
|
||||
return getDescriptors(project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Set<UsageDescriptor> getDescriptors(@NotNull Project project) {
|
||||
Set<UsageDescriptor> usages = new HashSet<>();
|
||||
|
||||
ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
|
||||
AbstractVcs[] activeVcss = vcsManager.getAllActiveVcss();
|
||||
|
||||
List<String> vcsNames = ContainerUtil.map(activeVcss, vcs -> {
|
||||
PluginInfo pluginInfo = PluginInfoDetectorKt.getPluginInfo(vcs.getClass());
|
||||
if (pluginInfo.isDevelopedByJetBrains()) return vcs.getName();
|
||||
if (pluginInfo.isSafeToReport()) return "third.party." + pluginInfo.getId();
|
||||
return "third.party.other";
|
||||
});
|
||||
|
||||
for (String vcs : vcsNames) {
|
||||
usages.add(new UsageDescriptor(vcs, 1));
|
||||
}
|
||||
|
||||
return usages;
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
// Copyright 2000-2018 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.vcs.statistics;
|
||||
|
||||
import com.intellij.internal.statistic.beans.UsageDescriptor;
|
||||
import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
|
||||
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.internal.statistic.utils.StatisticsUtilKt.getBooleanUsage;
|
||||
import static com.intellij.internal.statistic.utils.StatisticsUtilKt.getCountingUsage;
|
||||
|
||||
public class VcsStatsUsagesCollector extends ProjectUsagesCollector {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getGroupId() {
|
||||
return "vcs.metrics";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<UsageDescriptor> getUsages(@NotNull Project project) {
|
||||
return getDescriptors(project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Set<UsageDescriptor> getDescriptors(@NotNull Project project) {
|
||||
Set<UsageDescriptor> usages = new HashSet<>();
|
||||
|
||||
ChangeListManagerImpl clm = ChangeListManagerImpl.getInstanceImpl(project);
|
||||
ProjectLevelVcsManagerEx vcsManager = ProjectLevelVcsManagerEx.getInstanceEx(project);
|
||||
|
||||
usages.add(getCountingUsage("active.changelists.count", clm.getChangeListsNumber()));
|
||||
usages.add(getCountingUsage("unversioned.files.count", clm.getUnversionedFiles().size()));
|
||||
usages.add(getCountingUsage("ignored.files.count", clm.getIgnoredFiles().size()));
|
||||
usages.add(getCountingUsage("vcs.roots.count", vcsManager.getAllVcsRoots().length));
|
||||
usages.add(getBooleanUsage("has.default.vcs.root.mapping", vcsManager.haveDefaultMapping() != null));
|
||||
|
||||
return usages;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
// 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.
|
||||
package com.intellij.openapi.vcs.statistics
|
||||
|
||||
import com.intellij.internal.statistic.beans.MetricEvent
|
||||
import com.intellij.internal.statistic.beans.newCounterMetric
|
||||
import com.intellij.internal.statistic.beans.newMetric
|
||||
import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector
|
||||
import com.intellij.internal.statistic.utils.getPluginInfo
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl
|
||||
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx
|
||||
import com.intellij.util.text.nullize
|
||||
import com.intellij.vcsUtil.VcsUtil
|
||||
import java.util.*
|
||||
|
||||
class VcsUsagesCollector : ProjectUsagesCollector() {
|
||||
override fun getGroupId(): String = "vcs.configuration"
|
||||
override fun getVersion(): Int = 2
|
||||
|
||||
override fun getMetrics(project: Project): Set<MetricEvent> {
|
||||
val set = HashSet<MetricEvent>()
|
||||
|
||||
val vcsManager = ProjectLevelVcsManagerEx.getInstanceEx(project)
|
||||
val clm = ChangeListManagerImpl.getInstanceImpl(project)
|
||||
val projectBaseDir = project.basePath?.let { VcsUtil.getVirtualFile(it) }
|
||||
|
||||
for (vcs in vcsManager.allActiveVcss) {
|
||||
val pluginInfo = getPluginInfo(vcs.javaClass)
|
||||
|
||||
val metric = newMetric("active.vcs")
|
||||
metric.data.addPluginInfo(pluginInfo)
|
||||
metric.data.addData("vcs", vcs.name)
|
||||
set.add(metric)
|
||||
}
|
||||
|
||||
for (mapping in vcsManager.directoryMappings) {
|
||||
val vcsName = mapping.vcs.nullize(true)
|
||||
val vcs = vcsManager.findVcsByName(vcsName)
|
||||
val pluginInfo = vcs?.let { getPluginInfo(it.javaClass) }
|
||||
|
||||
val metric = newMetric("mapping")
|
||||
metric.data.addPluginInfo(pluginInfo)
|
||||
metric.data.addData("vcs", vcsName ?: "None")
|
||||
metric.data.addData("is_project_mapping", mapping.isDefaultMapping)
|
||||
if (!mapping.isDefaultMapping) {
|
||||
metric.data.addData("is_base_dir", projectBaseDir != null &&
|
||||
projectBaseDir == VcsUtil.getVirtualFile(mapping.directory))
|
||||
}
|
||||
set.add(metric)
|
||||
}
|
||||
|
||||
val defaultVcs = vcsManager.findVcsByName(vcsManager.haveDefaultMapping())
|
||||
if (defaultVcs != null) {
|
||||
val pluginInfo = getPluginInfo(defaultVcs.javaClass)
|
||||
|
||||
val explicitRoots = vcsManager.directoryMappings
|
||||
.filter { it.vcs == defaultVcs.name }
|
||||
.filter { it.directory.isNotEmpty() }
|
||||
.map { VcsUtil.getVirtualFile(it.directory) }
|
||||
.toSet()
|
||||
|
||||
val projectMappedRoots = vcsManager.allVcsRoots
|
||||
.filter { it.vcs == defaultVcs }
|
||||
.filter { it.path != null && !explicitRoots.contains(it.path) }
|
||||
|
||||
for (vcsRoot in projectMappedRoots) {
|
||||
val metric = newMetric("project.mapped.root")
|
||||
metric.data.addPluginInfo(pluginInfo)
|
||||
metric.data.addData("vcs", defaultVcs.name)
|
||||
metric.data.addData("is_base_dir", vcsRoot.path == projectBaseDir)
|
||||
set.add(metric)
|
||||
}
|
||||
}
|
||||
|
||||
set.add(newCounterMetric("mapped.roots", vcsManager.allVcsRoots.size))
|
||||
set.add(newCounterMetric("changelists", clm.changeListsNumber))
|
||||
set.add(newCounterMetric("unversioned.files", clm.unversionedFiles.size))
|
||||
set.add(newCounterMetric("ignored.files", clm.ignoredFiles.size))
|
||||
|
||||
return set
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,6 @@
|
||||
<vcsAnnotationGutterActionProvider implementation="git4idea.actions.GitToggleAnnotationOptionsActionProvider" />
|
||||
<vcsAnnotationGutterActionProvider implementation="git4idea.actions.GitShowCommitInLogAnnotationGutterActionProvider" />
|
||||
<statistics.projectUsagesCollector implementation="git4idea.GitStatisticsCollector"/>
|
||||
<statistics.projectUsagesCollector implementation="git4idea.GitProjectMigrationStatisticsCollector"/>
|
||||
<vcsRepositoryInitializer implementation="git4idea.repo.GitRepositoryInitializer"/>
|
||||
<openapi.vcs.changes.actions.diff.ChangeDiffRequestProvider
|
||||
implementation="git4idea.diff.GitSubmoduleDiffRequestProvider"/>
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
// Copyright 2000-2018 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 git4idea
|
||||
|
||||
import com.intellij.internal.statistic.beans.UsageDescriptor
|
||||
import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector
|
||||
import com.intellij.internal.statistic.utils.getBooleanUsage
|
||||
import com.intellij.internal.statistic.utils.getCountingUsage
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
|
||||
class GitProjectMigrationStatisticsCollector : ProjectUsagesCollector() {
|
||||
|
||||
override fun getUsages(project: Project): Set<UsageDescriptor> {
|
||||
val usages = hashSetOf<UsageDescriptor>()
|
||||
|
||||
val gitVcs = GitVcs.getInstance(project)
|
||||
val manager = ProjectLevelVcsManager.getInstance(project)
|
||||
|
||||
val baseDir = project.baseDir
|
||||
val actualGitRoots = manager.getRootsUnderVcs(gitVcs)
|
||||
val mappings = manager.directoryMappings.filter { it.vcs != null }
|
||||
|
||||
val gitMappings = mappings.filter { it.vcs == gitVcs.name }
|
||||
val hasDefaultGitMapping = gitMappings.any { it.isDefaultMapping }
|
||||
val explicitlyMappedRoots = gitMappings.mapNotNull { LocalFileSystem.getInstance().findFileByPath(it.directory) }
|
||||
val projectMappingRoots = actualGitRoots.toMutableSet() - explicitlyMappedRoots
|
||||
|
||||
if (hasDefaultGitMapping) {
|
||||
usages.add(getBooleanUsage("base.dir.undefined", baseDir == null))
|
||||
usages.add(getBooleanUsage("has.default.git.mapping", hasDefaultGitMapping))
|
||||
usages.add(getBooleanUsage("has.other.vcses.mappings", mappings.size != gitMappings.size))
|
||||
usages.add(getCountingUsage("git.mappings.count", gitMappings.size))
|
||||
usages.add(getCountingUsage("git.detected.roots.count", actualGitRoots.size))
|
||||
usages.add(getCountingUsage("project.mapping.roots.count", projectMappingRoots.size))
|
||||
|
||||
if (baseDir != null) {
|
||||
var prefix: String? = null
|
||||
var gitRoot: VirtualFile? = null
|
||||
|
||||
if (gitMappings.size == 1 && actualGitRoots.size == 1) {
|
||||
prefix = "single.mapping"
|
||||
gitRoot = actualGitRoots.single()
|
||||
}
|
||||
else if (projectMappingRoots.size == 1) {
|
||||
prefix = "singe.base.mapping"
|
||||
gitRoot = projectMappingRoots.single()
|
||||
}
|
||||
|
||||
if (gitRoot != null && prefix != null) {
|
||||
if (gitRoot == baseDir) {
|
||||
usages.add(UsageDescriptor("$prefix.is.base.dir", 1))
|
||||
}
|
||||
else if (VfsUtilCore.isAncestor(gitRoot, baseDir, false)) {
|
||||
usages.add(UsageDescriptor("$prefix.above.base.dir", 1))
|
||||
}
|
||||
else if (VfsUtilCore.isAncestor(baseDir, gitRoot, false)) {
|
||||
usages.add(UsageDescriptor("$prefix.under.base.dir", 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return usages
|
||||
}
|
||||
|
||||
override fun getGroupId(): String {
|
||||
return "vcs.git.project.root"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user