CPP-778 Support for semantic per-variable highlighting (test)
authorAlexey Utkin <alexey.utkin@jetbrains.com>
Tue, 7 Jun 2016 14:47:12 +0000 (17:47 +0300)
committerAlexey Utkin <alexey.utkin@jetbrains.com>
Tue, 7 Jun 2016 14:51:46 +0000 (17:51 +0300)
platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java

index 9eabcd33202bbc574f288e04133de2871866091e..7d48e82d6143ba8620eddc5f3ab9003d32085a14 100644 (file)
@@ -1778,6 +1778,23 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
     return result.toString();
   }
 
+  @NotNull
+  public String getHighlightingDescription(@NotNull List<HighlightInfo> highlighting, @NotNull String tagName) {
+    final List<Border> borders = new LinkedList<Border>();
+    for (HighlightInfo region : highlighting) {
+      borders.add(new Border(Border.LEFT, region.getStartOffset(), "", false));
+      borders.add(new Border(Border.RIGHT, region.getEndOffset(), "", false));
+    }
+    Collections.sort(borders);
+
+    StringBuilder result = new StringBuilder(myEditor.getDocument().getText());
+    for (Border border : borders) {
+      result.insert(border.getOffset(), (border.isSide() == Border.LEFT ? "<": "</") + tagName + ">");
+    }
+
+    return result.toString();
+  }
+
   private void testFoldingRegions(@NotNull String verificationFileName, @Nullable String destinationFileName, boolean doCheckCollapseStatus) {
     String expectedContent;
     try {