Code Editor
Use the Code Editor to simplify the process of writing scripts in ScriptRunner. The browser-based Code Editor provides completions and parameter assistance using four simple keyboard shortcuts.
The browser-based Code Editor provides completions, and parameter assistance using four simple keyboard shortcuts.
Completions - Press Ctrl+space to complete the current class, method, property or variable.
Smart completions - Press Ctrl+shift+space to complete the method, property or variable, respecting the expected type.
Parameter hints - Press Ctrl+p when inside method parameters to show the possible parameter types for a method.
Completions
Press Ctrl+space to display a list of suggestions based on what is written in the Code Editor. Select a completion or continue typing, suggested completions narrow down as more is typed.
Example
Click the question mark icon below the script to see binding variables.
Pressing Ctrl+space shows a list of possible completions. The text to the right of the suggestions shows the type of the property or return type of the method. Completions also work for classes. Most standalone scripts require a ComponentLocator
, but it’s hard to remember the class name for the import
. To save time, enter a part of the class name, using camel case abbreviations if required, and press Ctrl+space. Upon selecting the class, the import
line is added automatically.
Smart Completions
Press Ctrl+shift+space to display suggestions as above, suggesting only the types applicable to the current context. Type to see a list of smart completions matching the type of the preceding input.
Example
In the following script, regular completions would suggest the dog
and duck
variables. However, Smart Completions only shows the string dog
and not the integer duck
. This is because only dog
matches the "cat"
type (string). Smart completions suggests only other string types, as that is the expected type based on the preceding input.
dump()
also returns a string, so it is valid in this context.
Similarly, in the following example, Smart Completions only shows variables or methods that fit the parameters of the method used.
Parameters
When typing method parameters, it is easy to forget the expected types. The Code Editor displays all possible parameter types applicable. Press Ctrl+p to show possible options based on the text entered in the Code Editor.
Bold items indicate the parameter being entered or edited. Greyed out items are methods that are incompatible with the parameters typed.