Search in sources :

Example 1 with StatisticsInfo

use of com.intellij.psi.statistics.StatisticsInfo in project intellij-community by JetBrains.

the class GrPullUpDialog method doAction.

@Override
protected void doAction() {
    if (!myCallback.checkConflicts(this))
        return;
    JavaRefactoringSettings.getInstance().PULL_UP_MEMBERS_JAVADOC = myJavaDocPanel.getPolicy();
    final PsiClass superClass = getSuperClass();
    String name = superClass.getQualifiedName();
    if (name != null) {
        StatisticsManager.getInstance().incUseCount(new StatisticsInfo(PULL_UP_STATISTICS_KEY + myClass.getQualifiedName(), name));
    }
    List<GrMemberInfo> infos = getSelectedMemberInfos();
    //GrPullUpProcessor processor = new GrPullUpProcessor(myClass, superClass, infos.toArray(new GrMemberInfo[infos.size()]), new DocCommentPolicy(getJavaDocPolicy()));
    //invokeRefactoring(processor);
    close(OK_EXIT_CODE);
}
Also used : StatisticsInfo(com.intellij.psi.statistics.StatisticsInfo) GrMemberInfo(org.jetbrains.plugins.groovy.refactoring.classMembers.GrMemberInfo)

Example 2 with StatisticsInfo

use of com.intellij.psi.statistics.StatisticsInfo in project intellij-community by JetBrains.

the class PullUpDialog method getPreselection.

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)

Example 3 with StatisticsInfo

use of com.intellij.psi.statistics.StatisticsInfo in project intellij-community by JetBrains.

the class PullUpDialog method doAction.

protected void doAction() {
    if (!myCallback.checkConflicts(this))
        return;
    JavaRefactoringSettings.getInstance().PULL_UP_MEMBERS_JAVADOC = myJavaDocPanel.getPolicy();
    final PsiClass superClass = getSuperClass();
    String name = superClass.getQualifiedName();
    if (name != null) {
        StatisticsManager.getInstance().incUseCount(new StatisticsInfo(PULL_UP_STATISTICS_KEY + myClass.getQualifiedName(), name));
    }
    List<MemberInfo> infos = getSelectedMemberInfos();
    invokeRefactoring(new PullUpProcessor(myClass, superClass, infos.toArray(new MemberInfo[infos.size()]), new DocCommentPolicy(getJavaDocPolicy())));
    close(OK_EXIT_CODE);
}
Also used : StatisticsInfo(com.intellij.psi.statistics.StatisticsInfo) MemberInfo(com.intellij.refactoring.util.classMembers.MemberInfo) DocCommentPolicy(com.intellij.refactoring.util.DocCommentPolicy)

Example 4 with StatisticsInfo

use of com.intellij.psi.statistics.StatisticsInfo in project intellij-community by JetBrains.

the class JavaInheritorsGetter method processMostProbableInheritors.

private static boolean processMostProbableInheritors(PsiFile contextFile, PsiElement context, Collection<PsiClassType> expectedClassTypes, Consumer<PsiType> consumer) {
    for (final PsiClassType type : expectedClassTypes) {
        consumer.consume(type);
        final PsiClassType.ClassResolveResult baseResult = JavaCompletionUtil.originalize(type).resolveGenerics();
        final PsiClass baseClass = baseResult.getElement();
        if (baseClass == null)
            return false;
        final PsiSubstitutor baseSubstitutor = baseResult.getSubstitutor();
        final Processor<PsiClass> processor = CodeInsightUtil.createInheritorsProcessor(context, type, 0, false, consumer, baseClass, baseSubstitutor);
        final StatisticsInfo[] stats = StatisticsManager.getInstance().getAllValues(JavaStatisticsManager.getAfterNewKey(type));
        for (final StatisticsInfo statisticsInfo : stats) {
            final String value = statisticsInfo.getValue();
            if (value.startsWith(JavaStatisticsManager.CLASS_PREFIX)) {
                final String qname = value.substring(JavaStatisticsManager.CLASS_PREFIX.length());
                final PsiClass psiClass = JavaPsiFacade.getInstance(contextFile.getProject()).findClass(qname, contextFile.getResolveScope());
                if (psiClass != null && !PsiTreeUtil.isAncestor(contextFile, psiClass, true) && !processor.process(psiClass))
                    break;
            }
        }
    }
    return true;
}
Also used : StatisticsInfo(com.intellij.psi.statistics.StatisticsInfo)

Example 5 with StatisticsInfo

use of com.intellij.psi.statistics.StatisticsInfo in project intellij-community by JetBrains.

the class PsiProximityComparator method compare.

@Override
public int compare(final Object o1, final Object o2) {
    PsiElement element1 = o1 instanceof PsiElement ? (PsiElement) o1 : null;
    PsiElement element2 = o2 instanceof PsiElement ? (PsiElement) o2 : null;
    if (element1 == null)
        return element2 == null ? 0 : 1;
    if (element2 == null)
        return -1;
    if (myContext != null && myContextModule != null) {
        final ProximityLocation location = new ProximityLocation(myContext, myContextModule);
        StatisticsInfo info1 = StatisticsManager.serialize(STATISTICS_KEY, element1, location);
        StatisticsInfo info2 = StatisticsManager.serialize(STATISTICS_KEY, element2, location);
        if (info1 != null && info2 != null) {
            StatisticsManager statisticsManager = StatisticsManager.getInstance();
            int count1 = statisticsManager.getLastUseRecency(info1);
            int count2 = statisticsManager.getLastUseRecency(info2);
            if (count1 != count2) {
                return count1 < count2 ? -1 : 1;
            }
        }
    }
    final WeighingComparable<PsiElement, ProximityLocation> proximity1 = myProximities.get(element1);
    final WeighingComparable<PsiElement, ProximityLocation> proximity2 = myProximities.get(element2);
    if (proximity1 == null || proximity2 == null) {
        return 0;
    }
    return -proximity1.compareTo(proximity2);
}
Also used : StatisticsInfo(com.intellij.psi.statistics.StatisticsInfo) StatisticsManager(com.intellij.psi.statistics.StatisticsManager) PsiElement(com.intellij.psi.PsiElement) ProximityLocation(com.intellij.psi.util.ProximityLocation)

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