Support-automatically-inserting-non-required-attrs

This commit is contained in:
Dmitry Avdeev
2016-03-16 14:13:03 +03:00
parent 851d56e3a5
commit 20e9d564a6
2 changed files with 7 additions and 2 deletions
@@ -226,7 +226,8 @@ public class XmlTagInsertHandler implements InsertHandler<LookupElement> {
for (XmlAttributeDescriptor attributeDecl : attributes) {
String attributeName = attributeDecl.getName(tag);
if (attributeDecl.isRequired() && (tag == null || tag.getAttributeValue(attributeName) == null)) {
boolean shouldBeInserted = extension.shouldBeInserted(attributeDecl);
if (shouldBeInserted && (tag == null || tag.getAttributeValue(attributeName) == null)) {
if (!notRequiredAttributes.contains(attributeName)) {
if (!extension.isIndirectSyntax(attributeDecl)) {
template.addTextSegment(" " + attributeName + "=\"");
@@ -239,7 +240,7 @@ public class XmlTagInsertHandler implements InsertHandler<LookupElement> {
}
}
}
else if (attributeDecl.isRequired() && attributeDecl.isFixed() && attributeDecl.getDefaultValue() != null && !htmlCode) {
else if (shouldBeInserted && attributeDecl.isFixed() && attributeDecl.getDefaultValue() != null && !htmlCode) {
template.addTextSegment(" " + attributeName + "=\"" + attributeDecl.getDefaultValue() + "\"");
}
}
@@ -164,6 +164,10 @@ public abstract class XmlExtension {
return false;
}
public boolean shouldBeInserted(final XmlAttributeDescriptor descriptor) {
return descriptor.isRequired();
}
public boolean isCustomTagAllowed(final XmlTag tag) {
return false;
}