Completion tests: added ability to test presentation text attributes

This commit is contained in:
Valentin Kipyatkov
2014-11-14 21:34:09 +03:00
parent 7410c36e3a
commit 79cfe2bac4
3 changed files with 23 additions and 4 deletions
@@ -1,5 +1,5 @@
fun foo(): Boolean = <caret> fun foo(): Boolean = <caret>
// EXIST: true // EXIST: { itemText: "true", attributes: "bold" }
// EXIST: false // EXIST: { itemText: "false", attributes: "bold" }
// ABSENT: Boolean // ABSENT: Boolean
+1 -1
View File
@@ -4,4 +4,4 @@ fun bar() {
foo(<caret>) foo(<caret>)
} }
// EXIST: null // EXIST: { itemText: "null", attributes: "bold" }
@@ -49,8 +49,10 @@ public class ExpectedCompletionUtils {
public static final String PRESENTATION_ITEM_TEXT = "itemText"; public static final String PRESENTATION_ITEM_TEXT = "itemText";
public static final String PRESENTATION_TYPE_TEXT = "typeText"; public static final String PRESENTATION_TYPE_TEXT = "typeText";
public static final String PRESENTATION_TAIL_TEXT = "tailText"; public static final String PRESENTATION_TAIL_TEXT = "tailText";
public static final String PRESENTATION_TEXT_ATTRIBUTES = "attributes";
public static final Set<String> validKeys = new HashSet<String>( public static final Set<String> validKeys = new HashSet<String>(
Arrays.asList(LOOKUP_STRING, PRESENTATION_ITEM_TEXT, PRESENTATION_TYPE_TEXT, PRESENTATION_TAIL_TEXT) Arrays.asList(LOOKUP_STRING, PRESENTATION_ITEM_TEXT, PRESENTATION_TYPE_TEXT, PRESENTATION_TAIL_TEXT,
PRESENTATION_TEXT_ATTRIBUTES)
); );
private final Map<String, String> map; private final Map<String, String> map;
@@ -292,6 +294,7 @@ public class ExpectedCompletionUtils {
map.put(CompletionProposal.LOOKUP_STRING, item.getLookupString()); map.put(CompletionProposal.LOOKUP_STRING, item.getLookupString());
if (presentation.getItemText() != null){ if (presentation.getItemText() != null){
map.put(CompletionProposal.PRESENTATION_ITEM_TEXT, presentation.getItemText()); map.put(CompletionProposal.PRESENTATION_ITEM_TEXT, presentation.getItemText());
map.put(CompletionProposal.PRESENTATION_TEXT_ATTRIBUTES, textAttributes(presentation));
} }
if (presentation.getTypeText() != null){ if (presentation.getTypeText() != null){
map.put(CompletionProposal.PRESENTATION_TYPE_TEXT, presentation.getTypeText()); map.put(CompletionProposal.PRESENTATION_TYPE_TEXT, presentation.getTypeText());
@@ -306,6 +309,22 @@ public class ExpectedCompletionUtils {
return result; return result;
} }
private static String textAttributes(LookupElementPresentation presentation) {
StringBuilder builder = new StringBuilder();
if (presentation.isItemTextBold()) {
builder.append("bold");
}
if (presentation.isItemTextUnderlined()) {
if (builder.length() > 0) builder.append(" ");
builder.append("underlined");
}
if (presentation.isStrikeout()) {
if (builder.length() > 0) builder.append(" ");
builder.append("strikeout");
}
return builder.toString();
}
public static String listToString(Collection<CompletionProposal> items) { public static String listToString(Collection<CompletionProposal> items) {
return StringUtil.join( return StringUtil.join(
Collections2.transform(items, new Function<CompletionProposal, String>() { Collections2.transform(items, new Function<CompletionProposal, String>() {