use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class HTMLTextPainter method getMethodSeparator.
private LineMarkerInfo getMethodSeparator(int offset) {
if (myDocument == null)
return null;
int line = myDocument.getLineNumber(Math.max(0, Math.min(myDocument.getTextLength(), offset)));
LineMarkerInfo marker = null;
LineMarkerInfo tmpMarker;
while (myCurrentMethodSeparator < myMethodSeparators.length && (tmpMarker = myMethodSeparators[myCurrentMethodSeparator]) != null && FileSeparatorProvider.getDisplayLine(tmpMarker, myDocument) <= line) {
marker = tmpMarker;
myCurrentMethodSeparator++;
}
return marker;
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class TextPainter method getMethodSeparator.
private LineMarkerInfo getMethodSeparator(int line) {
LineMarkerInfo marker = null;
LineMarkerInfo tmpMarker;
while (myCurrentMethodSeparator < myMethodSeparators.length && (tmpMarker = myMethodSeparators[myCurrentMethodSeparator]) != null && FileSeparatorProvider.getDisplayLine(tmpMarker, myDocument) <= line) {
marker = tmpMarker;
myCurrentMethodSeparator++;
}
return marker;
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class RunLineMarkerProvider method getLineMarkerInfo.
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
List<RunLineMarkerContributor> contributors = RunLineMarkerContributor.EXTENSION.allForLanguage(element.getLanguage());
Icon icon = null;
List<Info> infos = null;
for (RunLineMarkerContributor contributor : contributors) {
Info info = contributor.getInfo(element);
if (info == null) {
continue;
}
if (icon == null) {
icon = info.icon;
}
if (infos == null) {
infos = new SmartList<>();
}
infos.add(info);
}
if (icon == null)
return null;
if (infos.size() > 1) {
Collections.sort(infos, COMPARATOR);
final Info first = infos.get(0);
for (Iterator<Info> it = infos.iterator(); it.hasNext(); ) {
Info info = it.next();
if (info != first && first.shouldReplace(info)) {
it.remove();
}
}
}
final DefaultActionGroup actionGroup = new DefaultActionGroup();
for (Info info : infos) {
for (AnAction action : info.actions) {
actionGroup.add(new LineMarkerActionWrapper(element, action));
}
if (info != infos.get(infos.size() - 1)) {
actionGroup.add(new Separator());
}
}
List<Info> finalInfos = infos;
Function<PsiElement, String> tooltipProvider = element1 -> {
final StringBuilder tooltip = new StringBuilder();
for (Info info : finalInfos) {
if (info.tooltipProvider != null) {
String string = info.tooltipProvider.apply(element1);
if (string == null)
continue;
if (tooltip.length() != 0) {
tooltip.append("\n");
}
tooltip.append(string);
}
}
return tooltip.length() == 0 ? null : tooltip.toString();
};
return new LineMarkerInfo<PsiElement>(element, element.getTextRange(), icon, Pass.LINE_MARKERS, tooltipProvider, null, GutterIconRenderer.Alignment.CENTER) {
@Nullable
@Override
public GutterIconRenderer createGutterRenderer() {
return new LineMarkerGutterIconRenderer<PsiElement>(this) {
@Override
public AnAction getClickAction() {
return null;
}
@Override
public boolean isNavigateAction() {
return true;
}
@Nullable
@Override
public ActionGroup getPopupMenuActions() {
return actionGroup;
}
};
}
};
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project kotlin by JetBrains.
the class TagsTestDataUtil method insertInfoTags.
public static String insertInfoTags(List<LineMarkerInfo> lineMarkers, boolean withDescription, String text) {
List<LineMarkerTagPoint> lineMarkerPoints = Lists.newArrayList();
for (LineMarkerInfo markerInfo : lineMarkers) {
lineMarkerPoints.add(new LineMarkerTagPoint(markerInfo.startOffset, true, markerInfo, withDescription));
lineMarkerPoints.add(new LineMarkerTagPoint(markerInfo.endOffset, false, markerInfo, withDescription));
}
return insertTagsInText(lineMarkerPoints, text);
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project kotlin by JetBrains.
the class AbstractLineMarkersTest method assertNavigationElements.
private void assertNavigationElements(List<LineMarkerInfo> markers) {
List<String> navigationDataComments = KotlinTestUtils.getLastCommentsInFile((KtFile) myFixture.getFile(), KotlinTestUtils.CommentType.BLOCK_COMMENT, false);
if (navigationDataComments.isEmpty())
return;
for (String navigationComment : navigationDataComments) {
final String description = getLineMarkerDescription(navigationComment);
LineMarkerInfo navigateMarker = ContainerUtil.find(markers, new Condition<LineMarkerInfo>() {
@Override
public boolean value(LineMarkerInfo marker) {
String tooltip = marker.getLineMarkerTooltip();
return tooltip != null && tooltip.startsWith(description);
}
});
assertNotNull(String.format("Can't find marker for navigation check with description \"%s\"", description), navigateMarker);
GutterIconNavigationHandler handler = navigateMarker.getNavigationHandler();
if (handler instanceof SuperDeclarationMarkerNavigationHandler) {
PsiElement element = navigateMarker.getElement();
//noinspection unchecked
handler.navigate(null, element);
List<NavigatablePsiElement> navigateElements = ((SuperDeclarationMarkerNavigationHandler) handler).getNavigationElements();
Collections.sort(navigateElements, new Comparator<NavigatablePsiElement>() {
@Override
public int compare(@NotNull NavigatablePsiElement first, @NotNull NavigatablePsiElement second) {
String elementFirstStr = ReferenceUtils.renderAsGotoImplementation(first);
String elementSecondStr = ReferenceUtils.renderAsGotoImplementation(second);
return elementFirstStr.compareTo(elementSecondStr);
}
});
String actualNavigationData = NavigationTestUtils.getNavigateElementsText(myFixture.getProject(), navigateElements);
assertSameLines(getExpectedNavigationText(navigationComment), actualNavigationData);
} else {
Assert.fail("Only SuperDeclarationMarkerNavigationHandler are supported in navigate check");
}
}
}
Aggregations