Tutorialpaste-template




Prev | Up | Next | Back | Forward | Online Documentation Home Page

paste-template





Paste-template constructs a template appropriate for using the Ada definition currently contained in the template buffer. It then either inserts or merges the constructed template at the location from which the command was issued.

The possible results of paste-template, which depend on both the contents of the template buffer (``the source'') and the selected phrase in the buffer from which the command was invoked (``the target''), are categorized below according to the syntactic category of the source:

Subprogram_specification, or subprogram_declaration. The source will be either a function or a procedure declaration. The paste is valid if the target is a phrase where a function or procedure call is appropriate.

If the target is a placeholder, a subprogram call is constructed, where the name is taken from the specification, and the parameter list is a named association list where the left hand sides of each association are the names of the formal parameters to the subprogram, and where the right hand sides are expression placeholders.

If the target is already a call of the appropriate form, then it is transformed into a call that uses the named association list for parameters throughout.

Type_declaration. The paste is valid if the target is a declaration placeholder or an expression placeholder.

If it is a declaration, then an object declaration is created for declaring objects of the given type.

If the target is an expression placeholder, then the expression is transformed into a qualified expression. If the source is a record declaration, then the qualified expression consists of a named association list where the left hand sides of each association are the names of the record components, and the right hand sides are expression placeholders. Components that are variant parts are not inserted.

Generic_declaration. The paste is valid if the target is a declaration placeholder. In this case, it is transformed into a template for a generic instantiation of the source. The parameters for the instantiation are constructed using the names of the formal parameters of the source.

Entry_declaration, or accept_statement. The paste is valid if the target is a statement placeholder. An entry call is constructed that consists of the name of the entry declaration, with a placeholder for an entry index if one exists, and an argument list that is an association list where the left hand sides of the association are taken from the formal parameters of the entry declaration.

The command is parser-initiating.


Forward