use of com.intellij.xml.impl.schema.AnyXmlAttributeDescriptor in project intellij-plugins by JetBrains.
the class MxmlWriter method processElements.
@SuppressWarnings("StatementWithEmptyBody")
private boolean processElements(final XmlTag tag, @Nullable final Context parentContext, final boolean allowIncludeInExcludeFrom, final int dataPosition, final int referencePosition, final boolean writeLocation, @Nullable final Condition<AnnotationBackedDescriptor> propertyFilter) {
boolean staticChild = true;
ByteRange dataRange = null;
// if state specific property before includeIn, state override data range wil be added before object data range, so,
// we keep current index and insert at the specified position
final Marker dataRangeAfterAnchor = writer.getBlockOut().getLastMarker();
if (writeLocation) {
out.writeUInt29(writer.P_FUD_RANGE_ID);
out.writeUInt29(rangeMarkers.size());
rangeMarkers.add(document.createRangeMarker(tag.getTextOffset(), tag.getTextOffset() + tag.getTextLength()));
}
assert !tagAttributeProcessContext.isCssRulesetDefined();
Context context = tagAttributeProcessContext;
if (parentContext != null && parentContext.getScope().staticObjectPointToScope) {
tagAttributeProcessContext.setTempParentScope(parentContext.getScope());
}
for (final XmlAttribute attribute : tag.getAttributes()) {
if (attribute.getValueElement() == null) {
// skip invalid - "<Button label/>"
continue;
}
final XmlAttributeDescriptor attributeDescriptor = attribute.getDescriptor();
final AnnotationBackedDescriptor descriptor;
if (attributeDescriptor instanceof AnnotationBackedDescriptor) {
descriptor = (AnnotationBackedDescriptor) attributeDescriptor;
// id and includeIn/excludeFrom only as attribute, not as tag
if (descriptor.isPredefined()) {
if (descriptor.hasIdType()) {
processObjectWithExplicitId(attribute.getValue(), context);
} else if (allowIncludeInExcludeFrom) {
String name = descriptor.getName();
boolean excludeFrom = false;
if (name.equals(FlexStateElementNames.INCLUDE_IN) || (excludeFrom = name.equals(FlexStateElementNames.EXCLUDE_FROM))) {
if (context == tagAttributeProcessContext) {
context = new DynamicObjectContext(tagAttributeProcessContext);
}
// must be before stateWriter.includeIn - start object data range before state data range
dataRange = writer.getBlockOut().startRange(dataPosition, dataRangeAfterAnchor);
((DynamicObjectContext) context).setDataRange(dataRange);
stateWriter.includeInOrExcludeFrom(attribute.getValueElement(), parentContext, (DynamicObjectContext) context, excludeFrom);
staticChild = false;
} else if (name.equals(FlexStateElementNames.ITEM_CREATION_POLICY)) {
if (attribute.getValue().charAt(0) == 'i') {
if (context == tagAttributeProcessContext) {
context = new DynamicObjectContext(tagAttributeProcessContext);
}
((DynamicObjectContext) context).setImmediateCreation(true);
}
} else if (name.equals(FlexStateElementNames.ITEM_DESTRUCTION_POLICY)) {
if (attribute.getValue().charAt(0) == 'a') {
stateWriter.applyItemAutoDestruction(context, parentContext);
}
}
}
} else if (propertyFilter != null && !propertyFilter.value(descriptor)) {
// skip
} else if (MxmlUtil.isIdLanguageAttribute(attribute, descriptor)) {
String explicitId = attribute.getValue();
writer.idMxmlProperty(explicitId);
processObjectWithExplicitId(explicitId, context);
} else if (descriptor.getTypeName() == null) {
//IDEA-73453
// skip
LOG.warn("Skip " + descriptor.getName() + " in " + tag.getText() + " due to IDEA-73453");
} else if (hasStates && stateWriter.checkStateSpecificPropertyValue(this, propertyProcessor, valueProviderFactory.create(attribute), descriptor, context)) {
// skip
} else {
writeAttributeBackedProperty(attribute, descriptor, context, context);
}
} else if (attributeDescriptor instanceof AnyXmlAttributeDescriptor) {
writeAttributeBackedProperty(attribute, new AnyXmlAttributeDescriptorWrapper(attributeDescriptor), context, context);
} else if (!attribute.isNamespaceDeclaration()) {
LOG.warn("unknown attribute (" + attribute.getText() + ") descriptor: " + (attributeDescriptor == null ? "null" : attributeDescriptor.toString()) + " of tag " + tag.getText());
}
}
if (!hasStates) {
assert context == tagAttributeProcessContext;
context = writer.createStaticContext(parentContext, referencePosition);
if (tagAttributeProcessContext.isCssRulesetDefined()) {
context.markCssRulesetDefined();
}
} else if (context == tagAttributeProcessContext) {
context = stateWriter.createContextForStaticBackSibling(allowIncludeInExcludeFrom, referencePosition, parentContext);
stateWriter.finalizeStateSpecificAttributesForStaticContext((StaticObjectContext) context, parentContext, this);
if (tagAttributeProcessContext.isCssRulesetDefined()) {
context.markCssRulesetDefined();
}
}
tagAttributeProcessContext.reset();
processTagChildren(tag, context, parentContext, true, null);
// width="150"><group>{cardtype} !!id (for binding target, RadioButton id="visa") allocation here!!</group></RadioButton>
if (dataPosition != -1) {
writer.endObject();
if (dataRange != null) {
writer.getBlockOut().endRange(dataRange);
}
}
return staticChild;
}
Aggregations