mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Testing Framework: show highlighting keys when necessary in comparison results
This commit is contained in:
+18
-4
@@ -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<Pair<String, HighlightInfo>>() {
|
||||
@Override
|
||||
@@ -547,14 +557,14 @@ public class ExpectedHighlightingData {
|
||||
|
||||
// combine highlighting data with original text
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Couple<Integer> result = composeText(sb, list, 0, text, text.length(), 0);
|
||||
Couple<Integer> result = composeText(sb, list, 0, text, text.length(), 0, showAttributesKeys);
|
||||
sb.insert(0, text.substring(0, result.second));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static Couple<Integer> composeText(StringBuilder sb,
|
||||
List<Pair<String, HighlightInfo>> 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<String, HighlightInfo> pair = list.get(i);
|
||||
@@ -570,12 +580,16 @@ public class ExpectedHighlightingData {
|
||||
sb.insert(0, "</" + severity + ">");
|
||||
endPos = info.endOffset;
|
||||
if (prev != null && prev.endOffset > info.startOffset) {
|
||||
Couple<Integer> result = composeText(sb, list, i + 1, text, endPos, info.startOffset);
|
||||
Couple<Integer> 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++;
|
||||
|
||||
Reference in New Issue
Block a user