diff --git a/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java b/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java index 897f38ae2c3d..2f6a8dc60084 100644 --- a/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java +++ b/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java @@ -519,6 +519,16 @@ public class ExpectedHighlightingData { } }); + boolean showAttributesKeys = false; + for (ExpectedHighlightingSet eachSet : types.values()) { + for (HighlightInfo eachInfo : eachSet.infos) { + if (eachInfo.forcedTextAttributesKey != null) { + showAttributesKeys = true; + break; + } + } + } + // sort filtered highlighting data by end offset in descending order Collections.sort(list, new Comparator>() { @Override @@ -547,14 +557,14 @@ public class ExpectedHighlightingData { // combine highlighting data with original text StringBuilder sb = new StringBuilder(); - Couple result = composeText(sb, list, 0, text, text.length(), 0); + Couple result = composeText(sb, list, 0, text, text.length(), 0, showAttributesKeys); sb.insert(0, text.substring(0, result.second)); return sb.toString(); } private static Couple composeText(StringBuilder sb, List> list, int index, - String text, int endPos, int startPos) { + String text, int endPos, int startPos, boolean showAttributesKeys) { int i = index; while (i < list.size()) { Pair pair = list.get(i); @@ -570,12 +580,16 @@ public class ExpectedHighlightingData { sb.insert(0, ""); endPos = info.endOffset; if (prev != null && prev.endOffset > info.startOffset) { - Couple result = composeText(sb, list, i + 1, text, endPos, info.startOffset); + Couple result = composeText(sb, list, i + 1, text, endPos, info.startOffset, showAttributesKeys); i = result.first - 1; endPos = result.second; } sb.insert(0, text.substring(info.startOffset, endPos)); - sb.insert(0, "<" + severity + " descr=\"" + info.getDescription() + "\">"); + + String str = "<" + severity + " descr=\"" + info.getDescription() + "\""; + if (showAttributesKeys) str += " textAttributesKey=\"" + info.forcedTextAttributesKey + "\""; + str += ">"; + sb.insert(0, str); endPos = info.startOffset; i++;