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


Java PsiUtil.allMethodsHaveSameSignature方法代码示例

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


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

示例1: browse

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public void browse(MouseEvent e, PsiElement element) {
  PsiElement parent = element.getParent();
  if (!(parent instanceof GrField)) return;
  final GrField field = (GrField)parent;
  final List<GrAccessorMethod> accessors = GroovyPropertyUtils.getFieldAccessors(field);
  final ArrayList<PsiMethod> superMethods = new ArrayList<PsiMethod>();
  for (GrAccessorMethod method : accessors) {
    Collections.addAll(superMethods, method.findSuperMethods(false));
  }
  if (superMethods.isEmpty()) return;
  final PsiMethod[] supers = ContainerUtil.toArray(superMethods, new PsiMethod[superMethods.size()]);
  boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature(supers);
  PsiElementListNavigator.openTargets(e, supers, 
                                      DaemonBundle.message("navigation.title.super.method", field.getName()),
                                      DaemonBundle.message("navigation.findUsages.title.super.method", field.getName()),
                                      new MethodCellRenderer(showMethodNames));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GroovyMarkerTypes.java

示例2: invoke

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
  FeatureUsageTracker.getInstance().triggerFeatureUsed(GotoSuperAction.FEATURE_ID);

  int offset = editor.getCaretModel().getOffset();
  PsiElement[] superElements = findSuperElements(file, offset);
  if (superElements.length == 0) return;
  if (superElements.length == 1) {
    PsiElement superElement = superElements[0].getNavigationElement();
    final PsiFile containingFile = superElement.getContainingFile();
    if (containingFile == null) return;
    final VirtualFile virtualFile = containingFile.getVirtualFile();
    if (virtualFile == null) return;
    OpenFileDescriptor descriptor = new OpenFileDescriptor(project, virtualFile, superElement.getTextOffset());
    FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
  }
  else if (superElements[0] instanceof PsiMethod) {
    boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature((PsiMethod[])superElements);
    PsiElementListNavigator.openTargets(editor, (PsiMethod[])superElements,
                                        CodeInsightBundle.message("goto.super.method.chooser.title"),
                                        CodeInsightBundle
                                          .message("goto.super.method.findUsages.title", ((PsiMethod)superElements[0]).getName()),
                                        new MethodCellRenderer(showMethodNames));
  }
  else {
    NavigationUtil.getPsiElementPopup(superElements, CodeInsightBundle.message("goto.super.class.chooser.title"))
      .showInBestPositionFor(editor);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:JavaGotoSuperHandler.java

示例3: navigateToOverridingMethod

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static void navigateToOverridingMethod(MouseEvent e, @NotNull PsiMethod method, boolean acceptSelf) {
  PsiMethod[] superMethods = composeSuperMethods(method, acceptSelf);
  if (superMethods.length == 0) return;
  boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature(superMethods);
  PsiElementListNavigator.openTargets(e, superMethods,
                                      DaemonBundle.message("navigation.title.super.method", method.getName()),
                                      DaemonBundle.message("navigation.findUsages.title.super.method", method.getName()),
                                      new MethodCellRenderer(showMethodNames));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:MarkerType.java

示例4: navigateToOverriddenMethod

import com.intellij.psi.util.PsiUtil; //导入方法依赖的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


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