Child pages
  • Code Writing Features
Skip to end of metadata
Go to start of metadata

This section describes useful code writing features in Servoy Script Editor.

In This Chapter

Code Completion

Servoy supports code completion. As users type into the Script Editor, all known, non-private functions are displayed in a drop-down select box that becomes filtered as more characters are typed. A description box also shows when an item is selected (see below).  

  • To insert a selected item into the code, hit Enter.
  • If a code containing variables is selected, hit the tab key to enter the items in sequence.

Code Hints

To see information relevant to a particular code item, users can hover over the relevant parts of the code. This is true for both the code list shown in the Solution Explorer, as well as code in the Script Editor view. Servoy will provide an item description if it exists, for both out-of-the box functions as well as functions defined by the user via JSDoc (see Support for JSDoc_ _section below).

If a function is deprecated (annotated with @deprecated) , by default the editor does not show the description of the deprecated method . To see the description first hold alt key (option key on mac os)  and then hover over the deprecated method call, this is useful if you want to see why it was deprecated.

Dynamic Code Validation

Code is dynamically validated at design-time. The success of the validation process is partially dependent on comprehensive JSDoc commenting, which enables Servoy to provide more information regarding code errors and other warnings. Warnings are flagged in the vertical ruler and outline bar, and details are provided in the Problems view at the bottom of the Servoy Workbench (see image below).

As previously mentioned, the type of warnings/annotations that Servoy shows can be customized using the Preferences menu (found in the Script Editor context menu).

Script Templates

Servoy allows users to create templates for frequently-used scripts and JSDoc comments. These scripts are then enabled by Servoy for use in code completion.

Templates can be created by accessing Preferences from the contextual menu in Script Editor (users may have to unfold the menu tree on the left of the Preferences window to see the Templates option, see below).

Support for JSDoc

Servoy features support for regular comments and JSDoc comments. Importantly, disciplined use of JSDoc comments when creating functions and variables ensures more complete information for Servoy in refactoring and code completion.

JSDoc tags can be created for an existing function by accessing the context menu Script Editor > Source > Generate Element Comment) or using the keyboard shortcut ALT+SHIFT+J (alt+cmd+J).

Note

If business logic is added from Form Editor, JSDoc comment templates are automatically generated based on the context. Users can complete the comment information as needed in Script Editor.

When creating JSDoc comments, code completion is also available for the following supported tags (type '@' first, then Control-Space):

@AllowToRunInFind
@author {userName}
@constructor
@deprecated
@example
@param {Type} name
@private
@return {Type}
@see
@since
@throws {Type}
@type {Type}
@version

A complete list of other supported tags in JSDoc is provided in the Programming Guide.

Spellchecker for Comments

Servoy features SpellChecker support for comments in the Script Editor. This feature works with singleline, multiline and JSDoc comments.

  • No labels