Search in sources :

Example 6 with UsageDescriptor

use of com.intellij.internal.statistic.beans.UsageDescriptor in project intellij-community by JetBrains.

the class StatisticsUploadAssistantTest method assertSetEquals.

private static void assertSetEquals(@NotNull Set<? extends UsageDescriptor> expected, @NotNull Set<? extends UsageDescriptor> actual) {
    assertEquals(expected.size(), actual.size());
    for (UsageDescriptor usageDescriptor : expected) {
        boolean exists = false;
        for (UsageDescriptor descriptor : actual) {
            if (usageDescriptor.getKey().equals(descriptor.getKey()) && usageDescriptor.getValue() == descriptor.getValue()) {
                exists = true;
                break;
            }
        }
        assertTrue(asString(usageDescriptor) + " usage doesn't exist", exists);
    }
}
Also used : UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor)

Example 7 with UsageDescriptor

use of com.intellij.internal.statistic.beans.UsageDescriptor in project intellij-community by JetBrains.

the class FeaturesUsageCollector method getUsages.

@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
    Set<UsageDescriptor> usages = new HashSet<>();
    final ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance();
    for (String featureId : registry.getFeatureIds()) {
        final FeatureDescriptor featureDescriptor = registry.getFeatureDescriptor(featureId);
        if (featureDescriptor != null) {
            usages.add(new UsageDescriptor(featureId, featureDescriptor.getUsageCount()));
        }
    }
    return usages;
}
Also used : UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) HashSet(com.intellij.util.containers.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with UsageDescriptor

use of com.intellij.internal.statistic.beans.UsageDescriptor in project intellij-community by JetBrains.

the class OsVersionUsageCollector method getUsages.

@NotNull
@Override
public Set<UsageDescriptor> getUsages() throws CollectUsagesException {
    UsageDescriptor descriptor;
    if (SystemInfo.isLinux) {
        String releaseId = null, releaseVersion = null;
        try {
            Map<String, String> values = Files.lines(Paths.get("/etc/os-release")).map(line -> StringUtil.split(line, "=")).filter(parts -> parts.size() == 2).collect(Collectors.toMap(parts -> parts.get(0), parts -> StringUtil.unquoteString(parts.get(1))));
            releaseId = values.get("ID");
            releaseVersion = values.get("VERSION_ID");
        } catch (IOException ignored) {
        }
        if (releaseId == null)
            releaseId = "unknown";
        if (releaseVersion == null) {
            releaseVersion = SystemInfo.OS_VERSION;
            Version version = Version.parseVersion(releaseVersion);
            if (version != null) {
                releaseVersion = version.toCompactString();
            }
        }
        descriptor = new UsageDescriptor("Linux/" + releaseId + " " + releaseVersion, 1);
    } else {
        descriptor = new UsageDescriptor(SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION, 1);
    }
    return Collections.singleton(descriptor);
}
Also used : GroupDescriptor(com.intellij.internal.statistic.beans.GroupDescriptor) Files(java.nio.file.Files) StringUtil(com.intellij.openapi.util.text.StringUtil) UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) Set(java.util.Set) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) SystemInfo(com.intellij.openapi.util.SystemInfo) Version(com.intellij.openapi.util.Version) Paths(java.nio.file.Paths) Map(java.util.Map) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) Version(com.intellij.openapi.util.Version) IOException(java.io.IOException) UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with UsageDescriptor

use of com.intellij.internal.statistic.beans.UsageDescriptor in project intellij-community by JetBrains.

the class IdeSettingsStatisticsUtils method getUsages.

public static Set<UsageDescriptor> getUsages(@NotNull IdeSettingsDescriptor descriptor, @NotNull Object componentInstance) {
    Set<UsageDescriptor> descriptors = new HashSet<>();
    String providerName = descriptor.myProviderName;
    List<String> propertyNames = descriptor.getPropertyNames();
    if (providerName != null && propertyNames.size() > 0) {
        for (String propertyName : propertyNames) {
            Object propertyValue = getPropertyValue(componentInstance, propertyName);
            if (propertyValue != null) {
                descriptors.add(new UsageDescriptor(getUsageDescriptorKey(providerName, propertyName, propertyValue.toString()), 1));
            }
        }
    }
    return descriptors;
}
Also used : UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) HashSet(com.intellij.util.containers.hash.HashSet)

Example 10 with UsageDescriptor

use of com.intellij.internal.statistic.beans.UsageDescriptor in project intellij-community by JetBrains.

the class FileTypeUsagesCollectorTest method doTest.

private void doTest(@NotNull Collection<FileType> fileTypes) throws CollectUsagesException {
    final Set<UsageDescriptor> usages = new FileTypeUsagesCollector().getProjectUsages(getProject());
    for (UsageDescriptor usage : usages) {
        assertEquals(1, usage.getValue());
    }
    assertEquals(ContainerUtil.map2Set(fileTypes, (NotNullFunction<FileType, String>) fileType -> fileType.getName()), ContainerUtil.map2Set(usages, (NotNullFunction<UsageDescriptor, String>) usageDescriptor -> usageDescriptor.getKey()));
}
Also used : UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) NotNullFunction(com.intellij.util.NotNullFunction)

Aggregations

UsageDescriptor (com.intellij.internal.statistic.beans.UsageDescriptor)23 NotNull (org.jetbrains.annotations.NotNull)19 HashSet (com.intellij.util.containers.HashSet)4 HashSet (java.util.HashSet)4 GroupDescriptor (com.intellij.internal.statistic.beans.GroupDescriptor)3 Module (com.intellij.openapi.module.Module)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 HashSet (com.intellij.util.containers.hash.HashSet)2 VcsProjectLog (com.intellij.vcs.log.impl.VcsProjectLog)2 THashSet (gnu.trove.THashSet)2 Set (java.util.Set)2 CodeInsightSettings (com.intellij.codeInsight.CodeInsightSettings)1 RunManager (com.intellij.execution.RunManager)1 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)1 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 AbstractApplicationUsagesCollector (com.intellij.internal.statistic.AbstractApplicationUsagesCollector)1 CollectedUsages (com.intellij.internal.statistic.persistence.CollectedUsages)1 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)1