com.intellij.codeInsight.daemon.GutterIconNavigationHandler Java Examples

The following examples show how to use com.intellij.codeInsight.daemon.GutterIconNavigationHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ANTLRv4LineMarkerProvider.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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;
}
 
Example #2
Source File: LambdaLineMarkerCollector.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
public MarkerInfo(@Nonnull PsiElement element,
		@Nonnull TextRange textRange,
		Image icon,
		int updatePass,
		@Nullable Function<? super PsiElement, String> tooltipProvider,
		@Nullable GutterIconNavigationHandler<PsiElement> navHandler,
		@Nonnull GutterIconRenderer.Alignment alignment)
{
	super(element, textRange, icon, updatePass, tooltipProvider, navHandler, alignment);
}
 
Example #3
Source File: HaxeLineMarkerProvider.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Nullable
private static LineMarkerInfo createImplementationMarker(final HaxeClass componentWithDeclarationList,
                                                         final List<HaxeClass> items) {
  final HaxeComponentName componentName = componentWithDeclarationList.getComponentName();
  if (componentName == null) {
    return null;
  }
  final PsiElement element = componentName.getIdentifier().getFirstChild();
  return new LineMarkerInfo<>(
    element,
    element.getTextRange(),
    componentWithDeclarationList instanceof HaxeInterfaceDeclaration
    ? AllIcons.Gutter.ImplementedMethod
    : AllIcons.Gutter.OverridenMethod,
    Pass.UPDATE_ALL,
    item -> DaemonBundle.message("method.is.implemented.too.many"),
    new GutterIconNavigationHandler<PsiElement>() {
      @Override
      public void navigate(MouseEvent e, PsiElement elt) {
        PsiElementListNavigator.openTargets(
          e, HaxeResolveUtil.getComponentNames(items).toArray(new NavigatablePsiElement[items.size()]),
          DaemonBundle.message("navigation.title.subclass", componentWithDeclarationList.getName(), items.size()),
          "Subclasses of " + componentWithDeclarationList.getName(),
          new DefaultPsiElementCellRenderer()
        );
      }
    },
    GutterIconRenderer.Alignment.RIGHT
  );
}
 
Example #4
Source File: ThriftLineMarkerProvider.java    From intellij-thrift with Apache License 2.0 5 votes vote down vote up
@Nullable
private LineMarkerInfo findImplementationsAndCreateMarker(final ThriftDefinitionName definitionName) {
  final List<NavigatablePsiElement> implementations = ThriftPsiUtil.findImplementations(definitionName);
  if (implementations.isEmpty()) {
    return null;
  }
  return new LineMarkerInfo<PsiElement>(
    definitionName,
    definitionName.getTextRange(),
    AllIcons.Gutter.ImplementedMethod,
    Pass.UPDATE_ALL,
    new Function<PsiElement, String>() {
      @Override
      public String fun(PsiElement element) {
        return DaemonBundle.message("interface.is.implemented.too.many");
      }
    },
    new GutterIconNavigationHandler<PsiElement>() {
      @Override
      public void navigate(MouseEvent e, PsiElement elt) {
        PsiElementListNavigator.openTargets(
          e,
          implementations.toArray(new NavigatablePsiElement[implementations.size()]),
          DaemonBundle.message("navigation.title.implementation.method", definitionName.getText(), implementations.size()),
          "Implementations of " + definitionName.getText(),
          new DefaultPsiElementCellRenderer()
        );
      }
    },
    GutterIconRenderer.Alignment.RIGHT
  );
}
 
Example #5
Source File: LambdaLineMarkerCollector.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@RequiredReadAction
@Override
public void collect(PsiElement psiElement, @Nonnull Consumer<LineMarkerInfo> lineMarkerInfos)
{
	IElementType elementType = PsiUtilCore.getElementType(psiElement);
	if(elementType == CSharpTokens.DARROW)
	{
		PsiElement parent = psiElement.getParent();
		if(!(parent instanceof CSharpLambdaExpressionImpl))
		{
			return;
		}

		MarkerInfo markerInfo = new MarkerInfo(parent, psiElement.getTextRange(), AllIcons.Gutter.ImplementingFunctional, Pass.UPDATE_ALL, new ConstantFunction<>("Navigate to lambda delegate"),
				new GutterIconNavigationHandler<PsiElement>()
		{
			@Override
			@RequiredUIAccess
			public void navigate(MouseEvent e, PsiElement elt)
			{
				if(!(elt instanceof CSharpLambdaExpressionImpl))
				{
					return;
				}
				CSharpLambdaResolveResult lambdaResolveResult = CSharpLambdaExpressionImplUtil.resolveLeftLambdaTypeRef(elt);
				if(lambdaResolveResult == null)
				{
					return;
				}

				PsiElement element = lambdaResolveResult.getElement();
				if(element instanceof Navigatable)
				{
					((Navigatable) element).navigate(true);
				}
			}
		}, GutterIconRenderer.Alignment.RIGHT);
		NavigateAction.setNavigateAction(markerInfo, "Navigate to lambda delegate", IdeActions.ACTION_GOTO_SUPER);
		lineMarkerInfos.consume(markerInfo);
	}
}