当前位置: 首页>>代码示例>>Java>>正文


Java PsiElementProcessor.CollectElementsWithLimit方法代码示例

本文整理汇总了Java中com.intellij.psi.search.PsiElementProcessor.CollectElementsWithLimit方法的典型用法代码示例。如果您正苦于以下问题:Java PsiElementProcessor.CollectElementsWithLimit方法的具体用法?Java PsiElementProcessor.CollectElementsWithLimit怎么用?Java PsiElementProcessor.CollectElementsWithLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.search.PsiElementProcessor的用法示例。


在下文中一共展示了PsiElementProcessor.CollectElementsWithLimit方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addExprTypesByDerivedClasses

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
private void addExprTypesByDerivedClasses(LinkedHashSet<PsiType> set, PsiExpression expr) {
  PsiType type = expr.getType();
  if (!(type instanceof PsiClassType)) return;
  PsiClass refClass = PsiUtil.resolveClassInType(type);
  if (refClass == null) return;

  PsiManager manager = PsiManager.getInstance(myProject);
  PsiElementProcessor.CollectElementsWithLimit<PsiClass> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiClass>(5);
  ClassInheritorsSearch.search(refClass, true).forEach(new PsiElementProcessorAdapter<PsiClass>(processor));
  if (processor.isOverflow()) return;

  for (PsiClass derivedClass : processor.getCollection()) {
    if (derivedClass instanceof PsiAnonymousClass) continue;
    PsiType derivedType = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createType(derivedClass);
    set.add(derivedType);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GuessManagerImpl.java

示例2: update

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
@Override
public void update(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  presentation.setVisible(false);
  final DataContext dataContext = e.getDataContext();
  final PsiElement[] psiElements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext);
  if (psiElements != null) {
    PsiElementProcessor.CollectElementsWithLimit<PsiElement> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiElement>(2);
    getPatternBasedProducer().collectTestMembers(psiElements, false, false, processor);
    Collection<PsiElement> collection = processor.getCollection();
    if (collection.isEmpty()) return;
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project != null) {
      final List<T> foundConfigurations = collectPatternConfigurations(collection, project);
      if (!foundConfigurations.isEmpty()) {
        presentation.setVisible(true);
        if (foundConfigurations.size() == 1) {
          presentation.setText("Add to temp suite: " + foundConfigurations.get(0).getName());
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AbstractAddToTestsPatternAction.java

示例3: getOverriddenMethodTooltip

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
private static String getOverriddenMethodTooltip(@NotNull PsiMethod method) {
  PsiElementProcessor.CollectElementsWithLimit<PsiMethod> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiMethod>(5);
  OverridingMethodsSearch.search(method, true).forEach(new PsiElementProcessorAdapter<PsiMethod>(processor));

  boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT);

  if (processor.isOverflow()){
    return isAbstract ? DaemonBundle.message("method.is.implemented.too.many") : DaemonBundle.message("method.is.overridden.too.many");
  }

  PsiMethod[] overridings = processor.toArray(PsiMethod.EMPTY_ARRAY);
  if (overridings.length == 0) {
    final PsiClass aClass = method.getContainingClass();
    if (aClass != null && FunctionalExpressionSearch.search(aClass).findFirst() != null) {
      return "Has functional implementations";
    }
    return null;
  }

  Comparator<PsiMethod> comparator = new MethodCellRenderer(false).getComparator();
  Arrays.sort(overridings, comparator);

  String start = isAbstract ? DaemonBundle.message("method.is.implemented.header") : DaemonBundle.message("method.is.overriden.header");
  @NonNls String pattern = "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#javaClass/{1}\">{1}</a>";
  return composeText(overridings, start, pattern, IdeActions.ACTION_GOTO_IMPLEMENTATION);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:MarkerType.java

示例4: implementersHaveOnlyPrivateConstructors

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
private boolean implementersHaveOnlyPrivateConstructors(final PsiClass aClass) {
  final GlobalSearchScope scope = GlobalSearchScope.allScope(aClass.getProject());
  final PsiElementProcessor.CollectElementsWithLimit<PsiClass> processor = new PsiElementProcessor.CollectElementsWithLimit(6);
  final ProgressManager progressManager = ProgressManager.getInstance();
  progressManager.runProcess(new Runnable() {
    @Override
    public void run() {
      ClassInheritorsSearch.search(aClass, scope, true, true).forEach(new PsiElementProcessorAdapter<PsiClass>(processor));
    }
  }, null);
  if (processor.isOverflow()) {
    return false;
  }
  final Collection<PsiClass> implementers = processor.getCollection();
  for (PsiClass implementer : implementers) {
    if (!implementer.isInterface() && !implementer.hasModifierProperty(PsiModifier.ABSTRACT)) {
      if (!hasOnlyPrivateConstructors(implementer)) {
        return false;
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ObjectEqualityInspection.java

示例5: fun

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
@Nullable
@Override
public String fun(PsiElement element) {
  PsiElement parent = element.getParent();
  if (!(parent instanceof GrField)) return null;
  final List<GrAccessorMethod> accessors = GroovyPropertyUtils.getFieldAccessors((GrField)parent);

  PsiElementProcessor.CollectElementsWithLimit<PsiMethod> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiMethod>(5);

  for (GrAccessorMethod method : accessors) {
    OverridingMethodsSearch.search(method, true).forEach(new PsiElementProcessorAdapter<PsiMethod>(processor));
  }
  if (processor.isOverflow()) {
    return DaemonBundle.message("method.is.overridden.too.many");
  }

  PsiMethod[] overridings = processor.toArray(new PsiMethod[processor.getCollection().size()]);
  if (overridings.length == 0) return null;

  Comparator<PsiMethod> comparator = new MethodCellRenderer(false).getComparator();
  Arrays.sort(overridings, comparator);

  String start = DaemonBundle.message("method.is.overriden.header");
  @NonNls String pattern = "&nbsp;&nbsp;&nbsp;&nbsp;{1}";
  return GutterIconTooltipHelper.composeText(overridings, start, pattern);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GroovyMarkerTypes.java

示例6: isMultipleElementsSelected

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
public boolean isMultipleElementsSelected(ConfigurationContext context) {
  final DataContext dataContext = context.getDataContext();
  if (TestsUIUtil.isMultipleSelectionImpossible(dataContext)) return false;
  final LinkedHashSet<String> classes = new LinkedHashSet<String>();
  final PsiElementProcessor.CollectElementsWithLimit<PsiElement> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiElement>(2);
  final PsiElement[] locationElements = collectLocationElements(classes, dataContext);
  if (locationElements != null) {
    collectTestMembers(locationElements, false, false, processor);
  }
  else {
    collectContextElements(dataContext, false, false, classes, processor);
  }
  return processor.getCollection().size() > 1;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:AbstractPatternBasedConfigurationProducer.java

示例7: getSubclassedClassTooltip

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
public static String getSubclassedClassTooltip(@NotNull PsiClass aClass) {
  PsiElementProcessor.CollectElementsWithLimit<PsiClass> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiClass>(5, new THashSet<PsiClass>());
  ClassInheritorsSearch.search(aClass, true).forEach(new PsiElementProcessorAdapter<PsiClass>(processor));

  if (processor.isOverflow()) {
    return aClass.isInterface()
           ? DaemonBundle.message("interface.is.implemented.too.many")
           : DaemonBundle.message("class.is.subclassed.too.many");
  }

  PsiClass[] subclasses = processor.toArray(PsiClass.EMPTY_ARRAY);
  if (subclasses.length == 0) {
    final PsiElementProcessor.CollectElementsWithLimit<PsiFunctionalExpression> functionalImplementations =
      new PsiElementProcessor.CollectElementsWithLimit<PsiFunctionalExpression>(2, new THashSet<PsiFunctionalExpression>());
    FunctionalExpressionSearch.search(aClass).forEach(new PsiElementProcessorAdapter<PsiFunctionalExpression>(functionalImplementations));
    if (!functionalImplementations.getCollection().isEmpty()) {
      return "Has functional implementations";
    }
    return null;
  }

  Comparator<PsiClass> comparator = new PsiClassListCellRenderer().getComparator();
  Arrays.sort(subclasses, comparator);

  String start = aClass.isInterface()
                 ? DaemonBundle.message("interface.is.implemented.by.header")
                 : DaemonBundle.message("class.is.subclassed.by.header");
  @NonNls String pattern = "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#javaClass/{0}\">{0}</a>";
  return composeText(subclasses, start, pattern, IdeActions.ACTION_GOTO_IMPLEMENTATION);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:MarkerType.java

示例8: navigateToSubclassedClass

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
public static void navigateToSubclassedClass(MouseEvent e, @NotNull final PsiClass aClass) {
  if (DumbService.isDumb(aClass.getProject())) {
    DumbService.getInstance(aClass.getProject()).showDumbModeNotification("Navigation to overriding methods is not possible during index update");
    return;
  }

  final PsiElementProcessor.CollectElementsWithLimit<PsiClass> collectProcessor = new PsiElementProcessor.CollectElementsWithLimit<PsiClass>(2, new THashSet<PsiClass>());
  final PsiElementProcessor.CollectElementsWithLimit<PsiFunctionalExpression> collectExprProcessor = new PsiElementProcessor.CollectElementsWithLimit<PsiFunctionalExpression>(2, new THashSet<PsiFunctionalExpression>());
  if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      ClassInheritorsSearch.search(aClass, true).forEach(new PsiElementProcessorAdapter<PsiClass>(collectProcessor));
      if (collectProcessor.getCollection().size() < 2) {
        FunctionalExpressionSearch.search(aClass).forEach(new PsiElementProcessorAdapter<PsiFunctionalExpression>(collectExprProcessor));
      }
    }
  }, SEARCHING_FOR_OVERRIDDEN_METHODS, true, aClass.getProject(), (JComponent)e.getComponent())) {
    return;
  }

  final List<NavigatablePsiElement> inheritors = new ArrayList<NavigatablePsiElement>();
  inheritors.addAll(collectProcessor.getCollection());
  inheritors.addAll(collectExprProcessor.getCollection());
  if (inheritors.isEmpty()) return;
  final PsiClassOrFunctionalExpressionListCellRenderer renderer = new PsiClassOrFunctionalExpressionListCellRenderer();
  final SubclassUpdater subclassUpdater = new SubclassUpdater(aClass, renderer);
  Collections.sort(inheritors, renderer.getComparator());
  PsiElementListNavigator.openTargets(e, inheritors.toArray(new NavigatablePsiElement[inheritors.size()]), subclassUpdater.getCaption(inheritors.size()), CodeInsightBundle.message("goto.implementation.findUsages.title", aClass.getName()), renderer, subclassUpdater);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:MarkerType.java

示例9: isMultipleElementsSelected

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
public static boolean isMultipleElementsSelected(ConfigurationContext context) {
  final DataContext dataContext = context.getDataContext();
  if (TestsUIUtil.isMultipleSelectionImpossible(dataContext)) {
    return false;
  }
  final PsiElementProcessor.CollectElementsWithLimit<PsiElement> processor =
      new PsiElementProcessor.CollectElementsWithLimit<PsiElement>(2);
  final PsiElement[] locationElements = collectLocationElements(dataContext);
  if (locationElements != null) {
    collectTestMembers(locationElements, false, false, processor);
  } else {
    collectContextElements(dataContext, false, false, processor);
  }
  return processor.getCollection().size() > 1;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:16,代码来源:JUnitConfigurationUtil.java

示例10: navigateToOverriddenMethod

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
private static void navigateToOverriddenMethod(MouseEvent e, @NotNull final PsiMethod method) {
  if (DumbService.isDumb(method.getProject())) {
    DumbService.getInstance(method.getProject()).showDumbModeNotification(
      "Navigation to overriding classes is not possible during index update");
    return;
  }

  final PsiElementProcessor.CollectElementsWithLimit<PsiMethod> collectProcessor =
    new PsiElementProcessor.CollectElementsWithLimit<PsiMethod>(2, new THashSet<PsiMethod>());
  final PsiElementProcessor.CollectElementsWithLimit<PsiFunctionalExpression> collectExprProcessor = 
    new PsiElementProcessor.CollectElementsWithLimit<PsiFunctionalExpression>(2, new THashSet<PsiFunctionalExpression>());
  final boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT);
  if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      OverridingMethodsSearch.search(method, true).forEach(new PsiElementProcessorAdapter<PsiMethod>(collectProcessor));
      if (isAbstract && collectProcessor.getCollection().size() < 2) {
        final PsiClass aClass = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
          @Override
          public PsiClass compute() {
            return method.getContainingClass();
          }
        });
        if (aClass != null) {
          FunctionalExpressionSearch.search(aClass).forEach(new PsiElementProcessorAdapter<PsiFunctionalExpression>(collectExprProcessor));
        }
      }
    }
  }, SEARCHING_FOR_OVERRIDING_METHODS, true, method.getProject(), (JComponent)e.getComponent())) {
    return;
  }

  final PsiMethod[] methodOverriders = collectProcessor.toArray(PsiMethod.EMPTY_ARRAY);
  final List<NavigatablePsiElement> overridings = new ArrayList<NavigatablePsiElement>();
  overridings.addAll(collectProcessor.getCollection());
  overridings.addAll(collectExprProcessor.getCollection());
  if (overridings.isEmpty()) return;
  boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature(methodOverriders);
  MethodOrFunctionalExpressionCellRenderer renderer = new MethodOrFunctionalExpressionCellRenderer(showMethodNames);
  Collections.sort(overridings, renderer.getComparator());
  final OverridingMethodsUpdater methodsUpdater = new OverridingMethodsUpdater(method, renderer);
  PsiElementListNavigator.openTargets(e, overridings.toArray(new NavigatablePsiElement[overridings.size()]), methodsUpdater.getCaption(overridings.size()), "Overriding methods of " + method.getName(), renderer, methodsUpdater);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:MarkerType.java

示例11: browse

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
@Override
public void browse(MouseEvent e, PsiElement element) {
  PsiElement parent = element.getParent();
  if (!(parent instanceof GrMethod)) return;
  if (DumbService.isDumb(element.getProject())) {
    DumbService.getInstance(element.getProject()).showDumbModeNotification("Navigation to overriding classes is not possible during index update");
    return;
  }


  //collect all overrings (including fields with implicit accessors and method with default parameters)
  final GrMethod method = (GrMethod)parent;
  final PsiElementProcessor.CollectElementsWithLimit<PsiMethod> collectProcessor =
    new PsiElementProcessor.CollectElementsWithLimit<PsiMethod>(2, new THashSet<PsiMethod>());
  if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runReadAction(new Runnable() {
        @Override
        public void run() {
          for (GrMethod m : PsiImplUtil.getMethodOrReflectedMethods(method)) {
            OverridingMethodsSearch.search(m, true).forEach(new ReadActionProcessor<PsiMethod>() {
              @Override
              public boolean processInReadAction(PsiMethod psiMethod) {
                if (psiMethod instanceof GrReflectedMethod) {
                  psiMethod = ((GrReflectedMethod)psiMethod).getBaseMethod();
                }
                return collectProcessor.execute(psiMethod);
              }
            });
          }
        }
      });
    }
  }, MarkerType.SEARCHING_FOR_OVERRIDING_METHODS, true, method.getProject(), (JComponent)e.getComponent())) {
    return;
  }

  PsiMethod[] overridings = collectProcessor.toArray(PsiMethod.EMPTY_ARRAY);
  if (overridings.length == 0) return;

  PsiElementListCellRenderer<PsiMethod> renderer = new MethodCellRenderer(!PsiUtil.allMethodsHaveSameSignature(overridings));
  Arrays.sort(overridings, renderer.getComparator());
  final OverridingMethodsUpdater methodsUpdater = new OverridingMethodsUpdater(method, renderer);
  PsiElementListNavigator.openTargets(e, overridings, methodsUpdater.getCaption(overridings.length),
                                      "Overriding Methods of " + method.getName(),
                                      renderer, methodsUpdater);
  
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:50,代码来源:GroovyMarkerTypes.java


注:本文中的com.intellij.psi.search.PsiElementProcessor.CollectElementsWithLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。