Java Code Examples for com.intellij.codeInsight.daemon.LineMarkerInfo#LineMarkerGutterIconRenderer
The following examples show how to use
com.intellij.codeInsight.daemon.LineMarkerInfo#LineMarkerGutterIconRenderer .
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: JavaCamelRouteLineMarkerProviderTestIT.java From camel-idea-plugin with Apache License 2.0 | 6 votes |
public void testCamelGutterForVariableAndConstant() { myFixture.configureByFiles("JavaCamelRouteLineMarkerProviderFromVariableTestData.java"); List<GutterMark> gutters = myFixture.findAllGutters(); assertNotNull(gutters); //remove first element since it is navigate to super implementation gutter icon gutters.remove(0); assertEquals("Should contain 2 Camel gutters", 2, gutters.size()); assertGuttersHasCamelIcon(gutters); LineMarkerInfo.LineMarkerGutterIconRenderer firstGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(0); assertTrue(firstGutter.getLineMarkerInfo().getElement() instanceof PsiIdentifier); assertEquals("The navigation start element doesn't match", "uriVar", firstGutter.getLineMarkerInfo().getElement().getText()); List<GotoRelatedItem> firstGutterTargets = GutterTestUtil.getGutterNavigationDestinationElements(firstGutter); assertEquals("Navigation should have two targets", 2, firstGutterTargets.size()); }
Example 2
Source File: JavaCamelRouteLineMarkerProviderTestIT.java From camel-idea-plugin with Apache License 2.0 | 6 votes |
public void testCamelGutterForMethodCallFrom() { myFixture.configureByFiles("JavaCamelRouteLineMarkerProviderFromMethodCallTestData.java"); List<GutterMark> gutters = myFixture.findAllGutters(); assertNotNull(gutters); //remove first element since it is navigate to super implementation gutter icon gutters.remove(0); // remove last element since it is from method returning route uri gutters.remove(gutters.size() - 1); assertEquals("Should contain 1 Camel gutters", 1, gutters.size()); assertGuttersHasCamelIcon(gutters); LineMarkerInfo.LineMarkerGutterIconRenderer firstGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(0); assertTrue(firstGutter.getLineMarkerInfo().getElement() instanceof PsiIdentifier); assertEquals("The navigation start element doesn't match", "calcEndpoint", firstGutter.getLineMarkerInfo().getElement().getText()); List<GotoRelatedItem> firstGutterTargets = GutterTestUtil.getGutterNavigationDestinationElements(firstGutter); assertEquals("Navigation should have two targets", 2, firstGutterTargets.size()); assertEquals("The navigation variable target element doesn't match", "calcEndpoint", GutterTestUtil.getGuttersWithMethodTarget(firstGutterTargets).get(0).getName()); }
Example 3
Source File: XmlCamelRouteLineMarkerProviderTestIT.java From camel-idea-plugin with Apache License 2.0 | 6 votes |
public void testCamelGutterForToD() { myFixture.configureByFiles("XmlCamelRouteLineMarkerProviderToDTestData.xml"); List<GutterMark> gutters = myFixture.findAllGutters(); assertNotNull(gutters); assertEquals("Should contain 1 Camel gutter", 1, gutters.size()); assertSame("Gutter should have the Camel icon", ServiceManager.getService(CamelPreferenceService.class).getCamelIcon(), gutters.get(0).getIcon()); assertEquals("Camel route", gutters.get(0).getTooltipText()); LineMarkerInfo.LineMarkerGutterIconRenderer gutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(0); assertTrue(gutter.getLineMarkerInfo().getElement() instanceof XmlToken); assertEquals("The navigation start element doesn't match", "file:inbox", PsiTreeUtil.getParentOfType(gutter.getLineMarkerInfo().getElement(), XmlTag.class).getAttribute("uri").getValue()); List<GotoRelatedItem> gutterTargets = GutterTestUtil.getGutterNavigationDestinationElements(gutter); assertEquals("Navigation should have one target", 1, gutterTargets.size()); assertEquals("The navigation target route doesn't match", "file:inbox", gutterTargets.get(0).getElement().getText()); assertEquals("The navigation target tag name doesn't match", "toD", GutterTestUtil.getGuttersWithXMLTarget(gutterTargets).get(0).getLocalName()); }
Example 4
Source File: GutterTestUtil.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
static List<GotoRelatedItem> getGutterNavigationDestinationElements(LineMarkerInfo.LineMarkerGutterIconRenderer gutter) { LineMarkerProvider lineMarkerProvider1 = LineMarkersPass.getMarkerProviders(JavaLanguage.INSTANCE, gutter .getLineMarkerInfo() .getElement().getProject()) .stream() .filter(lineMarkerProvider -> lineMarkerProvider instanceof CamelRouteLineMarkerProvider).findAny() .get(); List<RelatedItemLineMarkerInfo> result = new ArrayList<>(); ((CamelRouteLineMarkerProvider) lineMarkerProvider1).collectNavigationMarkers(gutter.getLineMarkerInfo().getElement(), result); return (List<GotoRelatedItem>) result.get(0).createGotoRelatedItems(); }
Example 5
Source File: JavaCamelRouteLineMarkerProviderTestIT.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
public void testCamelGutter() { myFixture.configureByFiles("JavaCamelRouteLineMarkerProviderTestData.java"); List<GutterMark> gutters = myFixture.findAllGutters(); assertNotNull(gutters); //remove first element since it is navigate to super implementation gutter icon gutters.remove(0); assertEquals("Should contain 3 Camel gutters", 3, gutters.size()); assertGuttersHasCamelIcon(gutters); LineMarkerInfo.LineMarkerGutterIconRenderer firstGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(1); assertTrue(firstGutter.getLineMarkerInfo().getElement() instanceof PsiJavaToken); assertEquals("The navigation start element doesn't match", "\"file:inbox\"", firstGutter.getLineMarkerInfo().getElement().getText()); List<GotoRelatedItem> firstGutterTargets = GutterTestUtil.getGutterNavigationDestinationElements(firstGutter); assertEquals("Navigation should have one target", 1, firstGutterTargets.size()); assertEquals("The navigation target element doesn't match", "from(\"file:outbox\")", GutterTestUtil.getGuttersWithJavaTarget(firstGutterTargets).get(0).getMethodExpression().getQualifierExpression().getText()); LineMarkerInfo.LineMarkerGutterIconRenderer secondGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(2); assertTrue(secondGutter.getLineMarkerInfo().getElement() instanceof PsiJavaToken); assertEquals("The navigation start element doesn't match", "\"file:outbox\"", secondGutter.getLineMarkerInfo().getElement().getText()); List<GotoRelatedItem> secondGutterTargets = GutterTestUtil.getGutterNavigationDestinationElements(secondGutter); assertEquals("Navigation should have one target", 1, secondGutterTargets.size()); assertEquals("The navigation target element doesn't match", "from(\"file:inbox\")", GutterTestUtil.getGuttersWithJavaTarget(secondGutterTargets).get(0).getMethodExpression().getQualifierExpression().getText()); }
Example 6
Source File: JavaCamelRouteLineMarkerProviderTestIT.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
public void testCamelGutterForToDAndToF() { myFixture.configureByFiles("JavaCamelRouteLineMarkerProviderAlternateToTestData.java"); List<GutterMark> gutters = myFixture.findAllGutters(); assertNotNull(gutters); //remove first element since it is navigate to super implementation gutter icon gutters.remove(0); assertEquals("Should contain 2 Camel gutters", 2, gutters.size()); assertGuttersHasCamelIcon(gutters); LineMarkerInfo.LineMarkerGutterIconRenderer firstGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(0); assertTrue(firstGutter.getLineMarkerInfo().getElement() instanceof PsiJavaToken); assertEquals("The navigation start element doesn't match", "\"file:test\"", firstGutter.getLineMarkerInfo().getElement().getText()); List<GotoRelatedItem> firstGutterTargets = GutterTestUtil.getGutterNavigationDestinationElements(firstGutter); assertEquals("Navigation should have one target", 1, firstGutterTargets.size()); assertEquals("The navigation target element doesn't match", "from(\"file:test\")", GutterTestUtil.getGuttersWithJavaTarget(firstGutterTargets).get(0).getMethodExpression().getQualifierExpression().getText()); LineMarkerInfo.LineMarkerGutterIconRenderer secondGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(1); assertTrue(secondGutter.getLineMarkerInfo().getElement() instanceof PsiJavaToken); assertEquals("The navigation start element doesn't match", "\"file:test\"", secondGutter.getLineMarkerInfo().getElement().getText()); List<GotoRelatedItem> secondGutterTargets = GutterTestUtil.getGutterNavigationDestinationElements(secondGutter); assertEquals("Navigation should have one target", 1, secondGutterTargets.size()); assertEquals("The navigation target element doesn't match", "from(\"file:test\")", GutterTestUtil.getGuttersWithJavaTarget(secondGutterTargets).get(0).getMethodExpression().getQualifierExpression().getText()); }
Example 7
Source File: XmlCamelRouteLineMarkerProviderTestIT.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
public void testCamelGutter() { myFixture.configureByFiles("XmlCamelRouteLineMarkerProviderTestData.xml"); List<GutterMark> gutters = myFixture.findAllGutters(); assertNotNull(gutters); assertEquals("Does not contain the expected amount of Camel gutters", 3, gutters.size()); Icon defaultIcon = ServiceManager.getService(CamelPreferenceService.class).getCamelIcon(); gutters.forEach(gutterMark -> { assertSame("Gutter should have the Camel icon", defaultIcon, gutterMark.getIcon()); assertEquals("Camel route", gutterMark.getTooltipText()); }); LineMarkerInfo.LineMarkerGutterIconRenderer firstGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(1); assertTrue(firstGutter.getLineMarkerInfo().getElement() instanceof XmlToken); assertEquals("The navigation start element doesn't match", "file:inbox", PsiTreeUtil.getParentOfType(firstGutter.getLineMarkerInfo().getElement(), XmlTag.class).getAttribute("uri").getValue()); List<GotoRelatedItem> firstGutterTargets = GutterTestUtil.getGutterNavigationDestinationElements(firstGutter); assertEquals("Navigation should have one target", 1, firstGutterTargets.size()); assertEquals("The navigation target route doesn't match", "file:inbox", firstGutterTargets.get(0).getElement().getText()); assertEquals("The navigation target tag name doesn't match", "to", GutterTestUtil.getGuttersWithXMLTarget(firstGutterTargets).get(0).getLocalName()); LineMarkerInfo.LineMarkerGutterIconRenderer secondGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(2); assertTrue(secondGutter.getLineMarkerInfo().getElement() instanceof XmlToken); assertEquals("The navigation start element doesn't match", "file:outbox", PsiTreeUtil.getParentOfType(secondGutter.getLineMarkerInfo().getElement(), XmlTag.class).getAttribute("uri").getValue()); List<GotoRelatedItem> secondGutterTargets = GutterTestUtil.getGutterNavigationDestinationElements(secondGutter); assertEquals("Navigation should have one target", 1, secondGutterTargets.size()); assertEquals("The navigation target route doesn't match", "file:outbox", secondGutterTargets.get(0).getElement().getText()); assertEquals("The navigation target tag name doesn't match", "to", GutterTestUtil.getGuttersWithXMLTarget(secondGutterTargets).get(0).getLocalName()); }
Example 8
Source File: MultiLanguageCamelRouteLineMarkerProviderTestIT.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
public void testCamelGutterForJavaAndXMLRoutes() { myFixture.configureByFiles("XmlCamelRouteLineMarkerProviderTestData.xml", "JavaCamelRouteLineMarkerProviderTestData.java"); List<GutterMark> javaGutters = myFixture.findAllGutters("JavaCamelRouteLineMarkerProviderTestData.java"); assertNotNull(javaGutters); List<GutterMark> xmlGutters = myFixture.findAllGutters("XmlCamelRouteLineMarkerProviderTestData.xml"); assertNotNull(xmlGutters); //remove first element since it is navigate to super implementation gutter icon javaGutters.remove(0); assertEquals("Should contain 3 Java Camel gutters", 3, javaGutters.size()); assertEquals("Should contain 2 XML Camel gutters", 3, xmlGutters.size()); //from Java to XML LineMarkerInfo.LineMarkerGutterIconRenderer firstJavaGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) javaGutters.get(1); assertTrue(firstJavaGutter.getLineMarkerInfo().getElement() instanceof PsiJavaToken); assertEquals("The navigation start element doesn't match", "\"file:inbox\"", firstJavaGutter.getLineMarkerInfo().getElement().getText()); List<GotoRelatedItem> firstJavaGutterTargets = GutterTestUtil.getGutterNavigationDestinationElements(firstJavaGutter); assertEquals("Navigation should have two targets", 2, firstJavaGutterTargets.size()); assertEquals("The navigation target XML tag name doesn't match", "to", getGuttersWithXMLTarget(firstJavaGutterTargets).get(0).getLocalName()); assertEquals("The navigation Java target element doesn't match", "from(\"file:outbox\")", getGuttersWithJavaTarget(firstJavaGutterTargets).get(0).getMethodExpression().getQualifierExpression().getText()); //from XML to Java LineMarkerInfo.LineMarkerGutterIconRenderer firstXmlGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) xmlGutters.get(1); assertTrue(firstXmlGutter.getLineMarkerInfo().getElement() instanceof XmlToken); assertEquals("The navigation start element doesn't match", "\"file:inbox\"", (firstJavaGutter.getLineMarkerInfo().getElement()).getText()); List<GotoRelatedItem> firstXmlGutterTargets = GutterTestUtil.getGutterNavigationDestinationElements(firstXmlGutter); assertEquals("Navigation should have two targets", 2, firstXmlGutterTargets.size()); assertEquals("The navigation target XML tag name doesn't match", "to", getGuttersWithXMLTarget(firstXmlGutterTargets).get(0).getLocalName()); assertEquals("The navigation Java target element doesn't match", "from(\"file:outbox\")", getGuttersWithJavaTarget(firstXmlGutterTargets).get(0).getMethodExpression().getQualifierExpression().getText()); }
Example 9
Source File: LineMarkersUtil.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static RangeHighlighter createOrReuseLineMarker(@Nonnull LineMarkerInfo<?> info, @Nonnull MarkupModelEx markupModel, @Nullable HighlightersRecycler toReuse) { LineMarkerInfo.LineMarkerGutterIconRenderer<?> newRenderer = (LineMarkerInfo.LineMarkerGutterIconRenderer<?>)info.createGutterRenderer(); RangeHighlighter highlighter = toReuse == null ? null : toReuse.pickupHighlighterFromGarbageBin(info.startOffset, info.endOffset, HighlighterLayer.ADDITIONAL_SYNTAX); boolean newHighlighter = false; if (highlighter == null) { newHighlighter = true; highlighter = markupModel.addRangeHighlighterAndChangeAttributes(info.startOffset, info.endOffset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.LINES_IN_RANGE, false, markerEx -> { markerEx.setGutterIconRenderer(newRenderer); markerEx.setLineSeparatorColor(info.separatorColor); markerEx.setLineSeparatorPlacement(info.separatorPlacement); markerEx.putUserData(LINE_MARKER_INFO, info); }); MarkupEditorFilter editorFilter = info.getEditorFilter(); if (editorFilter != MarkupEditorFilter.EMPTY) { highlighter.setEditorFilter(editorFilter); } } if (!newHighlighter) { highlighter.putUserData(LINE_MARKER_INFO, info); LineMarkerInfo.LineMarkerGutterIconRenderer<?> oldRenderer = highlighter.getGutterIconRenderer() instanceof LineMarkerInfo.LineMarkerGutterIconRenderer ? (LineMarkerInfo.LineMarkerGutterIconRenderer<?>)highlighter.getGutterIconRenderer() : null; boolean rendererChanged = newRenderer == null || !newRenderer.equals(oldRenderer); boolean lineSeparatorColorChanged = !Comparing.equal(highlighter.getLineSeparatorColor(), info.separatorColor); boolean lineSeparatorPlacementChanged = !Comparing.equal(highlighter.getLineSeparatorPlacement(), info.separatorPlacement); if (rendererChanged || lineSeparatorColorChanged || lineSeparatorPlacementChanged) { markupModel.changeAttributesInBatch((RangeHighlighterEx)highlighter, markerEx -> { if (rendererChanged) { markerEx.setGutterIconRenderer(newRenderer); } if (lineSeparatorColorChanged) { markerEx.setLineSeparatorColor(info.separatorColor); } if (lineSeparatorPlacementChanged) { markerEx.setLineSeparatorPlacement(info.separatorPlacement); } }); } } info.highlighter = highlighter; return highlighter; }