use of com.intellij.psi.statistics.StatisticsInfo in project intellij-community by JetBrains.
the class StatisticsManagerTest method testRecency.
public void testRecency() {
int limit = StatisticsManager.RECENCY_OBLIVION_THRESHOLD;
for (int i = limit + 1; i >= 0; i--) {
new StatisticsInfo("context", "value" + i).incUseCount();
}
for (int i = 0; i < limit; i++) {
assertEquals(i, new StatisticsInfo("context", "value" + i).getLastUseRecency());
}
assertEquals(Integer.MAX_VALUE, new StatisticsInfo("context", "value" + limit).getLastUseRecency());
assertEquals(Integer.MAX_VALUE, new StatisticsInfo("anotherContext", "value0").getLastUseRecency());
}
use of com.intellij.psi.statistics.StatisticsInfo in project intellij-community by JetBrains.
the class ListPopupImpl method valuesSelected.
private void valuesSelected(final Object[] values) {
if (shouldUseStatistics()) {
final String filter = getSpeedSearch().getFilter();
if (!StringUtil.isEmpty(filter)) {
for (Object value : values) {
final String text = getListStep().getTextFor(value);
StatisticsManager.getInstance().incUseCount(new StatisticsInfo("#list_popup:" + getListStep().getTitle() + "#" + filter, text));
}
}
}
}
use of com.intellij.psi.statistics.StatisticsInfo in project intellij-community by JetBrains.
the class ListPopupImpl method autoSelectUsingStatistics.
private boolean autoSelectUsingStatistics() {
final String filter = getSpeedSearch().getFilter();
if (!StringUtil.isEmpty(filter)) {
int maxUseCount = -1;
int mostUsedValue = -1;
int elementsCount = myListModel.getSize();
for (int i = 0; i < elementsCount; i++) {
Object value = myListModel.getElementAt(i);
final String text = getListStep().getTextFor(value);
final int count = StatisticsManager.getInstance().getUseCount(new StatisticsInfo("#list_popup:" + myStep.getTitle() + "#" + filter, text));
if (count > maxUseCount) {
maxUseCount = count;
mostUsedValue = i;
}
}
if (mostUsedValue > 0) {
ScrollingUtil.selectItem(myList, mostUsedValue);
return true;
}
}
return false;
}
use of com.intellij.psi.statistics.StatisticsInfo in project intellij-community by JetBrains.
the class ChooseByNamePopup method close.
@Override
public void close(final boolean isOk) {
if (checkDisposed()) {
return;
}
if (isOk) {
myModel.saveInitialCheckBoxState(myCheckBox.isSelected());
final List<Object> chosenElements = getChosenElements();
if (chosenElements != null) {
if (myActionListener instanceof MultiElementsCallback) {
((MultiElementsCallback) myActionListener).elementsChosen(chosenElements);
} else {
for (Object element : chosenElements) {
myActionListener.elementChosen(element);
String text = myModel.getFullName(element);
if (text != null) {
StatisticsManager.getInstance().incUseCount(new StatisticsInfo(statisticsContext(), text));
}
}
}
} else {
return;
}
if (!chosenElements.isEmpty()) {
final String enteredText = getTrimmedText();
if (enteredText.indexOf('*') >= 0) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.wildcards");
} else {
for (Object element : chosenElements) {
final String name = myModel.getElementName(element);
if (name != null) {
if (!StringUtil.startsWithIgnoreCase(name, enteredText)) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.camelprefix");
break;
}
}
}
}
} else {
return;
}
}
Disposer.dispose(this);
setDisposed(true);
myAlarm.cancelAllRequests();
cleanupUI(isOk);
if (ApplicationManager.getApplication().isUnitTestMode())
return;
if (myActionListener != null) {
myActionListener.onClose();
}
}
use of com.intellij.psi.statistics.StatisticsInfo in project intellij-community by JetBrains.
the class GrPullUpDialog method getPreselection.
@Override
protected PsiClass getPreselection() {
PsiClass preselection = RefactoringHierarchyUtil.getNearestBaseClass(myClass, false);
final String statKey = PULL_UP_STATISTICS_KEY + myClass.getQualifiedName();
for (StatisticsInfo info : StatisticsManager.getInstance().getAllValues(statKey)) {
final String superClassName = info.getValue();
PsiClass superClass = null;
for (PsiClass aClass : mySuperClasses) {
if (Comparing.strEqual(superClassName, aClass.getQualifiedName())) {
superClass = aClass;
break;
}
}
if (superClass != null && StatisticsManager.getInstance().getUseCount(info) > 0) {
preselection = superClass;
break;
}
}
return preselection;
}
Aggregations