void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiElement expression = descriptor.getPsiElement(); if (expression instanceof PyStringLiteralExpression && expression.isWritable()) { PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); String stringText = expression.getText(); int prefixLength = PyStringLiteralUtil.getPrefixLength(stringText); String prefix = stringText.substring(0, prefixLength); String content = stringText.substring(prefixLength); if (content.startsWith("'''") ) { content = content.substring(3, content.length()-3); } else if (content.startsWith("\"\"\"")) return; else { content = content.length() == 1 ? "" : content.substring(1, content.length()-1); } if (content.endsWith("\"")) content = StringUtil.replaceSubstring(content, TextRange.create(content.length()-1, content.length()), "\\\""); PyExpression newString = elementGenerator.createDocstring(prefix+"\"\"\"" + content + "\"\"\"").getExpression(); expression.replace(newString); } }