OperatorMethodDescriptor descriptor,
Type objectType) {
assert context != null;
assert descriptor != null;
assert objectType != null;
JavadocBuilder javadoc = new JavadocBuilder(factory);
javadoc.inline(descriptor.getDocumentation());
List<FormalParameterDeclaration> parameters = Lists.create();
List<Expression> arguments = Lists.create();
List<Expression> inputMetaData = Lists.create();
for (OperatorPortDeclaration var : descriptor.getInputPorts()) {
SimpleName name = factory.newSimpleName(var.getName());
javadoc.param(name).inline(var.getDocumentation());
parameters.add(util.toFactoryMethodInput(var, name));
inputMetaData.add(util.toMetaData(var, arguments.size()));
arguments.add(name);
}
List<Expression> outputMetaData = Lists.create();
for (OperatorPortDeclaration var : descriptor.getOutputPorts()) {
outputMetaData.add(util.toMetaData(var, -1));
}
List<Expression> parameterMetaData = Lists.create();
for (OperatorPortDeclaration var : descriptor.getParameters()) {
SimpleName name = factory.newSimpleName(var.getName());
javadoc.param(name).inline(var.getDocumentation());
parameters.add(factory.newFormalParameterDeclaration(
util.t(var.getType().getRepresentation()),
name));
parameterMetaData.add(util.toMetaData(var, arguments.size()));
arguments.add(name);
}
javadoc.returns().text("生成した演算子オブジェクト");
List<Type> rawParameterTypes = Lists.create();
for (VariableElement var : context.element.getParameters()) {
rawParameterTypes.add(util.t(environment.getErasure(var.asType())));
}
javadoc.seeMethod(
util.t(operatorClass.getElement()),
descriptor.getName(),
rawParameterTypes);
return factory.newMethodDeclaration(
javadoc.toJavadoc(),
new AttributeBuilder(factory)
.annotation(util.t(OperatorInfo.class),
"kind", factory.newClassLiteral(util.t(descriptor.getAnnotationType())),
"input", factory.newArrayInitializer(inputMetaData),
"output", factory.newArrayInitializer(outputMetaData),