Search in sources :

Example 16 with UsageDescriptor

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

the class AbstractApplicationUsagesCollector method getApplicationUsages.

@NotNull
public Set<UsageDescriptor> getApplicationUsages(@NotNull ApplicationStatisticsPersistence persistence) {
    ObjectIntHashMap<String> result = new ObjectIntHashMap<>();
    long lastTimeSent = UsageStatisticsPersistenceComponent.getInstance().getLastTimeSent();
    for (CollectedUsages usageDescriptors : persistence.getApplicationData(getGroupId()).values()) {
        if (!usageDescriptors.usages.isEmpty() && usageDescriptors.collectionTime > lastTimeSent) {
            result.ensureCapacity(usageDescriptors.usages.size());
            for (UsageDescriptor usageDescriptor : usageDescriptors.usages) {
                String key = usageDescriptor.getKey();
                result.put(key, result.get(key, 0) + usageDescriptor.getValue());
            }
        }
    }
    if (result.isEmpty()) {
        return Collections.emptySet();
    } else {
        final THashSet<UsageDescriptor> descriptors = new THashSet<>(result.size());
        result.forEachEntry(new TObjectIntProcedure<String>() {

            @Override
            public boolean execute(String key, int value) {
                descriptors.add(new UsageDescriptor(key, value));
                return true;
            }
        });
        return descriptors;
    }
}
Also used : ObjectIntHashMap(com.intellij.util.containers.ObjectIntHashMap) CollectedUsages(com.intellij.internal.statistic.persistence.CollectedUsages) UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) THashSet(gnu.trove.THashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with UsageDescriptor

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

the class ScaleInfoUsageCollector method getUsages.

@NotNull
@Override
public Set<UsageDescriptor> getUsages() throws CollectUsagesException {
    float scale = JBUI.sysScale();
    int scaleBase = (int) Math.floor(scale);
    float scaleFract = scale - scaleBase;
    if (// count integer scale on a precise match only
    scaleFract == 0.0f)
        // count integer scale on a precise match only
        scaleFract = 0.0f;
    else if (scaleFract < 0.375f)
        scaleFract = 0.25f;
    else if (scaleFract < 0.625f)
        scaleFract = 0.5f;
    else
        scaleFract = 0.75f;
    scale = scaleBase + scaleFract;
    String os = OS.isWindows() ? "Windows" : OS.isLinux() ? "Linux" : OS.isMacOSX() ? "Mac" : "Unknown OS";
    return Collections.singleton(new UsageDescriptor(os + " " + scale, 1));
}
Also used : UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with UsageDescriptor

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

the class LanguageLevelUsagesCollector method getProjectUsages.

@NotNull
public Set<UsageDescriptor> getProjectUsages(@NotNull Project project) {
    final Set<String> languageLevels = new HashSet<>();
    for (Module module : ModuleManager.getInstance(project).getModules()) {
        final LanguageLevelModuleExtension instance = LanguageLevelModuleExtensionImpl.getInstance(module);
        final LanguageLevel languageLevel = instance.getLanguageLevel();
        if (languageLevel != null) {
            languageLevels.add(languageLevel.toString());
        } else {
            languageLevels.add(LanguageLevelProjectExtension.getInstance(project).getLanguageLevel().toString());
        }
    }
    return ContainerUtil.map2Set(languageLevels, languageLevel -> new UsageDescriptor(languageLevel, 1));
}
Also used : LanguageLevel(com.intellij.pom.java.LanguageLevel) Module(com.intellij.openapi.module.Module) LanguageLevelModuleExtension(com.intellij.openapi.roots.LanguageLevelModuleExtension) UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) HashSet(com.intellij.util.containers.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with UsageDescriptor

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

the class AbstractRunConfigurationTypeUsagesCollector method getProjectUsages.

@NotNull
@Override
public final Set<UsageDescriptor> getProjectUsages(@NotNull final Project project) {
    final Set<String> runConfigurationTypes = new HashSet<>();
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {

        @Override
        public void run() {
            if (project.isDisposed())
                return;
            final RunManager runManager = RunManager.getInstance(project);
            for (RunnerAndConfigurationSettings settings : runManager.getAllSettings()) {
                RunConfiguration runConfiguration = settings.getConfiguration();
                if (runConfiguration != null && isApplicable(runManager, settings)) {
                    final ConfigurationFactory configurationFactory = runConfiguration.getFactory();
                    final ConfigurationType configurationType = configurationFactory.getType();
                    final StringBuilder keyBuilder = new StringBuilder();
                    keyBuilder.append(configurationType.getId());
                    if (configurationType.getConfigurationFactories().length > 1) {
                        keyBuilder.append(".").append(configurationFactory.getName());
                    }
                    runConfigurationTypes.add(keyBuilder.toString());
                }
            }
        }
    });
    return ContainerUtil.map2Set(runConfigurationTypes, runConfigurationType -> new UsageDescriptor(runConfigurationType, 1));
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) RunManager(com.intellij.execution.RunManager) HashSet(com.intellij.util.containers.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 20 with UsageDescriptor

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

the class VcsOptionsUsagesCollector method getProjectUsages.

@NotNull
public Set<UsageDescriptor> getProjectUsages(@NotNull Project project) {
    VcsConfiguration configuration = VcsConfiguration.getInstance(project);
    Set<UsageDescriptor> usages = new HashSet<>();
    usages.add(getBooleanUsage("offer.move.partially.committed", configuration.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT));
    usages.add(getEnumUsage("offer.move.failed.committed", configuration.MOVE_TO_FAILED_COMMIT_CHANGELIST));
    usages.add(getEnumUsage("offer.remove.empty.changelist", configuration.REMOVE_EMPTY_INACTIVE_CHANGELISTS));
    usages.add(getBooleanUsage("changelist.make.new.active", configuration.MAKE_NEW_CHANGELIST_ACTIVE));
    usages.add(getBooleanUsage("changelist.preselect.existing", configuration.PRESELECT_EXISTING_CHANGELIST));
    usages.add(getBooleanUsage("perform.update.in.background", configuration.PERFORM_UPDATE_IN_BACKGROUND));
    usages.add(getBooleanUsage("perform.commit.in.background", configuration.PERFORM_COMMIT_IN_BACKGROUND));
    usages.add(getBooleanUsage("perform.edit.in.background", configuration.PERFORM_EDIT_IN_BACKGROUND));
    usages.add(getBooleanUsage("perform.checkout.in.background", configuration.PERFORM_CHECKOUT_IN_BACKGROUND));
    usages.add(getBooleanUsage("perform.add_remove.in.background", configuration.PERFORM_ADD_REMOVE_IN_BACKGROUND));
    usages.add(getBooleanUsage("perform.rollback.in.background", configuration.PERFORM_ROLLBACK_IN_BACKGROUND));
    usages.add(getBooleanUsage("commit.before.check.code.smell", configuration.CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT));
    usages.add(getBooleanUsage("commit.before.check.code.cleanup", configuration.CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT));
    usages.add(getBooleanUsage("commit.before.check.todo", configuration.CHECK_NEW_TODO));
    usages.add(getBooleanUsage("commit.before.check.non.empty.comment", configuration.FORCE_NON_EMPTY_COMMENT));
    usages.add(getBooleanUsage("commit.before.optimize.imports", configuration.OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT));
    usages.add(getBooleanUsage("commit.before.check.files.up.to.date", configuration.CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT));
    usages.add(getBooleanUsage("commit.before.reformat.project", configuration.REFORMAT_BEFORE_PROJECT_COMMIT));
    usages.add(getBooleanUsage("commit.before.reformat.file", configuration.REFORMAT_BEFORE_FILE_COMMIT));
    usages.add(getBooleanUsage("commit.before.rearrange", configuration.REARRANGE_BEFORE_PROJECT_COMMIT));
    usages.add(getBooleanUsage("commit.clear.initial.comment", configuration.CLEAR_INITIAL_COMMIT_MESSAGE));
    usages.add(getBooleanUsage("commit.use.right.margin", configuration.USE_COMMIT_MESSAGE_MARGIN));
    usages.add(getBooleanUsage("commit.show.unversioned", configuration.SHOW_UNVERSIONED_FILES_WHILE_COMMIT));
    usages.add(getBooleanUsage("show.changes.preview", configuration.LOCAL_CHANGES_DETAILS_PREVIEW_SHOWN));
    usages.add(getBooleanUsage("include.text.into.shelf", configuration.INCLUDE_TEXT_INTO_SHELF));
    usages.add(getBooleanUsage("check.conflicts.in.background", configuration.CHECK_LOCALLY_CHANGED_CONFLICTS_IN_BACKGROUND));
    return usages;
}
Also used : UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) VcsConfiguration(com.intellij.openapi.vcs.VcsConfiguration) HashSet(com.intellij.util.containers.HashSet) NotNull(org.jetbrains.annotations.NotNull)

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