remove old statistics service

This commit is contained in:
sergey.vasiliev
2018-06-12 09:28:32 +02:00
parent 6575058748
commit 1e5c313405
130 changed files with 116 additions and 3756 deletions
-1
View File
@@ -24,7 +24,6 @@
<projectService serviceInterface="org.intellij.images.search.ImageTagManager"
serviceImplementation="org.intellij.images.search.ImageTagManager"/>
<statistics.usagesCollector implementation="org.intellij.images.statistics.BackgroundImagesUsageCollector"/>
</extensions>
<actions>
@@ -1,67 +0,0 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.intellij.images.statistics;
import com.intellij.internal.statistic.AbstractProjectsUsagesCollector;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.JBIterable;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Set;
import static com.intellij.openapi.wm.impl.IdeBackgroundUtil.*;
/**
* @author gregsh
*/
public class BackgroundImagesUsageCollector extends AbstractProjectsUsagesCollector {
private static final UsageDescriptor EDITOR = new UsageDescriptor("editor");
private static final UsageDescriptor FRAME = new UsageDescriptor("frame");
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("images.ide.background");
}
@NotNull
@Override
protected Set<UsageDescriptor> mergeUsagesPostProcess(@NotNull Set<UsageDescriptor> usagesFromAllProjects) {
JBIterable<UsageDescriptor> itt = JBIterable.from(usagesFromAllProjects);
return usageSet(itt.find(o -> EDITOR.getKey().equals(o.getKey())) != null,
itt.find(o -> FRAME.getKey().equals(o.getKey())) != null);
}
@NotNull
@Override
public Set<UsageDescriptor> getProjectUsages(@NotNull Project project) throws CollectUsagesException {
return usageSet(StringUtil.isNotEmpty(getBackgroundSpec(project, EDITOR_PROP)),
StringUtil.isNotEmpty(getBackgroundSpec(project, FRAME_PROP)));
}
@NotNull
private static Set<UsageDescriptor> usageSet(boolean editor, boolean frame) {
if (!editor && !frame) return Collections.emptySet();
if (editor && frame) return ContainerUtil.newHashSet(EDITOR, FRAME);
return Collections.singleton(editor ? EDITOR : FRAME);
}
}
@@ -1,56 +0,0 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.compiler;
import com.intellij.internal.statistic.AbstractProjectsUsagesCollector;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashSet;
import java.util.Set;
/**
* @author Eugene Zhuravlev
*/
public class CompilerSettingsUsageCollector extends AbstractProjectsUsagesCollector {
public static final String GROUP_ID = "compiler";
@NotNull
@Override
public Set<UsageDescriptor> getProjectUsages(@Nullable Project project) throws CollectUsagesException {
final CompilerWorkspaceConfiguration wsConfig = CompilerWorkspaceConfiguration.getInstance(project);
final Set<UsageDescriptor> result = new HashSet<>();
if (wsConfig.MAKE_PROJECT_ON_SAVE) {
result.add(new UsageDescriptor("auto_make", 1));
}
if (wsConfig.PARALLEL_COMPILATION) {
result.add(new UsageDescriptor("compile_parallel", 1));
}
return result;
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create(GROUP_ID);
}
}
@@ -12,7 +12,6 @@ import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.impl.HotSwapFile;
import com.intellij.debugger.impl.HotSwapManager;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
@@ -267,7 +266,6 @@ public class HotSwapUIImpl extends HotSwapUI {
private static void reloadModifiedClasses(final Map<DebuggerSession, Map<String, HotSwapFile>> modifiedClasses,
final HotSwapProgressImpl progress) {
UsageTrigger.trigger("debugger.reload.classes");
ProgressManager.getInstance().runProcess(() -> {
HotSwapManager.reloadModifiedClasses(modifiedClasses, progress);
progress.finished();
@@ -16,7 +16,6 @@
package com.intellij.testIntegration;
import com.intellij.execution.TestStateStorage;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
@@ -46,8 +45,6 @@ public class ShowRecentTests extends AnAction {
final Project project = e.getProject();
if (project == null) return;
UsageTrigger.trigger(ID);
final TestStateStorage testStorage = TestStateStorage.getInstance(project);
final TestLocator testLocator = new TestLocator(project);
final RecentTestRunnerImpl testRunner = new RecentTestRunnerImpl(testLocator);
@@ -1,62 +0,0 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.ide.projectWizard;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.hash.HashSet;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import java.util.Set;
/**
* @author Dmitry Avdeev
*/
public class ProjectCategoryUsagesCollector extends UsagesCollector {
private final Map<String, UsageDescriptor> myUsageDescriptors = ContainerUtil.newHashMap();
public static void projectTypeUsed(@NotNull String projectTypeId) {
String key = "project.category." + projectTypeId;
UsageDescriptor descriptor = getUsageDescriptors().get(key);
getUsageDescriptors().put(key, new UsageDescriptor(key, descriptor == null? 1: descriptor.getValue()+1));
}
@NotNull
@Override
public Set<UsageDescriptor> getUsages() throws CollectUsagesException {
HashSet<UsageDescriptor> descriptors = new HashSet<>();
descriptors.addAll(getUsageDescriptors().values());
getUsageDescriptors().clear();
return descriptors;
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("Project Category");
}
private static Map<String, UsageDescriptor> getUsageDescriptors() {
return ServiceManager.getService(ProjectCategoryUsagesCollector.class).myUsageDescriptors;
}
}
@@ -510,10 +510,6 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
throw new CommitStepException(null);
}
}
TemplatesGroup group = getSelectedGroup();
if (group != null) {
ProjectCategoryUsagesCollector.projectTypeUsed(group.getId());
}
}
@Override
@@ -1,64 +0,0 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.roots.ui.configuration.libraries.impl;
import com.intellij.internal.statistic.AbstractProjectsUsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryKind;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
/**
* @author nik
*/
public class LibraryUsageCollector extends AbstractProjectsUsagesCollector {
@NonNls private static final String GROUP_ID = "libraries";
@NotNull
@Override
public Set<UsageDescriptor> getProjectUsages(@NotNull Project project) {
final Set<LibraryKind> usedKinds = new HashSet<>();
final Processor<Library> processor = library -> {
usedKinds.addAll(LibraryPresentationManagerImpl.getLibraryKinds(library, null));
return true;
};
for (Module module : ModuleManager.getInstance(project).getModules()) {
ModuleRootManager.getInstance(module).orderEntries().librariesOnly().forEachLibrary(processor);
}
final HashSet<UsageDescriptor> usageDescriptors = new HashSet<>();
for (LibraryKind kind : usedKinds) {
usageDescriptors.add(new UsageDescriptor(kind.getKindId(), 1));
}
return usageDescriptors;
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create(GROUP_ID); }
}
@@ -327,7 +327,6 @@
<highlightUsagesHandlerFactory implementation="com.intellij.codeInsight.highlighting.HighlightSuppressedWarningsFactory"/>
<highlightUsagesHandlerFactory implementation="com.intellij.codeInsight.highlighting.HighlightExceptionsHandlerFactory"/>
<moduleExtension implementation="com.intellij.openapi.roots.impl.CompilerModuleExtensionImpl"/>
<statistics.usagesCollector implementation="com.intellij.openapi.roots.impl.LanguageLevelUsagesCollector"/>
<projectExtension implementation="com.intellij.openapi.roots.impl.LanguageLevelProjectExtensionImpl$MyProjectExtension"/>
<liveTemplateContext implementation="com.intellij.codeInsight.template.JavaCodeContextType$Generic"/>
<liveTemplateContext implementation="com.intellij.codeInsight.template.JavaCodeContextType$Statement"/>
@@ -1,6 +1,5 @@
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<statistics.usagesCollector implementation="com.intellij.internal.statistic.libraryJar.LibraryJarUsagesCollector"/>
<statistics.projectUsagesCollector implementation="com.intellij.internal.statistic.libraryJar.FUSLibraryJarUsagesCollector"/>
<postStartupActivity implementation="com.intellij.internal.statistic.libraryJar.LibraryJarStatisticsService"/>
</extensions>
@@ -6,7 +6,6 @@ import com.intellij.codeInsight.completion.CompletionMemory;
import com.intellij.codeInsight.completion.JavaMethodCallElement;
import com.intellij.codeInsight.hint.ParameterInfoController;
import com.intellij.codeInsight.hints.ParameterHintsPass;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.WriteAction;
@@ -114,8 +113,6 @@ class JavaMethodOverloadSwitchHandler extends EditorActionHandler {
}
}
UsageTrigger.trigger("method.overload.switch");
final PsiMethod targetMethod =
(PsiMethod)((CandidateInfo)objects[(currentIndex + (mySwitchUp ? -1 : 1) + objects.length) % objects.length]).getElement();
PsiParameterList parameterList = targetMethod.getParameterList();
@@ -1,98 +0,0 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.internal.statistic.libraryJar;
import com.intellij.internal.statistic.AbstractProjectsUsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.JarUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.search.ProjectScope;
import com.intellij.util.containers.hash.HashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
import java.util.jar.Attributes;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author Ivan Chirkov
* @Deprecated // To be removed in 2018.1. See {@link FUSLibraryJarUsagesCollector}
*/
public class LibraryJarUsagesCollector extends AbstractProjectsUsagesCollector {
private static final GroupDescriptor GROUP = GroupDescriptor.create("Libraries by jars", GroupDescriptor.LOWER_PRIORITY);
private static final String DIGIT_VERSION_PATTERN_PART = "(\\d+.\\d+|\\d+)";
private static final Pattern JAR_FILE_NAME_PATTERN = Pattern.compile("[\\w|\\-|\\.]+-(" + DIGIT_VERSION_PATTERN_PART + "[\\w|\\.]*)jar");
@NotNull
@Override
public Set<UsageDescriptor> getProjectUsages(@NotNull Project project) {
LibraryJarDescriptor[] descriptors = LibraryJarStatisticsService.getInstance().getTechnologyDescriptors();
Set<UsageDescriptor> result = new HashSet<>(descriptors.length);
ApplicationManager.getApplication().runReadAction(() -> {
for (LibraryJarDescriptor descriptor : descriptors) {
String className = descriptor.myClass;
if (className == null) continue;
PsiClass[] psiClasses = JavaPsiFacade.getInstance(project).findClasses(className, ProjectScope.getLibrariesScope(project));
for (PsiClass psiClass : psiClasses) {
VirtualFile jarFile = JarFileSystem.getInstance().getVirtualFileForJar(psiClass.getContainingFile().getVirtualFile());
if (jarFile != null) {
String version = getVersionByJarManifest(jarFile);
if (version == null) {
version = getVersionByJarFileName(jarFile.getName());
}
if (version != null && StringUtil.containsChar(version, '.')) {
result.add(new UsageDescriptor(descriptor.myName + "_" + version, 1));
}
}
}
}
});
return result;
}
@Nullable
private static String getVersionByJarManifest(@NotNull VirtualFile file) {
return JarUtil.getJarAttribute(VfsUtilCore.virtualToIoFile(file), Attributes.Name.IMPLEMENTATION_VERSION);
}
@Nullable
private static String getVersionByJarFileName(@NotNull String fileName) {
Matcher fileNameMatcher = JAR_FILE_NAME_PATTERN.matcher(fileName);
if (!fileNameMatcher.matches()) return null;
return StringUtil.trimTrailing(fileNameMatcher.group(1), '.');
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GROUP;
}
}
@@ -1,59 +0,0 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.roots.impl;
import com.intellij.internal.statistic.AbstractProjectsUsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.LanguageLevelModuleExtension;
import com.intellij.openapi.roots.LanguageLevelModuleExtensionImpl;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
public class LanguageLevelUsagesCollector extends AbstractProjectsUsagesCollector {
public static final String GROUP_ID = "module-language-level";
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create(GROUP_ID, GroupDescriptor.HIGHER_PRIORITY);
}
@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));
}
}
@@ -15,7 +15,6 @@
*/
package com.intellij.diff.actions.impl;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.event.EditorMouseEventArea;
@@ -99,7 +98,6 @@ public abstract class OpenInEditorWithMouseAction extends AnAction implements Du
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
UsageTrigger.trigger("diff.OpenInEditor.Mouse");
MouseEvent inputEvent = (MouseEvent)e.getInputEvent();
OpenInEditorAction openInEditorAction = e.getRequiredData(OpenInEditorAction.KEY);
@@ -33,8 +33,6 @@ import com.intellij.diff.util.DiffUserDataKeysEx.ScrollToPolicy;
import com.intellij.diff.util.DiffUtil;
import com.intellij.diff.util.LineRange;
import com.intellij.ide.impl.DataManagerImpl;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ActionUtil;
@@ -601,7 +599,6 @@ public abstract class DiffRequestProcessor implements Disposable {
public void actionPerformed(@NotNull AnActionEvent e) {
if (myState.getActiveTool() == myDiffTool) return;
UsageTrigger.trigger("diff.DiffSettings.Tool." + ConvertUsagesUtil.ensureProperKey(myDiffTool.getName()));
moveToolOnTop(myDiffTool);
updateRequest(true);
@@ -24,7 +24,6 @@ import com.intellij.diff.requests.DiffRequest;
import com.intellij.diff.tools.binary.BinaryDiffTool;
import com.intellij.ide.diff.DiffElement;
import com.intellij.ide.diff.DirDiffSettings;
import com.intellij.internal.statistic.UsageTrigger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -37,7 +36,6 @@ public class DirDiffTool implements FrameDiffTool, SuppressiveDiffTool {
@NotNull
@Override
public DiffViewer createComponent(@NotNull DiffContext context, @NotNull DiffRequest request) {
UsageTrigger.trigger("diff.DirDiffViewer");
return createViewer(context, (ContentDiffRequest)request);
}
@@ -18,7 +18,6 @@ package com.intellij.diff.tools.simple;
import com.intellij.diff.fragments.DiffFragment;
import com.intellij.diff.fragments.LineFragment;
import com.intellij.diff.util.*;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -317,7 +316,6 @@ public class SimpleDiffChange {
@Nullable
private GutterIconRenderer createAppendRenderer(@NotNull final Side side) {
return createIconRenderer(side, "Append", DiffUtil.getArrowDownIcon(side), () -> {
UsageTrigger.trigger("diff.SimpleDiffChange.Append");
myViewer.appendChange(this, side);
});
}
@@ -26,7 +26,6 @@ import com.intellij.diff.util.DiffUserDataKeys;
import com.intellij.diff.util.DiffUserDataKeysEx;
import com.intellij.diff.util.DiffUtil;
import com.intellij.icons.AllIcons;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
@@ -270,7 +269,6 @@ public class TextDiffViewerUtil {
@Override
protected void setValue(@NotNull HighlightPolicy option) {
if (getValue() == option) return;
UsageTrigger.trigger("diff.TextDiffSettings.HighlightPolicy." + option.name());
mySettings.setHighlightPolicy(option);
}
@@ -311,7 +309,6 @@ public class TextDiffViewerUtil {
@Override
protected void setValue(@NotNull IgnorePolicy option) {
if (getValue() == option) return;
UsageTrigger.trigger("diff.TextDiffSettings.IgnorePolicy." + option.name());
mySettings.setIgnorePolicy(option);
}
@@ -7,7 +7,6 @@ import com.intellij.CommonBundle;
import com.intellij.diff.DiffRequestFactory;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.diff.*;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
@@ -84,7 +83,6 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
private volatile boolean myDisposed;
public DirDiffTableModel(@Nullable Project project, DiffElement source, DiffElement target, DirDiffSettings settings) {
UsageTrigger.trigger("diff.DirDiffTableModel");
myProject = project;
mySettings = settings;
mySource = source;
@@ -11,8 +11,6 @@ import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
import com.intellij.execution.runners.ExecutionUtil;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.icons.AllIcons;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
import com.intellij.openapi.project.DumbService;
@@ -81,8 +79,6 @@ public class ProgramRunnerUtil {
}
}
}
UsageTrigger.trigger("execute." + ConvertUsagesUtil.ensureProperKey(runnerAndConfigurationSettings.getType().getId()) + "." + environment.getExecutor().getId());
}
try {
@@ -1,54 +0,0 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.facet.impl.statistics;
import com.intellij.facet.Facet;
import com.intellij.facet.FacetManager;
import com.intellij.internal.statistic.AbstractProjectsUsagesCollector;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
public class FrameworkUsagesCollector extends AbstractProjectsUsagesCollector {
public static final String GROUP_ID = "frameworks";
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create(GROUP_ID, GroupDescriptor.HIGHER_PRIORITY);
}
@Override
@NotNull
public Set<UsageDescriptor> getProjectUsages(@NotNull Project project) {
final Set<String> facets = new HashSet<>();
for (Module module : ModuleManager.getInstance(project).getModules()) {
for (Facet facet : FacetManager.getInstance(module).getAllFacets()) {
facets.add(facet.getType().getStringId());
}
}
return ContainerUtil.map2Set(facets, facet -> new UsageDescriptor(facet, 1));
}
}
@@ -1,50 +0,0 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.facet.impl.statistics;
import com.intellij.internal.statistic.AbstractProjectsUsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.project.Project;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
public class ModuleTypeUsagesCollector extends AbstractProjectsUsagesCollector {
public static final String GROUP_ID = "module type";
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create(GROUP_ID, GroupDescriptor.HIGHER_PRIORITY);
}
@Override
@NotNull
public Set<UsageDescriptor> getProjectUsages(@NotNull Project project) {
Set<String> modulesTypes = new HashSet<>();
for (Module module : ModuleManager.getInstance(project).getModules()) {
modulesTypes.add(ModuleType.get(module).getId());
}
return ContainerUtil.map2Set(modulesTypes, moduleType -> new UsageDescriptor(moduleType, 1));
}
}
@@ -18,7 +18,6 @@ package com.intellij.formatting.contextConfiguration;
import com.intellij.application.options.CodeStyle;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.lang.Language;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
@@ -81,7 +80,6 @@ public class ConfigureCodeStyleOnSelectedFragment implements IntentionAction {
@Override
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
UsageTrigger.trigger(ID);
SelectedTextFormatter textFormatter = new SelectedTextFormatter(project, editor, file);
CodeStyleSettingsToShow settingsToShow = calculateAffectingSettings(editor, file);
CodeStyleSettings settings = CodeStyle.getSettings(file);
@@ -18,7 +18,6 @@ package com.intellij.ide.actions;
import com.intellij.icons.AllIcons;
import com.intellij.ide.IdeBundle;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.fileTypes.FileTypeManager;
@@ -219,7 +218,6 @@ public class CreateFileAction extends CreateElementActionBase implements DumbAwa
@Override
public PsiElement[] create(String newName) throws Exception {
UsageTrigger.trigger("CreateFile." + CreateFileAction.this.getClass().getSimpleName());
return super.create(newName);
}
@@ -549,9 +549,6 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
if (newPane == null) return;
newPane.setSubId(subId);
showPane(newPane);
if (fromContentManager) {
ProjectViewStatistics.recordProjectViewPaneUsage(myCurrentViewId, myCurrentViewSubId);
}
ProjectViewSelectInTarget target = getProjectViewSelectInTarget(newPane);
if (target != null) target.setSubId(subId);
if (isAutoscrollFromSource(id)) {
@@ -1,30 +0,0 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:JvmName("ProjectViewStatistics")
package com.intellij.ide.projectView.impl
import com.intellij.internal.statistic.UsageTrigger
import com.intellij.internal.statistic.beans.ConvertUsagesUtil.ensureProperKey
private val prefix = "project.view.pane"
internal fun recordProjectViewPaneUsage(id: String?, subId: String?) {
if (id == null) return
val featureString = if (subId == null) "$prefix.$id" else "$prefix.$id.$subId"
val key = ensureProperKey(featureString)
UsageTrigger.trigger(key)
}
@@ -18,7 +18,6 @@ package com.intellij.ide.util.projectWizard;
import com.intellij.ide.RecentProjectsManager;
import com.intellij.ide.util.projectWizard.actions.ProjectSpecificAction;
import com.intellij.idea.ActionsBundle;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
@@ -202,7 +201,6 @@ public class AbstractNewProjectStep<T> extends DefaultActionGroup implements Dum
}
String generatorName = generator == null ? "empty" : ConvertUsagesUtil.ensureProperKey(generator.getName());
UsageTrigger.trigger("AbstractNewProjectStep." + generatorName);
RecentProjectsManager.getInstance().setLastProjectCreationLocation(PathUtil.toSystemIndependentName(location.getParent()));
@@ -1,157 +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.internal.statistic.editor;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.CodeInsightWorkspaceSettings;
import com.intellij.internal.statistic.AbstractProjectsUsagesCollector;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces;
import com.intellij.openapi.editor.richcopy.settings.RichCopySettings;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.BooleanFunction;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Function;
/**
* @deprecated To be removed in 2018.3 (replaced by EditorSettingsStatisticsCollector)
*/
class LegacyEditorSettingsStatisticsCollector extends UsagesCollector {
private static final GroupDescriptor GROUP_DESCRIPTOR = GroupDescriptor.create("Editor");
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GROUP_DESCRIPTOR;
}
@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
Set<UsageDescriptor> set = new HashSet<>();
EditorSettingsExternalizable es = EditorSettingsExternalizable.getInstance();
EditorSettingsExternalizable esDefault = new EditorSettingsExternalizable();
addBoolIfDiffers(set, es, esDefault, s -> s.isVirtualSpace(), "caretAfterLineEnd");
addBoolIfDiffers(set, es, esDefault, s -> s.isCaretInsideTabs(), "caretInsideTabs");
addBoolIfDiffers(set, es, esDefault, s -> s.isAdditionalPageAtBottom(), "virtualSpaceAtFileBottom");
addBoolIfDiffers(set, es, esDefault, s -> s.isUseSoftWraps(SoftWrapAppliancePlaces.MAIN_EDITOR), "softWraps");
addBoolIfDiffers(set, es, esDefault, s -> s.isUseSoftWraps(SoftWrapAppliancePlaces.CONSOLE), "softWraps.console");
addBoolIfDiffers(set, es, esDefault, s -> s.isUseSoftWraps(SoftWrapAppliancePlaces.PREVIEW), "softWraps.preview");
addBoolIfDiffers(set, es, esDefault, s -> s.isUseCustomSoftWrapIndent(), "softWraps.relativeIndent");
addBoolIfDiffers(set, es, esDefault, s -> s.isAllSoftWrapsShown(), "softWraps.showAll");
addIfDiffers(set, es, esDefault, s -> s.getStripTrailingSpaces(), "stripTrailingSpaces");
addBoolIfDiffers(set, es, esDefault, s -> s.isEnsureNewLineAtEOF(), "ensureNewlineAtEOF");
addBoolIfDiffers(set, es, esDefault, s -> s.isShowQuickDocOnMouseOverElement(), "quickDocOnMouseHover");
addBoolIfDiffers(set, es, esDefault, s -> s.isBlinkCaret(), "blinkingCaret");
addBoolIfDiffers(set, es, esDefault, s -> s.isBlockCursor(), "blockCaret");
addBoolIfDiffers(set, es, esDefault, s -> s.isRightMarginShown(), "rightMargin");
addBoolIfDiffers(set, es, esDefault, s -> s.isLineNumbersShown(), "lineNumbers");
addBoolIfDiffers(set, es, esDefault, s -> s.areGutterIconsShown(), "gutterIcons");
addBoolIfDiffers(set, es, esDefault, s -> s.isFoldingOutlineShown(), "foldingOutline");
addBoolIfDiffers(set, es, esDefault, s -> s.isWhitespacesShown() && s.isLeadingWhitespacesShown(), "showLeadingWhitespace");
addBoolIfDiffers(set, es, esDefault, s -> s.isWhitespacesShown() && s.isInnerWhitespacesShown(), "showInnerWhitespace");
addBoolIfDiffers(set, es, esDefault, s -> s.isWhitespacesShown() && s.isTrailingWhitespacesShown(), "showTrailingWhitespace");
addBoolIfDiffers(set, es, esDefault, s -> s.isIndentGuidesShown(), "indentGuides");
addBoolIfDiffers(set, es, esDefault, s -> s.isSmoothScrolling(), "animatedScroll");
addBoolIfDiffers(set, es, esDefault, s -> s.isDndEnabled(), "dragNDrop");
addBoolIfDiffers(set, es, esDefault, s -> s.isWheelFontChangeEnabled(), "wheelZoom");
addBoolIfDiffers(set, es, esDefault, s -> s.isMouseClickSelectionHonorsCamelWords(), "mouseCamel");
addBoolIfDiffers(set, es, esDefault, s -> s.isVariableInplaceRenameEnabled(), "inplaceRename");
addBoolIfDiffers(set, es, esDefault, s -> s.isPreselectRename(), "preselectOnRename");
addBoolIfDiffers(set, es, esDefault, s -> s.isShowInlineLocalDialog(), "inlineDialog");
addBoolIfDiffers(set, es, esDefault, s -> s.isRefrainFromScrolling(), "minimizeScrolling");
addBoolIfDiffers(set, es, esDefault, s -> s.getOptions().SHOW_NOTIFICATION_AFTER_REFORMAT_CODE_ACTION, "afterReformatNotification");
addBoolIfDiffers(set, es, esDefault, s -> s.getOptions().SHOW_NOTIFICATION_AFTER_OPTIMIZE_IMPORTS_ACTION, "afterOptimizeNotification");
addBoolIfDiffers(set, es, esDefault, s -> s.isSmartHome(), "smartHome");
addBoolIfDiffers(set, es, esDefault, s -> s.isCamelWords(), "camelWords");
addBoolIfDiffers(set, es, esDefault, s -> s.isShowParameterNameHints(), "editor.inlay.parameter.hints");
addBoolIfDiffers(set, es, esDefault, s -> s.isBreadcrumbsAbove(), "noBreadcrumbsBelow");
addBoolIfDiffers(set, es, esDefault, s -> s.isBreadcrumbsShown(), "breadcrumbs");
for (String language : es.getOptions().getLanguageBreadcrumbsMap().keySet()) {
addBoolIfDiffers(set, es, esDefault, s -> s.isBreadcrumbsShownFor(language), "breadcrumbsFor" + language);
}
RichCopySettings rcs = RichCopySettings.getInstance();
RichCopySettings rcsDefault = new RichCopySettings();
addBoolIfDiffers(set, rcs, rcsDefault, s -> s.isEnabled(), "richCopy");
CodeInsightSettings cis = CodeInsightSettings.getInstance();
CodeInsightSettings cisDefault = new CodeInsightSettings();
addBoolIfDiffers(set, cis, cisDefault, s -> s.AUTO_POPUP_PARAMETER_INFO, "parameterAutoPopup");
addBoolIfDiffers(set, cis, cisDefault, s -> s.AUTO_POPUP_JAVADOC_INFO, "javadocAutoPopup");
addBoolIfDiffers(set, cis, cisDefault, s -> s.AUTO_POPUP_COMPLETION_LOOKUP, "completionAutoPopup");
addIfDiffers(set, cis, cisDefault, s -> s.COMPLETION_CASE_SENSITIVE, "completionCaseSensitivity");
addBoolIfDiffers(set, cis, cisDefault, s -> s.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS, "autoPopupCharComplete");
addBoolIfDiffers(set, cis, cisDefault, s -> s.AUTOCOMPLETE_ON_CODE_COMPLETION, "autoCompleteBasic");
addBoolIfDiffers(set, cis, cisDefault, s -> s.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION, "autoCompleteSmart");
addBoolIfDiffers(set, cis, cisDefault, s -> s.SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO, "parameterInfoFullSignature");
addIfDiffers(set, cis, cisDefault, s -> s.getBackspaceMode(), "smartBackspace");
addBoolIfDiffers(set, cis, cisDefault, s -> s.SMART_INDENT_ON_ENTER, "indentOnEnter");
addBoolIfDiffers(set, cis, cisDefault, s -> s.INSERT_BRACE_ON_ENTER, "braceOnEnter");
addBoolIfDiffers(set, cis, cisDefault, s -> s.JAVADOC_STUB_ON_ENTER, "javadocOnEnter");
addBoolIfDiffers(set, cis, cisDefault, s -> s.SMART_END_ACTION, "smartEnd");
addBoolIfDiffers(set, cis, cisDefault, s -> s.JAVADOC_GENERATE_CLOSING_TAG, "autoCloseJavadocTags");
addBoolIfDiffers(set, cis, cisDefault, s -> s.SURROUND_SELECTION_ON_QUOTE_TYPED, "surroundByQuoteOrBrace");
addBoolIfDiffers(set, cis, cisDefault, s -> s.AUTOINSERT_PAIR_BRACKET, "pairBracketAutoInsert");
addBoolIfDiffers(set, cis, cisDefault, s -> s.AUTOINSERT_PAIR_QUOTE, "pairQuoteAutoInsert");
addBoolIfDiffers(set, cis, cisDefault, s -> s.REFORMAT_BLOCK_ON_RBRACE, "reformatOnRBrace");
addIfDiffers(set, cis, cisDefault, s -> s.REFORMAT_ON_PASTE, "reformatOnPaste");
addIfDiffers(set, cis, cisDefault, s -> s.ADD_IMPORTS_ON_PASTE, "importsOnPaste");
addBoolIfDiffers(set, cis, cisDefault, s -> s.HIGHLIGHT_BRACES, "bracesHighlight");
addBoolIfDiffers(set, cis, cisDefault, s -> s.HIGHLIGHT_SCOPE, "scopeHighlight");
addBoolIfDiffers(set, cis, cisDefault, s -> s.HIGHLIGHT_IDENTIFIER_UNDER_CARET, "identifierUnderCaretHighlight");
addBoolIfDiffers(set, cis, cisDefault, s -> s.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY, "autoAddImports");
addBoolIfDiffers(set, cis, cisDefault, s -> s.SHOW_PARAMETER_NAME_HINTS_ON_COMPLETION, "completionHints");
addBoolIfDiffers(set, cis, cisDefault, s -> s.SHOW_EXTERNAL_ANNOTATIONS_INLINE, "externalAnnotationsInline");
addBoolIfDiffers(set, cis, cisDefault, s -> s.SHOW_INFERRED_ANNOTATIONS_INLINE, "inferredAnnotationsInline");
addBoolIfDiffers(set, cis, cisDefault, s -> s.TAB_EXITS_BRACKETS_AND_QUOTES, "tabExitsBracketsAndQuotes");
return set;
}
private static <T> void addBoolIfDiffers(Set<UsageDescriptor> set,
T settingsBean, T defaultSettingsBean, BooleanFunction<T> valueFunction, String featureId) {
boolean value = valueFunction.fun(settingsBean);
boolean defaultValue = valueFunction.fun(defaultSettingsBean);
if (value != defaultValue) {
set.add(new UsageDescriptor(defaultValue ? "no" + StringUtil.capitalize(featureId) : featureId, 1));
}
}
private static <T> void addIfDiffers(Set<UsageDescriptor> set,
T settingsBean, T defaultSettingsBean, Function<T, Object> valueFunction, String featureIdPrefix) {
Object value = valueFunction.apply(settingsBean);
Object defaultValue = valueFunction.apply(defaultSettingsBean);
if (!Comparing.equal(value, defaultValue)) {
set.add(new UsageDescriptor(featureIdPrefix + "." + value, 1));
}
}
public static class ProjectUsages extends AbstractProjectsUsagesCollector {
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GROUP_DESCRIPTOR;
}
@NotNull
@Override
public Set<UsageDescriptor> getProjectUsages(@NotNull Project project) throws CollectUsagesException {
Set<UsageDescriptor> set = new HashSet<>();
CodeInsightWorkspaceSettings ciws = CodeInsightWorkspaceSettings.getInstance(project);
CodeInsightWorkspaceSettings ciwsDefault = new CodeInsightWorkspaceSettings();
addBoolIfDiffers(set, ciws, ciwsDefault, s -> s.optimizeImportsOnTheFly, "autoOptimizeImports");
return set;
}
}
}
@@ -1,229 +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.internal.statistic.tools;
import com.intellij.codeInspection.InspectionEP;
import com.intellij.codeInspection.ex.ScopeToolState;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.RepositoryHelper;
import com.intellij.internal.statistic.AbstractProjectsUsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.extensions.PluginDescriptor;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.project.DefaultProjectFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.ModificationTracker;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.util.ObjectUtils;
import one.util.streamex.StreamEx;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public abstract class AbstractToolsUsagesCollector extends AbstractProjectsUsagesCollector {
private static final Predicate<ScopeToolState> BUNDLED = state -> {
final IdeaPluginDescriptor descriptor = getIdeaPluginDescriptor(state);
return descriptor != null && descriptor.isBundled();
};
private static final Predicate<ScopeToolState> LISTED = state -> {
final IdeaPluginDescriptor descriptor = getIdeaPluginDescriptor(state);
if (descriptor != null) {
String path;
try {
//to avoid paths like this /home/kb/IDEA/bin/../config/plugins/APlugin
path = descriptor.getPath().getCanonicalPath();
}
catch (final IOException e) {
path = descriptor.getPath().getAbsolutePath();
}
if (path.startsWith(PathManager.getPluginsPath())) {
final PluginId id = descriptor.getPluginId();
if (id != null && getRepositoryPluginIds().contains(id.getIdString())) {
return true;
}
}
}
return false;
};
private static IdeaPluginDescriptor getIdeaPluginDescriptor(final ScopeToolState state) {
final InspectionEP extension = state.getTool().getExtension();
return extension != null ? ObjectUtils.tryCast(extension.getPluginDescriptor(), IdeaPluginDescriptor.class) : null;
}
private static final Predicate<ScopeToolState> ENABLED = state -> !state.getTool().isEnabledByDefault() && state.isEnabled();
private static final Predicate<ScopeToolState> DISABLED = state -> state.getTool().isEnabledByDefault() && !state.isEnabled();
@NotNull
@Override
public Set<UsageDescriptor> getProjectUsages(@NotNull final Project project) {
final List<ScopeToolState> tools = InspectionProjectProfileManager.getInstance(project).getCurrentProfile().getAllTools();
return filter(tools.stream())
.map(ScopeToolState::getTool)
.map(tool -> tool.getLanguage() + "." + tool.getID())
.map(UsageDescriptor::new)
.collect(Collectors.toSet());
}
@NotNull
protected abstract Stream<ScopeToolState> filter(@NotNull final Stream<ScopeToolState> tools);
public static class AllBundledToolsUsagesCollector extends AbstractToolsUsagesCollector {
private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("all-bundled-tools");
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GROUP_ID;
}
@NotNull
@Override
protected Stream<ScopeToolState> filter(@NotNull final Stream<ScopeToolState> tools) {
return tools.filter(BUNDLED);
}
}
public static class AllListedToolsUsagesCollector extends AbstractToolsUsagesCollector {
private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("all-listed-tools");
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GROUP_ID;
}
@NotNull
@Override
protected Stream<ScopeToolState> filter(@NotNull final Stream<ScopeToolState> tools) {
return tools.filter(LISTED);
}
}
public static class EnabledBundledToolsUsagesCollector extends AbstractToolsUsagesCollector {
private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("enabled-bundled-tools");
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GROUP_ID;
}
@NotNull
@Override
protected Stream<ScopeToolState> filter(@NotNull final Stream<ScopeToolState> tools) {
return tools.filter(ENABLED).filter(BUNDLED);
}
}
public static class EnabledListedToolsUsagesCollector extends AbstractToolsUsagesCollector {
private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("enabled-listed-tools");
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GROUP_ID;
}
@NotNull
@Override
protected Stream<ScopeToolState> filter(@NotNull final Stream<ScopeToolState> tools) {
return tools.filter(ENABLED).filter(LISTED);
}
}
public static class DisabledBundledToolsUsagesCollector extends AbstractToolsUsagesCollector {
private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("disabled-bundled-tools");
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GROUP_ID;
}
@NotNull
@Override
protected Stream<ScopeToolState> filter(@NotNull final Stream<ScopeToolState> tools) {
return tools.filter(DISABLED).filter(BUNDLED);
}
}
public static class DisabledListedToolsUsagesCollector extends AbstractToolsUsagesCollector {
private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("disabled-listed-tools");
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GROUP_ID;
}
@NotNull
@Override
protected Stream<ScopeToolState> filter(@NotNull final Stream<ScopeToolState> tools) {
return tools.filter(DISABLED).filter(LISTED);
}
}
private static Set<String> getRepositoryPluginIds() {
final Project project = DefaultProjectFactory.getInstance().getDefaultProject();
return CachedValuesManager.getManager(project).getCachedValue(project, () -> {
List<IdeaPluginDescriptor> plugins = Collections.emptyList();
try {
final List<IdeaPluginDescriptor> cached = RepositoryHelper.loadCachedPlugins();
if (cached != null) {
plugins = cached;
}
else {
// schedule plugins loading, will take them the next time
ApplicationManager.getApplication().executeOnPooledThread(() -> {
try {
RepositoryHelper.loadPlugins(null);
}
catch (final IOException ignored) {
}
});
}
}
catch (final IOException ignored) {
}
final Set<String> ids = StreamEx.of(plugins).map(PluginDescriptor::getPluginId).nonNull().map(PluginId::getIdString).toSet();
return CachedValueProvider.Result.create(ids, new DelayModificationTracker(1, TimeUnit.HOURS));
});
}
private static class DelayModificationTracker implements ModificationTracker {
private final long myStamp = System.currentTimeMillis();
private final long myDelay;
private DelayModificationTracker(final long delay, @NotNull final TimeUnit unit) {
myDelay = TimeUnit.MILLISECONDS.convert(delay, unit);
}
@Override
public long getModificationCount() {
final long diff = System.currentTimeMillis() - (myStamp + myDelay);
return diff > 0 ? diff : 0;
}
}
}
@@ -21,7 +21,6 @@ import com.intellij.ide.IdeBundle;
import com.intellij.ide.plugins.HelpSetPath;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.IdeUrlTrackingParametersProvider;
import com.intellij.openapi.application.ex.ApplicationInfoEx;
@@ -52,8 +51,6 @@ public class HelpManagerImpl extends HelpManager {
public void invokeHelp(@Nullable String id) {
id = StringUtil.notNullize(id, "top");
UsageTrigger.trigger("ide.help." + id);
for (WebHelpProvider provider : WEB_HELP_PROVIDER_EP_NAME.getExtensions()) {
if (id.startsWith(provider.getHelpTopicPrefix())) {
@@ -16,13 +16,11 @@
package com.intellij.ide.actions;
import com.intellij.ide.caches.CachesInvalidator;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ex.ApplicationEx;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.registry.Registry;
@@ -94,7 +92,6 @@ public class InvalidateCachesAction extends AnAction implements DumbAware {
return;
}
UsageTrigger.trigger(ApplicationManagerEx.getApplicationEx().getName() + ".caches.invalidated");
if (invalidateCachesInvalidatesVfs) FSRecords.invalidateCaches();
else FileBasedIndex.getInstance().invalidateCaches();
@@ -20,7 +20,6 @@ import com.intellij.icons.AllIcons;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.ide.plugins.PluginNode;
import com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigButtonUsages;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase;
import com.intellij.openapi.ui.VerticalFlowLayout;
@@ -205,7 +204,6 @@ public class CustomizeFeaturedPluginsStepPanel extends AbstractCustomizeWizardSt
public void run() {
try {
indicator.start();
IdeInitialConfigButtonUsages.addDownloadedPlugin(descriptor.getPluginId().getIdString());
PluginDownloader downloader = PluginDownloader.createDownloader(descriptor);
downloader.prepareToInstall(indicator);
downloader.install();
@@ -17,7 +17,6 @@ package com.intellij.ide.customize;
import com.intellij.ide.cloudConfig.CloudConfigProvider;
import com.intellij.ide.startup.StartupActionScriptManager;
import com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigButtonUsages;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.text.StringUtil;
@@ -178,7 +177,6 @@ public class CustomizeIDEWizardDialog extends DialogWrapper implements ActionLis
return;
}
}
IdeInitialConfigButtonUsages.setSkipRemainingPressedScreen(mySteps.get(myIndex).getClass().getName());
super.doOKAction();
}
@@ -16,7 +16,6 @@
package com.intellij.ide.customize;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigButtonUsages;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.VerticalFlowLayout;
@@ -36,7 +35,6 @@ import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -234,7 +232,6 @@ public class CustomizePluginsStepPanel extends AbstractCustomizeWizardStep imple
public boolean beforeOkAction() {
try {
PluginManager.saveDisabledPlugins(myPluginGroups.getDisabledPluginIds(), false);
IdeInitialConfigButtonUsages.setPredefinedDisabledPlugins(new HashSet<>(myPluginGroups.getDisabledPluginIds()));
}
catch (IOException ignored) {
}
@@ -17,7 +17,6 @@ package com.intellij.ide.util;
import com.intellij.CommonBundle;
import com.intellij.ide.IdeBundle;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.wm.ex.WindowManagerEx;
@@ -98,7 +97,6 @@ public class TipDialog extends DialogWrapper{
public void actionPerformed(ActionEvent e){
myTipPanel.prevTip();
UsageTrigger.trigger("tips.of.the.day.prev");
}
}
@@ -111,7 +109,6 @@ public class TipDialog extends DialogWrapper{
public void actionPerformed(ActionEvent e){
myTipPanel.nextTip();
UsageTrigger.trigger("tips.of.the.day.next");
}
}
@@ -7,7 +7,6 @@ import com.intellij.concurrency.IdeaForkJoinWorkerThreadFactory;
import com.intellij.ide.*;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.application.*;
import com.intellij.openapi.application.ex.ApplicationEx;
import com.intellij.openapi.application.ex.ApplicationInfoEx;
@@ -362,9 +361,6 @@ public class IdeaApplication {
//noinspection SSBasedInspection
SwingUtilities.invokeLater(PluginManager::reportPluginError);
//safe for headless and unit test modes
UsageTrigger.trigger("lifecycle", app.getName() + "app.started");
});
}
@@ -16,90 +16,21 @@
package com.intellij.internal.statistic;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.persistence.ApplicationStatisticsPersistence;
import com.intellij.internal.statistic.persistence.CollectedUsages;
import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent;
import com.intellij.internal.statistic.utils.StatisticsUtilKt;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.util.containers.ObjectIntHashMap;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Set;
// Collects(summarizes) project-level usages.
// Statistics is regularly sent with some period of time (see com.intellij.internal.statistic.configurable.SendPeriod).
// In this period the user can open/close N projects which are not available at the "special send statistics" time.
// AbstractProjectsUsagesCollector persists the statistics data from opened/closed projects
// and summarizes collected results when data are requested.
//
// Example for groupId="my-team-lead-wants-something":
// 1. project A: key_1= a1, key_2=b1, key_3=c1 // this project was opened and closed (not available just now)
// 2. project B: key_1= a2, key_2=b2 // this project was opened and closed (not available just now)
// 3. project C: key_1= a3, key_4=c3 // this project is open just now
// if "send statistics" action is invoked this UsageCollector returns :
// groupId="my-team-lead-wants-something": key_1=(a1+a2+a3), key_2=(b1+b2), key_3=c1, key_4=c3
//
@Deprecated // to be removed in 2018.2
public abstract class AbstractProjectsUsagesCollector extends UsagesCollector {
@NotNull
public abstract Set<UsageDescriptor> getProjectUsages(@NotNull Project project) throws CollectUsagesException;
private static final Logger LOG = Logger.getInstance(AbstractProjectsUsagesCollector.class);
// Achtung!!! don't invoke this method directly even you can.
void persistProjectUsages(@NotNull Project project) {
try {
persistProjectUsages(project, new CollectedUsages(getProjectUsages(project), System.currentTimeMillis()));
}
catch (Exception e) {
LOG.info(e);
}
}
private void persistProjectUsages(@NotNull Project project, @NotNull CollectedUsages usages) {
persistProjectUsages(project, usages, ApplicationStatisticsPersistenceComponent.getInstance());
}
private void persistProjectUsages(@NotNull Project project,
@NotNull CollectedUsages usages,
@NotNull ApplicationStatisticsPersistence persistence) {
persistence.persistUsages(getGroupId(), project, usages);
}
@NotNull
private Set<UsageDescriptor> getApplicationUsages() {
return mergeUsagesPostProcess(getApplicationUsages(ApplicationStatisticsPersistenceComponent.getInstance()));
}
@NotNull
@Deprecated
// this method should be overridden only in exceptional cases.
// you have summarized usages from all opened/closed projects here.
// do you want to add/merge something? Don't do it!!!
protected Set<UsageDescriptor> mergeUsagesPostProcess(@NotNull Set<UsageDescriptor> usagesFromAllProjects) {
return usagesFromAllProjects;
}
@NotNull
private 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());
}
}
}
return StatisticsUtilKt.toUsageDescriptors(result);
}
@Override
@NotNull
public final Set<UsageDescriptor> getUsages() throws CollectUsagesException {
return getApplicationUsages();
return Collections.emptySet();
}
}
@@ -1,206 +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.internal.statistic;
import com.intellij.concurrency.JobScheduler;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.persistence.ApplicationStatisticsPersistence;
import com.intellij.internal.statistic.persistence.CollectedUsages;
import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent;
import com.intellij.internal.statistic.utils.StatisticsUploadAssistant;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.*;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerListener;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.messages.MessageBusConnection;
import gnu.trove.THashSet;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@State(
name = "StatisticsApplicationUsages",
storages = {
@Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED),
@Storage(value = "statistics.application.usages.xml", roamingType = RoamingType.DISABLED, deprecated = true)
}
)
public class ApplicationStatisticsPersistenceComponent extends ApplicationStatisticsPersistence implements
PersistentStateComponent<Element>,
BaseComponent {
// 30 minutes considered enough for project indexing and other tasks
private static final int DELAY_IN_MIN = 30;
private static final Map<Project, Future> persistProjectStatisticsTasks = Collections.synchronizedMap(new HashMap<>());
private static final String TOKENIZER = ",";
@NonNls
private static final String GROUP_TAG = "group";
@NonNls
private static final String GROUP_NAME_ATTR = "name";
@NonNls
private static final String PROJECT_TAG = "project";
@NonNls
private static final String COLLECTION_TIME_TAG = "collectionTime";
@NonNls
private static final String PROJECT_ID_ATTR = "id";
@NonNls
private static final String VALUES_ATTR = "values";
public static ApplicationStatisticsPersistenceComponent getInstance() {
return ApplicationManager.getApplication().getComponent(ApplicationStatisticsPersistenceComponent.class);
}
@Override
public void loadState(@NotNull Element element) {
for (Element groupElement : element.getChildren(GROUP_TAG)) {
GroupDescriptor groupDescriptor = GroupDescriptor.create(groupElement.getAttributeValue(GROUP_NAME_ATTR));
List<Element> projectsList = groupElement.getChildren(PROJECT_TAG);
for (Element projectElement : projectsList) {
String projectId = projectElement.getAttributeValue(PROJECT_ID_ATTR);
String frameworks = projectElement.getAttributeValue(VALUES_ATTR);
if (!StringUtil.isEmptyOrSpaces(projectId) && !StringUtil.isEmptyOrSpaces(frameworks)) {
Set<UsageDescriptor> frameworkDescriptors = new THashSet<>();
for (String key : StringUtil.split(frameworks, TOKENIZER)) {
UsageDescriptor descriptor = getUsageDescriptor(key);
if (descriptor != null) {
frameworkDescriptors.add(descriptor);
}
}
long collectionTime;
try {
collectionTime = Long.valueOf(projectElement.getAttributeValue(COLLECTION_TIME_TAG));
} catch (NumberFormatException ignored) {
collectionTime = 0;
}
getApplicationData(groupDescriptor).put(projectId, new CollectedUsages(frameworkDescriptors, collectionTime));
}
}
}
}
@Override
public Element getState() {
Element element = new Element("state");
for (Map.Entry<GroupDescriptor, Map<String, CollectedUsages>> appData : getApplicationData().entrySet()) {
Element groupElement = new Element(GROUP_TAG);
groupElement.setAttribute(GROUP_NAME_ATTR, appData.getKey().getId());
boolean isEmptyGroup = true;
for (Map.Entry<String, CollectedUsages> projectData : appData.getValue().entrySet()) {
Element projectElement = new Element(PROJECT_TAG);
projectElement.setAttribute(PROJECT_ID_ATTR, projectData.getKey());
final CollectedUsages projectDataValue = projectData.getValue();
if (!projectDataValue.usages.isEmpty()) {
projectElement.setAttribute(VALUES_ATTR, joinUsages(projectDataValue.usages));
projectElement.setAttribute(COLLECTION_TIME_TAG, String.valueOf(projectDataValue.collectionTime));
groupElement.addContent(projectElement);
isEmptyGroup = false;
}
}
if (!isEmptyGroup) {
element.addContent(groupElement);
}
}
return element;
}
private static UsageDescriptor getUsageDescriptor(String usage) {
// for instance, usage can be: "_foo"(equals "_foo=1") or "_foo=2"
try {
final int i = usage.indexOf('=');
if (i > 0 && i < usage.length() - 1) {
String key = usage.substring(0, i).trim();
String value = usage.substring(i + 1).trim();
if (!StringUtil.isEmptyOrSpaces(key) && !StringUtil.isEmptyOrSpaces(value)) {
try {
final int count = Integer.parseInt(value);
if (count > 0) {
return new UsageDescriptor(key, count);
}
}
catch (NumberFormatException ignored) {
}
}
}
return new UsageDescriptor(usage, 1);
}
catch (AssertionError e) {
//escape loading of invalid usages
}
return null;
}
private static String joinUsages(@NotNull Set<UsageDescriptor> usages) {
// for instance, usage can be: "_foo"(equals "_foo=1") or "_foo=2"
return StringUtil.join(usages, usageDescriptor -> {
final String key = usageDescriptor.getKey();
final int value = usageDescriptor.getValue();
return value != 1 ? key + "=" + value : key;
}, TOKENIZER);
}
@Override
public void initComponent() {
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
connection.subscribe(ProjectManager.TOPIC, new ProjectManagerListener() {
@Override
public void projectOpened(Project project) {
ScheduledFuture<?> future =
JobScheduler.getScheduler().schedule(() -> doPersistProjectUsages(project), DELAY_IN_MIN, TimeUnit.MINUTES);
persistProjectStatisticsTasks.put(project, future);
}
public void projectClosed(Project project) {
Future future = persistProjectStatisticsTasks.remove(project);
if (future != null) {
future.cancel(true);
}
}
});
persistPeriodically();
}
private static void persistPeriodically() {
JobScheduler.getScheduler().scheduleWithFixedDelay(ApplicationStatisticsPersistenceComponent::persistOpenedProjects, 1, 1, TimeUnit.DAYS);
}
/**
* Collects statistics from all opened projects and persists it
*/
public static void persistOpenedProjects() {
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
doPersistProjectUsages(project);
}
}
private static void doPersistProjectUsages(@NotNull Project project) {
if (StatisticsUploadAssistant.isSendAllowed()) {
synchronized (StatisticsUploadAssistant.LOCK) {
if (!project.isInitialized() || DumbService.isDumb(project)) {
return;
}
for (UsagesCollector usagesCollector : UsagesCollector.EP_NAME.getExtensions()) {
if (usagesCollector instanceof AbstractProjectsUsagesCollector) {
((AbstractProjectsUsagesCollector)usagesCollector).persistProjectUsages(project);
}
}
}
}
}
}
@@ -1,91 +1,15 @@
// 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.internal.statistic;
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.eventLog.FeatureUsageLogger;
import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent;
import com.intellij.openapi.components.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xmlb.annotations.MapAnnotation;
import com.intellij.util.xmlb.annotations.Tag;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@State(
name = "UsageTrigger",
storages = {
@Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED),
@Storage(value = "statistics.application.usages.xml", roamingType = RoamingType.DISABLED, deprecated = true)
}
)
@Deprecated // to be removed in 2018.2
public class UsageTrigger implements PersistentStateComponent<UsageTrigger.State> {
final static class State {
@Tag("counts")
@MapAnnotation(surroundWithTag = false, keyAttributeName = "feature", valueAttributeName = "count")
public Map<String, Integer> myValues = new HashMap<>();
}
public class UsageTrigger {
private State myState = new State();
public static void trigger(@NotNull @NonNls String feature) {}
public static void trigger(@NotNull @NonNls String feature) {
FeatureUsageLogger.INSTANCE.log("trigger", feature);
getInstance().doTrigger(feature);
}
public static void trigger(@NotNull @NonNls String groupId, @NotNull @NonNls String feature) {}
public static void trigger(@NotNull @NonNls String groupId, @NotNull @NonNls String feature) {
FeatureUsageLogger.INSTANCE.log(groupId, feature);
getInstance().doTrigger(feature);
}
public static void triggerOnce(@NotNull @NonNls String feature) {
if (!getInstance().myState.myValues.containsKey(feature)) {
getInstance().doTrigger(feature);
}
}
private static UsageTrigger getInstance() {
return ServiceManager.getService(UsageTrigger.class);
}
private void doTrigger(String feature) {
ConvertUsagesUtil.assertDescriptorName(feature);
final Integer count = myState.myValues.get(feature);
if (count == null) {
myState.myValues.put(feature, 1);
}
else {
myState.myValues.put(feature, count + 1);
}
}
public State getState() {
return myState;
}
public void loadState(@NotNull final State state) {
myState = state;
}
final static class MyCollector extends UsagesCollector {
private static final GroupDescriptor GROUP = GroupDescriptor.create("features counts", GroupDescriptor.HIGHER_PRIORITY);
@NotNull
public Set<UsageDescriptor> getUsages() {
State state = getInstance().getState();
assert state != null;
return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue()));
}
@NotNull
public GroupDescriptor getGroupId() {
return GROUP;
}
}
public static void triggerOnce(@NotNull @NonNls String feature) {}
}
@@ -1,18 +1,12 @@
// Copyright 2000-2017 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.internal.statistic;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.ide.plugins.cl.PluginClassLoader;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
import java.util.function.Function;
@Deprecated // to be removed in 2018.2
public abstract class UsagesCollector {
@@ -25,53 +19,4 @@ public abstract class UsagesCollector {
@NotNull
public abstract GroupDescriptor getGroupId();
private static Pair<Double, Double> findBucket(double value, double... ranges) {
if (ranges.length == 0) throw new IllegalArgumentException("Constrains are empty");
if (value < ranges[0]) return Pair.create(null, ranges[0]);
for (int i = 1; i < ranges.length; i++) {
if (ranges[i] <= ranges[i - 1])
throw new IllegalArgumentException("Constrains are unsorted");
if (value < ranges[i]) {
return Pair.create(ranges[i - 1], ranges[i]);
}
}
return Pair.create(ranges[ranges.length - 1], null);
}
public static boolean isNotBundledPluginClass(@NotNull Class clazz) {
ClassLoader loader = clazz.getClassLoader();
if (loader instanceof PluginClassLoader) {
PluginId id = ((PluginClassLoader)loader).getPluginId();
if (id != null) {
IdeaPluginDescriptor plugin = PluginManager.getPlugin(id);
if (plugin != null && !plugin.isBundled()) {
return true;
}
}
}
return false;
}
protected static String findBucket(long value, Function<Long, String> valueConverter, long...ranges) {
double[] dRanges = new double[ranges.length];
for (int i = 0; i < dRanges.length; i++) {
dRanges[i] = ranges[i];
}
return findBucket((double)value, (d) -> valueConverter.apply(d.longValue()), dRanges);
}
protected static String findBucket(double value, Function<Double, String> valueConverter, double...ranges) {
for (double range : ranges) {
if (range == value) {
return valueConverter.apply(value);
}
}
Pair<Double, Double> bucket = findBucket(value, ranges);
if (bucket.first == null) return "(*, " + valueConverter.apply(bucket.second) + ")";
if (bucket.second == null) return "(" + valueConverter.apply(bucket.first) + ", *)";
return "(" + valueConverter.apply(bucket.first) + ", " + valueConverter.apply(bucket.second) + ")";
}
}
@@ -25,7 +25,7 @@ public class SendFUStatisticsAction extends AnAction {
return;
}
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Collecting And Sending _NEW_ Statistics", false) {
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Collecting And Sending Statistics", false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
StatisticsService service = StatisticsUploadAssistant.getApprovedGroupsStatisticsService();
@@ -1,66 +0,0 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.internal.statistic.actions;
import com.intellij.internal.statistic.ApplicationStatisticsPersistenceComponent;
import com.intellij.internal.statistic.connect.StatisticsResult;
import com.intellij.internal.statistic.connect.StatisticsService;
import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent;
import com.intellij.internal.statistic.utils.StatisticsUploadAssistant;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
public class SendStatisticsAction extends AnAction {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final Project project = e.getProject();
if (project == null) {
return;
}
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Collecting And Sending _OLD_ Statistics", false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
UsageStatisticsPersistenceComponent statisticsPersistenceComponent = UsageStatisticsPersistenceComponent.getInstance();
final boolean sendAllowed = statisticsPersistenceComponent.isAllowed();
try {
statisticsPersistenceComponent.setAllowed(true);
ApplicationStatisticsPersistenceComponent.getInstance().persistOpenedProjects();
}
finally {
statisticsPersistenceComponent.setAllowed(sendAllowed);
}
StatisticsService service = StatisticsUploadAssistant.getOldStatisticsService();
final StatisticsResult result = service.send();
ApplicationManager.getApplication().invokeLater(
() -> Messages.showMultilineInputDialog(project, "Result: " + result.getCode(), "Statistics Result",
StringUtil.replace(result.getDescription(), ";", "\n"),
null, null), ModalityState.NON_MODAL, project.getDisposed());
}
});
}
}
@@ -18,13 +18,14 @@ package com.intellij.internal.statistic.beans;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.Map;
import java.util.Set;
/**
* ATTENTION! DO NOT IMPORT @NotNull AND @Nullable ANNOTATIONS
* This class is also used on jetbrains web site
*/
@Deprecated // to be removed in 2018.2
public class ConvertUsagesUtil {
static final char GROUP_SEPARATOR = ':';
static final char GROUPS_SEPARATOR = ';';
@@ -83,50 +84,6 @@ public class ConvertUsagesUtil {
return "";
}
//@NotNull
public static Map<GroupDescriptor, Set<UsageDescriptor>> convertString(String usages) {
assert usages != null;
Map<GroupDescriptor, Set<UsageDescriptor>> descriptors = new HashMap<>();
for (String groupStr : usages.split(Character.toString(GROUPS_SEPARATOR))) {
if (!isEmptyOrSpaces(groupStr)) {
final StringPair group = getPair(groupStr, Character.toString(GROUP_SEPARATOR));
if (group != null) {
final String groupId = group.first;
assert groupId != null;
descriptors.putAll(convertValueString(GroupDescriptor.create(groupId), group.second));
}
}
}
return descriptors;
}
//@NotNull
public static Map<GroupDescriptor, Set<UsageDescriptor>> convertValueString(GroupDescriptor groupId, String valueData) {
assert groupId != null;
final Map<GroupDescriptor, Set<UsageDescriptor>> descriptors = new HashMap<>();
for (String value : valueData.split(Character.toString(GROUP_VALUE_SEPARATOR))) {
if (!isEmptyOrSpaces(value)) {
final StringPair pair = getPair(value, "=");
if (pair != null) {
final String count = pair.second;
if (!isEmptyOrSpaces(count)) {
try {
final int i = Integer.parseInt(count);
if (!descriptors.containsKey(groupId)) {
descriptors.put(groupId, new LinkedHashSet<>());
}
descriptors.get(groupId).add(new UsageDescriptor(pair.first, i));
}
catch (NumberFormatException ignored) {
}
}
}
}
}
return descriptors;
}
//@Nullable
public static StringPair getPair(String str, String separator) {
assert str != null;
@@ -142,19 +99,6 @@ public class ConvertUsagesUtil {
return null;
}
//@NotNull
public static <T extends UsageDescriptor> Map<GroupDescriptor, Set<T>> sortDescriptorsByPriority(Map<GroupDescriptor, Set<T>> descriptors) {
assert descriptors != null;
final SortedMap<GroupDescriptor, Set<T>> map = new TreeMap<>((g1, g2) -> {
final int priority = (int)(g2.getPriority() - g1.getPriority());
return priority == 0 ? g1.getId().compareTo(g2.getId()) : priority;
});
map.putAll(descriptors);
return map;
}
/**
* Escapes descriptor name so it could be used in {@link #assertDescriptorName(String)}
*
@@ -15,16 +15,12 @@
*/
package com.intellij.internal.statistic.beans;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
@Deprecated // to be removed in 2018.2
public class GroupDescriptor {
public static final double DEFAULT_PRIORITY = 0.0;
public static final double HIGHER_PRIORITY = 100.0;
public static final double LOWER_PRIORITY = -100.0;
private static final int MAX_ID_LENGTH = 30;
private final String myId;
private final double myPriority;
@@ -37,26 +33,9 @@ public class GroupDescriptor {
}
private GroupDescriptor(String id, double priority) {
if (StringUtil.isEmptyOrSpaces(id)) throw new IllegalArgumentException("Invalid ID: '" + id + "'");
checkSeparator(id, ConvertUsagesUtil.GROUP_SEPARATOR);
checkSeparator(id, ConvertUsagesUtil.GROUPS_SEPARATOR);
checkSeparator(id, ConvertUsagesUtil.GROUP_VALUE_SEPARATOR);
if (id.length() > MAX_ID_LENGTH) {
Logger.getInstance(GroupDescriptor.class).error("ID too long: '" + id + "', truncated");
id = id.substring(0, MAX_ID_LENGTH);
}
myId = ConvertUsagesUtil.ensureProperKey(id);
myPriority = priority;
}
private static void checkSeparator(String id, char separator) {
if (id.contains(Character.toString(separator))) {
Logger.getInstance(GroupDescriptor.class).
error("ID should not contain separator \'" + ConvertUsagesUtil.GROUP_SEPARATOR + "\'. Please fix ID \"" + id + "\"");
}
}
public String getId() {
return myId;
}
@@ -0,0 +1,24 @@
// 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.internal.statistic.collectors.fus.actions.persistence;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.ide.plugins.cl.PluginClassLoader;
import com.intellij.openapi.extensions.PluginId;
import org.jetbrains.annotations.NotNull;
public class BaseUICollector {
protected boolean isNotBundledPluginClass(@NotNull Class clazz) {
ClassLoader loader = clazz.getClassLoader();
if (loader instanceof PluginClassLoader) {
PluginId id = ((PluginClassLoader)loader).getPluginId();
if (id != null) {
IdeaPluginDescriptor plugin = PluginManager.getPlugin(id);
if (plugin != null && !plugin.isBundled()) {
return true;
}
}
}
return false;
}
}
@@ -5,7 +5,6 @@ import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.intention.IntentionActionDelegate;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ex.QuickFixWrapper;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent;
import com.intellij.lang.Language;
import com.intellij.openapi.components.*;
@@ -15,7 +14,10 @@ import com.intellij.util.xmlb.annotations.Tag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Konstantin Bulenkov
@@ -27,7 +29,7 @@ import java.util.*;
@Storage(value = "statistics.intentions.xml", roamingType = RoamingType.DISABLED, deprecated = true)
}
)
public class IntentionsCollector implements PersistentStateComponent<IntentionsCollector.State> {
public class IntentionsCollector extends BaseUICollector implements PersistentStateComponent<IntentionsCollector.State> {
private State myState = new State();
@Nullable
@@ -56,7 +58,7 @@ public class IntentionsCollector implements PersistentStateComponent<IntentionsC
}
@NotNull
private static String getIntentionId(@NotNull IntentionAction action) {
private String getIntentionId(@NotNull IntentionAction action) {
Object handler = action;
if (action instanceof IntentionActionDelegate) {
IntentionAction delegate = ((IntentionActionDelegate)action).getDelegate();
@@ -75,7 +77,7 @@ public class IntentionsCollector implements PersistentStateComponent<IntentionsC
fqn = StringUtil.trimStart(fqn, prefix);
}
if (UsagesCollector.isNotBundledPluginClass(handler.getClass())) {
if (isNotBundledPluginClass(handler.getClass())) {
fqn = "[!]" + fqn;
}
@@ -1,12 +1,12 @@
// 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.internal.statistic.collectors.fus.actions.persistence;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.impl.ActionMenu;
import com.intellij.openapi.components.*;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.xmlb.annotations.MapAnnotation;
import com.intellij.util.xmlb.annotations.Tag;
@@ -19,6 +19,7 @@ import java.awt.event.ItemEvent;
import java.awt.event.MouseEvent;
import java.util.*;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -31,7 +32,7 @@ import java.util.stream.Collectors;
@Storage(value = "statistics.main_menu.xml", roamingType = RoamingType.DISABLED, deprecated = true)
}
)
public class MainMenuCollector implements PersistentStateComponent<MainMenuCollector.State> {
public class MainMenuCollector extends BaseUICollector implements PersistentStateComponent<MainMenuCollector.State> {
private State myState = new State();
@Nullable
@Override
@@ -46,7 +47,7 @@ public class MainMenuCollector implements PersistentStateComponent<MainMenuColle
public void record(@NotNull AnAction action) {
try {
if (UsagesCollector.isNotBundledPluginClass(action.getClass())) {
if (isNotBundledPluginClass(action.getClass())) {
return;
}
@@ -71,6 +72,45 @@ public class MainMenuCollector implements PersistentStateComponent<MainMenuColle
}
}
private static Pair<Double, Double> findBucket(double value, double... ranges) {
if (ranges.length == 0) throw new IllegalArgumentException("Constrains are empty");
if (value < ranges[0]) return Pair.create(null, ranges[0]);
for (int i = 1; i < ranges.length; i++) {
if (ranges[i] <= ranges[i - 1])
throw new IllegalArgumentException("Constrains are unsorted");
if (value < ranges[i]) {
return Pair.create(ranges[i - 1], ranges[i]);
}
}
return Pair.create(ranges[ranges.length - 1], null);
}
protected static String findBucket(long value, Function<Long, String> valueConverter, long...ranges) {
double[] dRanges = new double[ranges.length];
for (int i = 0; i < dRanges.length; i++) {
dRanges[i] = ranges[i];
}
return findBucket((double)value, (d) -> valueConverter.apply(d.longValue()), dRanges);
}
protected static String findBucket(double value, Function<Double, String> valueConverter, double...ranges) {
for (double range : ranges) {
if (range == value) {
return valueConverter.apply(value);
}
}
Pair<Double, Double> bucket = findBucket(value, ranges);
if (bucket.first == null) return "(*, " + valueConverter.apply(bucket.second) + ")";
if (bucket.second == null) return "(" + valueConverter.apply(bucket.first) + ", *)";
return "(" + valueConverter.apply(bucket.first) + ", " + valueConverter.apply(bucket.second) + ")";
}
protected String getPathFromMenuSelectionManager(@NotNull AnAction action) {
List<String> groups = Arrays.stream(MenuSelectionManager.defaultManager().getSelectedPath())
.filter(o -> o instanceof ActionMenu)
@@ -1,35 +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.internal.statistic.collectors.legacy;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.application.Experiments;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author Konstantin Bulenkov
*/
@Deprecated // to be removed in 2018.2
public class ExperimentalFeaturesUsageCollector extends UsagesCollector {
private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("Experimental Features");
@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
return Arrays.stream(Experiments.EP_NAME.getExtensions())
.filter(f -> Experiments.isFeatureEnabled(f.id))
.map(f -> new UsageDescriptor(f.id))
.collect(Collectors.toSet());
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GROUP_ID;
}
}
@@ -1,34 +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.internal.statistic.collectors.legacy;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.util.registry.Registry;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author Konstantin Bulenkov
*/
@Deprecated // to be removed in 2018.2
public class LegacyRegistryUsagesCollector extends UsagesCollector {
private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("Registry");
@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
return Registry.getAll().stream()
.filter(key -> key.isChangedFromDefault())
.map(key -> new UsageDescriptor(key.getKey()))
.collect(Collectors.toSet());
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GROUP_ID;
}
}
@@ -1,28 +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.internal.statistic.collectors.legacy.actions;
import com.intellij.ide.actions.ActionsCollector;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
@Deprecated // old statistics service format
public final class LegacyActionUsagesCollector extends UsagesCollector {
private static final GroupDescriptor GROUP = GroupDescriptor.create("Actions", GroupDescriptor.HIGHER_PRIORITY);
@NotNull
public Set<UsageDescriptor> getUsages() {
ActionsCollector.State state = ActionsCollector.getInstance().getState();
assert state != null;
return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue()));
}
@NotNull
public GroupDescriptor getGroupId() {
return GROUP;
}
}
@@ -1,28 +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.internal.statistic.collectors.legacy.actions;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.collectors.fus.actions.persistence.IntentionsCollector;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
@Deprecated // to be removed in 2018.2
public final class LegacyIntentionUsagesCollector extends UsagesCollector {
private static final GroupDescriptor GROUP = GroupDescriptor.create("Intentions");
@NotNull
public Set<UsageDescriptor> getUsages() {
IntentionsCollector.State state = IntentionsCollector.getInstance().getState();
assert state != null;
return ContainerUtil.map2Set(state.myIntentions.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue()));
}
@NotNull
public GroupDescriptor getGroupId() {
return GROUP;
}
}
@@ -1,28 +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.internal.statistic.collectors.legacy.actions;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.collectors.fus.actions.persistence.MainMenuCollector;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
@Deprecated // to be removed in 2018.2
public final class LegacyMainMenuUsagesCollector extends UsagesCollector {
private static final GroupDescriptor GROUP = GroupDescriptor.create("Main Menu", GroupDescriptor.HIGHER_PRIORITY);
@NotNull
public Set<UsageDescriptor> getUsages() {
MainMenuCollector.State state = MainMenuCollector.getInstance().getState();
assert state != null;
return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue()));
}
@NotNull
public GroupDescriptor getGroupId() {
return GROUP;
}
}
@@ -1,30 +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.internal.statistic.collectors.legacy.actions;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.collectors.fus.actions.persistence.ToolWindowCollector;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
/**
* @author Konstantin Bulenkov
*/
public class LegacyToolWindowUsagesCollector extends UsagesCollector {
private static final GroupDescriptor GROUP = GroupDescriptor.create("Tool Windows", GroupDescriptor.HIGHER_PRIORITY);
@NotNull
public Set<UsageDescriptor> getUsages() {
ToolWindowCollector.State state = ToolWindowCollector.getInstance().getState();
assert state != null;
return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue()));
}
@NotNull
public GroupDescriptor getGroupId() {
return GROUP;
}
}
@@ -1,30 +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.internal.statistic.collectors.legacy.build;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Set;
/**
* @author Ivan Chirkov
*/
@Deprecated // to be removed in 2018.2
public class BuildNumberUsageCollector extends UsagesCollector {
@NotNull
@Override
public Set<UsageDescriptor> getUsages() throws CollectUsagesException {
return Collections.singleton(new UsageDescriptor(ApplicationInfoImpl.getShadowInstance().getBuild().asString(), 1));
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("application.build");
}
}
@@ -1,31 +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.internal.statistic.collectors.legacy.fileTypes;
import com.intellij.internal.statistic.AbstractProjectsUsagesCollector;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.collectors.fus.fileTypes.FileTypeUsagesCollector;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
/**
* @author Nikolay Matveev
*/
public class LegacyFileTypeUsagesCollector extends AbstractProjectsUsagesCollector {
private static final String GROUP_ID = "file-type";
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create(GROUP_ID);
}
@NotNull
@Override
public Set<UsageDescriptor> getProjectUsages(@NotNull final Project project) throws CollectUsagesException {
return FileTypeUsagesCollector.getDescriptors(project);
}
}
@@ -1,80 +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.internal.statistic.collectors.legacy.ideSettings;
import javax.swing.*;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public final class IdeInitialConfigButtonUsages {
public static final Set<String> ALL_PLUGINS_SELECTED = Collections.unmodifiableSet(Collections.emptySet());
private static volatile ConfigImport ourConfigImport = ConfigImport.NO_INIT;
private static volatile String ourSkipRemainingPressedScreen = "";
private static volatile Set<String> ourPredefinedDisabledPlugins = ALL_PLUGINS_SELECTED;
private static Set<String> ourDownloadedPlugins = Collections.emptySet();
public static ConfigImport getConfigImport() {
return ourConfigImport;
}
public static void setConfigImport(JRadioButton myRbDoNotImport,
JRadioButton myRbImport,
JRadioButton myRbImportAuto,
JRadioButton myCustomButton) {
if (myRbDoNotImport != null && myRbDoNotImport.isSelected()) {
ourConfigImport = ConfigImport.DO_NOT_IMPORT;
}
else if (myRbImport != null && myRbImport.isSelected()) {
ourConfigImport = ConfigImport.IMPORT_PATH;
}
else if (myRbImportAuto != null && myRbImportAuto.isSelected()) {
ourConfigImport = ConfigImport.IMPORT_AUTO;
}
else if (myCustomButton != null && myCustomButton.isSelected()) {
ourConfigImport = ConfigImport.IMPORT_CUSTOM;
}
}
public static String getSkipRemainingPressedScreen() {
return ourSkipRemainingPressedScreen;
}
public static void setSkipRemainingPressedScreen(String skipRemainingPressedScreen) {
ourSkipRemainingPressedScreen = skipRemainingPressedScreen;
}
public static Set<String> getPredefinedDisabledPlugins() {
return ourPredefinedDisabledPlugins;
}
public static void setPredefinedDisabledPlugins(Set<String> predefinedDisabledPlugins) {
if (predefinedDisabledPlugins.isEmpty()) {
return;
}
ourPredefinedDisabledPlugins = predefinedDisabledPlugins;
}
public synchronized static Set<String> getDownloadedPlugins() {
return ourDownloadedPlugins;
}
public synchronized static void addDownloadedPlugin(String pluginId) {
if (ourDownloadedPlugins.isEmpty()) {
ourDownloadedPlugins = new HashSet<>();
}
ourDownloadedPlugins.add(pluginId);
}
public enum ConfigImport {
DO_NOT_IMPORT,
IMPORT_PATH,
IMPORT_AUTO,
IMPORT_CUSTOM,
NO_INIT
}
}
@@ -1,140 +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.internal.statistic.collectors.legacy.ideSettings;
import com.intellij.ide.WelcomeWizardUtil;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.utils.StatisticsUtilKt;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import static com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigButtonUsages.*;
public final class IdeInitialConfigUsageCollectors {
public static class ConfigImport extends Base {
@NotNull
@Override
public Set<UsageDescriptor> doGetUsages() {
return Collections.singleton(StatisticsUtilKt.getEnumUsage("import", getConfigImport()));
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("Import settings");
}
}
public static class SkipSteps extends Base {
@NotNull
@Override
public Set<UsageDescriptor> doGetUsages() {
return Collections.singleton(new UsageDescriptor(getSkipRemainingPressedScreen(), 1));
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("Wizard_Skip remaining pressed");
}
}
public static class DisabledPlugins extends Base {
@NotNull
@Override
public Set<UsageDescriptor> doGetUsages() {
return getPredefinedDisabledPlugins().stream()
.map(pluginDescriptor -> new UsageDescriptor(pluginDescriptor, 1))
.collect(Collectors.toSet());
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("Wizard_Disabled plugins");
}
}
public static class DownloadedPlugins extends Base {
@NotNull
@Override
public Set<UsageDescriptor> doGetUsages() {
return getDownloadedPlugins().stream()
.map(pluginId -> new UsageDescriptor(pluginId, 1))
.collect(Collectors.toSet());
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("Wizard_Downloaded plugins");
}
}
public static class SelectedKeymap extends Base {
@Override
protected Set<UsageDescriptor> doGetUsages() {
final String keymapName = WelcomeWizardUtil.getWizardMacKeymap();
if (StringUtil.isEmpty(keymapName)) {
return Collections.emptySet();
}
else {
return Collections.singleton(new UsageDescriptor(keymapName, 1));
}
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("Wizard_Selected keymap");
}
}
public static class SelectedLAF extends Base {
@Override
protected Set<UsageDescriptor> doGetUsages() {
final String laf = WelcomeWizardUtil.getWizardLAF();
if (StringUtil.isEmpty(laf)) {
return Collections.emptySet();
}
else {
return Collections.singleton(new UsageDescriptor(laf, 1));
}
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("Wizard_Selected LAF");
}
}
private abstract static class Base extends UsagesCollector {
protected abstract Set<UsageDescriptor> doGetUsages() throws CollectUsagesException;
private static boolean shouldCount() {
return getConfigImport() != IdeInitialConfigButtonUsages.ConfigImport.NO_INIT;
}
@NotNull
@Override
public Set<UsageDescriptor> getUsages() throws CollectUsagesException {
if (!shouldCount()) {
return Collections.emptySet();
}
return doGetUsages();
}
}
}
@@ -1,85 +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.internal.statistic.collectors.legacy.jdk
import com.intellij.internal.statistic.UsagesCollector
import com.intellij.internal.statistic.beans.GroupDescriptor
import com.intellij.internal.statistic.beans.UsageDescriptor
import java.lang.management.ManagementFactory
import java.util.function.Function
/**
* @author Konstantin Bulenkov
*/
@Deprecated("") // to be removed in 2018.2
class JdkSettingsUsageCollector : UsagesCollector() {
override fun getUsages(): Set<UsageDescriptor> {
return ManagementFactory.getRuntimeMXBean().inputArguments
.filter { accept(it) }
.map { convertToBucket(it) }
.filter { !it.isEmpty() }
.map { UsageDescriptor(it) }
.toSet()
}
val prefixes: List<String> = listOf("-Xms",
"-Xmx",
"-XX:SoftRefLRUPolicyMSPerMB",
"-XX:ReservedCodeCacheSize")
fun accept(key: String?): Boolean {
if (key == null) return false
prefixes.forEach {
if (key.startsWith(it)) return true
}
return false
}
private fun convertToBucket(key: String): String {
val sizeMb = getMegabytes(key).toLong()
val converter = Function<Long, String> { it.toString() + "Mb" }
if (key.startsWith("-Xms"))
return "-Xmx " + findBucket(sizeMb, converter, 512, 750, 1000, 1024, 1500, 2000, 2048, 3000, 4000, 4096, 6000, 8000)
if (key.startsWith("-Xmx"))
return "-Xms " + findBucket(sizeMb, converter, 64, 128, 256, 512)
if (key.startsWith("-XX:SoftRefLRUPolicyMSPerMB"))
return "-XX:SoftRefLRUPolicyMSPerMB " + findBucket(sizeMb, converter, 50, 100)
if (key.startsWith("-XX:ReservedCodeCacheSize"))
return "-XX:ReservedCodeCacheSize " + findBucket(sizeMb, converter, 240, 300, 400, 500)
return ""
}
private fun getMegabytes(s: String): Int {
var num = prefixes.firstOrNull { s.startsWith(it) }
?.let { s.substring(it.length).toUpperCase().trim() }
if (num == null) return -1
if (num.startsWith("=")) num = num.substring(1)
if (num.last().isDigit()) {
return try { Integer.parseInt(num) } catch (e: Exception) { -1 }
}
try {
val size = Integer.parseInt(num.substring(0, num.length - 1))
when(num.last()) {
'B' -> return size / (1024 * 1024)
'K' -> return size / 1024
'M' -> return size
'G' -> return size * 1024
}
} catch (e: Exception) { return -1 }
return -1
}
override fun getGroupId(): GroupDescriptor {
return GroupDescriptor.create("JVM options")
}
}
@@ -1,31 +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.internal.statistic.collectors.legacy.jdk;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.util.lang.JavaVersion;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Set;
/**
* @author Konstantin Bulenkov
*/
@Deprecated // to be removed in 2018.2
class LegacyJdkInfoUsageCollector extends UsagesCollector {
@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
final String vendor = System.getProperty("java.vendor", "Unknown");
final String version = "1." + JavaVersion.current().feature;
return Collections.singleton(new UsageDescriptor(vendor + " " + version, 1));
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("user.jdk");
}
}
@@ -1,31 +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.internal.statistic.collectors.legacy.os;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.util.SystemInfo;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Set;
/**
* @author peter
*/
@Deprecated // to be removed in 2018.2
class LegacyOsNameUsageCollector extends UsagesCollector {
@NotNull
@Override
public Set<UsageDescriptor> getUsages() throws CollectUsagesException {
String osName = SystemInfo.isLinux ? "Linux" : SystemInfo.isMac ? "Mac OS X" : SystemInfo.isWindows ? "Windows" : SystemInfo.OS_NAME;
return Collections.singleton(new UsageDescriptor(osName, 1));
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("user.os.name");
}
}
@@ -1,29 +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.internal.statistic.collectors.legacy.os;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.collectors.fus.os.OsVersionUsageCollector;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
/**
* @author peter
*/
@Deprecated
// to be removed in 2018.2
class LegacyOsVersionUsageCollector extends UsagesCollector {
@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
return OsVersionUsageCollector.getDescriptors();
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("user.os.version");
}
}
@@ -1,26 +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.internal.statistic.collectors.legacy.plugins;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
@Deprecated // to be removed in 2018.2
public class LegacyDisabledPluginsUsagesCollector extends UsagesCollector {
private static final String GROUP_ID = "disabled-plugins";
@NotNull
public GroupDescriptor getGroupId() {
return GroupDescriptor.create(GROUP_ID, GroupDescriptor.HIGHER_PRIORITY);
}
@NotNull
public Set<UsageDescriptor> getUsages() {
return ContainerUtil.map2Set(PluginManagerCore.getDisabledPlugins(), descriptor -> new UsageDescriptor(descriptor, 1));
}
}
@@ -1,32 +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.internal.statistic.collectors.legacy.plugins;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Set;
@Deprecated // to be removed in 2018.2
public class LegacyNonBundledPluginsUsagesCollector extends UsagesCollector {
private static final String GROUP_ID = "non-bundled-plugins";
@NotNull
public GroupDescriptor getGroupId() {
return GroupDescriptor.create(GROUP_ID, GroupDescriptor.HIGHER_PRIORITY);
}
@NotNull
public Set<UsageDescriptor> getUsages() {
final IdeaPluginDescriptor[] plugins = PluginManagerCore.getPlugins();
final List<IdeaPluginDescriptor> nonBundledEnabledPlugins = ContainerUtil.filter(plugins, d -> d.isEnabled() && !d.isBundled() && d.getPluginId() != null);
return ContainerUtil.map2Set(nonBundledEnabledPlugins, descriptor -> new UsageDescriptor(descriptor.getPluginId().getIdString(), 1));
}
}
@@ -1,38 +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.internal.statistic.collectors.legacy.productivity;
import com.intellij.featureStatistics.FeatureDescriptor;
import com.intellij.featureStatistics.ProductivityFeaturesRegistry;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
@Deprecated // to be removed in 2018.2
public class LegacyProductivityFeaturesUsageCollector extends UsagesCollector {
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("productivity", GroupDescriptor.LOWER_PRIORITY);
}
@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;
}
}
@@ -1,33 +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.internal.statistic.collectors.legacy.ui;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.ui.accessibility.ScreenReader;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Set;
/**
* @author tav
*/
@Deprecated // to be removed in 2018.2
public class LegacyA11YUsagesCollector extends UsagesCollector {
@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
String activity = ScreenReader.isActive() ? "ENABLED" : "DISABLED";
String os = SystemInfo.isWindows ? "Windows" : SystemInfo.isLinux ? "Linux" : SystemInfo.isMac ? "Mac" : "Unknown OS";
return Collections.singleton(new UsageDescriptor(os + " screen reader " + activity, 1));
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("user.ui.a11y.screenreader");
}
}
@@ -1,29 +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.internal.statistic.collectors.legacy.ui;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.collectors.fus.ui.EditorColorSchemesUsagesCollector;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
@Deprecated // to be removed in 2018.2
public class LegacyEditorColorSchemesUsagesCollector extends UsagesCollector {
public static final String GROUP_ID = "Color Schemes";
@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
return EditorColorSchemesUsagesCollector.getDescriptors();
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create(GROUP_ID);
}
}
@@ -1,57 +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.internal.statistic.collectors.legacy.ui
import com.intellij.ide.ui.UISettings
import com.intellij.ide.util.PropertiesComponent
import com.intellij.internal.statistic.CollectUsagesException
import com.intellij.internal.statistic.UsagesCollector
import com.intellij.internal.statistic.beans.GroupDescriptor
import com.intellij.internal.statistic.beans.UsageDescriptor
import com.intellij.openapi.editor.colors.EditorColorsManager
import com.intellij.openapi.editor.colors.impl.AppEditorFontOptions
/**
* @author Konstantin Bulenkov
*/
class LegacyFontSizeInfoUsageCollector : UsagesCollector() {
@Throws(CollectUsagesException::class)
override fun getUsages(): Set<UsageDescriptor> {
val scheme = EditorColorsManager.getInstance().globalScheme
val ui = UISettings.shadowInstance
var usages = setOf(
UsageDescriptor("UI font size: ${ui.fontSize}"),
UsageDescriptor("UI font name: ${ui.fontFace}"),
UsageDescriptor("Presentation mode font size: ${ui.presentationModeFontSize}")
)
if (!scheme.isUseAppFontPreferencesInEditor) {
usages += setOf(
UsageDescriptor("Editor font size: ${scheme.editorFontSize}"),
UsageDescriptor("Editor font name: ${scheme.editorFontName}")
)
}
else {
val appPrefs = AppEditorFontOptions.getInstance().fontPreferences
usages += setOf(
UsageDescriptor("IDE editor font size: ${appPrefs.getSize(appPrefs.fontFamily)}"),
UsageDescriptor("IDE editor font name: ${appPrefs.fontFamily}")
)
}
if (!scheme.isUseEditorFontPreferencesInConsole) {
usages += setOf(
UsageDescriptor("Console font size: ${scheme.consoleFontSize}"),
UsageDescriptor("Console font name: ${scheme.consoleFontName}")
)
}
val quickDocFontSize = PropertiesComponent.getInstance().getValue("quick.doc.font.size")
if (quickDocFontSize != null) {
usages += setOf(
UsageDescriptor("QuickDoc font size:" + quickDocFontSize)
)
}
return usages
}
override fun getGroupId(): GroupDescriptor {
return GroupDescriptor.create("Fonts")
}
}
@@ -1,32 +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.internal.statistic.collectors.legacy.ui;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.Set;
/**
* @author tav
*/
@Deprecated // to be removed in 2018.2
public class LegacyHiDPIModeUsagesCollector extends UsagesCollector {
@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
String mode = UIUtil.isJreHiDPIEnabled() ? "per-monitor-dpi" : "system-dpi";
String os = SystemInfo.isWindows ? "Windows" : SystemInfo.isLinux ? "Linux" : SystemInfo.isMac ? "Mac" : "Unknown OS";
return Collections.singleton(new UsageDescriptor(os + " " + mode, 1));
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("user.ui.hidpi.mode");
}
}
@@ -1,35 +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.internal.statistic.collectors.legacy.ui;
import com.intellij.ide.ui.LafManager;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.Collections;
import java.util.Set;
@Deprecated // to be removed in 2018.2
public class LegacyLaFUsagesCollector extends UsagesCollector {
@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
UIManager.LookAndFeelInfo laf = LafManager.getInstance().getCurrentLookAndFeel();
String key = SystemInfo.OS_NAME + " - ";
if (!StringUtil.isEmptyOrSpaces(SystemInfo.SUN_DESKTOP)) {
key += SystemInfo.SUN_DESKTOP + " - ";
}
return laf != null ? Collections.singleton(new UsageDescriptor(key + laf.getName(), 1))
: Collections.emptySet();
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("Look and Feel");
}
}
@@ -1,28 +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.internal.statistic.collectors.legacy.ui;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.collectors.fus.ui.ScaleInfoUsageCollector;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
/**
* @author tav
*/
@Deprecated // to be removed in 2018.2
public class LegacyScaleInfoUsageCollector extends UsagesCollector {
@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
return ScaleInfoUsageCollector.getDescriptors();
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("user.ui.screen.scale");
}
}
@@ -1,35 +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.internal.statistic.collectors.legacy.ui;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.collectors.fus.ui.persistence.ShortcutsCollector;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
@Deprecated // to be removed in 2018.2
public final class LegacyShortcutUsagesCollector extends UsagesCollector {
private static final GroupDescriptor GROUP = GroupDescriptor.create(getGroupName(), GroupDescriptor.HIGHER_PRIORITY);
private static String getGroupName() {
if (SystemInfo.isMac) return "Shortcuts on Mac";
if (SystemInfo.isWindows) return "Shortcuts on Windows";
if (SystemInfo.isLinux) return "Shortcuts on Linux";
return "Shortcuts on OtherOs";
}
@NotNull
public Set<UsageDescriptor> getUsages() {
ShortcutsCollector.MyState state = ShortcutsCollector.getInstance().getState();
return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue()));
}
@NotNull
public GroupDescriptor getGroupId() {
return GROUP;
}
}
@@ -1,28 +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.internal.statistic.collectors.legacy.ui;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.collectors.fus.ui.persistence.ToolbarClicksCollector;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
@Deprecated // to be removed in 2018.2
public final class LegacyToolbarClicksUsagesCollector extends UsagesCollector {
private static final GroupDescriptor GROUP = GroupDescriptor.create("Toolbar Clicks", GroupDescriptor.HIGHER_PRIORITY);
@NotNull
public Set<UsageDescriptor> getUsages() {
ToolbarClicksCollector.ClicksState state = ToolbarClicksCollector.getInstance().getState();
assert state != null;
return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue()));
}
@NotNull
public GroupDescriptor getGroupId() {
return GROUP;
}
}
@@ -1,28 +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.internal.statistic.collectors.legacy.ui;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.collectors.fus.ui.UiInfoUsageCollector;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
/**
* @author Konstantin Bulenkov
*/
@Deprecated // to be removed in 2018.2
class LegacyUiInfoUsageCollector extends UsagesCollector {
@NotNull
@Override
public Set<UsageDescriptor> getUsages() {
return UiInfoUsageCollector.getDescriptors();
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create("UI Features");
}
}
@@ -18,10 +18,6 @@ package com.intellij.internal.statistic.connect;
public class StatServiceException extends RuntimeException {
public StatServiceException() {
super();
}
public StatServiceException(String s) {
super(s);
}
@@ -29,8 +25,4 @@ public class StatServiceException extends RuntimeException {
public StatServiceException(String s, Throwable throwable) {
super(s, throwable);
}
public StatServiceException(Throwable throwable) {
super(throwable);
}
}
@@ -27,7 +27,6 @@ import org.jetbrains.annotations.Nullable;
// 2. permitted: true/false. statistics could be stopped remotely. if false UsageCollectors won't be started
public class StatisticsConnectionService extends SettingsConnectionService {
private static final String PERMISSION_ATTR_NAME = "permitted";
private static final String DISABLED = "disabled";
public StatisticsConnectionService() {
this("localhost", null);
@@ -1,24 +0,0 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.internal.statistic.connect;
import org.jetbrains.annotations.NotNull;
public interface StatisticsDataSender {
void send(@NotNull String url) throws StatServiceException;
}
@@ -22,10 +22,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface StatisticsService {
@Deprecated // to be removed in 2018.1
ExtensionPointName<StatisticsServiceEP> EP_NAME = ExtensionPointName.create("com.intellij.statisticsService");
StatisticsResult send();
Notification createNotification(@NotNull String groupDisplayId, @Nullable NotificationListener listener);
@@ -1,50 +0,0 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.internal.statistic.connect;
import com.intellij.openapi.extensions.AbstractExtensionPointBean;
import com.intellij.openapi.util.LazyInstance;
import com.intellij.util.KeyedLazyInstance;
import com.intellij.util.xmlb.annotations.Attribute;
import org.jetbrains.annotations.NotNull;
@Deprecated // to be removed in 2018.1x
public class StatisticsServiceEP extends AbstractExtensionPointBean implements KeyedLazyInstance<StatisticsService> {
@Attribute("key")
public String key;
@Attribute("implementationClass")
public String implementationClass;
private final LazyInstance<StatisticsService> myHandler = new LazyInstance<StatisticsService>() {
@Override
protected Class<StatisticsService> getInstanceClass() throws ClassNotFoundException {
return findClass(implementationClass);
}
};
@NotNull
@Override
public StatisticsService getInstance() {
return myHandler.getValue();
}
@Override
public String getKey() {
return key;
}
}
@@ -1,32 +0,0 @@
package com.intellij.internal.statistic.persistence;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.openapi.project.Project;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
public abstract class ApplicationStatisticsPersistence {
private final Map<GroupDescriptor, Map<String, CollectedUsages>> myApplicationData = new THashMap<>();
public void persistUsages(@NotNull GroupDescriptor groupDescriptor, @NotNull Project project, @NotNull CollectedUsages usageDescriptors) {
if (!myApplicationData.containsKey(groupDescriptor)) {
myApplicationData.put(groupDescriptor, new THashMap<>());
}
myApplicationData.get(groupDescriptor).put(project.getName(), usageDescriptors);
}
@NotNull
public Map<String, CollectedUsages> getApplicationData(@NotNull GroupDescriptor groupDescriptor) {
if (!myApplicationData.containsKey(groupDescriptor)) {
myApplicationData.put(groupDescriptor, new THashMap<>());
}
return myApplicationData.get(groupDescriptor);
}
@NotNull
public Map<GroupDescriptor, Map<String, CollectedUsages>> getApplicationData() {
return myApplicationData;
}
}
@@ -16,55 +16,42 @@
package com.intellij.internal.statistic.persistence;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.util.containers.hash.HashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import java.util.Set;
public class BasicSentUsagesPersistenceComponent extends SentUsagesPersistence {
public BasicSentUsagesPersistenceComponent() {
}
public BasicSentUsagesPersistenceComponent() {
}
protected Map<GroupDescriptor, Set<UsageDescriptor>> mySentDescriptors = new HashMap<>();
@NonNls
private long mySentTime = 0;
@NonNls
private long myEventLogSentTime = 0;
@NonNls
private long mySentTime = 0;
@NonNls
private long myEventLogSentTime = 0;
@Override
public boolean isAllowed() {
return true;
}
@Override
public boolean isAllowed() {
return true;
}
@Override
public boolean isShowNotification() {
return false;
}
@Override
public boolean isShowNotification() {
return false;
}
@Override
public long getLastTimeSent() {
return mySentTime;
}
@Override
public long getLastTimeSent() {
return mySentTime;
}
public void setSentTime(long time) {
mySentTime = time;
}
public void setSentTime(long time) {
mySentTime = time;
}
public long getEventLogLastTimeSent() {
return myEventLogSentTime;
}
public long getEventLogLastTimeSent() {
return myEventLogSentTime;
}
public void setEventLogSentTime(long time) {
myEventLogSentTime = time;
}
@NotNull
public Map<GroupDescriptor, Set<UsageDescriptor>> getSentUsages () {
return mySentDescriptors;
}
public void setEventLogSentTime(long time) {
myEventLogSentTime = time;
}
}
@@ -1,35 +0,0 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.internal.statistic.persistence;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
/**
* @author Ivan Chirkov
*/
public class CollectedUsages {
@NotNull
public final Set<UsageDescriptor> usages;
public final long collectionTime;
public CollectedUsages(@NotNull Set<UsageDescriptor> usages, long time) {
this.usages = usages;
collectionTime = time;
}
}
@@ -16,18 +16,8 @@
package com.intellij.internal.statistic.persistence;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import java.util.Set;
public abstract class SentUsagesPersistence {
@NotNull
public abstract Map<GroupDescriptor, Set<UsageDescriptor>> getSentUsages();
public abstract boolean isAllowed();
public abstract boolean isShowNotification();
@@ -3,9 +3,6 @@
package com.intellij.internal.statistic.persistence;
import com.intellij.ide.gdpr.ConsentOptions;
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.configurable.SendPeriod;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
@@ -16,9 +13,6 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.Set;
@State(
name = "UsagesStatistic",
storages = @Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED)
@@ -30,15 +24,9 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste
@NonNls private boolean isShowNotification = true;
@NotNull private SendPeriod myPeriod = SendPeriod.DAILY;
@NonNls private static final String DATA_ATTR = "data";
@NonNls private static final String GROUP_TAG = "group";
@NonNls private static final String GROUP_ID_ATTR = "id";
@NonNls private static final String GROUP_PRIORITY_ATTR = "priority";
@NonNls private static final String LAST_TIME_ATTR = "time";
@NonNls private static final String EVENT_LOG_LAST_TIME_ATTR = "event-log-time";
@NonNls private static final String IS_ALLOWED_ATTR = "allowed";
@NonNls private static final String PERIOD_ATTR = "period";
@NonNls private static final String SHOW_NOTIFICATION_ATTR = "show-notification";
public static UsageStatisticsPersistenceComponent getInstance() {
@@ -53,21 +41,6 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste
@Override
public void loadState(@NotNull final Element element) {
for (Element groupElement : element.getChildren(GROUP_TAG)) {
String groupId = groupElement.getAttributeValue(GROUP_ID_ATTR);
double groupPriority = getPriority(groupElement.getAttributeValue(GROUP_PRIORITY_ATTR));
String valueData = groupElement.getAttributeValue(DATA_ATTR);
if (!StringUtil.isEmptyOrSpaces(groupId) && !StringUtil.isEmptyOrSpaces(valueData)) {
try {
getSentUsages().putAll(ConvertUsagesUtil.convertValueString(GroupDescriptor.create(groupId, groupPriority), valueData));
}
catch (AssertionError e) {
//don't load incorrect groups
}
}
}
try {
setSentTime(Long.parseLong(element.getAttributeValue(LAST_TIME_ATTR, "0")));
}
@@ -90,23 +63,12 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste
final String isShowNotificationValue = element.getAttributeValue(SHOW_NOTIFICATION_ATTR);
setShowNotification(StringUtil.isEmptyOrSpaces(isShowNotificationValue) || Boolean.parseBoolean(isShowNotificationValue));
//setPeriod(parsePeriod(element.getAttributeValue(PERIOD_ATTR)));
}
@Override
public Element getState() {
Element element = new Element("state");
for (Map.Entry<GroupDescriptor, Set<UsageDescriptor>> entry : ConvertUsagesUtil.sortDescriptorsByPriority(getSentUsages()).entrySet()) {
Element projectElement = new Element(GROUP_TAG);
projectElement.setAttribute(GROUP_ID_ATTR, entry.getKey().getId());
projectElement.setAttribute(GROUP_PRIORITY_ATTR, Double.toString(entry.getKey().getPriority()));
projectElement.setAttribute(DATA_ATTR, ConvertUsagesUtil.convertValueMap(entry.getValue()));
element.addContent(projectElement);
}
long lastTimeSent = getLastTimeSent();
if (lastTimeSent > 0) {
element.setAttribute(LAST_TIME_ATTR, String.valueOf(lastTimeSent));
@@ -116,17 +78,9 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste
if (lastEventLogTimeSent > 0) {
element.setAttribute(EVENT_LOG_LAST_TIME_ATTR, String.valueOf(lastEventLogTimeSent));
}
//if (isAllowed()) {
// element.setAttribute(IS_ALLOWED_ATTR, "true");
//}
if (!isShowNotification()) {
element.setAttribute(SHOW_NOTIFICATION_ATTR, "false");
}
//if (myPeriod != SendPeriod.WEEKLY) {
// element.setAttribute(PERIOD_ATTR, myPeriod.getName());
//}
return element;
}
@@ -165,12 +119,6 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste
return isShowNotification;
}
private static double getPriority(String priority) {
if (StringUtil.isEmptyOrSpaces(priority)) return GroupDescriptor.DEFAULT_PRIORITY;
return Double.parseDouble(priority);
}
@Override
@NonNls
@NotNull
@@ -1,97 +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.internal.statistic.service.old;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.UsagesCollector;
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.connect.StatServiceException;
import com.intellij.internal.statistic.connect.StatisticsConnectionService;
import com.intellij.internal.statistic.service.ConfigurableStatisticsService;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.application.PermanentInstallationID;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.net.HttpConfigurable;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.fluent.Form;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.fluent.Response;
import org.jetbrains.annotations.NotNull;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import static com.intellij.internal.statistic.utils.StatisticsUploadAssistant.LOCK;
@Deprecated // to be removed in 2018.1x
public class OldConfigurableStatisticsService extends
ConfigurableStatisticsService<StatisticsConnectionService> {
private static final Logger LOG = Logger.getInstance(OldConfigurableStatisticsService.class);
private final StatisticsConnectionService connectionService = new OldStatisticsConnectionService();
@NotNull
@Override
public String sendData() {
String url = connectionService.getServiceUrl();
Map<String, Set<UsageDescriptor>> content = getContentToSend();
try {
HttpConfigurable.getInstance().prepareURL(url);
String usages = ConvertUsagesUtil.convertUsages(content);
Response response = Request.Post(url).bodyForm(Form.form().
add("content", usages).
add("uuid", PermanentInstallationID.get()).
add("patch", String.valueOf(false)).
add("ide", ApplicationNamesInfo.getInstance().getProductName()).build(),
Consts.UTF_8).execute();
final HttpResponse httpResponse = response.returnResponse();
if (httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
throw new StatServiceException("Error during data sending... Code: " + httpResponse.getStatusLine().getStatusCode());
}
final Header errors = httpResponse.getFirstHeader("errors");
if (errors != null) {
String value = errors.getValue();
throw new StatServiceException("Error during updating statistics " + (!StringUtil.isEmptyOrSpaces(value) ? " : " + value : ""));
}
return usages;
}
catch (StatServiceException e) {
throw e;
}
catch (Exception e) {
throw new StatServiceException("Error during data sending...", e);
}
}
@NotNull
public Map<String, Set<UsageDescriptor>> getContentToSend() {
synchronized (LOCK) {
Map<String, Set<UsageDescriptor>> usageDescriptors = new LinkedHashMap<>();
for (UsagesCollector usagesCollector : UsagesCollector.EP_NAME.getExtensions()) {
String groupDescriptor = usagesCollector.getGroupId().getId();
try {
usageDescriptors.merge(groupDescriptor, usagesCollector.getUsages(), ContainerUtil::union);
}
catch (CollectUsagesException e) {
LOG.info(e);
}
}
return usageDescriptors;
}
}
@Override
public StatisticsConnectionService getConnectionService() {
return connectionService;
}
}
@@ -1,15 +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.internal.statistic.service.old;
import com.intellij.internal.statistic.connect.StatisticsConnectionService;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Deprecated // to be removed in 2018.1x
public class OldStatisticsConnectionService extends StatisticsConnectionService {
public OldStatisticsConnectionService() {
super(((ApplicationInfoImpl)ApplicationInfoImpl.getShadowInstance()).getStatisticsSettingsUrl(),
((ApplicationInfoImpl)ApplicationInfoImpl.getShadowInstance()).getStatisticsServiceUrl());
}
}
@@ -84,11 +84,7 @@ public class StatisticsJobsScheduler implements ApplicationComponent {
final StatisticsService statisticsService = StatisticsUploadAssistant.getApprovedGroupsStatisticsService();
if (StatisticsUploadAssistant.isSendAllowed() && StatisticsUploadAssistant.isTimeToSend()) {
runStatisticsServiceWithDelay(statisticsService, SEND_STATISTICS_DELAY_IN_MIN);
// TODO: to be removed in 2018.1
runStatisticsServiceWithDelay(StatisticsUploadAssistant.getOldStatisticsService(), 2 * SEND_STATISTICS_DELAY_IN_MIN);
}
if (FeatureUsageLogger.INSTANCE.isEnabled() && StatisticsUploadAssistant.isTimeToSendEventLog()) {
runStatisticsServiceWithDelay(StatisticsUploadAssistant.getEventLogStatisticsService(), 3 * SEND_STATISTICS_DELAY_IN_MIN);
}
@@ -22,7 +22,6 @@ import com.intellij.internal.statistic.eventLog.EventLogStatisticsService;
import com.intellij.internal.statistic.persistence.SentUsagesPersistence;
import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent;
import com.intellij.internal.statistic.service.fus.FUStatisticsService;
import com.intellij.internal.statistic.service.old.OldConfigurableStatisticsService;
import com.intellij.util.Time;
public class StatisticsUploadAssistant {
@@ -66,11 +65,6 @@ public class StatisticsUploadAssistant {
UsageStatisticsPersistenceComponent.getInstance().setSentTime(System.currentTimeMillis());
}
@Deprecated // to be removed in 2018.1x
public static StatisticsService getOldStatisticsService() {
return new OldConfigurableStatisticsService();
}
public static StatisticsService getApprovedGroupsStatisticsService() {
return new FUStatisticsService();
}
@@ -2,7 +2,6 @@
package com.intellij.openapi.application;
import com.intellij.ide.cloudConfig.CloudConfigProvider;
import com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigButtonUsages;
import com.intellij.openapi.MnemonicHelper;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.Pair;
@@ -118,8 +117,6 @@ class ImportOldConfigsPanel extends JDialog {
}
private void close() {
IdeInitialConfigButtonUsages.setConfigImport(myRbDoNotImport, myRbImport, myRbImportAuto, myCustomButton);
if (myRbImport.isSelected()) {
String text = myPrevInstallation.getText();
if (StringUtil.isEmptyOrSpaces(text)) {
@@ -18,7 +18,6 @@ package com.intellij.openapi.diff.impl;
import com.intellij.icons.AllIcons;
import com.intellij.ide.actions.EditSourceAction;
import com.intellij.idea.ActionsBundle;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.Application;
@@ -152,7 +151,6 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
boolean horizontal,
int diffDividerPolygonsOffset,
DiffTool parentTool) {
UsageTrigger.trigger("diff.DiffPanelImpl");
myProject = project;
myIsHorizontal = horizontal;
@@ -16,7 +16,6 @@
package com.intellij.openapi.diff.impl.incrementalMerge.ui;
import com.intellij.icons.AllIcons;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
@@ -89,7 +88,6 @@ public class MergePanel2 implements DiffViewer {
private final MyDataProvider myProvider;
public MergePanel2(DialogBuilder builder, @NotNull Disposable parent) {
UsageTrigger.trigger("diff.MergePanel2");
ArrayList<EditorPlace> editorPlaces = new ArrayList<>();
EditorPlace.EditorListener placeListener = new EditorPlace.EditorListener() {
@@ -2,7 +2,6 @@
package com.intellij.openapi.options.newEditor;
import com.intellij.CommonBundle;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
import com.intellij.internal.statistic.eventLog.FeatureUsageUiEvents;
import com.intellij.openapi.Disposable;
@@ -317,7 +316,6 @@ class ConfigurableEditor extends AbstractEditor implements AnActionListener, AWT
configurable.apply();
final String key = getConfigurableEventId(configurable);
FeatureUsageUiEvents.INSTANCE.logApplyConfigurable(key);
UsageTrigger.trigger(key);
}
catch (ConfigurationException exception) {
return exception;
@@ -5,8 +5,6 @@ import com.intellij.ide.FrameStateManager;
import com.intellij.ide.IdeEventQueue;
import com.intellij.ide.actions.ActivateToolWindowAction;
import com.intellij.ide.actions.MaximizeActiveDialogAction;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
import com.intellij.internal.statistic.collectors.fus.actions.persistence.ToolWindowCollector;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionManager;
@@ -2304,6 +2302,5 @@ public class ToolWindowManagerImpl extends ToolWindowManagerEx implements Persis
private static void triggerUsage(@NotNull String feature) {
//noinspection deprecation
UsageTrigger.trigger(ConvertUsagesUtil.escapeDescriptorName(feature));
}
}
@@ -6,7 +6,6 @@ import com.intellij.diagnostic.MessagePool;
import com.intellij.icons.AllIcons;
import com.intellij.ide.DataManager;
import com.intellij.ide.RecentProjectsManager;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.notification.NotificationType;
import com.intellij.notification.impl.IdeNotificationArea;
import com.intellij.openapi.Disposable;
@@ -368,7 +367,6 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac
.createActionGroupPopup(null, new IconsFreeActionGroup(configureGroup), e.getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false,
ActionPlaces.WELCOME_SCREEN);
popup.showUnderneathOfLabel(ref.get());
UsageTrigger.trigger("welcome.screen." + groupId);
}
};
JComponent panel = createActionLink(text, icon, ref, action);
@@ -707,7 +705,6 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
child.actionPerformed(e);
UsageTrigger.trigger("welcome.screen." + e.getActionManager().getId(child));
}
@Override
@@ -730,7 +727,8 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac
}
private static Runnable createUsageTracker(final AnAction action) {
return () -> UsageTrigger.trigger("welcome.screen." + ActionManager.getInstance().getId(action));
return () -> {
};
}
private static JLabel createArrow(final ActionLink link) {
@@ -914,7 +914,6 @@
<copyPastePostProcessor implementation="com.intellij.codeInsight.editorActions.CopyPasteIndentProcessor"/>
<copyPastePostProcessor implementation="com.intellij.codeInsight.editorActions.CopyPasteFoldingProcessor"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.fileTypes.LegacyFileTypeUsagesCollector"/>
<statistics.projectUsagesCollector implementation="com.intellij.internal.statistic.collectors.fus.fileTypes.FileTypeUsagesCollector"/>
<statistics.projectUsagesCollector implementation="com.intellij.internal.statistic.collectors.fus.fileTypes.FileExtensionUsagesCollector"/>
<statistics.projectUsagesCollector implementation="com.intellij.internal.statistic.collectors.fus.fileTypes.FileExtensionOpenUsageTriggerCollector"/>
@@ -924,20 +923,10 @@
<statistics.projectUsagesCollector implementation="com.intellij.codeInsight.daemon.impl.tooltips.TooltipActionUsagesCollector"/>
<postStartupActivity implementation="com.intellij.internal.statistic.collectors.fus.fileTypes.FileTypeExtensionUsagesCollectorStartupActivity"/>
<statistics.usagesCollector implementation="com.intellij.facet.impl.statistics.FrameworkUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.facet.impl.statistics.ModuleTypeUsagesCollector"/>
<statistics.projectUsagesCollector implementation="com.intellij.execution.impl.statistics.RunConfigurationTypeUsagesCollector"/>
<statistics.projectUsagesCollector implementation="com.intellij.execution.impl.statistics.TemporaryRunConfigurationTypeUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.editor.LegacyEditorSettingsStatisticsCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.editor.LegacyEditorSettingsStatisticsCollector$ProjectUsages"/>
<statistics.applicationUsagesCollector implementation="com.intellij.internal.statistic.editor.EditorSettingsStatisticsCollector"/>
<statistics.projectUsagesCollector implementation="com.intellij.internal.statistic.editor.EditorSettingsStatisticsCollector$ProjectUsages"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.tools.AbstractToolsUsagesCollector$AllBundledToolsUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.tools.AbstractToolsUsagesCollector$AllListedToolsUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.tools.AbstractToolsUsagesCollector$EnabledBundledToolsUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.tools.AbstractToolsUsagesCollector$EnabledListedToolsUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.tools.AbstractToolsUsagesCollector$DisabledBundledToolsUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.tools.AbstractToolsUsagesCollector$DisabledListedToolsUsagesCollector"/>
<statistics.projectUsagesCollector implementation="com.intellij.internal.statistic.service.fus.collectors.KeymapUsageCollector" />
<statistics.projectUsagesCollector implementation="com.intellij.execution.dashboard.RunDashboardUsagesCollector"/>
<statistics.projectUsagesCollector implementation="com.intellij.ide.actions.runAnything.RunAnythingUsageCollector"/>
@@ -160,10 +160,6 @@
<extensionPoint name="welcomeFrameProvider" interface="com.intellij.openapi.wm.WelcomeFrameProvider"/>
<extensionPoint name="frameEditorComponentProvider" interface="com.intellij.openapi.wm.ex.FrameEditorComponentProvider"/>
<extensionPoint name="statisticsService" beanClass="com.intellij.internal.statistic.connect.StatisticsServiceEP">
<with attribute="implementationClass" implements="com.intellij.internal.statistic.connect.StatisticsService"/>
</extensionPoint>
<extensionPoint name="statistic.eventLog.featureUsageEventLogger" interface="com.intellij.internal.statistic.eventLog.FeatureUsageFileEventLogger"/>
<extensionPoint name="uiDropperActions" interface="com.intellij.internal.inspector.UiDropperActionExtension"/>
@@ -207,8 +207,6 @@
<applicationService serviceInterface="com.intellij.openapi.roots.ui.FileAppearanceService"
serviceImplementation="com.intellij.openapi.roots.ui.FileAppearanceServiceImpl"/>
<applicationService serviceImplementation="com.intellij.internal.statistic.UsageTrigger"/>
<projectService serviceImplementation="com.intellij.internal.statistic.service.fus.collectors.FUSProjectUsageTrigger"/>
<applicationService serviceImplementation="com.intellij.internal.statistic.service.fus.collectors.FUSApplicationUsageTrigger"/>
@@ -425,50 +423,11 @@
<statistics.applicationUsagesCollector implementation="com.intellij.diff.statistics.DiffUsagesCollector"/>
<statistics.applicationUsagesCollector implementation="com.intellij.internal.statistic.collectors.fus.RegistryApplicationUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.productivity.LegacyProductivityFeaturesUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.plugins.LegacyDisabledPluginsUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.plugins.LegacyNonBundledPluginsUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ui.LegacyToolbarClicksUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ui.LegacyEditorColorSchemesUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.actions.LegacyActionUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.actions.LegacyToolWindowUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.actions.LegacyIntentionUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.actions.LegacyMainMenuUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.jdk.LegacyJdkInfoUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.os.LegacyOsNameUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.os.LegacyOsVersionUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ui.LegacyFontSizeInfoUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ui.LegacyHiDPIModeUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ui.LegacyLaFUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ui.LegacyScaleInfoUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ui.LegacyShortcutUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ui.LegacyUiInfoUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ui.LegacyUiInfoUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ui.LegacyA11YUsagesCollector"/>
<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.internal.statistic.collectors.fus.RegistryProjectUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.openapi.vcs.statistics.LegacyVcsOptionsUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.openapi.vcs.statistics.LegacyVcsStatsUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.openapi.vcs.statistics.LegacyVcsUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.UsageTrigger$MyCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ExperimentalFeaturesUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.LegacyRegistryUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.jdk.JdkSettingsUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.build.BuildNumberUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigUsageCollectors$ConfigImport"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigUsageCollectors$SkipSteps"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigUsageCollectors$SelectedLAF"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigUsageCollectors$SelectedKeymap"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigUsageCollectors$DisabledPlugins"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigUsageCollectors$DownloadedPlugins"/>
<statistic.eventLog.featureUsageEventLogger implementation="com.intellij.internal.statistic.eventLog.FeatureUsageFileEventLogger"/>
<postStartupActivity implementation="com.intellij.internal.statistic.eventLog.SystemStateMonitor"/>
@@ -92,11 +92,6 @@
<implementation-class>com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent</implementation-class>
</component>
<component>
<interface-class>com.intellij.internal.statistic.ApplicationStatisticsPersistenceComponent</interface-class>
<implementation-class>com.intellij.internal.statistic.ApplicationStatisticsPersistenceComponent</implementation-class>
</component>
<component>
<interface-class>com.intellij.ide.ClipboardSynchronizer</interface-class>
<implementation-class>com.intellij.ide.ClipboardSynchronizer</implementation-class>
@@ -830,8 +830,7 @@
<separator/>
<reference ref="MaintenanceGroup"/>
<action internal="true" id="SendStatistics" class="com.intellij.internal.statistic.actions.SendStatisticsAction" text="OLD: Collect And Send Statistics"/>
<action internal="true" id="SendFUStatistics" class="com.intellij.internal.statistic.actions.SendFUStatisticsAction" text="NEW: Collect And Send Statistics"/>
<action internal="true" id="SendFUStatistics" class="com.intellij.internal.statistic.actions.SendFUStatisticsAction" text="Collect And Send Statistics"/>
<action internal="true" id="SendEventLogStatistics" class="com.intellij.internal.statistic.actions.SendEventLogAction" text="Send Feature Usage Event Log"/>
<action internal="true" id="ShowEditorHighlighterTokens" class="com.intellij.openapi.editor.actions.ShowEditorHighlighterTokensAction"
@@ -1,60 +0,0 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.fileTypes;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.collectors.legacy.fileTypes.LegacyFileTypeUsagesCollector;
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.Collection;
import java.util.Set;
/**
* @author Nikolay Matveev
*/
public class FileTypeUsagesCollectorTest extends LightPlatformCodeInsightFixtureTestCase {
private void doTest(@NotNull Collection<FileType> fileTypes) throws CollectUsagesException {
final Set<UsageDescriptor> usages = new LegacyFileTypeUsagesCollector().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())
);
}
public void testEmptyProject() throws CollectUsagesException {
doTest(Arrays.asList());
}
public void testSingleFileProject() throws CollectUsagesException {
myFixture.configureByText("a.txt", "");
doTest(Arrays.asList(PlainTextFileType.INSTANCE));
}
public void testSeveralSameFilesProject() throws CollectUsagesException {
myFixture.configureByText("a.txt", "");
myFixture.configureByText("b.txt", "");
doTest(Arrays.asList(PlainTextFileType.INSTANCE));
}
}
@@ -16,7 +16,6 @@
package com.intellij.remoteServer.util.ssh;
import com.intellij.execution.filters.HyperlinkInfo;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
import com.intellij.openapi.options.ConfigurationException;
@@ -246,7 +245,6 @@ public class SshKeyChecker {
@Override
protected void uploadKey(final File sskKey) {
UsageTrigger.trigger(CloudsTriggerKeys.UPLOAD_SSH_KEY);
try {
myServerConfigurable.apply();
}

Some files were not shown because too many files have changed in this diff Show More