mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
PY-73911: fix "the inserted app is double-quoted" issue
GitOrigin-RevId: e22cadbea69abbfaf312b67bce3a82b9190912b7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d969c2efbc
commit
3bcabcf4a0
@@ -33,11 +33,18 @@ public abstract class PyElementGenerator extends PyAstElementGenerator {
|
||||
* @param destination where the literal is destined to; used to determine the encoding.
|
||||
* @param unescaped the string
|
||||
* @param preferUTF8 try to use UTF8 (would use ascii if false)
|
||||
* @param preferDoubleQuotes try to use double/single quotes
|
||||
* @return a newly created literal
|
||||
*/
|
||||
protected abstract PyStringLiteralExpression createStringLiteralFromString(@Nullable PsiFile destination,
|
||||
@NotNull String unescaped,
|
||||
boolean preferUTF8, boolean preferDoubleQuotes);
|
||||
|
||||
public abstract PyStringLiteralExpression createStringLiteralFromString(@Nullable PsiFile destination, String unescaped,
|
||||
boolean preferUTF8);
|
||||
|
||||
public abstract PyStringLiteralExpression createStringLiteralFromString(@NotNull String unescaped, boolean preferDoubleQuotes);
|
||||
|
||||
public abstract PyStringLiteralExpression createStringLiteralFromString(@NotNull String unescaped);
|
||||
|
||||
public abstract PyStringLiteralExpression createStringLiteral(@NotNull StringLiteralExpression oldElement, @NotNull String unescaped);
|
||||
@@ -50,7 +57,7 @@ public abstract class PyElementGenerator extends PyAstElementGenerator {
|
||||
|
||||
@NotNull
|
||||
public abstract PyExpression createExpressionFromText(@NotNull LanguageLevel languageLevel, @NotNull String text) throws IncorrectOperationException;
|
||||
|
||||
|
||||
@NotNull
|
||||
public abstract PyPattern createPatternFromText(@NotNull LanguageLevel languageLevel, @NotNull String text) throws IncorrectOperationException;
|
||||
|
||||
|
||||
@@ -80,10 +80,11 @@ public final class PyElementGeneratorImpl extends PyElementGenerator {
|
||||
|
||||
|
||||
@Override
|
||||
public PyStringLiteralExpression createStringLiteralFromString(@Nullable PsiFile destination,
|
||||
protected PyStringLiteralExpression createStringLiteralFromString(@Nullable PsiFile destination,
|
||||
@NotNull String unescaped,
|
||||
final boolean preferUTF8) {
|
||||
boolean useDouble = !unescaped.contains("\"");
|
||||
final boolean preferUTF8,
|
||||
boolean preferDoubleQuotes) {
|
||||
boolean useDouble = (!unescaped.contains("\"") && preferDoubleQuotes) || unescaped.contains("'");
|
||||
boolean useMulti = unescaped.matches(".*(\r|\n).*");
|
||||
String quotes;
|
||||
if (useMulti) {
|
||||
@@ -139,6 +140,18 @@ public final class PyElementGeneratorImpl extends PyElementGenerator {
|
||||
return createStringLiteralAlreadyEscaped(buf.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PyStringLiteralExpression createStringLiteralFromString(@Nullable PsiFile destination,
|
||||
@NotNull String unescaped,
|
||||
final boolean preferUTF8) {
|
||||
return createStringLiteralFromString(destination, unescaped, preferUTF8, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PyStringLiteralExpression createStringLiteralFromString(@NotNull String unescaped, boolean preferDoubleQuotes) {
|
||||
return createStringLiteralFromString(null, unescaped, true, preferDoubleQuotes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PyListLiteralExpression createListLiteral() {
|
||||
final PsiFile dummyFile = createDummyFile(LanguageLevel.getDefault(), "[]");
|
||||
|
||||
Reference in New Issue
Block a user