Add arguments declaration

Now we want to handle the arguments of the operations.

Arguments are linked to their owner operation through the reference arguments. An Argument has an attribute name and a reference to its type. Create a declaration script as a Text script that returns the name of the type of the argument and the name of the argument.

Change its contents to:

[#package tutorial.java]

[#metatype rhapsody.Argument]

[#script public declaration]
${self.type.name} ${self.name}[#rtrim]
[/#script]

The rtrim directive removes the whitespace at the end of the argument declaration so that all the arguments can be printed on the same line.

The declaration script is now called from the declaration script on Operation.

[#package tutorial.java]

[#metatype rhapsody.Operation]

[#script public declaration]
    public ${self.returnType} ${self.name}(${self.arguments.concat("declaration", ", ")}) {
        return null;
    }

[/#script]

The concat operation appends the results of the declaration script for each of the arguments in the arguments collection. The "," argument will insert a comma between each of the declarations in the case when more than one argument exists.


Next Section: Add operation body
Prev Section: Add return type declaration


Related reference
MDWList
Trim