diff --git a/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java b/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java index 00ca3b34bfed..4eebab82e8fd 100644 --- a/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java +++ b/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java @@ -363,18 +363,9 @@ public class ExpectedHighlightingData { for (LineMarkerInfo info : markerInfos) { if (!containsLineMarker(info, lineMarkerInfos.values())) { - final int startOffset = info.startOffset; - final int endOffset = info.endOffset; - - int y1 = StringUtil.offsetToLineNumber(text, startOffset); - int y2 = StringUtil.offsetToLineNumber(text, endOffset); - int x1 = startOffset - StringUtil.lineColToOffset(text, y1, 0); - int x2 = endOffset - StringUtil.lineColToOffset(text, y2, 0); - if (!failMessage.isEmpty()) failMessage += '\n'; failMessage += fileName + "Extra line marker highlighted " + - "(" + (x1 + 1) + ", " + (y1 + 1) + ")" + "-" + - "(" + (x2 + 1) + ", " + (y2 + 1) + ")" + rangeString(text, info.startOffset, info.endOffset) + ": '"+info.getLineMarkerTooltip()+"'" ; } @@ -382,18 +373,9 @@ public class ExpectedHighlightingData { for (LineMarkerInfo expectedLineMarker : lineMarkerInfos.values()) { if (!markerInfos.isEmpty() && !containsLineMarker(expectedLineMarker, markerInfos)) { - final int startOffset = expectedLineMarker.startOffset; - final int endOffset = expectedLineMarker.endOffset; - - int y1 = StringUtil.offsetToLineNumber(text, startOffset); - int y2 = StringUtil.offsetToLineNumber(text, endOffset); - int x1 = startOffset - StringUtil.lineColToOffset(text, y1, 0); - int x2 = endOffset - StringUtil.lineColToOffset(text, y2, 0); - if (!failMessage.isEmpty()) failMessage += '\n'; failMessage += fileName + "Line marker was not highlighted " + - "(" + (x1 + 1) + ", " + (y1 + 1) + ")" + "-" + - "(" + (x2 + 1) + ", " + (y2 + 1) + ")" + rangeString(text, expectedLineMarker.startOffset, expectedLineMarker.endOffset) + ": '"+expectedLineMarker.getLineMarkerTooltip()+"'" ; } @@ -439,15 +421,9 @@ public class ExpectedHighlightingData { String s = text.substring(startOffset, endOffset); String desc = info.getDescription(); - int y1 = StringUtil.offsetToLineNumber(text, startOffset); - int y2 = StringUtil.offsetToLineNumber(text, endOffset); - int x1 = startOffset - StringUtil.lineColToOffset(text, y1, 0); - int x2 = endOffset - StringUtil.lineColToOffset(text, y2, 0); - if (!failMessage.isEmpty()) failMessage += '\n'; failMessage += fileName + "Extra text fragment highlighted " + - "(" + (x1 + 1) + ", " + (y1 + 1) + ")" + "-" + - "(" + (x2 + 1) + ", " + (y2 + 1) + ")" + + rangeString(text, startOffset, endOffset) + " :'" + s + "'" + (desc == null ? "" : " (" + desc + ")") @@ -465,15 +441,9 @@ public class ExpectedHighlightingData { String s = text.substring(startOffset, endOffset); String desc = expectedInfo.getDescription(); - int y1 = StringUtil.offsetToLineNumber(text, startOffset); - int y2 = StringUtil.offsetToLineNumber(text, endOffset); - int x1 = startOffset - StringUtil.lineColToOffset(text, y1, 0); - int x2 = endOffset - StringUtil.lineColToOffset(text, y2, 0); - if (!failMessage.isEmpty()) failMessage += '\n'; failMessage += fileName + "Text fragment was not highlighted " + - "(" + (x1 + 1) + ", " + (y1 + 1) + ")" + "-" + - "(" + (x2 + 1) + ", " + (y2 + 1) + ")" + + rangeString(text, startOffset, endOffset) + " :'" + s + "'" + (desc == null ? "" : " (" + desc + ")"); @@ -635,4 +605,14 @@ public class ExpectedHighlightingData { info.getTextAttributes(null, null))) && (expectedInfo.forcedTextAttributesKey == null || expectedInfo.forcedTextAttributesKey.equals(info.forcedTextAttributesKey)); } + + private static String rangeString(String text, int startOffset, int endOffset) { + int y1 = StringUtil.offsetToLineNumber(text, startOffset); + int y2 = StringUtil.offsetToLineNumber(text, endOffset); + int x1 = startOffset - StringUtil.lineColToOffset(text, y1, 0); + int x2 = endOffset - StringUtil.lineColToOffset(text, y2, 0); + + return "(" + (x1 + 1) + ", " + (y1 + 1) + ")" + "-" + + "(" + (x2 + 1) + ", " + (y2 + 1) + ")"; + } }