@Override public final String toString() { return getRawText(); }
@Override public final String toString() { return getRawText(); }
/** Append the raw text segment to the output stream. */ private static void writeRawText(SoyMsgRawTextPart msgPart, Appendable out) throws IOException { out.append(msgPart.getRawText()); }
/** * Private helper to build valid Python string for a list of {@link SoyMsgPart}s. * * <p>It only processes {@link SoyMsgRawTextPart} and {@link SoyMsgPlaceholderPart} and ignores * others, because we didn't generate a direct string for plural and select nodes. * * <p>For {@link SoyMsgRawTextPart}, it appends the raw text and applies necessary escaping; For * {@link SoyMsgPlaceholderPart}, it turns the placeholder's variable name into Python replace * format. * * @param parts The SoyMsgPart parts to convert. * @param escaper A Function which provides escaping for raw text. * @return A String representing all the {@code parts} in Python. */ private static String processMsgPartsHelper( ImmutableList<SoyMsgPart> parts, Function<String, String> escaper) { StringBuilder rawMsgTextSb = new StringBuilder(); for (SoyMsgPart part : parts) { if (part instanceof SoyMsgRawTextPart) { rawMsgTextSb.append(escaper.apply(((SoyMsgRawTextPart) part).getRawText())); } if (part instanceof SoyMsgPlaceholderPart) { String phName = ((SoyMsgPlaceholderPart) part).getPlaceholderName(); rawMsgTextSb.append("{" + phName + "}"); } } return rawMsgTextSb.toString(); }
/** * Private helper to build valid Python string for a list of {@link SoyMsgPart}s. * * <p>It only processes {@link SoyMsgRawTextPart} and {@link SoyMsgPlaceholderPart} and ignores * others, because we didn't generate a direct string for plural and select nodes. * * <p>For {@link SoyMsgRawTextPart}, it appends the raw text and applies necessary escaping; For * {@link SoyMsgPlaceholderPart}, it turns the placeholder's variable name into Python replace * format. * * @param parts The SoyMsgPart parts to convert. * @param escaper A Function which provides escaping for raw text. * @return A String representing all the {@code parts} in Python. */ private static String processMsgPartsHelper( ImmutableList<SoyMsgPart> parts, Function<String, String> escaper) { StringBuilder rawMsgTextSb = new StringBuilder(); for (SoyMsgPart part : parts) { if (part instanceof SoyMsgRawTextPart) { rawMsgTextSb.append(escaper.apply(((SoyMsgRawTextPart) part).getRawText())); } if (part instanceof SoyMsgPlaceholderPart) { String phName = ((SoyMsgPlaceholderPart) part).getPlaceholderName(); rawMsgTextSb.append("{" + phName + "}"); } } return rawMsgTextSb.toString(); }
/** * Processes a {@code SoyMsgRawTextPart} and appends the contained text to the {@code * StringBuilder} object in {@code RenderVisitor}. * * @param rawTextPart The raw text part. */ private void appendRawTextPart(SoyMsgRawTextPart rawTextPart) { RenderVisitor.append(master.getCurrOutputBufForUseByAssistants(), rawTextPart.getRawText()); } }
/** * Processes a {@code SoyMsgRawTextPart} and appends the contained text to * the {@code StringBuilder} object in {@code RenderVisitor}. * @param rawTextPart The raw text part. */ private void visitPart(SoyMsgRawTextPart rawTextPart) { RenderVisitor.append(master.getCurrOutputBufForUseByAssistants(), rawTextPart.getRawText()); }
msgStrSb.append(((SoyMsgRawTextPart) msgPart).getRawText());
/** * Processes a {@code SoyMsgRawTextPart} and appends the contained text to the {@code * StringBuilder} object in {@code RenderVisitor}. * * @param rawTextPart The raw text part. */ private void appendRawTextPart(SoyMsgRawTextPart rawTextPart) { RenderVisitor.append(master.getCurrOutputBufForUseByAssistants(), rawTextPart.getRawText()); } }
msgStrSb.append(((SoyMsgRawTextPart) msgPart).getRawText());
msgStrSb.append(((SoyMsgRawTextPart) msgPart).getRawText());
msgStrSb.append(((SoyMsgRawTextPart) msgPart).getRawText());
/** * Appends a list of SoyMsgParts to the passed StringBuilder. * * @param stringBuilder The StringBuilder to append to. * @param soyMsgParts The list of SoyMsgParts to add. * @param doUseBracedPhs Whether to use braced placeholders. */ private static void appendMsgPartsToTcStringBuilder( StringBuilder stringBuilder, List<SoyMsgPart> soyMsgParts, boolean doUseBracedPhs) { for (SoyMsgPart msgPart : soyMsgParts) { if (msgPart instanceof SoyMsgRawTextPart) { stringBuilder.append(((SoyMsgRawTextPart) msgPart).getRawText()); } else if (msgPart instanceof SoyMsgPlaceholderPart) { if (doUseBracedPhs) { stringBuilder.append('{'); } stringBuilder.append(((SoyMsgPlaceholderPart) msgPart).getPlaceholderName()); if (doUseBracedPhs) { stringBuilder.append('}'); } } else if (msgPart instanceof SoyMsgPluralRemainderPart) { stringBuilder.append(IcuSyntaxUtils.getPluralRemainderString()); } else if (msgPart instanceof SoyMsgPluralPart) { appendPluralToStringBuilder(stringBuilder, (SoyMsgPluralPart) msgPart, doUseBracedPhs); } else if (msgPart instanceof SoyMsgSelectPart) { appendSelectToStringBuilder(stringBuilder, (SoyMsgSelectPart) msgPart, doUseBracedPhs); } } }
String rawText = ((SoyMsgRawTextPart) origMsgPart).getRawText(); if (isInPlrselPart) { rawText = icuEscape(rawText);
String rawText = ((SoyMsgRawTextPart) origMsgPart).getRawText(); if (isInPlrselPart) { rawText = icuEscape(rawText);
/** Private helper for visitMsgFallbackGroupNode() to render a message from its translation. */ private void renderMsgFromTranslation( MsgNode msg, ImmutableList<SoyMsgPart> msgParts, @Nullable ULocale locale) { SoyMsgPart firstPart = msgParts.get(0); if (firstPart instanceof SoyMsgPluralPart) { new PlrselMsgPartsVisitor(msg, locale).visitPart((SoyMsgPluralPart) firstPart); } else if (firstPart instanceof SoyMsgSelectPart) { new PlrselMsgPartsVisitor(msg, locale).visitPart((SoyMsgSelectPart) firstPart); } else { for (SoyMsgPart msgPart : msgParts) { if (msgPart instanceof SoyMsgRawTextPart) { RenderVisitor.append( master.getCurrOutputBufForUseByAssistants(), ((SoyMsgRawTextPart) msgPart).getRawText()); } else if (msgPart instanceof SoyMsgPlaceholderPart) { String placeholderName = ((SoyMsgPlaceholderPart) msgPart).getPlaceholderName(); visit(msg.getRepPlaceholderNode(placeholderName)); } else { throw new AssertionError(); } } } }
String rawText = ((SoyMsgRawTextPart) msgPart).getRawText(); currReplacementNodes.add( new RawTextNode(nodeIdGen.genId(), rawText, msg.getSourceLocation()));
/** Private helper for visitMsgFallbackGroupNode() to render a message from its translation. */ private void renderMsgFromTranslation( MsgNode msg, ImmutableList<SoyMsgPart> msgParts, @Nullable ULocale locale) { SoyMsgPart firstPart = msgParts.get(0); if (firstPart instanceof SoyMsgPluralPart) { new PlrselMsgPartsVisitor(msg, locale).visitPart((SoyMsgPluralPart) firstPart); } else if (firstPart instanceof SoyMsgSelectPart) { new PlrselMsgPartsVisitor(msg, locale).visitPart((SoyMsgSelectPart) firstPart); } else { for (SoyMsgPart msgPart : msgParts) { if (msgPart instanceof SoyMsgRawTextPart) { RenderVisitor.append( master.getCurrOutputBufForUseByAssistants(), ((SoyMsgRawTextPart) msgPart).getRawText()); } else if (msgPart instanceof SoyMsgPlaceholderPart) { String placeholderName = ((SoyMsgPlaceholderPart) msgPart).getPlaceholderName(); visit(msg.getRepPlaceholderNode(placeholderName)); } else { throw new AssertionError(); } } } }
String rawText = ((SoyMsgRawTextPart) msgPart).getRawText(); currReplacementNodes.add( new RawTextNode(nodeIdGen.genId(), rawText, msg.getSourceLocation()));
} else if (part instanceof SoyMsgRawTextPart) { return SOY_MSG_RAW_TEXT_PART_OF.invoke( constant(((SoyMsgRawTextPart) part).getRawText(), variables)); } else if (part instanceof SoyMsgSelectPart) { SoyMsgSelectPart selectPart = (SoyMsgSelectPart) part;