public void checkResult(Collection<HighlightInfo> infos, String text, @Nullable String filePath) { if (filePath == null) { VirtualFile virtualFile = myFile == null ? null : myFile.getVirtualFile(); filePath = virtualFile == null ? null : virtualFile.getUserData(VfsTestUtil.TEST_DATA_FILE_PATH); } String fileName = myFile == null ? "" : myFile.getName() + ": "; String failMessage = ""; for (HighlightInfo info : reverseCollection(infos)) { if (!expectedInfosContainsInfo(info) && !myIgnoreExtraHighlighting) { final int startOffset = info.startOffset; final int endOffset = info.endOffset; String s = text.substring(startOffset, endOffset); String desc = info.getDescription(); if (!failMessage.isEmpty()) failMessage += '\n'; failMessage += fileName + "Extra " + rangeString(text, startOffset, endOffset) + " :'" + s + "'" + (desc == null ? "" : " (" + desc + ")") + " [" + info.type + "]"; } } final Collection<ExpectedHighlightingSet> expectedHighlights = myHighlightingTypes.values(); for (ExpectedHighlightingSet highlightingSet : reverseCollection(expectedHighlights)) { final Set<HighlightInfo> expInfos = highlightingSet.infos; for (HighlightInfo expectedInfo : expInfos) { if (!infosContainsExpectedInfo(infos, expectedInfo) && highlightingSet.enabled) { final int startOffset = expectedInfo.startOffset; final int endOffset = expectedInfo.endOffset; String s = text.substring(startOffset, endOffset); String desc = expectedInfo.getDescription(); if (!failMessage.isEmpty()) failMessage += '\n'; failMessage += fileName + "Missing " + rangeString(text, startOffset, endOffset) + " :'" + s + "'" + (desc == null ? "" : " (" + desc + ")"); } } } if (!failMessage.isEmpty()) { compareTexts(infos, text, failMessage + "\n", filePath); } }
public void checkResult(Collection<HighlightInfo> infos, String text, @Nullable String filePath) { if (filePath == null) { VirtualFile virtualFile = myFile == null ? null : myFile.getVirtualFile(); filePath = virtualFile == null ? null : virtualFile.getUserData(VfsTestUtil.TEST_DATA_FILE_PATH); } String fileName = myFile == null ? "" : myFile.getName() + ": "; String failMessage = ""; for (HighlightInfo info : reverseCollection(infos)) { if (!expectedInfosContainsInfo(info)) { final int startOffset = info.startOffset; final int endOffset = info.endOffset; 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) + ")" + " :'" + s + "'" + (desc == null ? "" : " (" + desc + ")") + " [" + info.type + "]"; } } final Collection<ExpectedHighlightingSet> expectedHighlights = highlightingTypes.values(); for (ExpectedHighlightingSet highlightingSet : reverseCollection(expectedHighlights)) { final Set<HighlightInfo> expInfos = highlightingSet.infos; for (HighlightInfo expectedInfo : expInfos) { if (!infosContainsExpectedInfo(infos, expectedInfo) && highlightingSet.enabled) { final int startOffset = expectedInfo.startOffset; final int endOffset = expectedInfo.endOffset; 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) + ")" + " :'" + s + "'" + (desc == null ? "" : " (" + desc + ")"); } } } if (!failMessage.isEmpty()) { compareTexts(infos, text, failMessage + "\n", filePath); } }