Search in sources :

Example 6 with StatisticsInfo

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());
}
Also used : StatisticsInfo(com.intellij.psi.statistics.StatisticsInfo)

Example 7 with StatisticsInfo

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));
            }
        }
    }
}
Also used : StatisticsInfo(com.intellij.psi.statistics.StatisticsInfo)

Example 8 with StatisticsInfo

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;
}
Also used : StatisticsInfo(com.intellij.psi.statistics.StatisticsInfo) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 9 with StatisticsInfo

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();
    }
}
Also used : StatisticsInfo(com.intellij.psi.statistics.StatisticsInfo)

Example 10 with StatisticsInfo

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;
}
Also used : StatisticsInfo(com.intellij.psi.statistics.StatisticsInfo)

Aggregations

StatisticsInfo (com.intellij.psi.statistics.StatisticsInfo)11 VirtualFileWindow (com.intellij.injected.editor.VirtualFileWindow)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiElement (com.intellij.psi.PsiElement)1 StatisticsManager (com.intellij.psi.statistics.StatisticsManager)1 ProximityLocation (com.intellij.psi.util.ProximityLocation)1 DocCommentPolicy (com.intellij.refactoring.util.DocCommentPolicy)1 MemberInfo (com.intellij.refactoring.util.classMembers.MemberInfo)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 GrMemberInfo (org.jetbrains.plugins.groovy.refactoring.classMembers.GrMemberInfo)1