Code Completion and Tooltip Help
Code Completion
When typing Java code in a Method Editor window, it is possible to request suggestions for completions of partial code. The list of possible completions are shown in a separate completion list that opens. In some situations, detailed information appears in a separate window when an entry is selected in the list. Code completion can always be requested with the keyboard shortcut Ctrl+Space (or Ctrl+/). It appears automatically when you type a period because you typically want to choose between the available methods when accessing a field.
The Application Builder supports the following types of completion suggestions.
New statements: A simple example is hitting Ctrl+Space without having entered anything, as shown below.
The completion list contains the member fields (for example, appFeat or model) and member methods (for example, callGuiCommand) that can be called. You can select a completion in two ways:
Partial statements: If you enter the beginning of a variable, field, or method name and press Ctrl+Space, the suggested completions are shown.
Only variables that match the prefix ra are shown. This example shows that local variables also appear in the completion suggestions.
Class members: If you enter a variable or expression that resolves to a known Java class for the model object, then you can get completion suggestions for the members in the class, as shown below.
This completion also works for chains of calls, as shown below.
Class members in assignments and declarations: In assignments and variable declarations, the expected type can be used to filter the list of completions. Only completions that have the same type declared on the left side of the assignment statement are shown.
Tags in the model object: When the expression to complete can be resolved to a concrete entity in the embedded model, completions are available for the methods in the model object API that take a first argument that is a tag in a list, as shown.
The list above comes from an application whose embedded model contains two plot groups (pg1 and pg2). The completion list contains both the tags and the names of the corresponding plot groups. To transfer only the tag to the code, choose a completion in the list and then press Tab.
Types in the model object when creating new entities: When the expression to complete can be resolved to a concrete entity in the embedded model, completions are available for operation types in the model object when creating a new node.
Property names: When the expression to complete can be resolved to a concrete entity in the embedded model, completions are available for property names used as first arguments to the get and set operations. These are available for most features in the model object.
The example above shows the properties that are available for the plot group pg1 in the embedded model. If you select an entry in the list, you see the property’s description and its data type. When available, you may also see a link to the documentation and a set of allowed values. The allowed values appear if the set of allowed values is a finite array of strings.
Property values: When the expression to complete can be resolved to a concrete entity in the embedded model, completions are available for property values used as second arguments in the set operations that are available for most features in the model object.
If you select an entry in the list, you see the property value’s description and a link to the documentation, if available.
Tooltips for Code in the Method Editor
When hovering over different parts of the code for a method, tooltips appear to provide information about that part of the code. The following tooltips appear for different parts of the code:
Property Names
When you hover over a property name for a model or application object property, you get information about the property, similar to what you see for the property when code completion is used. For example, if you hover over numerical in model.result().numerical("gev1").setResult();, you see the following tooltip.
Model Entities
If you hover over the same property’s model entity name, "gev1" in this case, you see the following tooltip with information about the purpose of the model entity.
Declarations
For variables defined under Declarations in the Application Builder tree, the variable’s description appears as the tooltip when you hover above them. In this case, it is the string variable inXpolRatio.
Shortcuts
For shortcuts to form objects, also defined under Declarations, the description and the corresponding Java code appear in the tooltip. In this case, it is for the shortcut with the name labelinXpolRatio.
Preferences for Code Generation and Completion
In the Methods part of the Preferences dialog box, you can specify options for code generation and completion.
The Close brackets automatically check box is selected by default. The software then automatically inserts a corresponding closing bracket if you type a {, [, or ( character. Clear the check box to disable the addition of closing brackets.
The Generate compact code using 'with' statements check box is selected by default. The generated code uses with statements to set a target to use with the coming calls to set(), setIndex(), getString(), and so on, which makes the code more compact. Clear the check box if you prefer to use the full code without the use of with statements.