From 79cfe2bac4fcad1a33f6a20037161a8b796db697 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 14 Nov 2014 21:34:09 +0300 Subject: [PATCH] Completion tests: added ability to test presentation text attributes --- .../completion/smart/BooleanExpected.kt | 4 ++-- idea/testData/completion/smart/Null.kt | 2 +- .../completion/ExpectedCompletionUtils.java | 21 ++++++++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/idea/testData/completion/smart/BooleanExpected.kt b/idea/testData/completion/smart/BooleanExpected.kt index 3ddb58594a6..18be8fe16d3 100644 --- a/idea/testData/completion/smart/BooleanExpected.kt +++ b/idea/testData/completion/smart/BooleanExpected.kt @@ -1,5 +1,5 @@ fun foo(): Boolean = -// EXIST: true -// EXIST: false +// EXIST: { itemText: "true", attributes: "bold" } +// EXIST: { itemText: "false", attributes: "bold" } // ABSENT: Boolean diff --git a/idea/testData/completion/smart/Null.kt b/idea/testData/completion/smart/Null.kt index e38471fbdae..f5051349851 100644 --- a/idea/testData/completion/smart/Null.kt +++ b/idea/testData/completion/smart/Null.kt @@ -4,4 +4,4 @@ fun bar() { foo() } -// EXIST: null +// EXIST: { itemText: "null", attributes: "bold" } diff --git a/idea/tests/org/jetbrains/jet/completion/ExpectedCompletionUtils.java b/idea/tests/org/jetbrains/jet/completion/ExpectedCompletionUtils.java index c441aeed235..74577734976 100644 --- a/idea/tests/org/jetbrains/jet/completion/ExpectedCompletionUtils.java +++ b/idea/tests/org/jetbrains/jet/completion/ExpectedCompletionUtils.java @@ -49,8 +49,10 @@ public class ExpectedCompletionUtils { public static final String PRESENTATION_ITEM_TEXT = "itemText"; public static final String PRESENTATION_TYPE_TEXT = "typeText"; public static final String PRESENTATION_TAIL_TEXT = "tailText"; + public static final String PRESENTATION_TEXT_ATTRIBUTES = "attributes"; public static final Set validKeys = new HashSet( - 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 map; @@ -292,6 +294,7 @@ public class ExpectedCompletionUtils { map.put(CompletionProposal.LOOKUP_STRING, item.getLookupString()); if (presentation.getItemText() != null){ map.put(CompletionProposal.PRESENTATION_ITEM_TEXT, presentation.getItemText()); + map.put(CompletionProposal.PRESENTATION_TEXT_ATTRIBUTES, textAttributes(presentation)); } if (presentation.getTypeText() != null){ map.put(CompletionProposal.PRESENTATION_TYPE_TEXT, presentation.getTypeText()); @@ -306,6 +309,22 @@ public class ExpectedCompletionUtils { 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 items) { return StringUtil.join( Collections2.transform(items, new Function() {