mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RSL: convert invalid line separators (IDEA-190959)
This commit is contained in:
+1
-1
@@ -75,7 +75,7 @@ public class ConvertStringLiteralToRawAction implements IntentionAction, LowPrio
|
||||
String additionalQuotes = PsiRawStringLiteralUtil.getAdditionalTics(textTicsTrimmed, "`");
|
||||
PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
|
||||
CodeStyleManager.getInstance(project).reformat(
|
||||
elementToReplace.replace(elementFactory.createExpressionFromText(prefix + '`' + additionalQuotes + textTicsTrimmed + additionalQuotes + '`' + suffix, null)));
|
||||
elementToReplace.replace(elementFactory.createExpressionFromText(prefix + '`' + additionalQuotes + StringUtil.convertLineSeparators(textTicsTrimmed) + additionalQuotes + '`' + suffix, null)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class RawStringLiteralPasteProcessor implements PasteProvider {
|
||||
int ticsLength = PsiRawStringLiteralUtil.getLeadingTicsSequence(literalText);
|
||||
String quotes = literalText.substring(0, ticsLength);
|
||||
String additionalQuotes = PsiRawStringLiteralUtil.getAdditionalTics(text, quotes);
|
||||
insertAtCaret(text, additionalQuotes, stringLiteral, editor, prefix, suffix);
|
||||
insertAtCaret(StringUtil.convertLineSeparators(text), additionalQuotes, stringLiteral, editor, prefix, suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class A {
|
||||
{
|
||||
String s = `a
|
||||
`;
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class A {
|
||||
{
|
||||
String s = "a<caret>\r";
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -36,9 +36,8 @@ public class LightAdvRawStringLiteralsTest extends LightCodeInsightFixtureTestCa
|
||||
doTestIntention(QuickFixBundle.message("convert.to.string.text"));
|
||||
}
|
||||
|
||||
public void testStringToRawTransformation() {
|
||||
doTestIntention(QuickFixBundle.message("convert.to.raw.string.text"));
|
||||
}
|
||||
public void testStringToRawTransformation() { doTestIntention(QuickFixBundle.message("convert.to.raw.string.text")); }
|
||||
public void testStringToRawTransformationWithWrongSeparators() { doTestIntention(QuickFixBundle.message("convert.to.raw.string.text")); }
|
||||
|
||||
public void testStringToRawTransformationLeadingTics() {
|
||||
doTestIntention(QuickFixBundle.message("convert.to.raw.string.text"));
|
||||
@@ -57,6 +56,10 @@ public class LightAdvRawStringLiteralsTest extends LightCodeInsightFixtureTestCa
|
||||
doTestPaste("class A {{String s = `q<caret>`;}}", "a\nb`\nc", "class A {{String s = ``qa\nb`\nc``;}}");
|
||||
}
|
||||
|
||||
public void testPasteInRawStringLiteralWrongLineSeparator() {
|
||||
doTestPaste("class A {{String s = `<caret>a`;}}", "\r", "class A {{String s = `\na`;}}");
|
||||
}
|
||||
|
||||
public void testPasteInRawStringStaringWithTics() {
|
||||
doTestPaste("class A {{String s = `<caret>q`;}}", "``a\n``b", "class A {{String s = \"``\" + `a\n" + "``bq`;}}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user