# OT/J code completion

On this page:
1. Overriding an inherited role class
2. Completing a role's base class
3. Creating callout/callin method bindings
4. Completing special method calls
5. Completion templates

## 1. Overriding an inherited role class

Simply by typing `Ctrl-Space` in the body of a team class that inherits from another team, completion proposes to create a role declaration overriding any inherited role from the super team ( 1.3.1(c).).

So selecting this proposal:
will create this declaration:

    @Override
    protected class Subscriber {
    }

## 2. Completing a role's base class

When expanding the base type after the keyword `playedBy`, completion will also generate an "`import base ...`" declaration ( 2.1.2(d)), if needed.

## 3. Creating callout/callin method bindings

Specific support for code completion exists to facilitate the creation of callout ( 3.) and callin ( 4.) method bindings.
Completion can be used for

- Creating full method bindings (callout/callin)
- Completing partial callout/callin bindings
- Corrections after callin creation.

### 3.1 Creating full method bindings (callout/callin)

Just activating the completion anywhere in the body of a role class allows you to create a full callout or callin binding to an existing base method (or field — "callout to field", see 3.5).

After pressing `Ctrl-space`, selection of the desired binding happens in three steps:
a) Select a base method |
b) Change the role method name if desired. |
c) Select the binding kind. |

#### 3.1.1 Creating callout to field

Two additional kinds of callouts can be generated, by typing "`get`" or "`set`" before invoking completion:

after typing `get` | Create a callout to field getter.
after typing `set` | Create a callout to field setter.

#### 3.1.2 Mapping signatures using lifting/lowering

When binding to a base method/field, whose signature contains other base types for which a bound role exists in the current team, completion lets you select whether the role side of the binding should use base or role types. If role types are selected, they will be conform to the corresponding base type by implicitly using lifting ( 2.3) or lowering ( 2.2).

### 3.2 Completing partial callin/callout bindings

If a callin or callout binding has been typed up-to and including the "`<-`" or "`->`" token, completion can be used to expand the right hand side specifying the base method or field. For callin bindings you may optionally first type the callin modifier (`before, replace` or `after`). Otherwise you will be prompted for the desired callin modifier. In this case the proposed modifier is inferred to match the bound base method:

regular method | Default is `before` (also `after` is legal).
`callin` method | Default is `replace`

Normally, after "`->`" (as well as for "`<-`") completion will try to expand a base method, if for a callout one of the modifiers `get` or `set` has been typed, a field is searched instead.

### 3.3 Corrections after callin creation

After generating a callin binding using completion, the following two corrections might be especially helpful:

- Adjusting the role method's `callin` modifier, to match the binding's callin modifier.
- Creating a missing role method.

Both corrections can easily be performed by a quickfix offered on the erroneous role method spec.

## 4. Completing special method calls

- After `base.` ( 4.3) and `tsuper.` ( 1.3.1(f)) completion offers only those methods that are actually legal in this context, which in both cases implies the same name and signature as the surrounding role (callin) method.
- Completion also offers calls to members of the bound base class which are implicitly available using inferred callout ( 3.1(j), 3.5(h))

## 5. Completion templates

Content assist in the form of templates exists for a few specific OT/J language constructs like `within` (Expression).