Search in sources :

Example 1 with GotoRelatedProvider

use of com.intellij.navigation.GotoRelatedProvider in project intellij-community by JetBrains.

the class NavigationUtil method collectRelatedItems.

@NotNull
public static List<GotoRelatedItem> collectRelatedItems(@NotNull PsiElement contextElement, @Nullable DataContext dataContext) {
    Set<GotoRelatedItem> items = ContainerUtil.newLinkedHashSet();
    for (GotoRelatedProvider provider : Extensions.getExtensions(GotoRelatedProvider.EP_NAME)) {
        items.addAll(provider.getItems(contextElement));
        if (dataContext != null) {
            items.addAll(provider.getItems(dataContext));
        }
    }
    GotoRelatedItem[] result = items.toArray(new GotoRelatedItem[items.size()]);
    Arrays.sort(result, (i1, i2) -> {
        String o1 = i1.getGroup();
        String o2 = i2.getGroup();
        return StringUtil.isEmpty(o1) ? 1 : StringUtil.isEmpty(o2) ? -1 : o1.compareTo(o2);
    });
    return Arrays.asList(result);
}
Also used : GotoRelatedProvider(com.intellij.navigation.GotoRelatedProvider) GotoRelatedItem(com.intellij.navigation.GotoRelatedItem) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GotoRelatedItem (com.intellij.navigation.GotoRelatedItem)1 GotoRelatedProvider (com.intellij.navigation.GotoRelatedProvider)1 NotNull (org.jetbrains.annotations.NotNull)1