use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class ExpectedHighlightingData method checkLineMarkers.
public void checkLineMarkers(@NotNull Collection<LineMarkerInfo> markerInfos, @NotNull String text) {
String fileName = myFile == null ? "" : myFile.getName() + ": ";
String failMessage = "";
for (LineMarkerInfo info : markerInfos) {
if (!containsLineMarker(info, myLineMarkerInfos.values())) {
if (!failMessage.isEmpty())
failMessage += '\n';
failMessage += fileName + "Extra line marker highlighted " + rangeString(text, info.startOffset, info.endOffset) + ": '" + info.getLineMarkerTooltip() + "'";
}
}
for (LineMarkerInfo expectedLineMarker : myLineMarkerInfos.values()) {
if (markerInfos.isEmpty() || !containsLineMarker(expectedLineMarker, markerInfos)) {
if (!failMessage.isEmpty())
failMessage += '\n';
failMessage += fileName + "Line marker was not highlighted " + rangeString(text, expectedLineMarker.startOffset, expectedLineMarker.endOffset) + ": '" + expectedLineMarker.getLineMarkerTooltip() + "'";
}
}
if (!failMessage.isEmpty())
Assert.fail(failMessage);
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class TextPainter method drawText.
private void drawText(Graphics2D g, Rectangle2D clip) {
float lineHeight = getLineHeight(g);
HighlighterIterator hIterator = myHighlighter.createIterator(myOffset);
if (hIterator.atEnd()) {
myOffset = mySegmentEnd;
return;
}
LineIterator lIterator = myDocument.createLineIterator();
lIterator.start(myOffset);
if (lIterator.atEnd()) {
myOffset = mySegmentEnd;
return;
}
TextAttributes attributes = hIterator.getTextAttributes();
Color currentColor = attributes.getForegroundColor();
Color backColor = attributes.getBackgroundColor();
Color underscoredColor = attributes.getEffectColor();
Font currentFont = getFont(attributes.getFontType());
setForegroundColor(g, currentColor);
setFont(g, currentFont);
g.translate(clip.getX(), 0);
Point2D position = new Point2D.Double(0, clip.getY());
double lineY = position.getY();
if (myPerformActualDrawing) {
getMethodSeparator(lIterator.getLineNumber());
}
char[] text = myDocument.getCharsSequence().toString().toCharArray();
while (!hIterator.atEnd() && !lIterator.atEnd()) {
int hEnd = hIterator.getEnd();
int lEnd = lIterator.getEnd();
int lStart = lIterator.getStart();
if (hEnd >= lEnd) {
if (!drawString(g, text, lEnd - lIterator.getSeparatorLength(), myOffset == lStart, position, clip, backColor, underscoredColor)) {
drawLineNumber(g, 0, lineY);
break;
}
drawLineNumber(g, 0, lineY);
lIterator.advance();
myLineNumber++;
position.setLocation(0, position.getY() + lineHeight);
lineY = position.getY();
myOffset = lEnd;
if (myPerformActualDrawing) {
LineMarkerInfo marker = getMethodSeparator(lIterator.getLineNumber());
if (marker != null) {
Color save = g.getColor();
setForegroundColor(g, marker.separatorColor);
UIUtil.drawLine(g, 0, (int) lineY, (int) clip.getWidth(), (int) lineY);
setForegroundColor(g, save);
}
}
if (position.getY() > clip.getY() + clip.getHeight() - lineHeight) {
break;
}
} else {
if (hEnd > lEnd - lIterator.getSeparatorLength()) {
if (!drawString(g, text, lEnd - lIterator.getSeparatorLength(), myOffset == lStart, position, clip, backColor, underscoredColor)) {
drawLineNumber(g, 0, lineY);
break;
}
} else {
if (!drawString(g, text, hEnd, myOffset == lStart, position, clip, backColor, underscoredColor)) {
drawLineNumber(g, 0, lineY);
break;
}
}
hIterator.advance();
attributes = hIterator.getTextAttributes();
Color color = attributes.getForegroundColor();
if (color == null) {
color = Color.black;
}
if (color != currentColor) {
setForegroundColor(g, color);
currentColor = color;
}
backColor = attributes.getBackgroundColor();
underscoredColor = attributes.getEffectColor();
Font font = getFont(attributes.getFontType());
if (font != currentFont) {
setFont(g, font);
currentFont = font;
}
myOffset = hEnd;
}
}
g.translate(-clip.getX(), 0);
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class JavaGotoSuperTest method testLambdaMarker.
public void testLambdaMarker() throws Exception {
configureByFile(getBasePath() + getTestName(false) + ".java");
int offset = myEditor.getCaretModel().getOffset();
doHighlighting();
Document document = getEditor().getDocument();
List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, getProject());
for (LineMarkerInfo info : markers) {
if (info.endOffset >= offset && info.startOffset <= offset) {
Shortcut shortcut = ActionManager.getInstance().getAction(IdeActions.ACTION_GOTO_SUPER).getShortcutSet().getShortcuts()[0];
assertEquals("<html><body>Overrides method in <a href=\"#javaClass/I\">I</a><br><div style='margin-top: 5px'><font size='2'>Click or press " + KeymapUtil.getShortcutText(shortcut) + " to navigate</font></div></body></html>", info.getLineMarkerTooltip());
return;
}
}
fail("Gutter expected");
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class JavaGotoSuperTest method testDoNotShowSiblingInheritanceLineMarkerIfSubclassImplementsTheSameInterfaceAsTheCurrentClass.
public void testDoNotShowSiblingInheritanceLineMarkerIfSubclassImplementsTheSameInterfaceAsTheCurrentClass() throws Throwable {
configureByFile(getBasePath() + "DeceivingSiblingInheritance.java");
PsiJavaFile file = (PsiJavaFile) getFile();
PsiClass OCBaseLanguageFileType = JavaPsiFacade.getInstance(getProject()).findClass("z.OCBaseLanguageFileType", GlobalSearchScope.fileScope(file));
PsiMethod getName = OCBaseLanguageFileType.getMethods()[0];
assertEquals("getName", getName.getName());
doHighlighting();
Document document = getEditor().getDocument();
List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, getProject());
List<LineMarkerInfo> inMyClass = ContainerUtil.filter(markers, info -> OCBaseLanguageFileType.getTextRange().containsRange(info.startOffset, info.endOffset));
assertTrue(inMyClass.toString(), inMyClass.size() == 2);
LineMarkerInfo iMarker = findMarkerWithElement(inMyClass, getName.getNameIdentifier());
assertSame(MarkerType.OVERRIDING_METHOD.getNavigationHandler(), iMarker.getNavigationHandler());
LineMarkerInfo aMarker = findMarkerWithElement(inMyClass, OCBaseLanguageFileType.getNameIdentifier());
assertSame(MarkerType.SUBCLASSED_CLASS.getNavigationHandler(), aMarker.getNavigationHandler());
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class JavaGotoSuperTest method testSiblingInheritanceLineMarkers.
public void testSiblingInheritanceLineMarkers() throws Throwable {
configureByFile(getBasePath() + "SiblingInheritance.java");
PsiJavaFile file = (PsiJavaFile) getFile();
PsiClass i = JavaPsiFacade.getInstance(getProject()).findClass("z.I", GlobalSearchScope.fileScope(file));
PsiClass a = JavaPsiFacade.getInstance(getProject()).findClass("z.A", GlobalSearchScope.fileScope(file));
PsiMethod iRun = i.getMethods()[0];
assertEquals("run", iRun.getName());
PsiMethod aRun = a.getMethods()[0];
assertEquals("run", aRun.getName());
doHighlighting();
Document document = getEditor().getDocument();
List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, getProject());
assertTrue(markers.size() >= 2);
LineMarkerInfo iMarker = findMarkerWithElement(markers, iRun.getNameIdentifier());
assertSame(MarkerType.OVERRIDDEN_METHOD.getNavigationHandler(), iMarker.getNavigationHandler());
LineMarkerInfo aMarker = findMarkerWithElement(markers, aRun.getNameIdentifier());
assertSame(MarkerType.SIBLING_OVERRIDING_METHOD.getNavigationHandler(), aMarker.getNavigationHandler());
}
Aggregations