use of com.intellij.flex.uiDesigner.io.PrimitiveAmfOutputStream in project intellij-plugins by JetBrains.
the class PropertyProcessor method writeInlineArray.
private void writeInlineArray(XmlElementValueProvider valueProvider) {
final PrimitiveAmfOutputStream out = writer.getOut();
out.write(Amf3Types.ARRAY);
final int lengthPosition = out.allocateShort();
int validChildrenCount = 0;
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
final String value = valueProvider.getTrimmed();
try {
char quoteChar = '\'';
boolean inQuotes = false;
for (int index = 1, length = value.length(); index < length; index++) {
char c = value.charAt(index);
switch(c) {
case '[':
if (inQuotes) {
builder.append(c);
}
break;
case '"':
case '\'':
if (inQuotes) {
if (quoteChar == c) {
inQuotes = false;
} else {
builder.append(c);
}
} else {
inQuotes = true;
quoteChar = c;
}
break;
case ',':
case ']':
if (inQuotes) {
builder.append(c);
} else {
int beginIndex = 0;
int endIndex = builder.length();
while (beginIndex < endIndex && builder.charAt(beginIndex) <= ' ') {
beginIndex++;
}
while (beginIndex < endIndex && builder.charAt(endIndex - 1) <= ' ') {
endIndex--;
}
if (endIndex == 0) {
writer.stringReference(XmlElementValueProvider.EMPTY);
} else {
out.write(Amf3Types.STRING);
out.writeAmfUtf(builder, false, beginIndex, endIndex);
}
validChildrenCount++;
builder.setLength(0);
}
break;
default:
builder.append(c);
}
}
} finally {
StringBuilderSpinAllocator.dispose(builder);
}
out.putShort(validChildrenCount, lengthPosition);
}
use of com.intellij.flex.uiDesigner.io.PrimitiveAmfOutputStream in project intellij-plugins by JetBrains.
the class StateWriter method writeDeferredInstance.
void writeDeferredInstance(DynamicObjectContext instance) {
PrimitiveAmfOutputStream out = writer.getOut();
if (instance.isWritten()) {
writeDeferredInstanceKind(AmfExtendedTypes.OBJECT_REFERENCE, instance);
out.writeUInt29(instance.id);
} else {
// IDEA-72004
if (instance.overrideUserCount > 0) {
instance.getOrAllocateId();
}
if (instance.id == -1) {
writeDeferredInstanceKind(ObjectMetadata.NEVER_REFERRED, instance);
} else {
writeDeferredInstanceKind(ObjectMetadata.REFERRED, instance);
instance.markAsWritten();
}
out.writeUInt29(BlockDataOutputStream.getDataRangeOwnLength(instance.getDataRange()) + 2);
out.writeShort(instance.getReferredObjectsCount());
writer.getBlockOut().append(instance.getDataRange());
if (instance.id != -1) {
out.writeUInt29(instance.id);
}
}
}
use of com.intellij.flex.uiDesigner.io.PrimitiveAmfOutputStream in project intellij-plugins by JetBrains.
the class ExpressionBinding method writeFunction.
private static void writeFunction(JSFunction function, BaseWriter writer, @Nullable ValueReferenceResolver valueReferenceResolver, boolean isBinding, @Nullable JSCallExpression expression, @Nullable JSReferenceExpression methodExpression) throws InvalidPropertyException {
final PrimitiveAmfOutputStream out = writer.getOut();
JSExpression[] arguments;
final int rollbackPosition;
final int start;
if (function.isConstructor()) {
assert expression != null;
arguments = expression.getArguments();
final JSClass jsClass = (JSClass) function.getParent();
// text="{new String('newString')}"
writer.newInstance(jsClass.getQualifiedName(), arguments.length, true);
rollbackPosition = out.allocateShort();
start = out.size();
} else {
out.write(ExpressionMessageTypes.CALL);
rollbackPosition = out.allocateShort();
start = out.size();
// text="{resourceManager.getString('core', 'viewSource')}"
if (methodExpression != null) {
JSReferenceExpression qualifier = (JSReferenceExpression) methodExpression.getQualifier();
while (qualifier != null) {
writer.classOrPropertyName(qualifier.getReferencedName());
qualifier = (JSReferenceExpression) qualifier.getQualifier();
}
}
out.write(0);
writer.classOrPropertyName(function.getName());
if (function.isGetProperty()) {
out.write(isBinding ? -2 : -1);
return;
} else {
assert expression != null;
arguments = expression.getArguments();
out.write(arguments.length);
}
}
for (JSExpression argument : arguments) {
writeExpression(argument, out, writer, valueReferenceResolver);
}
out.putShort(out.size() - start, rollbackPosition);
}
use of com.intellij.flex.uiDesigner.io.PrimitiveAmfOutputStream in project intellij-plugins by JetBrains.
the class PropertyProcessor method processFxComponent.
boolean processFxComponent(XmlTag tag, boolean allowNullableIdOrClassName) {
String className = getAttributeValue(tag, "className");
if (className != null && writeFxComponentReferenceIfProcessed(className)) {
return true;
}
final MxmlObjectReference objectReference = processFxDeclarationId(tag, className, allowNullableIdOrClassName);
if (objectReference == null && !allowNullableIdOrClassName) {
return false;
}
final int objectReferenceId = objectReference == null ? writer.allocateAbsoluteStaticObjectId() : objectReference.id;
final int sizePosition = writer.componentFactory(objectReferenceId);
final XmlTag[] subTags = tag.getSubTags();
final int objectTableSize;
final PrimitiveAmfOutputStream out = writer.getOut();
if (subTags.length == 1) {
out.write(Amf3Types.OBJECT);
Context context = writer.createInnerComponentContext(objectReference, objectReferenceId);
mxmlWriter.processPropertyTagValue(null, tag, context, COMPLEX);
objectTableSize = context.getScope().referenceCounter;
} else {
// as object without any properties
writer.objectHeader("Object");
writer.endObject();
if (subTags.length > 1) {
LOG.warn("Skip fx:component, only one root tag is allowed: " + tag.getText());
}
objectTableSize = 0;
}
out.putShort(out.size() - (sizePosition + 2), sizePosition);
out.putShort(objectTableSize, sizePosition + 2);
return true;
}
use of com.intellij.flex.uiDesigner.io.PrimitiveAmfOutputStream in project intellij-plugins by JetBrains.
the class StateWriter method write.
public void write() {
final PrimitiveAmfOutputStream out = writer.getOut();
out.write(states.size());
if (states.isEmpty()) {
return;
}
for (State state : states) {
writer.property(NAME).string(state.name);
if (!state.overrides.isEmpty()) {
writer.property(OVERRIDES).arrayHeader(state.overrides.size());
for (OverrideBase override : state.overrides) {
override.write(writer, this);
}
}
// object State footer
writer.endObject();
}
reset();
}
Aggregations