Search in sources :

Example 1 with LineMarkerProvider

use of com.intellij.codeInsight.daemon.LineMarkerProvider 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)

Example 2 with LineMarkerProvider

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

the class HtmlLineMarkerProvider method collectSlowLineMarkers.

@Override
public void collectSlowLineMarkers(@NotNull final List<PsiElement> elements, @NotNull final Collection<LineMarkerInfo> result) {
    Map<Language, LineMarkerProvider> localEmbeddedLanguagesLineMarkerProviders = null;
    Map<LineMarkerProvider, List<PsiElement>> embeddedLineMarkersWorkItems = null;
    for (PsiElement element : elements) {
        if (element instanceof PsiWhiteSpace)
            continue;
        final Language language = element.getLanguage();
        if (!(language instanceof XMLLanguage)) {
            if (localEmbeddedLanguagesLineMarkerProviders == null) {
                localEmbeddedLanguagesLineMarkerProviders = new THashMap<>();
            }
            final LineMarkerProvider lineMarkerProvider = getLineMarkerProviderFromLanguage(language, localEmbeddedLanguagesLineMarkerProviders);
            if (lineMarkerProvider != null) {
                if (embeddedLineMarkersWorkItems == null)
                    embeddedLineMarkersWorkItems = new THashMap<>();
                List<PsiElement> elementList = embeddedLineMarkersWorkItems.get(lineMarkerProvider);
                if (elementList == null) {
                    elementList = new ArrayList<>(5);
                    embeddedLineMarkersWorkItems.put(lineMarkerProvider, elementList);
                }
                elementList.add(element);
            }
        }
    }
    if (embeddedLineMarkersWorkItems != null) {
        for (Map.Entry<LineMarkerProvider, List<PsiElement>> entry : embeddedLineMarkersWorkItems.entrySet()) {
            entry.getKey().collectSlowLineMarkers(entry.getValue(), result);
        }
    }
}
Also used : LineMarkerProvider(com.intellij.codeInsight.daemon.LineMarkerProvider) Language(com.intellij.lang.Language) XMLLanguage(com.intellij.lang.xml.XMLLanguage) THashMap(gnu.trove.THashMap) ArrayList(java.util.ArrayList) List(java.util.List) XMLLanguage(com.intellij.lang.xml.XMLLanguage) THashMap(gnu.trove.THashMap) Map(java.util.Map) PsiElement(com.intellij.psi.PsiElement) PsiWhiteSpace(com.intellij.psi.PsiWhiteSpace)

Aggregations

LineMarkerProvider (com.intellij.codeInsight.daemon.LineMarkerProvider)2 Language (com.intellij.lang.Language)2 PsiElement (com.intellij.psi.PsiElement)2 RelatedItemLineMarkerInfo (com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo)1 RelatedItemLineMarkerProvider (com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider)1 XMLLanguage (com.intellij.lang.xml.XMLLanguage)1 GotoRelatedItem (com.intellij.navigation.GotoRelatedItem)1 PsiFile (com.intellij.psi.PsiFile)1 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)1 THashMap (gnu.trove.THashMap)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 NotNull (org.jetbrains.annotations.NotNull)1