IBM Streams 4.2.1
Code templates
Code templates are reusable code snippets that you can insert into your SPL source by using the content assist feature.
A code template is defined by the following attributes:
- Name: The name of the code template.
- Context: The location in source code where the code template is applicable. The context controls when the code template becomes available in content assist.
- Description: An optional description that provides more information about the code template.
- Pattern: The code snippet to be inserted into the source code when the code template is selected from content assist. A pattern can contain variables to represent a part of the snippet that requires user input. To insert a variable, type ${variable_name} in the pattern.
You can define code templates for the following context:
| Context | Location in source code |
|---|---|
| Composite Definition | Where a new composite definition is valid |
| Composite Parameter | Inside the parameter code of a composite definition |
| Config | Inside a config clause |
| Local Literal | In an expression |
| Namespace | Where you can specify a namespace in the SPL source |
| Operator Invocation | Where you can invoke an operator inside a graph clause |
| Operator Invocation Logic | Inside the logic clause of an operator invocation |
| Operator Invocation Output | Inside the output clause of an operator invocation |
| Operator Invocation Parameter | Inside the parameter clause of an operator invocation |
| Operator Invocation Window | Inside the window clause of an operator invocation |
| Use Directive | Where you can specify a use directive in the SPL source |
By default, Streams Studio includes the following code templates.
- Composite definition
- Main composite operator
- Operator invocation
- Use statement