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


Java MethodCellRenderer类代码示例

本文整理汇总了Java中com.intellij.ide.util.MethodCellRenderer的典型用法代码示例。如果您正苦于以下问题:Java MethodCellRenderer类的具体用法?Java MethodCellRenderer怎么用?Java MethodCellRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: browse

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的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: fun

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的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

示例3: chooseAndImport

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的package包/类
private void chooseAndImport(Editor editor) {
  final JList list = new JBList(getCandidates().toArray(new PsiMethod[getCandidates().size()]));
  list.setCellRenderer(new MethodCellRenderer(true));
  new PopupChooserBuilder(list).
    setTitle(QuickFixBundle.message("static.import.method.choose.method.to.import")).
    setMovable(true).
    setItemChoosenCallback(new Runnable() {
      @Override
      public void run() {
        PsiMethod selectedValue = (PsiMethod)list.getSelectedValue();
        if (selectedValue == null) return;
        LOG.assertTrue(selectedValue.isValid());
        doImport(selectedValue);
      }
    }).createPopup().
    showInBestPositionFor(editor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GroovyStaticImportMethodFix.java

示例4: getOverriddenMethodTooltip

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的package包/类
public static String getOverriddenMethodTooltip(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(new PsiMethod[processor.getCollection().size()]);
  if (overridings.length == 0) 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;{1}";
  return GutterIconTooltipHelper.composeText(overridings, start, pattern);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:MarkerType.java

示例5: navigateToOverriddenMethod

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的package包/类
public static void navigateToOverriddenMethod(MouseEvent e, 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>());
  if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      OverridingMethodsSearch.search(method, true).forEach(new PsiElementProcessorAdapter<PsiMethod>(collectProcessor));
    }
  }, SEARCHING_FOR_OVERRIDING_METHODS, true, method.getProject(), (JComponent)e.getComponent())) {
    return;
  }

  PsiMethod[] overridings = collectProcessor.toArray(PsiMethod.EMPTY_ARRAY);
  if (overridings.length == 0) return;
  boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature(overridings);
  MethodCellRenderer renderer = new MethodCellRenderer(showMethodNames);
  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:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:MarkerType.java

示例6: chooseAndImport

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的package包/类
private void chooseAndImport(Editor editor) {
  final JList list = new JBList(getCandidates().toArray(new PsiMethod[getCandidates().size()]));
  list.setCellRenderer(new MethodCellRenderer(true));
  new PopupChooserBuilder(list).
    setTitle(QuickFixBundle.message("static.import.method.choose.method.to.import")).
    setMovable(true).
    setItemChoosenCallback(new Runnable() {
      public void run() {
        PsiMethod selectedValue = (PsiMethod)list.getSelectedValue();
        if (selectedValue == null) return;
        LOG.assertTrue(selectedValue.isValid());
        doImport(selectedValue);
      }
    }).createPopup().
    showInBestPositionFor(editor);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:GroovyStaticImportMethodFix.java

示例7: invoke

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的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

示例8: getRenderer

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的package包/类
@Override
public PsiElementListCellRenderer getRenderer(@NotNull final PsiElement element, @NotNull GotoTargetHandler.GotoData gotoData) {
  if (element instanceof PsiMethod) {
    return new MethodCellRenderer(gotoData.hasDifferentNames());
  }
  else if (element instanceof PsiClass) {
    return new PsiClassListCellRenderer();
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JavaGotoTargetRendererProvider.java

示例9: invoke

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的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 == null || 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:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:JavaGotoSuperHandler.java

示例10: getRenderer

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的package包/类
@Override
public PsiElementListCellRenderer getRenderer(final PsiElement element, GotoTargetHandler.GotoData gotoData) {
  if (element instanceof PsiMethod) {
    return new MethodCellRenderer(gotoData.hasDifferentNames());
  }
  else if (element instanceof PsiClass) {
    return new PsiClassListCellRenderer();
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:JavaGotoTargetRendererProvider.java

示例11: navigateToOverridingMethod

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的package包/类
public static void navigateToOverridingMethod(MouseEvent e, PsiMethod method) {
  PsiMethod[] superMethods = method.findSuperMethods(false);
  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:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:MarkerType.java

示例12: navigateToOverridingMethod

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的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:consulo,项目名称:consulo-java,代码行数:12,代码来源:MarkerType.java

示例13: navigateToSiblingOverridingMethod

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的package包/类
private static void navigateToSiblingOverridingMethod(MouseEvent e, @NotNull PsiMethod method)
{
	PsiMethod superMethod = FindSuperElementsHelper.getSiblingInheritedViaSubClass(method);
	if(superMethod == null)
	{
		return;
	}
	PsiElementListNavigator.openTargets(e, new NavigatablePsiElement[]{superMethod}, DaemonBundle.message("navigation.title.super.method", method.getName()), DaemonBundle.message("navigation" +
			".findUsages.title.super.method", method.getName()), new MethodCellRenderer(false));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:11,代码来源:MarkerType.java

示例14: getOverriddenMethodTooltip

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的package包/类
private static String getOverriddenMethodTooltip(@NotNull PsiMethod method)
{
	PsiElementProcessor.CollectElementsWithLimit<PsiMethod> processor = new PsiElementProcessor.CollectElementsWithLimit<>(5);
	GlobalSearchScope scope = GlobalSearchScope.allScope(PsiUtilCore.getProjectInReadAction(method));
	OverridingMethodsSearch.search(method, scope, true).forEach(new PsiElementProcessorAdapter<>(processor));

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

	if(processor.isOverflow())
	{
		return DaemonBundle.message(isAbstract ? "method.is.implemented.too.many" : "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 = DaemonBundle.message(isAbstract ? "method.is.implemented.header" : "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:consulo,项目名称:consulo-java,代码行数:32,代码来源:MarkerType.java

示例15: performForContext

import com.intellij.ide.util.MethodCellRenderer; //导入依赖的package包/类
@Override
public void performForContext(@NotNull DataContext dataContext, final boolean invokedByShortcut) {
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext);

  if (project == null) return;

  PsiDocumentManager.getInstance(project).commitAllDocuments();
  final Editor editor = getEditor(dataContext);

  PsiElement element = getElement(project, file, editor, CommonDataKeys.PSI_ELEMENT.getData(dataContext));

  if (element == null && file == null) return;
  PsiFile containingFile = element != null ? element.getContainingFile() : file;
  if (containingFile == null || !containingFile.getViewProvider().isPhysical()) return;


  if (editor != null) {
    PsiReference ref = TargetElementUtil.findReference(editor, editor.getCaretModel().getOffset());
    if (element == null && ref != null) {
      element = TargetElementUtil.getInstance().adjustReference(ref);
    }
  }

  final NavigatablePsiElement[] superElements = (NavigatablePsiElement[])findSuperElements(element);
  if (superElements.length == 0) return;

  final boolean isMethod = superElements[0] instanceof PsiMethod;
  final JBPopup popup = PsiElementListNavigator.navigateOrCreatePopup(superElements, "Choose super " + (isMethod ? "method" : "class or interface"), "Super " + (isMethod ? "methods" : "classes/interfaces"),
                                                                     isMethod ? new MethodCellRenderer(false) : new PsiClassListCellRenderer(), null, new Consumer<Object[]>() {
    @Override
    public void consume(Object[] objects) {
      showSiblings(invokedByShortcut, project, editor, file, editor != null, (PsiElement)objects[0]);
    }
  });
  if (popup != null) {
    if (editor != null) {
      popup.showInBestPositionFor(editor);
    } else {
      popup.showCenteredInCurrentWindow(project);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:ShowSiblingsAction.java


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