}
}
// create attributes for name tokens
List<PolymerAttributeElement> attributes = Lists.newArrayList();
Set<String> definedNames = Sets.newHashSet();
ClassElement classElement = dartElement.getClassElement();
for (NameToken nameToken : nameTokens) {
int offset = nameToken.offset;
// prepare name
String name = nameToken.value;
if (!isValidAttributeName(name)) {
reportErrorForNameToken(nameToken, PolymerCode.INVALID_ATTRIBUTE_NAME, name);
continue;
}
if (!definedNames.add(name)) {
reportErrorForNameToken(nameToken, PolymerCode.DUPLICATE_ATTRIBUTE_DEFINITION, name);
continue;
}
// create attribute
PolymerAttributeElementImpl attribute = new PolymerAttributeElementImpl(name, offset);
attributes.add(attribute);
// resolve field
FieldElement field = classElement.getField(name);
if (field == null) {
reportErrorForNameToken(
nameToken,
PolymerCode.UNDEFINED_ATTRIBUTE_FIELD,
name,
classElement.getDisplayName());
continue;
}
if (!isPublishedField(field)) {
reportErrorForNameToken(
nameToken,
PolymerCode.ATTRIBUTE_FIELD_NOT_PUBLISHED,
name,
classElement.getDisplayName());
}
attribute.setField(field);
}
htmlElement.setAttributes(attributes.toArray(new PolymerAttributeElement[attributes.size()]));
}