mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-80213 Enable fragment editor for multiline strings
This commit is contained in:
+2
-4
@@ -157,13 +157,11 @@ public class GroovyLiteralCopyPasteProcessor extends StringLiteralCopyPasteProce
|
||||
}
|
||||
|
||||
if (tokenType == mGSTRING_CONTENT || tokenType == mGSTRING_LITERAL) {
|
||||
boolean escapeDoubleQuotes = !token.getText().contains("\"\"\"");
|
||||
return GrStringUtil.escapeSymbolsForGString(s, escapeDoubleQuotes, false);
|
||||
return GrStringUtil.escapeSymbolsForGString(s, !token.getText().contains("\"\"\""), false);
|
||||
}
|
||||
|
||||
if (tokenType == mSTRING_LITERAL) {
|
||||
boolean escapeQuotes = !token.getText().contains("'''");
|
||||
return GrStringUtil.escapeSymbolsForString(s, escapeQuotes, false);
|
||||
return GrStringUtil.escapeSymbolsForString(s, !token.getText().contains("'''"), false);
|
||||
}
|
||||
|
||||
return super.escapeCharCharacters(s, token);
|
||||
|
||||
@@ -242,20 +242,20 @@ public class GrStringUtil {
|
||||
buffer.append(hexCode);
|
||||
}
|
||||
|
||||
public static String escapeSymbolsForGString(String s, boolean escapeDoubleQuotes, boolean forInjection) {
|
||||
public static String escapeSymbolsForGString(String s, boolean isSingleLine, boolean forInjection) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
escapeStringCharacters(s.length(), s, escapeDoubleQuotes ? "$\"" : "$", forInjection, true, b);
|
||||
escapeStringCharacters(s.length(), s, isSingleLine ? "$\"" : "$", isSingleLine, true, b);
|
||||
if (!forInjection) {
|
||||
unescapeCharacters(b, escapeDoubleQuotes ? "'" : "'\"", true);
|
||||
unescapeCharacters(b, isSingleLine ? "'" : "'\"", true);
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public static String escapeSymbolsForString(String s, boolean escapeQuotes, boolean forInjection) {
|
||||
public static String escapeSymbolsForString(String s, boolean isSingleLine, boolean forInjection) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
escapeStringCharacters(s.length(), s, escapeQuotes ? "'" : "", forInjection, true, builder);
|
||||
escapeStringCharacters(s.length(), s, isSingleLine ? "'" : "", isSingleLine, true, builder);
|
||||
if (!forInjection) {
|
||||
unescapeCharacters(builder, escapeQuotes ? "$\"" : "$'\"", true);
|
||||
unescapeCharacters(builder, isSingleLine ? "$\"" : "$'\"", true);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
+4
-3
@@ -17,6 +17,7 @@ package org.jetbrains.plugins.groovy.lang.resolve;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.AbstractElementManipulator;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
|
||||
@@ -36,10 +37,10 @@ public class GroovyStringLiteralManipulator extends AbstractElementManipulator<G
|
||||
String oldText = expr.getText();
|
||||
final String quote = GrStringUtil.getStartQuote(oldText);
|
||||
|
||||
if (quote.startsWith("'")) {
|
||||
newContent = GrStringUtil.escapeSymbolsForString(newContent, !quote.equals("'''"), false);
|
||||
if (StringUtil.startsWithChar(quote, '\'')) {
|
||||
newContent = GrStringUtil.escapeSymbolsForString(newContent, !quote.equals("'''"), true);
|
||||
}
|
||||
else if (quote.startsWith("\"")) {
|
||||
else if (StringUtil.startsWithChar(quote, '\"')) {
|
||||
newContent = GrStringUtil.escapeSymbolsForGString(newContent, !quote.equals("\"\"\""), true);
|
||||
}
|
||||
else if ("/".equals(quote)) {
|
||||
|
||||
Reference in New Issue
Block a user