private SoyMsgPart compactPlaceholder(SoyMsgPlaceholderPart part) { return new SoyMsgPlaceholderPart( intern(part.getPlaceholderName()), /* placeholderExample=*/ null); }
private SoyMsgPart compactPlaceholder(SoyMsgPlaceholderPart part) { return new SoyMsgPlaceholderPart( intern(part.getPlaceholderName()), /* placeholderExample=*/ null); }
currRawTextPart = null; currMsgParts.add(new SoyMsgPlaceholderPart(atts.getValue("id"), atts.getValue("example")));
currRawTextPart = null; currMsgParts.add(new SoyMsgPlaceholderPart(atts.getValue("id"), atts.getValue("example")));
currRawTextPart = null; currMsgParts.add(new SoyMsgPlaceholderPart(atts.getValue("id")));
/** * Builds the list of SoyMsgParts for all the children of a given parent node. * * @param parent Can be MsgNode, MsgPluralCaseNode, MsgPluralDefaultNode, MsgSelectCaseNode, or * MsgSelectDefaultNode. * @param msgNode The MsgNode containing 'parent'. */ private static ImmutableList<SoyMsgPart> buildMsgPartsForChildren( BlockNode parent, MsgNode msgNode) { ImmutableList.Builder<SoyMsgPart> msgParts = ImmutableList.builder(); for (StandaloneNode child : parent.getChildren()) { if (child instanceof RawTextNode) { String rawText = ((RawTextNode) child).getRawText(); msgParts.add(SoyMsgRawTextPart.of(rawText)); } else if (child instanceof MsgPlaceholderNode) { PlaceholderInfo placeholder = msgNode.getPlaceholder((MsgPlaceholderNode) child); msgParts.add(new SoyMsgPlaceholderPart(placeholder.name(), placeholder.example())); } else if (child instanceof MsgPluralNode) { msgParts.add(buildMsgPartForPlural((MsgPluralNode) child, msgNode)); } else if (child instanceof MsgSelectNode) { msgParts.add(buildMsgPartForSelect((MsgSelectNode) child, msgNode)); } } return msgParts.build(); }
private static void doBuildMsgPartsForChildren( MsgBlockNode parent, MsgNode msgNode, ImmutableList.Builder<SoyMsgPart> msgParts) { for (StandaloneNode child : parent.getChildren()) { if (child instanceof RawTextNode) { String rawText = ((RawTextNode) child).getRawText(); msgParts.add(SoyMsgRawTextPart.of(rawText)); } else if (child instanceof MsgPlaceholderNode) { PlaceholderInfo placeholder = msgNode.getPlaceholder((MsgPlaceholderNode) child); msgParts.add(new SoyMsgPlaceholderPart(placeholder.name(), placeholder.example())); } else if (child instanceof MsgPluralNode) { msgParts.add(buildMsgPartForPlural((MsgPluralNode) child, msgNode)); } else if (child instanceof MsgSelectNode) { msgParts.add(buildMsgPartForSelect((MsgSelectNode) child, msgNode)); } else if (child instanceof VeLogNode) { doBuildMsgPartsForChildren((VeLogNode) child, msgNode, msgParts); } else { throw new AssertionError("unexpected child: " + child); } } }
/** * Builds the list of SoyMsgParts for all the children of a given parent node. * @param parent Can be MsgNode, MsgPluralCaseNode, MsgPluralDefaultNode, * MsgSelectCaseNode, or MsgSelectDefaultNode. * @param msgNode The MsgNode containing 'parent'. */ private static List<SoyMsgPart> buildMsgPartsForChildren( BlockNode parent, MsgNode msgNode) { List<SoyMsgPart> msgParts = Lists.newArrayList(); for (StandaloneNode child : parent.getChildren()) { if (child instanceof RawTextNode) { String rawText = ((RawTextNode) child).getRawText(); msgParts.add(new SoyMsgRawTextPart(rawText)); } else if (child instanceof MsgPlaceholderNode) { String placeholderName = msgNode.getPlaceholderName((MsgPlaceholderNode) child); msgParts.add(new SoyMsgPlaceholderPart(placeholderName)); } else if (child instanceof MsgPluralRemainderNode) { msgParts.add(new SoyMsgPluralRemainderPart( msgNode.getPluralVarName(child.getNearestAncestor(MsgPluralNode.class)))); } else if (child instanceof MsgPluralNode) { msgParts.add(buildMsgPartForPlural((MsgPluralNode) child, msgNode)); } else if (child instanceof MsgSelectNode) { msgParts.add(buildMsgPartForSelect((MsgSelectNode) child, msgNode)); } } return msgParts; }