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);
}
}
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;
}
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);
}
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;
}
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()));
}
Aggregations