// Check that all delegate templates with the same name have the same declared params and
// content kind.
for (List<DelegateTemplateDivision> divisions : delTemplatesMap.values()) {
TemplateDelegateNode firstDelTemplate = null;
String firstDelPackageName = null;
Set<SoyDocParam> firstSoyDocParamsSet = null;
ContentKind firstContentKind = null;
for (DelegateTemplateDivision division : divisions) {
for (TemplateDelegateNode delTemplate : division.delPackageNameToDelTemplateMap.values()) {
String currDelPackageName = (delTemplate.getDelPackageName() != null) ?
delTemplate.getDelPackageName() : "<default>";
if (firstDelTemplate == null) {
// First template encountered.
firstDelTemplate = delTemplate;
firstDelPackageName = currDelPackageName;
firstSoyDocParamsSet = Sets.newHashSet(delTemplate.getSoyDocParams());
firstContentKind = delTemplate.getContentKind();
} else {
// Not first template encountered.
Set<SoyDocParam> currSoyDocParamsSet = Sets.newHashSet(delTemplate.getSoyDocParams());
if (! currSoyDocParamsSet.equals(firstSoyDocParamsSet)) {
throw SoySyntaxExceptionUtils.createWithNode(
String.format(
"Found delegate templates with same name '%s' but different param" +
" declarations in delegate packages '%s' and '%s'.",
firstDelTemplate.getDelTemplateName(), firstDelPackageName,
currDelPackageName),
firstDelTemplate);
}
if (delTemplate.getContentKind() != firstContentKind) {
// TODO: This is only *truly* a requirement if the strict mode deltemplates are being