Generate the given object.

@param annotation the annotation.
@param it the target for the generated content.
@param context the context.
549896
protected void _generate(SarlAnnotationType annotation, PyAppendable it, IExtraLanguageGeneratorContext context) {
		generateTypeDeclaration(
				this.qualifiedNameProvider.getFullyQualifiedName(annotation).toString(),
				annotation.getName(), false, Collections.emptyList(),
				getTypeBuilder().getDocumentation(annotation),
				true,
				annotation.getMembers(), it, context, null);
	}
1098654
public AnnotatedTypeBuilder<X> addToField(AnnotatedField<? super X> field, Annotation annotation) {
       return addToField(field.getJavaMember(), annotation);
   }
1230544
protected void writeAnnotations( IAnnotated annotated)
    {
    toStream( annotated.getAnnotations())
      .sorted()
      .forEach( annotation -> {
        xmlWriter_
          .element( HAS_TAG)
          .attribute( NAME_ATR, annotation)
          .attribute( VALUE_ATR, annotated.getAnnotation( annotation))
          .write();
        });
    }
1365101
public static Annotation cloneAnnotation(ConstPool constPool, java.lang.annotation.Annotation annotation) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
		Class<?> clazz = annotation.annotationType();

		Annotation annot = new Annotation(clazz.getName(), constPool);
		for(Method method : clazz.getDeclaredMethods()) {
			MemberValue memberVal = null;
			
			if (method.getReturnType().isArray()) {
				List<MemberValue> memberVals = new LinkedList<MemberValue>();
				for(Object val : (Object[])method.invoke(annotation)) {
					memberVals.add(createMemberValue(constPool, val));
				}
				memberVal = new ArrayMemberValue(constPool);
				((ArrayMemberValue)memberVal).setValue(memberVals.toArray(new MemberValue[]{}));
			} else {
				memberVal = createMemberValue(constPool, method.invoke(annotation));
			}
			annot.addMemberValue(method.getName(), memberVal);
		}
		return annot;
	}
619723
protected void _generate(SarlEnumeration enumeration, PyAppendable it, IExtraLanguageGeneratorContext context) {
		generateEnumerationDeclaration(enumeration, it, context);
	}
1070287
protected void _generate(SarlScript script, IExtraLanguageGeneratorContext context) {
		if (script != null) {
			for (final XtendTypeDeclaration content : script.getXtendTypes()) {
				if (context.getCancelIndicator().isCanceled()) {
					return;
				}
				try {
					generate(content, context);
				} finally {
					context.clearData();
				}
			}
		}
	}
908205
protected void _generate(SarlAgent agent, IExtraLanguageGeneratorContext context) {
		final JvmDeclaredType jvmType = getJvmModelAssociations().getInferredType(agent);
		final PyAppendable appendable = createAppendable(jvmType, context);
		final List<JvmTypeReference> superTypes;
		if (agent.getExtends() != null) {
			superTypes = Collections.singletonList(agent.getExtends());
		} else {
			superTypes = Collections.singletonList(getTypeReferences().getTypeForName(Agent.class, agent));
		}
		final String qualifiedName = this.qualifiedNameProvider.getFullyQualifiedName(agent).toString();
		if (generateTypeDeclaration(
				qualifiedName,
				agent.getName(), agent.isAbstract(), superTypes,
				getTypeBuilder().getDocumentation(agent),
				true,
			agent.getMembers(), appendable, context, (it, context2) -> {
				generateGuardEvaluators(qualifiedName, it, context2);
			})) {
			final QualifiedName name = getQualifiedNameProvider().getFullyQualifiedName(agent);
			writeFile(name, appendable, context);
		}
	}
1146614
public static AnnotationTypeFieldBuilder getInstance(
            Context context, TypeElement typeElement,
            AnnotationTypeFieldWriter writer) {
        return new AnnotationTypeFieldBuilder(context, typeElement,
                    writer, VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS);
    }
1303614
protected XExpression _generate(SarlAssertExpression assertStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
		final boolean haveAssert = !assertStatement.isIsStatic() && assertStatement.getCondition() != null;
		if (haveAssert) {
			it.append("assert (lambda:"); //$NON-NLS-1$
			it.increaseIndentation().newLine();
			generate(assertStatement.getCondition(), it, context);
			it.decreaseIndentation().newLine();
			it.append(")()"); //$NON-NLS-1$
		}
		if (context.getExpectedExpressionType() != null) {
			if (haveAssert) {
				it.newLine();
			}
			it.append("return ").append(toDefaultValue(context.getExpectedExpressionType().toJavaCompliantTypeReference())); //$NON-NLS-1$
		}
		return assertStatement;
	}
595906
protected XExpression _generate(XBlockExpression block, IAppendable it, IExtraLanguageGeneratorContext context) {
		XExpression last = block;
		if (block.getExpressions().isEmpty()) {
			it.append("pass"); //$NON-NLS-1$
		} else {
			it.openScope();
			if (context.getExpectedExpressionType() == null) {
				boolean first = true;
				for (final XExpression expression : block.getExpressions()) {
					if (first) {
						first = false;
					} else {
						it.newLine();
					}
					last = generate(expression, it, context);
				}
			} else {
				final List<XExpression> exprs = block.getExpressions();
				if (!exprs.isEmpty()) {
					for (int i = 0; i < exprs.size() - 1; ++i) {
						if (i > 0) {
							it.newLine();
						}
						last = generate(exprs.get(i), it, context);
					}
					last = generate(exprs.get(exprs.size() - 1), context.getExpectedExpressionType(), it, context);
				}
			}
			it.closeScope();
		}
		return last;
	}
4791
public static <T> Qualifier<T> byAnnotation(Annotation annotation) {
        if (annotation.annotationType() == Type.class) {
            Type typeAnn = (Type) annotation;
            return byType(typeAnn.value());
        } else if (annotation.annotationType() == Named.class) {
            Named nameAnn = (Named) annotation;
            return byName(nameAnn.value());
        } else {
            return new AnnotationQualifier<>(annotation);
        }
    }
314239
@com.fasterxml.jackson.annotation.JsonProperty("Context")
    public void setContext(String context) {
        this.context = context;
    }
1043283
public void eInit(XtendTypeDeclaration container, IJvmTypeProvider context) {
		setTypeResolutionContext(context);
		if (this.sarlConstructor == null) {
			this.container = container;
			this.sarlConstructor = SarlFactory.eINSTANCE.createSarlConstructor();
			this.sarlConstructor.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendMember());
			container.getMembers().add(this.sarlConstructor);
		}
	}
244170
protected void _generate(SarlInterface interf, PyAppendable it, IExtraLanguageGeneratorContext context) {
		generateTypeDeclaration(
				this.qualifiedNameProvider.getFullyQualifiedName(interf).toString(),
				interf.getName(), true, interf.getExtends(),
				getTypeBuilder().getDocumentation(interf),
				true,
				interf.getMembers(), it, context, null);
	}
38529
protected static <T extends Annotation> T getAnnotationFromContext(InvocationContext context, Class<T> clazz) {
        T result = context.getMethod().getAnnotation(clazz);
        return result != null ? result : context.getTarget().getClass().getAnnotation(clazz);
    }
548955
private static void generateSerializeOnXml(BindTypeContext context, BindEntity entity) {
		// @formatter:off
		MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("serializeOnXml")
				.addJavadoc("method for xml serialization\n").addAnnotation(Override.class)
				.addModifiers(Modifier.PUBLIC)
				// .addParameter(typeName(KriptonXmlContext.class), "context")
				.addParameter(typeName(entity.getElement()), "object")
				.addParameter(typeName(XMLSerializer.class), "xmlSerializer")
				.addParameter(typeName(Integer.TYPE), "currentEventType").returns(Void.TYPE)
				.addException(Exception.class);
		// @formatter:on

		methodBuilder.beginControlFlow("if (currentEventType == 0)");
		methodBuilder.addStatement("xmlSerializer.writeStartElement(\"$L\")", entity.xmlInfo.label);

		// write namespace
		for (Pair<String, String> namespace : entity.xmlInfo.namespaces) {
			if (StringUtils.hasText(namespace.value0)) {
				methodBuilder.addStatement("xmlSerializer.writeAttribute(\"\", $S, $S)", "xmlns:" + namespace.value0,
						namespace.value1);
			} else {
				methodBuilder.addStatement("xmlSerializer.writeAttribute(\"\", $S, $S)", "xmlns", namespace.value1);
			}

		}

		methodBuilder.endControlFlow();

		BindTransform bindTransform;

		methodBuilder.addCode("\n");

		// attributes
		methodBuilder.addCode("// Persisted fields:\n\n");
		for (BindProperty item : entity.getCollection()) {
			bindTransform = BindTransformer.lookup(item);

			methodBuilder.addCode("// field $L (mapped with $S)\n", item.getName(), BindProperty.xmlName(item));
			if (item.hasTypeAdapter()) {
				methodBuilder.addCode("// field trasformation $L $L \n", item.typeAdapter.dataType,
						item.typeAdapter.adapterClazz);
			}
			bindTransform.generateSerializeOnXml(context, methodBuilder, "xmlSerializer",
					item.getPropertyType().getTypeName(), "object", item);
			methodBuilder.addCode("\n");
		}

		methodBuilder.beginControlFlow("if (currentEventType == 0)");
		methodBuilder.addStatement("xmlSerializer.writeEndElement()");
		methodBuilder.endControlFlow();

		// methodBuilder.nextControlFlow("catch($T e)",
		// typeName(Exception.class));
		// methodBuilder.addStatement("e.printStackTrace()");
		// methodBuilder.addStatement("throw (new $T(e))",
		// typeName(KriptonRuntimeException.class));
		// methodBuilder.endControlFlow();

		context.builder.addMethod(methodBuilder.build());
	}
1335325
@Override
    public void visitClassContext(final ClassContext classContext) {
        try {
            stack = new OpcodeStack();
            memberCollections = new HashMap<>();
            memberSourceLineAnnotations = new HashMap<>();
            super.visitClassContext(classContext);
        } finally {
            stack = null;
            memberCollections = null;
            memberSourceLineAnnotations = null;
        }
    }