diff --git a/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java b/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java index 19a36dc6b30e..288a161e3b06 100644 --- a/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java +++ b/platform/testFramework/src/com/intellij/testFramework/ExpectedHighlightingData.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -539,7 +539,10 @@ public class ExpectedHighlightingData { while (i < list.size()) { Pair pair = list.get(i); HighlightInfo info = pair.second; - if (info.endOffset < startPos) break; + if (info.endOffset <= startPos) { + break; + } + String severity = pair.first; HighlightInfo prev = i < list.size() - 1 ? list.get(i + 1).second : null; diff --git a/platform/testFramework/testSrc/com/intellij/testFramework/ExpectedHighlightingDataTest.java b/platform/testFramework/testSrc/com/intellij/testFramework/ExpectedHighlightingDataTest.java index 9e2270575594..e3c48c603a6c 100644 --- a/platform/testFramework/testSrc/com/intellij/testFramework/ExpectedHighlightingDataTest.java +++ b/platform/testFramework/testSrc/com/intellij/testFramework/ExpectedHighlightingDataTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.junit.Test; import java.util.*; +import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; public class ExpectedHighlightingDataTest { @@ -51,80 +52,87 @@ public class ExpectedHighlightingDataTest { @Test public void sequential() { doTest("_my text_", - Arrays.asList(error(1, 3, "1"), error(4, 8, "2")), + asList(error(1, 3, "1"), error(4, 8, "2")), "_my text_"); } @Test public void simpleNested() { doTest("[(nested)]", - Arrays.asList(error(1, 9, "1"), error(2, 8, "2")), + asList(error(1, 9, "1"), error(2, 8, "2")), "[(nested)]"); } @Test public void deepNested() { doTest("m1(m2(m3(m4(x))))", - Arrays.asList(error(3, 16, "m1"), error(6, 15, "m2"), error(9, 14, "m3"), error(12, 13, "m4")), + asList(error(3, 16, "m1"), error(6, 15, "m2"), error(9, 14, "m3"), error(12, 13, "m4")), "m1(m2(m3(m4(x))))"); } @Test public void sameStart() { doTest("same start", - Arrays.asList(error(0, 4, "1"), error(0, 10, "2")), + asList(error(0, 4, "1"), error(0, 10, "2")), "same start"); } @Test public void sameEnd() { doTest("same end", - Arrays.asList(error(0, 8, "1"), error(5, 8, "2")), + asList(error(0, 8, "1"), error(5, 8, "2")), "same end"); } @Test public void sameBothBounds() { doTest("same", - Arrays.asList(error(0, 4, "-"), warning(0, 4, "-")), + asList(error(0, 4, "-"), warning(0, 4, "-")), "same"); } @Test public void samePriority() { doTest("same", - Arrays.asList(warning(0, 4, "1"), warning(0, 4, "2")), + asList(warning(0, 4, "1"), warning(0, 4, "2")), "same"); } @Test public void twoNests() { doTest("(two nests)", - Arrays.asList(error(0, 11, "-"), error(1, 4, "1"), error(5, 10, "2")), + asList(error(0, 11, "-"), error(1, 4, "1"), error(5, 10, "2")), "(two nests)"); } @Test public void realistic() { doTest("one and (two nests)", - Arrays.asList(error(4, 7, "-"), error(8, 19, "-"), error(9, 12, "1"), error(13, 18, "2")), + asList(error(4, 7, "-"), error(8, 19, "-"), error(9, 12, "1"), error(13, 18, "2")), "one and (two nests)"); } @Test public void twoEOLs() { doTest("text\nmore text", - Arrays.asList(eolError(4, 4, "1"), eolError(4, 4, "2")), + asList(eolError(4, 4, "1"), eolError(4, 4, "2")), "text\nmore text"); } @Test public void eolAfterError() { doTest("some error\nmore text", - Arrays.asList(error(5, 10, "1"), eolError(10, 10, "2")), + asList(error(5, 10, "1"), eolError(10, 10, "2")), "some error\nmore text"); } + @Test + public void consecutiveNests() { + doTest(" ab ", + asList(error(1, 2, "a1"), error(1, 2, "a2"), error(2, 3, "b1"), error(2, 3, "b2")), + " ab "); + } + private static void doTest(String original, Collection highlighting, String expected) { String text = ExpectedHighlightingData.composeText(TYPES, highlighting, original); assertEquals(expected, text);