Java 类com.intellij.psi.statistics.StatisticsInfo 实例源码

项目:intellij-ce-playground    文件:TypeSelectorManagerImpl.java   
private void setTypesAndPreselect(PsiType[] types) {
  myTypeSelector.setTypes(types);

  Map<String, PsiType> map = new THashMap<String, PsiType>();
  for (final PsiType type : types) {
    map.put(serialize(type), type);
  }

  for (StatisticsInfo info : StatisticsManager.getInstance().getAllValues(getStatsKey())) {
    final PsiType candidate = map.get(info.getValue());
    if (candidate != null && StatisticsManager.getInstance().getUseCount(info) > 0) {
      myTypeSelector.selectType(candidate);
      return;
    }
  }
}
项目:intellij-ce-playground    文件:PullUpDialog.java   
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;
}
项目:intellij-ce-playground    文件:ListPopupImpl.java   
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;
}
项目:intellij-ce-playground    文件:StatisticsWeigher.java   
/**
 * For different prefixes we want to prefer different completion items,
 *   so we decorate their basic stat-infos depending on prefix.
 * For example, consider that an item "fooBar" was chosen with a prefix "foo"
 * Then we'll register "fooBar" for each of the sub-prefixes: "", "f", "fo" and "foo"
 *   and suggest "foobar" whenever we a user types any of those prefixes
 *
 * If a user has typed "fooB" for which there's no stat-info registered, we want to check
 *   all of its sub-prefixes: "", "f", "fo", "foo" and see if any of them is associated with a stat-info
 * But if the item were "fobia" and the user has typed "fob", we don't want to claim
 *   that "fooBar" (which matches) is statistically better than "fobia" with prefix "fob" even though both begin with "fo"
 * So we only check non-partial sub-prefixes, then ones that had been really typed by the user before completing
 *
 * @param forWriting controls whether this stat-info will be used for incrementing usage count or for its retrieval (for sorting)
 */
public static StatisticsInfo composeStatsWithPrefix(StatisticsInfo info, final String fullPrefix, boolean forWriting) {
  ArrayList<StatisticsInfo> infos = new ArrayList<StatisticsInfo>((fullPrefix.length() + 3) * info.getConjuncts().size());
  for (StatisticsInfo conjunct : info.getConjuncts()) {
    if (forWriting) {
      // some completion contributors may need pure statistical information to speed up searching for frequently chosen items
      infos.add(conjunct);
    }
    for (int i = 0; i <= fullPrefix.length(); i++) {
      // if we're incrementing usage count, register all sub-prefixes with "partial" mark
      // if we're sorting and any sub-prefix was used as non-partial to choose this completion item, prefer it
      infos.add(composeWithPrefix(conjunct, fullPrefix.substring(0, i), forWriting));
    }
    // if we're incrementing usage count, the full prefix is registered as non-partial
    // if we're sorting and the current prefix was used as partial sub-prefix to choose this completion item, prefer it
    infos.add(composeWithPrefix(conjunct, fullPrefix, !forWriting));
  }
  return StatisticsInfo.createComposite(infos);
}
项目:intellij-ce-playground    文件:CompletionLookupArranger.java   
public static StatisticsUpdate collectStatisticChanges(LookupElement item, final Lookup lookup) {
  applyLastCompletionStatisticsUpdate();

  final StatisticsInfo base = StatisticsWeigher.getBaseStatisticsInfo(item, null);
  if (base == StatisticsInfo.EMPTY) {
    return new StatisticsUpdate(StatisticsInfo.EMPTY);
  }

  StatisticsUpdate update = new StatisticsUpdate(StatisticsWeigher.composeStatsWithPrefix(base, lookup.itemPattern(item), true));
  ourPendingUpdate = update;
  Disposer.register(update, new Disposable() {
    @Override
    public void dispose() {
      //noinspection AssignmentToStaticFieldFromInstanceMethod
      ourPendingUpdate = null;
    }
  });

  return update;
}
项目:intellij-ce-playground    文件:GrPullUpDialog.java   
@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;
}
项目:tools-idea    文件:TypeSelectorManagerImpl.java   
private void setTypesAndPreselect(PsiType[] types) {
  myTypeSelector.setTypes(types);

  Map<String, PsiType> map = new THashMap<String, PsiType>();
  for (final PsiType type : types) {
    map.put(serialize(type), type);
  }

  for (StatisticsInfo info : StatisticsManager.getInstance().getAllValues(getStatsKey())) {
    final PsiType candidate = map.get(info.getValue());
    if (candidate != null && StatisticsManager.getInstance().getUseCount(info) > 0) {
      myTypeSelector.selectType(candidate);
      return;
    }
  }
}
项目:tools-idea    文件:PullUpDialog.java   
private 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;
}
项目:tools-idea    文件:ListPopupImpl.java   
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) {
      ListScrollingUtil.selectItem(myList, mostUsedValue);
      return true;
    }
  }

  return false;
}
项目:tools-idea    文件:StatisticsWeigher.java   
/**
 * For different prefixes we want to prefer different completion items,
 *   so we decorate their basic stat-infos depending on prefix.
 * For example, consider that an item "fooBar" was chosen with a prefix "foo"
 * Then we'll register "fooBar" for each of the sub-prefixes: "", "f", "fo" and "foo"
 *   and suggest "foobar" whenever we a user types any of those prefixes
 *
 * If a user has typed "fooB" for which there's no stat-info registered, we want to check
 *   all of its sub-prefixes: "", "f", "fo", "foo" and see if any of them is associated with a stat-info
 * But if the item were "fobia" and the user has typed "fob", we don't want to claim
 *   that "fooBar" (which matches) is statistically better than "fobia" with prefix "fob" even though both begin with "fo"
 * So we only check non-partial sub-prefixes, then ones that had been really typed by the user before completing
 *
 * @param forWriting controls whether this stat-info will be used for incrementing usage count or for its retrieval (for sorting)
 */
public static StatisticsInfo composeStatsWithPrefix(StatisticsInfo info, final String fullPrefix, boolean forWriting) {
  ArrayList<StatisticsInfo> infos = new ArrayList<StatisticsInfo>((fullPrefix.length() + 3) * info.getConjuncts().size());
  for (StatisticsInfo conjunct : info.getConjuncts()) {
    if (forWriting) {
      // some completion contributors may need pure statistical information to speed up searching for frequently chosen items
      infos.add(conjunct);
    }
    for (int i = 0; i <= fullPrefix.length(); i++) {
      // if we're incrementing usage count, register all sub-prefixes with "partial" mark
      // if we're sorting and any sub-prefix was used as non-partial to choose this completion item, prefer it
      infos.add(composeWithPrefix(conjunct, fullPrefix.substring(0, i), forWriting));
    }
    // if we're incrementing usage count, the full prefix is registered as non-partial
    // if we're sorting and the current prefix was used as partial sub-prefix to choose this completion item, prefer it
    infos.add(composeWithPrefix(conjunct, fullPrefix, !forWriting));
  }
  return StatisticsInfo.createComposite(infos);
}
项目:tools-idea    文件:CompletionLookupArranger.java   
public static StatisticsUpdate collectStatisticChanges(LookupElement item, final Lookup lookup) {
  applyLastCompletionStatisticsUpdate();

  final StatisticsInfo base = StatisticsWeigher.getBaseStatisticsInfo(item, null);
  if (base == StatisticsInfo.EMPTY) {
    return new StatisticsUpdate(StatisticsInfo.EMPTY);
  }

  StatisticsUpdate update = new StatisticsUpdate(StatisticsWeigher.composeStatsWithPrefix(base, lookup.itemPattern(item), true));
  ourPendingUpdate = update;
  Disposer.register(update, new Disposable() {
    @Override
    public void dispose() {
      //noinspection AssignmentToStaticFieldFromInstanceMethod
      ourPendingUpdate = null;
    }
  });

  return update;
}
项目:intellij-haxe    文件:HaxePullUpDialog.java   
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;
}
项目:consulo    文件:ListPopupImpl.java   
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;
}
项目:consulo-java    文件:TypeSelectorManagerImpl.java   
private void setTypesAndPreselect(PsiType[] types)
{
    myTypeSelector.setTypes(types);

    Map<String, PsiType> map = new THashMap<String, PsiType>();
    for(final PsiType type : types)
    {
        map.put(serialize(type), type);
    }

    for(StatisticsInfo info : StatisticsManager.getInstance().getAllValues(getStatsKey()))
    {
        final PsiType candidate = map.get(info.getValue());
        if(candidate != null && StatisticsManager.getInstance().getUseCount(info) > 0)
        {
            myTypeSelector.selectType(candidate);
            return;
        }
    }
}
项目:consulo-java    文件:PullUpDialog.java   
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;
}
项目:consulo-java    文件:PullUpDialog.java   
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);
}
项目:intellij-ce-playground    文件:JavaInheritorsGetter.java   
private static boolean processMostProbableInheritors(CompletionParameters parameters,
                                                     Collection<PsiClassType> expectedClassTypes,
                                                     Consumer<PsiType> consumer) {
  PsiFile file = parameters.getOriginalFile();
  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(parameters.getPosition(), 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(file.getProject()).findClass(qname, file.getResolveScope());
        if (psiClass != null && !PsiTreeUtil.isAncestor(file, psiClass, true) && !processor.process(psiClass)) break;
      }
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:PullUpDialog.java   
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);
}
项目:intellij-ce-playground    文件:ListPopupImpl.java   
private void valuesSelected(final Object[] values) {
  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));
    }
  }
}
项目:intellij-ce-playground    文件:StatisticsManagerImpl.java   
public int getUseCount(@NotNull final StatisticsInfo info) {
  if (info == StatisticsInfo.EMPTY) return 0;

  int useCount = 0;

  for (StatisticsInfo conjunct : info.getConjuncts()) {
    useCount = Math.max(doGetUseCount(conjunct), useCount);
  }

  return useCount;
}
项目:intellij-ce-playground    文件:StatisticsManagerImpl.java   
private int doGetUseCount(StatisticsInfo info) {
  String key1 = info.getContext();
  int unitNumber = getUnitNumber(key1);
  synchronized (LOCK) {
    StatisticsUnit unit = getUnit(unitNumber);
    return unit.getData(key1, info.getValue());
  }
}
项目:intellij-ce-playground    文件:StatisticsManagerImpl.java   
@Override
public int getLastUseRecency(@NotNull StatisticsInfo info) {
  if (info == StatisticsInfo.EMPTY) return 0;

  int recency = Integer.MAX_VALUE;
  for (StatisticsInfo conjunct : info.getConjuncts()) {
    recency = Math.min(doGetRecency(conjunct), recency);
  }
  return recency;
}
项目:intellij-ce-playground    文件:StatisticsManagerImpl.java   
private int doGetRecency(StatisticsInfo info) {
  String key1 = info.getContext();
  int unitNumber = getUnitNumber(key1);
  synchronized (LOCK) {
    StatisticsUnit unit = getUnit(unitNumber);
    return unit.getRecency(key1, info.getValue());
  }
}
项目:intellij-ce-playground    文件:StatisticsManagerImpl.java   
public void incUseCount(@NotNull final StatisticsInfo info) {
  if (info == StatisticsInfo.EMPTY) return;
  if (ApplicationManager.getApplication().isUnitTestMode() && !myTestingStatistics) {
    return;
  }

  ApplicationManager.getApplication().assertIsDispatchThread();

  for (StatisticsInfo conjunct : info.getConjuncts()) {
    doIncUseCount(conjunct);
  }
}
项目:intellij-ce-playground    文件:StatisticsManagerImpl.java   
private void doIncUseCount(StatisticsInfo info) {
  final String key1 = info.getContext();
  int unitNumber = getUnitNumber(key1);
  synchronized (LOCK) {
    StatisticsUnit unit = getUnit(unitNumber);
    unit.incData(key1, info.getValue());
    myModifiedUnits.add(unit);
  }
}
项目:intellij-ce-playground    文件:StatisticsManagerImpl.java   
public StatisticsInfo[] getAllValues(final String context) {
  final String[] strings;
  synchronized (LOCK) {
    strings = getUnit(getUnitNumber(context)).getKeys2(context);
  }
  return ContainerUtil.map2Array(strings, StatisticsInfo.class, new NotNullFunction<String, StatisticsInfo>() {
    @NotNull
    public StatisticsInfo fun(final String s) {
      return new StatisticsInfo(context, s);
    }
  });
}
项目:intellij-ce-playground    文件:StatisticsWeigher.java   
@Override
public void addElement(LookupElement element, ProcessingContext context) {
  StatisticsInfo baseInfo = getBaseStatisticsInfo(element, myLocation);
  myWeights.put(element, weigh(element, baseInfo, context.get(CompletionLookupArranger.WEIGHING_CONTEXT)));
  if (baseInfo == StatisticsInfo.EMPTY) {
    myNoStats.add(element);
  }
  super.addElement(element, context);
}
项目:intellij-ce-playground    文件:StatisticsWeigher.java   
private static int weigh(@NotNull LookupElement item, final StatisticsInfo baseInfo, WeighingContext context) {
  if (baseInfo == StatisticsInfo.EMPTY) {
    return 0;
  }
  String prefix = context.itemPattern(item);
  StatisticsInfo composed = composeStatsWithPrefix(baseInfo, prefix, false);
  int minRecency = composed.getLastUseRecency();
  int useCount = composed.getUseCount();
  return minRecency == Integer.MAX_VALUE ? useCount : 100 - minRecency;
}
项目:intellij-ce-playground    文件:StatisticsWeigher.java   
@NotNull
public static StatisticsInfo getBaseStatisticsInfo(LookupElement item, @Nullable CompletionLocation location) {
  StatisticsInfo info = BASE_STATISTICS_INFO.get(item);
  if (info == null) {
    if (location == null) {
      return StatisticsInfo.EMPTY;
    }
    BASE_STATISTICS_INFO.set(item, info = calcBaseInfo(item, location));
  }
  return info;
}
项目:intellij-ce-playground    文件:StatisticsWeigher.java   
@NotNull
private static StatisticsInfo calcBaseInfo(LookupElement item, @NotNull CompletionLocation location) {
  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    LOG.assertTrue(!ApplicationManager.getApplication().isDispatchThread());
  }
  StatisticsInfo info = StatisticsManager.serialize(CompletionService.STATISTICS_KEY, item, location);
  return info == null ? StatisticsInfo.EMPTY : info;
}
项目:intellij-ce-playground    文件:PsiProximityComparator.java   
@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);
}
项目:intellij-ce-playground    文件:ChooseByNameBase.java   
private int detectBestStatisticalPosition() {
  if (myModel instanceof Comparator) {
    return 0;
  }

  int best = 0;
  int bestPosition = 0;
  int bestMatch = Integer.MIN_VALUE;
  final int count = myListModel.getSize();

  Matcher matcher = buildPatternMatcher(transformPattern(getTrimmedText()));

  final String statContext = statisticsContext();
  for (int i = 0; i < count; i++) {
    final Object modelElement = myListModel.getElementAt(i);
    String text = EXTRA_ELEM.equals(modelElement) || NON_PREFIX_SEPARATOR.equals(modelElement) ? null : myModel.getFullName(modelElement);
    if (text != null) {
      String shortName = myModel.getElementName(modelElement);
      int match = shortName != null && matcher instanceof MinusculeMatcher
                  ? ((MinusculeMatcher)matcher).matchingDegree(shortName) : Integer.MIN_VALUE;
      int stats = StatisticsManager.getInstance().getUseCount(new StatisticsInfo(statContext, text));
      if (match > bestMatch || match == bestMatch && stats > best) {
        best = stats;
        bestPosition = i;
        bestMatch = match;
      }
    }
  }

  if (bestPosition < count - 1 && myListModel.getElementAt(bestPosition) == NON_PREFIX_SEPARATOR) {
    bestPosition++;
  }

  return bestPosition;
}
项目:intellij-ce-playground    文件:GrPullUpDialog.java   
@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);
}
项目:tools-idea    文件:JavaInheritorsGetter.java   
private static boolean processMostProbableInheritors(CompletionParameters parameters,
                                                     Collection<PsiClassType> expectedClassTypes,
                                                     Consumer<PsiType> consumer) {
  PsiFile file = parameters.getOriginalFile();
  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(parameters.getPosition(), 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(file.getProject()).findClass(qname, file.getResolveScope());
        if (psiClass != null && !PsiTreeUtil.isAncestor(file, psiClass, true) && !processor.process(psiClass)) break;
      }
    }
  }
  return true;
}
项目:tools-idea    文件:PullUpDialog.java   
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));
  }

  invokeRefactoring(new PullUpHelper(myClass, superClass, getSelectedMemberInfos(),
                                             new DocCommentPolicy(getJavaDocPolicy())));
  close(OK_EXIT_CODE);
}
项目:tools-idea    文件:ListPopupImpl.java   
private void valuesSelected(final Object[] values) {
  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));
    }
  }
}
项目:tools-idea    文件:StatisticsManagerImpl.java   
public int getUseCount(@NotNull final StatisticsInfo info) {
  if (info == StatisticsInfo.EMPTY) return 0;

  int useCount = 0;

  for (StatisticsInfo conjunct : info.getConjuncts()) {
    useCount = Math.max(doGetUseCount(conjunct), useCount);
  }

  return useCount;
}
项目:tools-idea    文件:StatisticsManagerImpl.java   
private int doGetUseCount(StatisticsInfo info) {
  String key1 = info.getContext();
  int unitNumber = getUnitNumber(key1);
  synchronized (LOCK) {
    StatisticsUnit unit = getUnit(unitNumber);
    return unit.getData(key1, info.getValue());
  }
}
项目:tools-idea    文件:StatisticsManagerImpl.java   
@Override
public int getLastUseRecency(@NotNull StatisticsInfo info) {
  if (info == StatisticsInfo.EMPTY) return 0;

  int recency = Integer.MAX_VALUE;
  for (StatisticsInfo conjunct : info.getConjuncts()) {
    recency = Math.min(doGetRecency(conjunct), recency);
  }
  return recency;
}
项目:tools-idea    文件:StatisticsManagerImpl.java   
private int doGetRecency(StatisticsInfo info) {
  String key1 = info.getContext();
  int unitNumber = getUnitNumber(key1);
  synchronized (LOCK) {
    StatisticsUnit unit = getUnit(unitNumber);
    return unit.getRecency(key1, info.getValue());
  }
}