Search in sources :

Example 1 with RelatedItemLineMarkerProvider

use of com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider in project intellij-community by JetBrains.

the class RelatedItemLineMarkerGotoAdapter method getItems.

@NotNull
@Override
public List<? extends GotoRelatedItem> getItems(@NotNull PsiElement context) {
    List<PsiElement> parents = new ArrayList<>();
    PsiElement current = context;
    Set<Language> languages = new HashSet<>();
    while (current != null) {
        parents.add(current);
        languages.add(current.getLanguage());
        if (current instanceof PsiFile)
            break;
        current = current.getParent();
    }
    List<LineMarkerProvider> providers = new ArrayList<>();
    for (Language language : languages) {
        providers.addAll(LineMarkersPass.getMarkerProviders(language, context.getProject()));
    }
    List<GotoRelatedItem> items = new ArrayList<>();
    for (LineMarkerProvider provider : providers) {
        if (provider instanceof RelatedItemLineMarkerProvider) {
            List<RelatedItemLineMarkerInfo> markers = new ArrayList<>();
            RelatedItemLineMarkerProvider relatedItemLineMarkerProvider = (RelatedItemLineMarkerProvider) provider;
            for (PsiElement parent : parents) {
                ContainerUtil.addIfNotNull(markers, relatedItemLineMarkerProvider.getLineMarkerInfo(parent));
            }
            relatedItemLineMarkerProvider.collectNavigationMarkers(parents, markers, true);
            addItemsForMarkers(markers, items);
        }
    }
    return items;
}
Also used : RelatedItemLineMarkerProvider(com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider) LineMarkerProvider(com.intellij.codeInsight.daemon.LineMarkerProvider) RelatedItemLineMarkerInfo(com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo) Language(com.intellij.lang.Language) RelatedItemLineMarkerProvider(com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider) PsiFile(com.intellij.psi.PsiFile) GotoRelatedItem(com.intellij.navigation.GotoRelatedItem) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

LineMarkerProvider (com.intellij.codeInsight.daemon.LineMarkerProvider)1 RelatedItemLineMarkerInfo (com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo)1 RelatedItemLineMarkerProvider (com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider)1 Language (com.intellij.lang.Language)1 GotoRelatedItem (com.intellij.navigation.GotoRelatedItem)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 NotNull (org.jetbrains.annotations.NotNull)1