boolean (@NotNull Field field, @NotNull StringBuilder fStringText) { final String stringText = myPyString.getText(); // Actual format field fStringText.append("{"); final PySubstitutionChunkReference reference = createReference(field); final PyExpression resolveResult = adjustResolveResult(reference.resolve()); if (resolveResult == null) return false; final PsiElement adjusted = prepareExpressionToInject(resolveResult, field); if (adjusted == null) return false; fStringText.append(adjusted.getText()); final String quotedAttrsAndItems = quoteItemsInFragments(field); if (quotedAttrsAndItems == null) return false; fStringText.append(quotedAttrsAndItems); // Conversion is copied as is if it's present final String conversion = field.getConversion(); if (conversion != null) { fStringText.append(conversion); } // Format spec is copied if present handling nested fields final TextRange specRange = field.getFormatSpecRange(); if (specRange != null) { int specOffset = specRange.getStartOffset(); // Do not proceed too nested fields if (field.getDepth() == 1) { for (Field nestedField : field.getNestedFields()) { // Copy text of the format spec between nested fragments fStringText.append(stringText, specOffset, nestedField.getLeftBraceOffset()); specOffset = nestedField.getFieldEnd(); // recursively format nested field if (!processSubstitutionChunk(nestedField, fStringText)) { return false; } } } if (specOffset < specRange.getEndOffset()) { fStringText.append(stringText, specOffset, specRange.getEndOffset()); } } fStringText.append("}"); return true; }