| <html> |
| <head> |
| <meta name="copyright" content="Copyright Technical University Berlin and others 2004, 2010. This page is made available under the Eclipse Public License v1.0. For full details see http://www.eclipse.org/legal/epl-v10.html" /> |
| <link rel=stylesheet type="text/css" href="../css/book.css"> |
| <link rel=stylesheet type="text/css" href="otjld/css/ot.css"> |
| <link rel=stylesheet type="text/css" href="otguide.css"/> |
| <style type="text/css"> |
| body { margin:10px; } |
| .high { background-color:#a5b7bd;color:white; } |
| .low { background-color:#fff0c8; padding:2px; } |
| .caption { text-decoration:underline; vertical-align:top;position:relative;top:20px; margin-top:10px;} |
| </style> |
| <title>OT/J content/code assist</title> |
| <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| </head> |
| <body> |
| <h1 align="center" id="completion">OT/J code completion</h1> |
| <span class="underline">On this page:</span> |
| <br /><a href="#completeRole">1. Overriding an inherited role class</a> |
| <br /><a href="#completeBase">2. Completing a role's base class</a> |
| <br /><a href="#completeMapping">3. Creating callout/callin method bindings</a> |
| <br /><a href="#completeCall">4. Completing special method calls</a> |
| <br /><a href="#completeTemplate">5. Completion templates</a> |
| |
| <h2 id="completeRole">1. Overriding an inherited role class</h2> |
| Simply by typing <code class="ui">Ctrl-Space</code> 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 (<a href="otjld/def/s1.html#s1.3.1.c"><img src="../images/ot_paragraph.png"> 1.3.1(c).</a>). |
| |
| <p> |
| So selecting this proposal:<br> |
| <img style="margin:10px;margin-left:25px;" src="images/screenshots/OverrideRole.png"><br> |
| will create this declaration: |
| <pre style="margin-left:25px;"><code style="color:#606060;">@Override</code> |
| <code class="keyword">protected class</code> <code>Subscriber { |
| }</code></pre> |
| |
| <h2 id="completeBase">2. Completing a role's base class</h2> |
| When expanding the base type after the keyword <code class="keyword">playedBy</code>, |
| completion will also generate an "<code class="keyword">import <strong>base</strong> ...</code>" declaration |
| (<a href="otjld/def/s2.html#s2.1.2.d"><img src="../images/ot_paragraph.png"> 2.1.2(d)</a>), if needed. |
| |
| |
| <h2 id="completeMapping">3. Creating callout/callin method bindings</h2> |
| |
| Specific support for code completion exists to facilitate the creation of <b>callout</b> (<a href="otjld/def/s3.html"><img src="../images/ot_paragraph.png"> 3.</a>) and <b>callin</b> (<a href="otjld/def/s4.html"><img src="../images/ot_paragraph.png"> 4.</a>) method bindings.<br /> |
| Completion can be used for |
| <ul> |
| <li><a href="#full">Creating full method bindings (callout/callin)</a> |
| <li><a href="#partial">Completing partial callout/callin bindings</a> |
| <li><a href="#correct">Corrections after callin creation.</a> |
| </ul> |
| |
| <h3 id="full">3.1 Creating full method bindings (callout/callin)</h3> |
| 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 <a href="otjld/def/s3.html#s3.5"><img src="../images/ot_paragraph.png"> 3.5</a>).<br /> |
| <table> |
| <tr><td colspan=2> |
| After pressing <code>Ctrl-space</code>, selection of the desired binding happens in three steps: |
| <tr><td class="caption">a) Select a base method</td> |
| <td><img src="images/screenshots/complete_binding_1.png"> |
| <tr><td class="caption">b) Change the role method name if desired.</td> |
| <td><img src="images/screenshots/complete_binding_2.png"> |
| <tr><td class="caption">c) Select the binding kind.</td> |
| <td><img src="images/screenshots/complete_binding_3.png"> |
| </table> |
| <h4>3.1.1 Creating callout to field</h4> |
| <p> |
| Two additional kinds of callouts can be generated, by typing "<code>get</code>" or "<code>set</code>" before invoking completion: |
| <table class="border pad5" > |
| <tr class="z2"> |
| <td>after typing <code class="keyword">get</code></td> |
| <td>Create a callout to field <i>getter</i>.</td> |
| </tr> |
| <tr class="z3"> |
| <td>after typing <code class="keyword">set</code></td> |
| <td>Create a callout to field <i>setter</i>.</td> |
| </tr> |
| </table> |
| <h4>3.1.2 Mapping signatures using lifting/lowering</h4> |
| <p> |
| 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 (<a href="otjld/def/s2.html#s2.3"><img src="../images/ot_paragraph.png"> 2.3</a>) or lowering (<a href="otjld/def/s2.html#s2.2"><img src="../images/ot_paragraph.png"> 2.2</a>). |
| </p> |
| |
| <h3 id="partial">3.2 Completing partial callin/callout bindings</h3> |
| <p> |
| If a callin or callout binding has been typed up-to and including the "<code class="keyword"><-</code>" or "<code class="keyword">-></code>" 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 (<code class="keyword">before, replace</code> or <code class="keyword">after</code>). Otherwise you will be prompted for the desired callin modifier. |
| In this case the proposed modifier is inferred to match the bound base method:<br /> |
| <table class="border pad5"> |
| <tr class="z2"><td>regular method<td>Default is <code class="keyword">before</code> (also <code class="keyword">after</code> is legal). |
| <tr class="z3"><td><code class="keyword">callin</code> method<td>Default is <code class="keyword">replace</code> |
| </table> |
| <p> |
| Normally, after "<code class="keyword">-></code>" (as well as for "<code class="keyword"><-</code>") completion will try to expand a base <i>method</i>, if for a callout one of the modifiers <code>get</code> or <code>set</code> has been typed, a <i>field</i> is searched instead. |
| |
| <h3 id="correct">3.3 Corrections after callin creation</h3> |
| After generating a callin binding using completion, the following two corrections might be especially helpful: |
| <ul> |
| <li>Adjusting the role method's <code class="keyword">callin</code> modifier, to match the binding's callin modifier. |
| <li>Creating a missing role method. |
| </ul> |
| Both corrections can easily be performed by a <a href="quickfix.html">quickfix</a> offered on the erroneous role method spec. |
| |
| <h2 id="completeCall">4. Completing special method calls</h2> |
| <ul> |
| <li>After <code class="keyword">base.</code> (<a href="otjld/def/s4.html#s4.3"><img src="../images/ot_paragraph.png"> 4.3</a>) and <code class="keyword">tsuper.</code> (<a href="otjld/def/s1.html#s1.3.1.f"><img src="../images/ot_paragraph.png"> 1.3.1(f)</a>) 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.</li> |
| <li>Completion also offers calls to members of the bound base class which are implicitly available using <b>inferred callout</b> (<a href="otjld/def/s3.html#s3.1.j"><img src="../images/ot_paragraph.png"> 3.1(j)</a>, <a href="otjld/def/s3.html#s3.5.h"><img src="../images/ot_paragraph.png"> 3.5(h)</a>) |
| </ul> |
| <h2 id="completeTemplate">5. Completion templates</h2> |
| <p> |
| Content assist in the |
| form of <a href="PLUGINS_ROOT/org.eclipse.jdt.doc.user/concepts/concept-editor-templates.htm"> |
| templates</a> exists for a few specific OT/J language constructs like <span class="low"><code class="keyword">within</code> (<i>Expression</i>)</span>. |
| </p> |
| |