Java Code Examples for com.intellij.codeInsight.daemon.impl.PsiElementListNavigator#openTargets()
The following examples show how to use
com.intellij.codeInsight.daemon.impl.PsiElementListNavigator#openTargets() .
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: CSharpLineMarkerUtil.java From consulo-csharp with Apache License 2.0 | 6 votes |
@RequiredReadAction public static void openTargets(@Nonnull Collection<? extends PsiElement> members, @Nonnull MouseEvent mouseEvent, @Nonnull String text, @Nonnull final Function<PsiElement, PsiElement> map) { NavigatablePsiElement[] navigatablePsiElements = members.toArray(new NavigatablePsiElement[members.size()]); ContainerUtil.sort(navigatablePsiElements, (o1, o2) -> { PsiElement map1 = map.fun(o1); PsiElement map2 = map.fun(o2); if(map1 instanceof PsiNamedElement && map2 instanceof PsiNamedElement) { return Comparing.compare(((PsiNamedElement) map1).getName(), ((PsiNamedElement) map2).getName()); } return 0; }); PsiElementListNavigator.openTargets(mouseEvent, navigatablePsiElements, text, text, new PsiMappedElementListCellRender(map)); }
Example 2
Source File: HaxeGotoSuperHandler.java From intellij-haxe with Apache License 2.0 | 6 votes |
private static void tryNavigateToSuperMethod(Editor editor, HaxeMethod methodDeclaration, List<HaxeNamedComponent> superItems) { final String methodName = methodDeclaration.getName(); if (methodName == null) { return; } final List<HaxeNamedComponent> filteredSuperItems = ContainerUtil.filter(superItems, new Condition<HaxeNamedComponent>() { @Override public boolean value(HaxeNamedComponent component) { return methodName.equals(component.getName()); } }); if (!filteredSuperItems.isEmpty()) { PsiElementListNavigator.openTargets(editor, HaxeResolveUtil.getComponentNames(filteredSuperItems) .toArray(new NavigatablePsiElement[filteredSuperItems.size()]), DaemonBundle.message("navigation.title.super.method", methodName), null, new DefaultPsiElementCellRenderer()); } }
Example 3
Source File: HaxeGotoSuperHandler.java From intellij-haxe with Apache License 2.0 | 5 votes |
@Override public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { final PsiElement at = file.findElementAt(editor.getCaretModel().getOffset()); final HaxeComponentName componentName = PsiTreeUtil.getParentOfType(at, HaxeComponentName.class); final HaxeClass haxeClass = PsiTreeUtil.getParentOfType(at, HaxeClass.class); final HaxeNamedComponent namedComponent = componentName == null ? haxeClass : (HaxeNamedComponent)componentName.getParent(); if (at == null || haxeClass == null || namedComponent == null) return; final List<HaxeClass> supers = HaxeResolveUtil.tyrResolveClassesByQName(haxeClass.getHaxeExtendsList()); supers.addAll(HaxeResolveUtil.tyrResolveClassesByQName(haxeClass.getHaxeImplementsList())); final List<HaxeNamedComponent> superItems = HaxeResolveUtil.findNamedSubComponents(false, supers.toArray(new HaxeClass[supers.size()])); final HaxeComponentType type = HaxeComponentType.typeOf(namedComponent); if (type == HaxeComponentType.METHOD) { final HaxeMethod methodDeclaration = (HaxeMethod)namedComponent; tryNavigateToSuperMethod(editor, methodDeclaration, superItems); } else if (!supers.isEmpty() && namedComponent instanceof HaxeClass) { PsiElementListNavigator.openTargets( editor, HaxeResolveUtil.getComponentNames(supers).toArray(new NavigatablePsiElement[supers.size()]), DaemonBundle.message("navigation.title.subclass", namedComponent.getName(), supers.size()), "Subclasses of " + namedComponent.getName(), new DefaultPsiElementCellRenderer() ); } }
Example 4
Source File: HaxeLineMarkerProvider.java From intellij-haxe with Apache License 2.0 | 5 votes |
@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 5
Source File: ThriftLineMarkerProvider.java From intellij-thrift with Apache License 2.0 | 5 votes |
@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 6
Source File: DefaultGutterIconNavigationHandler.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void navigate(MouseEvent e, T elt) { PsiElementListNavigator.openTargets(e, myReferences.toArray(new NavigatablePsiElement[myReferences.size()]), myTitle, null, createListCellRenderer()); }