use of com.intellij.flex.uiDesigner.InvalidPropertyException in project intellij-plugins by JetBrains.
the class PropertyProcessor method write.
@SuppressWarnings("StatementWithEmptyBody")
@Override
public PropertyKind write(AnnotationBackedDescriptor descriptor, XmlElementValueProvider valueProvider, PrimitiveAmfOutputStream out, BaseWriter writer, boolean isStyle, @Nullable Context parentContext) throws InvalidPropertyException {
final String type = descriptor.getType();
if (isStyle) {
int flags = 0;
if (isEffect()) {
flags |= StyleFlags.EFFECT;
out.write(flags);
out.write(Amf3Types.OBJECT);
return COMPLEX_STYLE;
} else {
out.write(flags);
}
} else if (isEffect()) {
out.write(Amf3Types.OBJECT);
return COMPLEX;
}
if (writeIfPrimitive(valueProvider, type, out, descriptor, isStyle, false)) {
} else if (type.equals(JSCommonTypeNames.ARRAY_CLASS_NAME)) {
if (!descriptor.isRichTextContent() && valueProvider instanceof XmlAttributeValueProvider && isInlineArray(valueProvider.getTrimmed())) {
writeInlineArray(valueProvider);
} else {
out.write(Amf3Types.ARRAY);
return ARRAY;
}
} else if (descriptor.getArrayType() != null) {
if (valueProvider.getElement() instanceof XmlTag) {
final XmlTag propertyTag = (XmlTag) valueProvider.getElement();
final XmlTag[] subTags = propertyTag.getSubTags();
if (subTags.length == 1) {
final XmlTag contentTag = subTags[0];
final XmlElementDescriptor contentTagDescriptor = contentTag.getDescriptor();
if (contentTagDescriptor instanceof ClassBackedElementDescriptor && CodeContext.AS3_VEC_VECTOR_QUALIFIED_NAME.equals(contentTagDescriptor.getQualifiedName())) {
if (!mxmlWriter.processMxmlVector(contentTag, parentContext, false)) {
throw new InvalidPropertyException(contentTag, "invalid.vector.value");
}
return isStyle ? PRIMITIVE_STYLE : PRIMITIVE;
}
}
}
writer.vectorHeader(descriptor.getArrayType());
return VECTOR;
} else if (type.equals(JSCommonTypeNames.OBJECT_CLASS_NAME) || type.equals(JSCommonTypeNames.ANY_TYPE)) {
final PropertyKind propertyKind = writeUntypedPropertyValue(out, valueProvider, descriptor, isStyle, parentContext);
if (propertyKind != null) {
return propertyKind;
}
} else if (type.equals(FlexCommonTypeNames.IFACTORY)) {
writeClassFactory(valueProvider);
} else {
out.write(Amf3Types.OBJECT);
return isStyle ? COMPLEX_STYLE : COMPLEX;
}
return isStyle ? PRIMITIVE_STYLE : PRIMITIVE;
}
use of com.intellij.flex.uiDesigner.InvalidPropertyException in project intellij-plugins by JetBrains.
the class StateWriter method checkStateSpecificPropertyValue.
public boolean checkStateSpecificPropertyValue(MxmlWriter mxmlWriter, PropertyProcessor propertyProcessor, XmlElementValueProvider valueProvider, AnnotationBackedDescriptor descriptor, @NotNull Context context) {
PsiReference[] references = valueProvider.getElement().getReferences();
if (references.length < 2) {
return false;
}
List<State> states = null;
for (int i = references.length - 1; i > -1; i--) {
PsiReference psiReference = references[i];
if (psiReference instanceof StateReference) {
// resolve is expensive for StateReference, so, we use string key (states name) instead of object key (states tag)
states = nameToState.get(psiReference.getCanonicalText());
break;
}
}
if (states == null) {
return false;
}
final List<State> filteredStates;
if (context instanceof DynamicObjectContext) {
final ArrayList<State> includeInStates = ((DynamicObjectContext) context).includeInStates;
filteredStates = new ArrayList<>(states.size());
for (State state : states) {
if (includeInStates.contains(state)) {
filteredStates.add(state);
} else {
MxmlWriter.LOG.warn("Skip " + valueProvider.getElement().getText() + " from " + state.name + " " + "due to element parent object included only in " + includeInStates);
}
}
if (filteredStates.isEmpty()) {
return true;
}
} else {
filteredStates = states;
}
ValueWriter valueWriter = null;
try {
valueWriter = propertyProcessor.process(valueProvider.getElement(), valueProvider, descriptor, context);
} catch (InvalidPropertyException ignored) {
}
if (valueWriter == null) {
// binding is not yet supported for state specific
return true;
}
final PrimitiveAmfOutputStream out = writer.getOut();
SetPropertyOrStyle override = new SetPropertyOrStyle(writer.getBlockOut().startRange());
writer.classOrPropertyName(propertyProcessor.isStyle() ? "com.intellij.flex.uiDesigner.flex.states.SetStyle" : "com.intellij.flex.uiDesigner.flex.states.SetProperty");
writer.property(NAME).stringReference(propertyProcessor.getName());
writer.property(VALUE);
PropertyKind propertyKind;
try {
propertyKind = valueWriter.write(descriptor, valueProvider, out, writer, false, context);
} catch (InvalidPropertyException ignored) {
// todo handle invalidProperty for state
throw new UnsupportedOperationException("");
}
if (propertyKind.isComplex()) {
mxmlWriter.processPropertyTagValue(descriptor, (XmlTag) valueProvider.getElement(), context, propertyKind);
}
override.targetId = context.getOrAllocateId();
if (pendingFirstSetProperty == null && context instanceof NullContext) {
pendingFirstSetProperty = override;
}
writer.getBlockOut().endRange(override.dataRange);
for (State state : filteredStates) {
state.overrides.add(override);
}
return true;
}
use of com.intellij.flex.uiDesigner.InvalidPropertyException in project intellij-plugins by JetBrains.
the class LocalCssWriter method writeClassReference.
@Override
protected void writeClassReference(JSClass jsClass, FlexStyleIndexInfo info, CssString cssString) throws InvalidPropertyException {
final int projectComponentFactoryId;
if (info != null && info.getAttributeName().equals("skinClass")) {
projectComponentFactoryId = InjectionUtil.getProjectComponentFactoryId(jsClass, projectComponentReferenceCounter);
} else if (InjectionUtil.isProjectComponent(jsClass)) {
throw new InvalidPropertyException(cssString, "class.reference.in.css.support.only.skin.class", jsClass.getQualifiedName());
} else {
projectComponentFactoryId = -1;
}
if (projectComponentFactoryId == -1) {
super.writeClassReference(jsClass, info, cssString);
} else {
propertyOut.write(AmfExtendedTypes.DOCUMENT_FACTORY_REFERENCE);
propertyOut.writeUInt29(projectComponentFactoryId);
}
}
Aggregations