Search in sources :

Example 26 with LineMarkerInfo

use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-plugins by JetBrains.

the class DartServerImplementationsMarkerProvider method createMarkerClass.

@NotNull
private static LineMarkerInfo createMarkerClass(@NotNull final DartComponentName name) {
    final VirtualFile file = name.getContainingFile().getVirtualFile();
    final int nameOffset = name.getTextRange().getStartOffset();
    return new LineMarkerInfo<>(name, name.getTextRange(), AllIcons.Gutter.OverridenMethod, Pass.LINE_MARKERS, element -> DaemonBundle.message("class.is.subclassed.too.many"), (GutterIconNavigationHandler<PsiElement>) (e, elt) -> {
        final List<TypeHierarchyItem> items = DartAnalysisServerService.getInstance(name.getProject()).search_getTypeHierarchy(file, nameOffset, false);
        if (items.isEmpty()) {
            return;
        }
        final List<DartComponent> components = DartInheritorsSearcher.getSubClasses(name.getProject(), GlobalSearchScope.allScope(name.getProject()), items);
        PsiElementListNavigator.openTargets(e, DartResolveUtil.getComponentNameArray(components), DaemonBundle.message("navigation.title.subclass", name.getName(), components.size(), ""), "Subclasses of " + name.getName(), new DefaultPsiElementCellRenderer());
    }, GutterIconRenderer.Alignment.RIGHT);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DartResolveUtil(com.jetbrains.lang.dart.util.DartResolveUtil) AllIcons(com.intellij.icons.AllIcons) GutterIconRenderer(com.intellij.openapi.editor.markup.GutterIconRenderer) TypeHierarchyItem(org.dartlang.analysis.server.protocol.TypeHierarchyItem) DartInheritorsSearcher(com.jetbrains.lang.dart.ide.actions.DartInheritorsSearcher) VirtualFile(com.intellij.openapi.vfs.VirtualFile) DartAnalysisServerService(com.jetbrains.lang.dart.analyzer.DartAnalysisServerService) DartServerData(com.jetbrains.lang.dart.analyzer.DartServerData) PsiElementListNavigator(com.intellij.codeInsight.daemon.impl.PsiElementListNavigator) Collection(java.util.Collection) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) DartComponentName(com.jetbrains.lang.dart.psi.DartComponentName) DartComponent(com.jetbrains.lang.dart.psi.DartComponent) Pass(com.intellij.codeHighlighting.Pass) DefaultPsiElementCellRenderer(com.intellij.ide.util.DefaultPsiElementCellRenderer) Nullable(org.jetbrains.annotations.Nullable) DaemonBundle(com.intellij.codeInsight.daemon.DaemonBundle) List(java.util.List) GutterIconNavigationHandler(com.intellij.codeInsight.daemon.GutterIconNavigationHandler) PsiElement(com.intellij.psi.PsiElement) LineMarkerProvider(com.intellij.codeInsight.daemon.LineMarkerProvider) NotNull(org.jetbrains.annotations.NotNull) LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) DefaultPsiElementCellRenderer(com.intellij.ide.util.DefaultPsiElementCellRenderer) List(java.util.List) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 27 with LineMarkerInfo

use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-plugins by JetBrains.

the class FlashUIDesignerLineMarkerProvider method getLineMarkerInfo.

@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
    if (!(element instanceof XmlTag)) {
        return null;
    }
    final XmlTag tag = (XmlTag) element;
    final XmlFile psiFile = (XmlFile) tag.getContainingFile();
    if (psiFile.getRootTag() != tag || !DesignerApplicationManager.isApplicable(tag.getProject(), psiFile)) {
        return null;
    }
    //holder.createInfoAnnotation(textRange, null).setGutterIconRenderer(new MyRenderer());
    return new LineMarkerInfo<>(element, element.getTextRange(), PlatformIcons.UI_FORM_ICON, Pass.LINE_MARKERS, element1 -> FlashUIDesignerBundle.message("gutter.open"), new GutterIconNavigationHandler<PsiElement>() {

        @Override
        public void navigate(MouseEvent e, PsiElement elt) {
            DesignerApplicationManager.getInstance().openDocument(psiFile, false);
        }
    }, GutterIconRenderer.Alignment.LEFT);
}
Also used : LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) MouseEvent(java.awt.event.MouseEvent) XmlFile(com.intellij.psi.xml.XmlFile) PsiElement(com.intellij.psi.PsiElement) XmlTag(com.intellij.psi.xml.XmlTag)

Example 28 with LineMarkerInfo

use of com.intellij.codeInsight.daemon.LineMarkerInfo in project android by JetBrains.

the class AndroidGotoRelatedTest method doGetRelatedLineMarkers.

private List<LineMarkerInfo> doGetRelatedLineMarkers() {
    myFixture.doHighlighting();
    final List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(myFixture.getEditor().getDocument(), myFixture.getProject());
    final List<LineMarkerInfo> relatedMarkers = new ArrayList<>();
    for (LineMarkerInfo marker : markers) {
        if (marker.getNavigationHandler() instanceof AndroidLineMarkerProvider.MyNavigationHandler) {
            relatedMarkers.add(marker);
        }
    }
    return relatedMarkers;
}
Also used : LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo)

Example 29 with LineMarkerInfo

use of com.intellij.codeInsight.daemon.LineMarkerInfo in project android by JetBrains.

the class AndroidGotoRelatedTest method testSimpleClassToLayout.

public void testSimpleClassToLayout() throws Exception {
    createManifest();
    myFixture.copyFileToProject(BASE_PATH + "layout1.xml", "res/layout/layout.xml");
    final VirtualFile file = myFixture.copyFileToProject(BASE_PATH + "Class1.java", "src/p1/p2/Class1.java");
    doTestGotoRelatedFile(file, Collections.<VirtualFile>emptyList(), PsiFile.class);
    final List<LineMarkerInfo> markerInfos = doGetRelatedLineMarkers();
    assertEmpty(markerInfos);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo)

Example 30 with LineMarkerInfo

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

the class ExpectedHighlightingData method refreshLineMarkers.

private void refreshLineMarkers() {
    for (Map.Entry<RangeMarker, LineMarkerInfo> entry : myLineMarkerInfos.entrySet()) {
        RangeMarker rangeMarker = entry.getKey();
        int startOffset = rangeMarker.getStartOffset();
        int endOffset = rangeMarker.getEndOffset();
        LineMarkerInfo value = entry.getValue();
        PsiElement element = value.getElement();
        assert element != null : value;
        TextRange range = new TextRange(startOffset, endOffset);
        final String tooltip = value.getLineMarkerTooltip();
        LineMarkerInfo markerInfo = new LineMarkerInfo<>(element, range, null, value.updatePass, e -> tooltip, null, GutterIconRenderer.Alignment.RIGHT);
        entry.setValue(markerInfo);
    }
}
Also used : LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) RangeMarker(com.intellij.openapi.editor.RangeMarker) THashMap(gnu.trove.THashMap) PsiElement(com.intellij.psi.PsiElement)

Aggregations

LineMarkerInfo (com.intellij.codeInsight.daemon.LineMarkerInfo)42 PsiElement (com.intellij.psi.PsiElement)16 Nullable (org.jetbrains.annotations.Nullable)12 NotNull (org.jetbrains.annotations.NotNull)7 Pass (com.intellij.codeHighlighting.Pass)5 GutterIconNavigationHandler (com.intellij.codeInsight.daemon.GutterIconNavigationHandler)5 AllIcons (com.intellij.icons.AllIcons)5 Document (com.intellij.openapi.editor.Document)5 GutterIconRenderer (com.intellij.openapi.editor.markup.GutterIconRenderer)5 Collection (java.util.Collection)5 LineMarkerProvider (com.intellij.codeInsight.daemon.LineMarkerProvider)4 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)4 Project (com.intellij.openapi.project.Project)4 List (java.util.List)4 javax.swing (javax.swing)4 DaemonBundle (com.intellij.codeInsight.daemon.DaemonBundle)3 PsiElementListNavigator (com.intellij.codeInsight.daemon.impl.PsiElementListNavigator)3 DefaultPsiElementCellRenderer (com.intellij.ide.util.DefaultPsiElementCellRenderer)3 MarkupModelEx (com.intellij.openapi.editor.ex.MarkupModelEx)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3