void () { final String stringText = myPyString.getText(); final StringBuilder fStringText = new StringBuilder(); fStringText.append("f"); fStringText.append(StringUtil.replaceIgnoreCase(myNodeInfo.getPrefix(), "u", "")); fStringText.append(myNodeInfo.getQuote()); final TextRange contentRange = myNodeInfo.getContentRange(); int offset = contentRange.getStartOffset(); for (final T chunk : extractTopLevelSubstitutionChunks()) { processLiteralChunk(stringText.substring(offset, chunk.getStartIndex()), fStringText); if (!processSubstitutionChunk(chunk, fStringText)) { return; } offset = chunk.getEndIndex(); } if (offset < contentRange.getEndOffset()) { processLiteralChunk(stringText.substring(offset, contentRange.getEndOffset()), fStringText); } fStringText.append(myNodeInfo.getQuote()); final PyExpression expressionToReplace = getWholeExpressionToReplace(); final PyElementGenerator generator = PyElementGenerator.getInstance(myPyString.getProject()); final PyExpression fString = generator.createExpressionFromText(LanguageLevel.forElement(myPyString), fStringText.toString()); expressionToReplace.replace(fString); }