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);
}
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;
}
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);
}
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;
}
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);
}
Aggregations