mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Improve handling of escaped attributes inside test data markers
* Unescape quotes preceded with single backslash inside "descr" attribute * Escape them back in the "actual" text when comparing results
This commit is contained in:
@@ -290,6 +290,7 @@ public class ExpectedHighlightingData {
|
||||
}
|
||||
if (descr != null) {
|
||||
descr = descr.replaceAll("\\\\\\\\\"", "\""); // replace: \\" to ", doesn't check symbol before sequence \\"
|
||||
descr = descr.replaceAll("\\\\\"", "\"");
|
||||
}
|
||||
|
||||
HighlightInfoType type = WHATEVER;
|
||||
@@ -554,8 +555,10 @@ public class ExpectedHighlightingData {
|
||||
}
|
||||
sb.insert(0, text.substring(info.startOffset, endPos));
|
||||
|
||||
String str = "<" + severity + " descr=\"" + info.getDescription() + "\"";
|
||||
if (showAttributesKeys) str += " textAttributesKey=\"" + info.forcedTextAttributesKey + "\"";
|
||||
String str = "<" + severity + " descr=\"" + StringUtil.escapeQuotes(String.valueOf(info.getDescription())) + "\"";
|
||||
if (showAttributesKeys) {
|
||||
str += " textAttributesKey=\"" + info.forcedTextAttributesKey + "\"";
|
||||
}
|
||||
str += ">";
|
||||
sb.insert(0, str);
|
||||
|
||||
|
||||
+4
@@ -41,6 +41,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.testFramework.EditorTestUtil;
|
||||
import com.intellij.testFramework.ExpectedHighlightingData;
|
||||
import com.intellij.testFramework.HighlightTestInfo;
|
||||
import com.intellij.testFramework.TestDataFile;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
@@ -246,6 +247,9 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
/**
|
||||
* Runs highlighting test for the given files.
|
||||
* Checks for {@link #ERROR_MARKER} markers by default.
|
||||
* <p/>
|
||||
* Double quotes in "descr" attribute of markers must be escaped by either one or two backslashes
|
||||
* (see {@link ExpectedHighlightingData#extractExpectedHighlightsSet(Document)}).
|
||||
*
|
||||
* @param checkWarnings enables {@link #WARNING_MARKER} support.
|
||||
* @param checkInfos enables {@link #INFO_MARKER} support.
|
||||
|
||||
Reference in New Issue
Block a user