mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Support-automatically-inserting-non-required-attrs
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user