use of com.intellij.codeInsight.daemon.GutterMark in project intellij-community by JetBrains.
the class EditorGutterComponentImpl method buildGutterRenderersCache.
private void buildGutterRenderersCache() {
myLineToGutterRenderers = new TIntObjectHashMap<>();
processRangeHighlighters(0, myEditor.getDocument().getTextLength(), highlighter -> {
GutterMark renderer = highlighter.getGutterIconRenderer();
if (renderer == null) {
return;
}
if (!areIconsShown() && !(renderer instanceof NonHideableIconGutterMark)) {
return;
}
if (!isHighlighterVisible(highlighter)) {
return;
}
int lineStartOffset = EditorUtil.getNotFoldedLineStartOffset(myEditor, highlighter.getStartOffset());
int line = myEditor.getDocument().getLineNumber(lineStartOffset);
List<GutterMark> renderers = myLineToGutterRenderers.get(line);
if (renderers == null) {
renderers = new SmartList<>();
myLineToGutterRenderers.put(line, renderers);
}
renderers.add(renderer);
});
myLineToGutterRenderers.transformValues(value -> {
List<GutterMark> newValue = value;
for (GutterMarkPreprocessor preprocessor : GutterMarkPreprocessor.EP_NAME.getExtensions()) {
newValue = preprocessor.processMarkers(value);
}
if (newValue.size() >= 5) {
newValue = newValue.subList(0, 4);
}
return newValue;
});
}
use of com.intellij.codeInsight.daemon.GutterMark in project intellij-community by JetBrains.
the class EditorGutterComponentImpl method mouseMoved.
@Override
public void mouseMoved(final MouseEvent e) {
String toolTip = null;
final GutterIconRenderer renderer = getGutterRenderer(e);
TooltipController controller = TooltipController.getInstance();
if (renderer != null) {
toolTip = renderer.getTooltipText();
} else {
TextAnnotationGutterProvider provider = getProviderAtPoint(e.getPoint());
if (provider != null) {
final int line = getLineNumAtPoint(e.getPoint());
toolTip = provider.getToolTip(line, myEditor);
if (!Comparing.equal(toolTip, myLastGutterToolTip)) {
controller.cancelTooltip(GUTTER_TOOLTIP_GROUP, e, true);
myLastGutterToolTip = toolTip;
}
} else {
ActiveGutterRenderer lineRenderer = getActiveRendererByMouseEvent(e);
if (lineRenderer != null) {
toolTip = lineRenderer.getTooltipText();
}
}
}
if (toolTip != null && !toolTip.isEmpty()) {
final Ref<Point> t = new Ref<>(e.getPoint());
int line = EditorUtil.yPositionToLogicalLine(myEditor, e);
List<GutterMark> row = getGutterRenderers(line);
Balloon.Position ballPosition = Balloon.Position.atRight;
if (row != null) {
final TreeMap<Integer, GutterMark> xPos = new TreeMap<>();
final int[] currentPos = { 0 };
processIconsRow(line, row, (x, y, r) -> {
xPos.put(x, r);
if (renderer == r) {
currentPos[0] = x;
Icon icon = scaleIcon(r.getIcon());
t.set(new Point(x + icon.getIconWidth() / 2, y + icon.getIconHeight() / 2));
}
});
List<Integer> xx = new ArrayList<>(xPos.keySet());
int posIndex = xx.indexOf(currentPos[0]);
if (xPos.size() > 1 && posIndex == 0) {
ballPosition = Balloon.Position.below;
}
}
RelativePoint showPoint = new RelativePoint(this, t.get());
controller.showTooltipByMouseMove(myEditor, showPoint, ((EditorMarkupModel) myEditor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(toolTip), false, GUTTER_TOOLTIP_GROUP, new HintHint(this, t.get()).setAwtTooltip(true).setPreferredPosition(ballPosition));
} else {
controller.cancelTooltip(GUTTER_TOOLTIP_GROUP, e, false);
}
}
use of com.intellij.codeInsight.daemon.GutterMark in project intellij-community by JetBrains.
the class DescriptionTypeRelatedItemLineMarkerProviderTest method testInspectionDescription.
public void testInspectionDescription() {
myFixture.copyDirectoryToProject("inspectionDescriptions", "inspectionDescriptions");
final GutterMark gutter = myFixture.findGutter("MyWithDescriptionInspection.java");
DevKitGutterTargetsChecker.checkGutterTargets(gutter, "Description", AllIcons.FileTypes.Html, "MyWithDescription.html");
}
use of com.intellij.codeInsight.daemon.GutterMark in project intellij-community by JetBrains.
the class DevKitGutterTargetsChecker method checkGutterTargets.
public static void checkGutterTargets(final GutterMark gutterMark, final String tooltip, final Icon icon, final String... expectedTargets) {
assertNotNull(gutterMark);
assertEquals(tooltip, gutterMark.getTooltipText());
assertEquals(icon, gutterMark.getIcon());
final Collection<PsiElement> targetElements;
if (gutterMark instanceof LineMarkerInfo.LineMarkerGutterIconRenderer) {
final LineMarkerInfo.LineMarkerGutterIconRenderer renderer = UsefulTestCase.assertInstanceOf(gutterMark, LineMarkerInfo.LineMarkerGutterIconRenderer.class);
final LineMarkerInfo lineMarkerInfo = renderer.getLineMarkerInfo();
GutterIconNavigationHandler handler = lineMarkerInfo.getNavigationHandler();
if (handler instanceof NavigationGutterIconRenderer) {
targetElements = ((NavigationGutterIconRenderer) handler).getTargetElements();
} else {
throw new IllegalArgumentException(handler + ": handler not supported");
}
} else {
throw new IllegalArgumentException(gutterMark.getClass() + ": gutter not supported");
}
UsefulTestCase.assertSameElements(ContainerUtil.map(targetElements, element -> SymbolPresentationUtil.getSymbolPresentableText(element)), expectedTargets);
}
use of com.intellij.codeInsight.daemon.GutterMark in project intellij-community by JetBrains.
the class ExtensionPointDeclarationRelatedItemLineMarkerProviderTest method assertSingleEPDeclaration.
private void assertSingleEPDeclaration(String filePath) {
// index
myFixture.configureByFile("plugin.xml");
final GutterMark gutter = myFixture.findGutter(filePath);
DevKitGutterTargetsChecker.checkGutterTargets(gutter, "Extension Point Declaration", AllIcons.Nodes.Plugin, "extensionPoint");
}
Aggregations