Java 类com.intellij.openapi.editor.markup.GutterIconRenderer 实例源码

项目:intellij-ce-playground    文件:BreakpointManager.java   
public void editBreakpoint(final Breakpoint breakpoint, final Editor editor) {
  DebuggerInvocationUtil.swingInvokeLater(myProject, new Runnable() {
    @Override
    public void run() {
      XBreakpoint xBreakpoint = breakpoint.myXBreakpoint;
      if (xBreakpoint instanceof XLineBreakpointImpl) {
        RangeHighlighter highlighter = ((XLineBreakpointImpl)xBreakpoint).getHighlighter();
        if (highlighter != null) {
          GutterIconRenderer renderer = highlighter.getGutterIconRenderer();
          if (renderer != null) {
            DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class).getEditBreakpointAction().editBreakpoint(
              myProject, editor, breakpoint.myXBreakpoint, renderer
            );
          }
        }
      }
    }
  });
}
项目:intellij-ce-playground    文件:IconLineMarkerProvider.java   
@Nullable
private static LineMarkerInfo<PsiElement> createIconLineMarker(PsiType type,
                                                               @Nullable PsiExpression initializer,
                                                               PsiElement bindingElement) {
  if (initializer == null) return null;

  final Project project = initializer.getProject();

  final VirtualFile file = ProjectIconsAccessor.getInstance(project).resolveIconFile(type, initializer);
  if (file == null) return null;

  final Icon icon = ProjectIconsAccessor.getInstance(project).getIcon(file);
  if (icon == null) return null;

  final GutterIconNavigationHandler<PsiElement> navHandler = new GutterIconNavigationHandler<PsiElement>() {
    @Override
    public void navigate(MouseEvent e, PsiElement elt) {
      FileEditorManager.getInstance(project).openFile(file, true);
    }
  };

  return new LineMarkerInfo<PsiElement>(bindingElement, bindingElement.getTextRange(), icon,
                                        Pass.UPDATE_ALL, null, navHandler,
                                        GutterIconRenderer.Alignment.LEFT);
}
项目:intellij-ce-playground    文件:JavaLineMarkerProvider.java   
public static void collectInheritingClasses(@NotNull PsiClass aClass,
                                            @NotNull Collection<LineMarkerInfo> result,
                                            @NotNull Map<PsiClass, PsiClass> subClassCache) {
  if (aClass.hasModifierProperty(PsiModifier.FINAL)) {
    return;
  }
  if (CommonClassNames.JAVA_LANG_OBJECT.equals(aClass.getQualifiedName())) return; // It's useless to have overridden markers for object.

  PsiClass subClass = subClassCache.get(aClass);
  if (subClass != null || FunctionalExpressionSearch.search(aClass).findFirst() != null) {
    final Icon icon = aClass.isInterface() ? AllIcons.Gutter.ImplementedMethod : AllIcons.Gutter.OverridenMethod;
    PsiElement range = aClass.getNameIdentifier();
    if (range == null) {
      range = aClass;
    }
    MarkerType type = MarkerType.SUBCLASSED_CLASS;
    LineMarkerInfo info = new LineMarkerInfo<PsiElement>(range, range.getTextRange(),
                                                         icon, Pass.UPDATE_OVERRIDEN_MARKERS, type.getTooltip(),
                                                         type.getNavigationHandler(),
                                                         GutterIconRenderer.Alignment.RIGHT);
    NavigateAction.setNavigateAction(info, aClass.isInterface() ? "Go to implementation(s)" : "Go to subclass(es)", IdeActions.ACTION_GOTO_IMPLEMENTATION);
    result.add(info);
  }
}
项目:intellij-ce-playground    文件:RunLineMarkerTest.java   
public void testTestClassWithMain() throws Exception {
  myFixture.addClass("package junit.framework; public class TestCase {}");
  myFixture.configureByText("MainTest.java", "public class <caret>MainTest extends junit.framework.TestCase {\n" +
                                             "    public static void main(String[] args) {\n" +
                                             "    }\n" +
                                             "    public void testFoo() {\n" +
                                             "    }\n" +
                                             "}");
  List<GutterMark> marks = myFixture.findGuttersAtCaret();
  assertEquals(1, marks.size());
  GutterIconRenderer mark = (GutterIconRenderer)marks.get(0);
  ActionGroup group = mark.getPopupMenuActions();
  assertNotNull(group);
  TestActionEvent event = new TestActionEvent();
  List<AnAction> list = ContainerUtil.findAll(group.getChildren(event), action -> {
    TestActionEvent actionEvent = new TestActionEvent();
    action.update(actionEvent);
    String text = actionEvent.getPresentation().getText();
    return text != null && text.startsWith("Run ") && text.endsWith("'");
  });
  assertEquals(list.toString(), 2, list.size());
  list.get(0).update(event);
  assertEquals("Run 'MainTest.main()'", event.getPresentation().getText());
  list.get(1).update(event);
  assertEquals("Run 'MainTest'", event.getPresentation().getText());
}
项目:intellij-ce-playground    文件:LineMarkerInfo.java   
public LineMarkerInfo(@NotNull T element,
                      @NotNull TextRange range,
                      Icon icon,
                      int updatePass,
                      @Nullable Function<? super T, String> tooltipProvider,
                      @Nullable GutterIconNavigationHandler<T> navHandler,
                      @NotNull GutterIconRenderer.Alignment alignment) {
  myIcon = icon;
  myTooltipProvider = tooltipProvider;
  myIconAlignment = alignment;
  elementRef = new WeakReference<T>(element);
  myNavigationHandler = navHandler;
  startOffset = range.getStartOffset();
  this.updatePass = updatePass;

  endOffset = range.getEndOffset();
}
项目:intellij-ce-playground    文件:XBreakpointUtil.java   
@NotNull
public static Pair<GutterIconRenderer, Object> findSelectedBreakpoint(@NotNull final Project project, @NotNull final Editor editor) {
  int offset = editor.getCaretModel().getOffset();
  Document editorDocument = editor.getDocument();

  DebuggerSupport[] debuggerSupports = DebuggerSupport.getDebuggerSupports();
  for (DebuggerSupport debuggerSupport : debuggerSupports) {
    final BreakpointPanelProvider<?> provider = debuggerSupport.getBreakpointPanelProvider();

    final int textLength = editor.getDocument().getTextLength();
    if (offset > textLength) {
      offset = textLength;
    }

    Object breakpoint = provider.findBreakpoint(project, editorDocument, offset);
    if (breakpoint != null) {
      final GutterIconRenderer iconRenderer = provider.getBreakpointGutterIconRenderer(breakpoint);
      return Pair.create(iconRenderer, breakpoint);
    }
  }
  return Pair.create(null, null);
}
项目:intellij-ce-playground    文件:LineMarkersPass.java   
@NotNull
public static LineMarkerInfo createMethodSeparatorLineMarker(@NotNull PsiElement startFrom, @NotNull EditorColorsManager colorsManager) {
  LineMarkerInfo info = new LineMarkerInfo<PsiElement>(
    startFrom, 
    startFrom.getTextRange(), 
    null, 
    Pass.UPDATE_ALL, 
    FunctionUtil.<Object, String>nullConstant(),
    null, 
    GutterIconRenderer.Alignment.RIGHT
  );
  EditorColorsScheme scheme = colorsManager.getGlobalScheme();
  info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
  info.separatorPlacement = SeparatorPlacement.TOP;
  return info;
}
项目:idea-php-laravel-plugin    文件:TemplateLineMarker.java   
@NotNull
private LineMarkerInfo getRelatedPopover(@NotNull String singleItemTitle, @NotNull String singleItemTooltipPrefix, @NotNull PsiElement lineMarkerTarget, @NotNull Collection<GotoRelatedItem> gotoRelatedItems, @NotNull Icon icon) {
    // single item has no popup
    String title = singleItemTitle;
    if(gotoRelatedItems.size() == 1) {
        String customName = gotoRelatedItems.iterator().next().getCustomName();
        if(customName != null) {
            title = String.format(singleItemTooltipPrefix, customName);
        }
    }

    return new LineMarkerInfo<>(
        lineMarkerTarget,
        lineMarkerTarget.getTextRange(),
        icon,
        6,
        new ConstantFunction<>(title),
        new RelatedPopupGotoLineMarker.NavigationHandler(gotoRelatedItems),
        GutterIconRenderer.Alignment.RIGHT
    );
}
项目:idea-php-shopware-plugin    文件:SmartyTemplateLineMarkerProvider.java   
private LineMarkerInfo getRelatedPopover(String singleItemTitle, String singleItemTooltipPrefix, PsiElement lineMarkerTarget, List<GotoRelatedItem> gotoRelatedItems) {

        // single item has no popup
        String title = singleItemTitle;
        if(gotoRelatedItems.size() == 1) {
            String customName = gotoRelatedItems.get(0).getCustomName();
            if(customName != null) {
                title = String.format(singleItemTooltipPrefix, customName);
            }
        }

        return new LineMarkerInfo<>(
            lineMarkerTarget,
            lineMarkerTarget.getTextRange(),
            ShopwarePluginIcons.SHOPWARE_LINEMARKER,
            6,
            new ConstantFunction<>(title),
            new fr.adrienbrault.idea.symfony2plugin.dic.RelatedPopupGotoLineMarker.NavigationHandler(gotoRelatedItems),
            GutterIconRenderer.Alignment.RIGHT
        );
    }
项目:consulo-unity3d    文件:UnityEventCSharpMethodLineMarkerProvider.java   
@Nullable
@RequiredReadAction
private static LineMarkerInfo createMarker(final PsiElement element)
{
    CSharpMethodDeclaration methodDeclaration = CSharpLineMarkerUtil.getNameIdentifierAs(element, CSharpMethodDeclaration.class);
    if(methodDeclaration != null)
    {
        Unity3dModuleExtension extension = ModuleUtilCore.getExtension(element, Unity3dModuleExtension.class);
        if(extension == null)
        {
            return null;
        }

        UnityFunctionManager.FunctionInfo magicMethod = findMagicMethod(methodDeclaration);
        if(magicMethod != null)
        {
            return new LineMarkerInfo<>(element, element.getTextRange(), Unity3dIcons.EventMethod, Pass.LINE_MARKERS, new ConstantFunction<>(magicMethod.getDescription()), null,
                    GutterIconRenderer.Alignment.LEFT);
        }
    }

    return null;
}
项目:tools-idea    文件:JavaLineMarkerProvider.java   
private static void collectInheritingClasses(PsiClass aClass, Collection<LineMarkerInfo> result) {
  if (aClass.hasModifierProperty(PsiModifier.FINAL)) {
    return;
  }
  if (CommonClassNames.JAVA_LANG_OBJECT.equals(aClass.getQualifiedName())) return; // It's useless to have overridden markers for object.

  PsiClass inheritor = ClassInheritorsSearch.search(aClass, false).findFirst();
  if (inheritor != null) {
    final Icon icon = aClass.isInterface() ? AllIcons.Gutter.ImplementedMethod : AllIcons.Gutter.OverridenMethod;
    PsiElement range = aClass.getNameIdentifier();
    if (range == null) range = aClass;
    MarkerType type = MarkerType.SUBCLASSED_CLASS;
    LineMarkerInfo info = new LineMarkerInfo<PsiElement>(range, range.getTextRange(),
                                                         icon, Pass.UPDATE_OVERRIDEN_MARKERS, type.getTooltip(),
                                                         type.getNavigationHandler(),
                                                         GutterIconRenderer.Alignment.RIGHT);
    result.add(info);
  }
}
项目:tools-idea    文件:LineMarkerInfo.java   
public LineMarkerInfo(@NotNull T element,
                      @NotNull TextRange range,
                      Icon icon,
                      int updatePass,
                      @Nullable Function<? super T, String> tooltipProvider,
                      @Nullable GutterIconNavigationHandler<T> navHandler,
                      GutterIconRenderer.Alignment alignment) {
  myIcon = icon;
  myTooltipProvider = tooltipProvider;
  myIconAlignment = alignment;
  elementRef = new WeakReference<T>(element);
  myNavigationHandler = navHandler;
  startOffset = range.getStartOffset();
  this.updatePass = updatePass;

  endOffset = range.getEndOffset();
}
项目:tools-idea    文件:XBreakpointUtil.java   
@NotNull
public static Pair<GutterIconRenderer, Object> findSelectedBreakpoint(@NotNull final Project project, @NotNull final Editor editor) {
  int offset = editor.getCaretModel().getOffset();
  Document editorDocument = editor.getDocument();

  DebuggerSupport[] debuggerSupports = DebuggerSupport.getDebuggerSupports();
  for (DebuggerSupport debuggerSupport : debuggerSupports) {
    final BreakpointPanelProvider<?> provider = debuggerSupport.getBreakpointPanelProvider();

    final int textLength = editor.getDocument().getTextLength();
    if (offset > textLength) {
      offset = textLength;
    }

    Object breakpoint = provider.findBreakpoint(project, editorDocument, offset);
    if (breakpoint != null) {
      final GutterIconRenderer iconRenderer = provider.getBreakpointGutterIconRenderer(breakpoint);
      return Pair.create(iconRenderer, breakpoint);
    }
  }
  return Pair.create(null, null);
}
项目:tools-idea    文件:LineMarkersPass.java   
@NotNull
public static LineMarkerInfo createMethodSeparatorLineMarker(@NotNull PsiElement startFrom, @NotNull EditorColorsManager colorsManager) {
  LineMarkerInfo info = new LineMarkerInfo<PsiElement>(
    startFrom, 
    startFrom.getTextRange(), 
    null, 
    Pass.UPDATE_ALL, 
    FunctionUtil.<Object, String>nullConstant(),
    null, 
    GutterIconRenderer.Alignment.RIGHT
  );
  EditorColorsScheme scheme = colorsManager.getGlobalScheme();
  info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
  info.separatorPlacement = SeparatorPlacement.TOP;
  return info;
}
项目:consulo-csharp    文件:RecursiveCallCollector.java   
@RequiredReadAction
@Override
public void collect(PsiElement psiElement, @NotNull Consumer<LineMarkerInfo> consumer)
{
    if(psiElement.getNode().getElementType() == CSharpTokens.IDENTIFIER && psiElement.getParent() instanceof CSharpReferenceExpression &&
            psiElement.getParent().getParent() instanceof CSharpMethodCallExpressionImpl)
    {
        PsiElement resolvedElement = ((CSharpReferenceExpression) psiElement.getParent()).resolve();
        if(resolvedElement instanceof CSharpMethodDeclaration)
        {
            CSharpMethodDeclaration methodDeclaration = PsiTreeUtil.getParentOfType(psiElement, CSharpMethodDeclaration.class);
            if(resolvedElement.isEquivalentTo(methodDeclaration))
            {
                LineMarkerInfo<PsiElement> lineMarkerInfo = new LineMarkerInfo<PsiElement>(psiElement, psiElement.getTextRange(), AllIcons.Gutter.RecursiveMethod, Pass.LINE_MARKERS,
                        FunctionUtil.constant("Recursive call"), null, GutterIconRenderer.Alignment.CENTER);
                consumer.consume(lineMarkerInfo);
            }
        }
    }
}
项目:consulo-lua    文件:LuaMethodSeparatorMarkerProvider.java   
@RequiredReadAction
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element)
{
    if(myDaemonSettings.SHOW_METHOD_SEPARATORS)
    {
        if(element instanceof LuaDocComment)
        {
            LuaDocCommentOwner owner = ((LuaDocComment) element).getOwner();

            if(owner instanceof LuaFunctionDefinition)
            {
                TextRange range = new TextRange(element.getTextOffset(), owner.getTextRange().getEndOffset());
                LineMarkerInfo<PsiElement> info = new LineMarkerInfo<>(element, range, null, Pass.UPDATE_ALL, NullableFunction.NULL, null, GutterIconRenderer.Alignment.RIGHT);
                EditorColorsScheme scheme = myColorsManager.getGlobalScheme();
                info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
                info.separatorPlacement = SeparatorPlacement.TOP;
                return info;
            }
        }
    }
    return null;
}
项目:idea-php-symfony2-plugin    文件:TwigLineMarkerProvider.java   
private LineMarkerInfo getRelatedPopover(String singleItemTitle, String singleItemTooltipPrefix, PsiElement lineMarkerTarget, List<GotoRelatedItem> gotoRelatedItems, Icon icon) {

        // single item has no popup
        String title = singleItemTitle;
        if(gotoRelatedItems.size() == 1) {
            String customName = gotoRelatedItems.get(0).getCustomName();
            if(customName != null) {
                title = String.format(singleItemTooltipPrefix, customName);
            }
        }

        return new LineMarkerInfo<>(
            lineMarkerTarget,
            lineMarkerTarget.getTextRange(),
            icon,
            6,
            new ConstantFunction<>(title),
            new RelatedPopupGotoLineMarker.NavigationHandler(gotoRelatedItems),
            GutterIconRenderer.Alignment.RIGHT
        );
    }
项目:intellij-plugin-v4    文件:ANTLRv4LineMarkerProvider.java   
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
    final GutterIconNavigationHandler<PsiElement> navHandler =
        new GutterIconNavigationHandler<PsiElement>() {
            @Override
            public void navigate(MouseEvent e, PsiElement elt) {
                System.out.println("don't click on me");
            }
        };
    if ( element instanceof RuleSpecNode ) {
        return new LineMarkerInfo<PsiElement>(element, element.getTextRange(), Icons.FILE,
                                              Pass.UPDATE_ALL, null, navHandler,
                                              GutterIconRenderer.Alignment.LEFT);
    }
    return null;
}
项目:DeftIDEA    文件:DylanLineMarkerProvider.java   
@Override
@Nullable
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
  if (myDaemonSettings.SHOW_METHOD_SEPARATORS) {
    if (element instanceof DylanDefinition) {
      LineMarkerInfo info = new LineMarkerInfo<PsiElement>(element, element.getTextRange(), null, Pass.UPDATE_ALL,
                                                           FunctionUtil.<Object, String>nullConstant(), null,
                                                           GutterIconRenderer.Alignment.RIGHT);
      EditorColorsScheme scheme = myColorsManager.getGlobalScheme();
      info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
      info.separatorPlacement = SeparatorPlacement.BOTTOM;
      return info;
    }
  }
  return null;
}
项目:consulo    文件:UnifiedDiffChange.java   
@Nullable
private GutterIconRenderer createIconRenderer(@Nonnull final Side sourceSide,
                                              @Nonnull final String tooltipText,
                                              @Nonnull final Icon icon) {
  return new DiffGutterRenderer(icon, tooltipText) {
    @Override
    protected void performAction(AnActionEvent e) {
      if (myViewer.isStateIsOutOfDate()) return;
      if (!myViewer.isEditable(sourceSide.other(), true)) return;

      final Project project = e.getProject();
      final Document document = myViewer.getDocument(sourceSide.other());

      DiffUtil.executeWriteCommand(document, project, "Replace change", () -> {
        myViewer.replaceChange(UnifiedDiffChange.this, sourceSide);
        myViewer.scheduleRediff();
      });
      // applyChange() will schedule rediff, but we want to try to do it in sync
      // and we can't do it inside write action
      myViewer.rediff();
    }
  };
}
项目:consulo    文件:SimpleDiffChange.java   
@javax.annotation.Nullable
public GutterIconRenderer createRenderer() {
  myCtrlPressed = myViewer.getModifierProvider().isCtrlPressed();

  boolean isOtherEditable = DiffUtil.isEditable(myViewer.getEditor(mySide.other()));
  boolean isAppendable = myFragment.getStartLine1() != myFragment.getEndLine1() &&
                         myFragment.getStartLine2() != myFragment.getEndLine2();

  if (isOtherEditable) {
    if (myCtrlPressed && isAppendable) {
      return createAppendRenderer(mySide);
    }
    else {
      return createApplyRenderer(mySide);
    }
  }
  return null;
}
项目:consulo    文件:SimpleDiffChange.java   
@javax.annotation.Nullable
private GutterIconRenderer createIconRenderer(@Nonnull final Side sourceSide,
                                              @Nonnull final String tooltipText,
                                              @Nonnull final Icon icon,
                                              @Nonnull final Runnable perform) {
  if (!DiffUtil.isEditable(myViewer.getEditor(sourceSide.other()))) return null;
  return new DiffGutterRenderer(icon, tooltipText) {
    @Override
    protected void performAction(AnActionEvent e) {
      if (!myIsValid) return;
      final Project project = e.getProject();
      final Document document = myViewer.getEditor(sourceSide.other()).getDocument();
      DiffUtil.executeWriteCommand(document, project, "Replace change", perform);
    }
  };
}
项目:consulo    文件:LineMarkerInfo.java   
/**
 * Creates a line marker info for the element.
 * @param element         the element for which the line marker is created.
 * @param range     the range (relative to beginning of file) with which the marker is associated
 * @param icon            the icon to show in the gutter for the line marker
 * @param updatePass      the ID of the daemon pass during which the marker should be recalculated
 * @param tooltipProvider the callback to calculate the tooltip for the gutter icon
 * @param navHandler      the handler executed when the gutter icon is clicked
 */
public LineMarkerInfo(@Nonnull T element,
                      @Nonnull TextRange range,
                      Icon icon,
                      int updatePass,
                      @Nullable Function<? super T, String> tooltipProvider,
                      @Nullable GutterIconNavigationHandler<T> navHandler,
                      @Nonnull GutterIconRenderer.Alignment alignment) {
  myIcon = icon;
  myTooltipProvider = tooltipProvider;
  myIconAlignment = alignment;
  elementRef = SmartPointerManager.getInstance(element.getProject()).createSmartPsiElementPointer(element);
  myNavigationHandler = navHandler;
  startOffset = range.getStartOffset();
  endOffset = range.getEndOffset();
  this.updatePass = 11; //Pass.LINE_MARKERS;
}
项目:consulo    文件:XBreakpointUtil.java   
@Nonnull
public static Pair<GutterIconRenderer, Object> findSelectedBreakpoint(@Nonnull final Project project, @Nonnull final Editor editor) {
  int offset = editor.getCaretModel().getOffset();
  Document editorDocument = editor.getDocument();

  DebuggerSupport[] debuggerSupports = DebuggerSupport.getDebuggerSupports();
  for (DebuggerSupport debuggerSupport : debuggerSupports) {
    final BreakpointPanelProvider<?> provider = debuggerSupport.getBreakpointPanelProvider();

    final int textLength = editor.getDocument().getTextLength();
    if (offset > textLength) {
      offset = textLength;
    }

    Object breakpoint = provider.findBreakpoint(project, editorDocument, offset);
    if (breakpoint != null) {
      final GutterIconRenderer iconRenderer = provider.getBreakpointGutterIconRenderer(breakpoint);
      return Pair.create(iconRenderer, breakpoint);
    }
  }
  return Pair.create(null, null);
}
项目:consulo    文件:LineMarkersPass.java   
@Nonnull
public static LineMarkerInfo createMethodSeparatorLineMarker(@Nonnull PsiElement startFrom, @Nonnull EditorColorsManager colorsManager) {
  LineMarkerInfo info = new LineMarkerInfo<>(
          startFrom,
          startFrom.getTextRange(),
          null,
          Pass.LINE_MARKERS,
          FunctionUtil.<Object, String>nullConstant(),
          null,
          GutterIconRenderer.Alignment.RIGHT
  );
  EditorColorsScheme scheme = colorsManager.getGlobalScheme();
  info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
  info.separatorPlacement = SeparatorPlacement.TOP;
  return info;
}
项目:consulo    文件:GutterIntentionAction.java   
private static void addActions(@Nonnull Project project,
                               @Nonnull RangeHighlighterEx info,
                               @Nonnull List<HighlightInfo.IntentionActionDescriptor> descriptors,
                               @Nonnull AnActionEvent event) {
  final GutterIconRenderer r = info.getGutterIconRenderer();
  if (r == null || DumbService.isDumb(project) && !DumbService.isDumbAware(r)) {
    return;
  }
  List<HighlightInfo.IntentionActionDescriptor> list = new ArrayList<>();
  for (AnAction action : ar(r.getClickAction(), r.getMiddleButtonClickAction(), r.getRightButtonClickAction(), r.getPopupMenuActions())) {
    if (action != null) {
      addActions(action, list, r, 0, event);
    }
  }

  if (list.isEmpty()) return;
  if (list.size() == 1) {
    descriptors.addAll(list);
  }
  else {
    HighlightInfo.IntentionActionDescriptor first = list.get(0);
    List<IntentionAction> options = ContainerUtil.map(list.subList(1, list.size()), HighlightInfo.IntentionActionDescriptor::getAction);
    descriptors.add(new HighlightInfo.IntentionActionDescriptor(first.getAction(), options, null, first.getIcon()));
  }
}
项目:consulo    文件:GutterIntentionAction.java   
private static void addActions(@Nonnull AnAction action,
                               @Nonnull List<HighlightInfo.IntentionActionDescriptor> descriptors,
                               @Nonnull GutterIconRenderer renderer,
                               int order,
                               @Nonnull AnActionEvent event) {
  if (action instanceof ActionGroup) {
    AnAction[] children = ((ActionGroup)action).getChildren(null);
    for (int i = 0; i < children.length; i++) {
      addActions(children[i], descriptors, renderer, i + order, event);
    }
  }
  Icon icon = action.getTemplatePresentation().getIcon();
  if (icon == null) icon = renderer.getIcon();
  if (icon.getIconWidth() < 16) icon = IconUtil.toSize(icon, 16, 16);
  final GutterIntentionAction gutterAction = new GutterIntentionAction(action, order, icon);
  if (!gutterAction.isAvailable(event)) return;
  descriptors.add(new HighlightInfo.IntentionActionDescriptor(gutterAction, Collections.emptyList(), null, icon) {
    @Nullable
    @Override
    public String getDisplayName() {
      return gutterAction.getText();
    }
  });
}
项目:consulo-java    文件:IconLineMarkerProvider.java   
@Nullable
private static LineMarkerInfo<PsiElement> createIconLineMarker(PsiType type, @Nullable PsiExpression initializer, PsiElement bindingElement)
{
    if(initializer == null)
    {
        return null;
    }

    final Project project = initializer.getProject();

    final VirtualFile file = ProjectIconsAccessor.getInstance(project).resolveIconFile(type, initializer);
    if(file == null)
    {
        return null;
    }

    final Icon icon = ProjectIconsAccessor.getInstance(project).getIcon(file, initializer);
    if(icon == null)
    {
        return null;
    }

    final GutterIconNavigationHandler<PsiElement> navHandler = (e, elt) -> FileEditorManager.getInstance(project).openFile(file, true);

    return new LineMarkerInfo<>(bindingElement, bindingElement.getTextRange(), icon, Pass.UPDATE_ALL, null, navHandler, GutterIconRenderer.Alignment.LEFT);
}
项目:consulo-java    文件:RecursiveCallLineMarkerProvider.java   
@Override
public GutterIconRenderer createGutterRenderer()
{
    if(myIcon == null)
    {
        return null;
    }
    return new LineMarkerGutterIconRenderer<PsiMethodCallExpression>(this)
    {
        @Override
        public AnAction getClickAction()
        {
            return null; // to place breakpoint on mouse click
        }
    };
}
项目:consulo-java    文件:ExternalAnnotationsLineMarkerProvider.java   
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element)
{
    PsiModifierListOwner owner = getAnnotationOwner(element);
    if(owner == null)
    {
        return null;
    }

    boolean includeSourceInferred = JavaCodeInsightSettings.getInstance().SHOW_SOURCE_INFERRED_ANNOTATIONS;
    boolean hasAnnotationsToShow = ContainerUtil.exists(NonCodeAnnotationGenerator.getSignatureNonCodeAnnotations(owner).values(), a -> includeSourceInferred || !a.isInferredFromSource());
    if(!hasAnnotationsToShow)
    {
        return null;
    }

    return new LineMarkerInfo<>(element, element.getTextRange(), JavaIcons.Gutter.ExtAnnotation, Pass.LINE_MARKERS, ourTooltipProvider, MyIconGutterHandler.INSTANCE, GutterIconRenderer.Alignment
            .RIGHT);
}
项目:consulo-java    文件:BreakpointManager.java   
public void editBreakpoint(final Breakpoint breakpoint, final Editor editor)
{
    DebuggerInvocationUtil.swingInvokeLater(myProject, new Runnable()
    {
        @Override
        public void run()
        {
            XBreakpoint xBreakpoint = breakpoint.myXBreakpoint;
            if(xBreakpoint instanceof XLineBreakpointImpl)
            {
                RangeHighlighter highlighter = ((XLineBreakpointImpl) xBreakpoint).getHighlighter();
                if(highlighter != null)
                {
                    GutterIconRenderer renderer = highlighter.getGutterIconRenderer();
                    if(renderer != null)
                    {
                        DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class).getEditBreakpointAction().editBreakpoint(myProject, editor, breakpoint.myXBreakpoint, renderer);
                    }
                }
            }
        }
    });
}
项目:idea-php-behat-plugin    文件:TestRunLineMarkerProvider.java   
@NotNull
private LineMarkerInfo<PsiElement> createLineMakerInfo(@NotNull PsiElement psiElement, @NotNull Icon icon) {
    return new LineMarkerInfo<>(
        psiElement,
        psiElement.getTextRange(),
        icon,
        6,
        new ConstantFunction<>("Run Test"),
        new MyProgramRunnerGutterIconNavigationHandler(),
        GutterIconRenderer.Alignment.LEFT
    );
}
项目:lua-for-idea    文件:LuaLineMarkerProvider.java   
@Override
public LineMarkerInfo getLineMarkerInfo(final PsiElement element) {
    if (element instanceof LuaReturnStatement && LuaApplicationSettings.getInstance().SHOW_TAIL_CALLS_IN_GUTTER) {
        LuaReturnStatement e = (LuaReturnStatement) element;

        if (e.isTailCall())
            return new LineMarkerInfo<PsiElement>(element, element.getTextRange(),
                    LuaIcons.TAIL_RECURSION, Pass.UPDATE_ALL,
                    tailCallTooltip, null,
                    GutterIconRenderer.Alignment.LEFT);
    }

    if (myDaemonSettings.SHOW_METHOD_SEPARATORS) {
        if (element instanceof LuaDocComment) {
            LuaDocCommentOwner owner = ((LuaDocComment) element).getOwner();

            if (owner instanceof LuaFunctionDefinition) {
                TextRange range = new TextRange(element.getTextOffset(), owner.getTextRange().getEndOffset());
                LineMarkerInfo<PsiElement> info =
                        new LineMarkerInfo<PsiElement>(element, range, null, Pass.UPDATE_ALL,
                                NullableFunction.NULL, null, GutterIconRenderer.Alignment.RIGHT);
                EditorColorsScheme scheme = myColorsManager.getGlobalScheme();
                info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
                info.separatorPlacement = SeparatorPlacement.TOP;
                return info;
            }
        }
    }

    return null;
}
项目:intellij-ce-playground    文件:JavaDebuggerSupport.java   
@Override
public GutterIconRenderer getBreakpointGutterIconRenderer(Object breakpoint) {
  //if (breakpoint instanceof BreakpointWithHighlighter) {
  //  final RangeHighlighter highlighter = ((BreakpointWithHighlighter)breakpoint).getHighlighter();
  //  if (highlighter != null) {
  //    return (GutterIconRenderer)highlighter.getGutterIconRenderer();
  //  }
  //}
  return null;
}
项目:intellij-ce-playground    文件:RecursiveCallLineMarkerProvider.java   
private RecursiveMethodCallMarkerInfo(@NotNull PsiMethodCallExpression methodCall) {
  super(methodCall,
        methodCall.getTextRange(),
        AllIcons.Gutter.RecursiveMethod,
        Pass.UPDATE_OVERRIDEN_MARKERS,
        FunctionUtil.<PsiMethodCallExpression, String>constant("Recursive call"),
        null,
        GutterIconRenderer.Alignment.RIGHT
  );
}
项目:intellij-ce-playground    文件:RecursiveCallLineMarkerProvider.java   
@Override
public GutterIconRenderer createGutterRenderer() {
  if (myIcon == null) return null;
  return new LineMarkerGutterIconRenderer<PsiMethodCallExpression>(this){
    @Override
    public AnAction getClickAction() {
      return null; // to place breakpoint on mouse click
    }
  };
}
项目:intellij-ce-playground    文件:ExternalAnnotationsLineMarkerProvider.java   
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) {
  PsiModifierListOwner owner = getAnnotationOwner(element);
  boolean includeSourceInferred = CodeInsightSettings.getInstance().SHOW_SOURCE_INFERRED_ANNOTATIONS;
  if (owner == null || findSignatureNonCodeAnnotations(owner, includeSourceInferred).isEmpty()) {
    return null;
  }

  return new LineMarkerInfo<PsiElement>(element, element.getTextRange().getStartOffset(),
                                        AllIcons.Gutter.ExtAnnotation,
                                        Pass.UPDATE_ALL,
                                        ourTooltipProvider, MyIconGutterHandler.INSTANCE,
                                        GutterIconRenderer.Alignment.RIGHT);
}
项目:intellij-ce-playground    文件:ExpectedHighlightingData.java   
private void refreshLineMarkers() {
  for (Map.Entry<RangeMarker, LineMarkerInfo> entry : lineMarkerInfos.entrySet()) {
    RangeMarker rangeMarker = entry.getKey();
    int startOffset = rangeMarker.getStartOffset();
    int endOffset = rangeMarker.getEndOffset();
    final LineMarkerInfo value = entry.getValue();
    LineMarkerInfo markerInfo = new LineMarkerInfo<PsiElement>(value.getElement(), new TextRange(startOffset,endOffset), null, value.updatePass, new Function<PsiElement,String>() {
      @Override
      public String fun(PsiElement psiElement) {
        return value.getLineMarkerTooltip();
      }
    }, null, GutterIconRenderer.Alignment.RIGHT);
    entry.setValue(markerInfo);
  }
}
项目:intellij-ce-playground    文件:ExpectedHighlightingData.java   
private void extractExpectedLineMarkerSet(Document document) {
  String text = document.getText();

  @NonNls String pat = ".*?((<" + LINE_MARKER + ")(?: descr=\"((?:[^\"\\\\]|\\\\\")*)\")?>)(.*)";
  final Pattern p = Pattern.compile(pat, Pattern.DOTALL);
  final Pattern pat2 = Pattern.compile("(.*?)(</" + LINE_MARKER + ">)(.*)", Pattern.DOTALL);

  while (true) {
    Matcher m = p.matcher(text);
    if (!m.matches()) break;
    int startOffset = m.start(1);
    final String descr = m.group(3) != null ? m.group(3) : ANY_TEXT;
    String rest = m.group(4);

    document.replaceString(startOffset, m.end(1), "");

    final Matcher matcher2 = pat2.matcher(rest);
    LOG.assertTrue(matcher2.matches(), "Cannot find closing </" + LINE_MARKER + ">");
    String content = matcher2.group(1);
    int endOffset = startOffset + matcher2.start(3);
    String endTag = matcher2.group(2);

    document.replaceString(startOffset, endOffset, content);
    endOffset -= endTag.length();

    LineMarkerInfo markerInfo = new LineMarkerInfo<PsiElement>(myFile, new TextRange(startOffset, endOffset), null, Pass.LINE_MARKERS,
                                                               new ConstantFunction<PsiElement, String>(descr), null,
                                                               GutterIconRenderer.Alignment.RIGHT);

    lineMarkerInfos.put(document.createRangeMarker(startOffset, endOffset), markerInfo);
    text = document.getText();
  }
}
项目:intellij-ce-playground    文件:RelatedItemLineMarkerInfo.java   
public RelatedItemLineMarkerInfo(@NotNull T element, @NotNull TextRange range, Icon icon, int updatePass,
                                 @Nullable Function<? super T, String> tooltipProvider,
                                 @Nullable GutterIconNavigationHandler<T> navHandler,
                                 @NotNull GutterIconRenderer.Alignment alignment,
                                 @NotNull NotNullLazyValue<Collection<? extends GotoRelatedItem>> targets) {
  super(element, range, icon, updatePass, tooltipProvider, navHandler, alignment);
  myTargets = targets;
}