use of com.intellij.codeInsight.daemon.LineMarkerInfo in project android by JetBrains.
the class AndroidLineMarkerProvider method doGetLineMarkerInfo.
private static LineMarkerInfo doGetLineMarkerInfo(PsiElement element) {
final MyMarkerInfo info = getMarkerInfo(element);
if (info == null) {
return null;
}
final PsiElement anchor = info.myElement;
final String tooltip = info.myTooltip;
return new LineMarkerInfo<PsiElement>(anchor, anchor.getTextOffset(), info.myIcon, Pass.LINE_MARKERS, new ConstantFunction<PsiElement, String>(tooltip), new MyNavigationHandler(info));
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo 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.LineMarkerInfo in project intellij-community by JetBrains.
the class LineMarkersUtil method createOrReuseLineMarker.
@NotNull
private static RangeHighlighter createOrReuseLineMarker(@NotNull LineMarkerInfo info, @NotNull MarkupModel markupModel, @Nullable HighlightersRecycler toReuse) {
RangeHighlighter highlighter = toReuse == null ? null : toReuse.pickupHighlighterFromGarbageBin(info.startOffset, info.endOffset, HighlighterLayer.ADDITIONAL_SYNTAX);
if (highlighter == null) {
highlighter = markupModel.addRangeHighlighter(info.startOffset, info.endOffset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.LINES_IN_RANGE);
}
highlighter.putUserData(LINE_MARKER_INFO, info);
LineMarkerInfo.LineMarkerGutterIconRenderer newRenderer = (LineMarkerInfo.LineMarkerGutterIconRenderer) info.createGutterRenderer();
LineMarkerInfo.LineMarkerGutterIconRenderer oldRenderer = highlighter.getGutterIconRenderer() instanceof LineMarkerInfo.LineMarkerGutterIconRenderer ? (LineMarkerInfo.LineMarkerGutterIconRenderer) highlighter.getGutterIconRenderer() : null;
boolean rendererChanged = oldRenderer == null || 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) {
((MarkupModelEx) 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;
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class FileSeparatorProvider method getFileSeparators.
@Nullable
public static List<LineMarkerInfo> getFileSeparators(PsiFile file, final Document document) {
final List<LineMarkerInfo> result = new ArrayList<>();
for (LineMarkerInfo lineMarkerInfo : LineMarkersPass.queryLineMarkers(file, document)) {
if (lineMarkerInfo.separatorColor != null) {
result.add(lineMarkerInfo);
}
}
Collections.sort(result, (i1, i2) -> getDisplayLine(i1, document) - getDisplayLine(i2, document));
return result;
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class HTMLTextPainter method writeStyles.
private void writeStyles(@NonNls final Writer writer) throws IOException {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
writer.write("<style type=\"text/css\">\n");
final Color lineNumbers = scheme.getColor(EditorColors.LINE_NUMBERS_COLOR);
writer.write(String.format(".ln { color: #%s; font-weight: normal; font-style: normal; }\n", ColorUtil.toHex(lineNumbers == null ? Gray.x00 : lineNumbers)));
HighlighterIterator hIterator = myHighlighter.createIterator(myOffset);
while (!hIterator.atEnd()) {
TextAttributes textAttributes = hIterator.getTextAttributes();
if (!myStyleMap.containsKey(textAttributes)) {
@NonNls String styleName = "s" + myStyleMap.size();
myStyleMap.put(textAttributes, styleName);
writer.write("." + styleName + " { ");
Color foreColor = textAttributes.getForegroundColor();
if (foreColor == null)
foreColor = scheme.getDefaultForeground();
writer.write("color: " + colorToHtml(foreColor) + "; ");
if (BitUtil.isSet(textAttributes.getFontType(), Font.BOLD)) {
writer.write("font-weight: bold; ");
}
if (BitUtil.isSet(textAttributes.getFontType(), Font.ITALIC)) {
writer.write("font-style: italic; ");
}
writer.write("}\n");
}
hIterator.advance();
}
for (LineMarkerInfo separator : myMethodSeparators) {
Color color = separator.separatorColor;
if (color != null && !mySeparatorStyles.containsKey(color)) {
@NonNls String styleName = "ls" + mySeparatorStyles.size();
mySeparatorStyles.put(color, styleName);
String htmlColor = colorToHtml(color);
writer.write("." + styleName + " { height: 1px; border-width: 0; color: " + htmlColor + "; background-color:" + htmlColor + "}\n");
}
}
writer.write("</style>\n");
}
Aggregations