Use the Code Editor to simplify the process of writing scripts in ScriptRunner. The browser-based Code Editor provides completions, Javadoc lookups, 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.
Javadoc lookup - Press Ctrl+j when the cursor is on a method, property, or class, to open the Javadoc for this symbol.
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.
event is available in the 'Event Listener' binding.
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.
Select one of the suggested completions or continue typing, the suggestions narrow down as you type. Alternatively, type part of a method or property, for example
event.getT, then press Ctrl+space.
To save typing, use camel case abbreviations. For example, to get a
Space instance from
getSpaFrPI to display
Text within parentheses shows the types for any expected arguments. Sometimes there may be multiple methods with the same name, but with different types of parameters. For example, obtain a
Space using its numeric ID, or its string ID:
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.
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.
In the following script, regular completions would suggest the
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.
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.
With hundreds of methods and properties, it is difficult to keep track of what each one does. The Code Editor helps to simplify this process by linking to the Javadoc for each method, property, or class. Press Ctrl+j to open the Javadoc in a new browser tab.
The image above is illustrative. The Javadoc opens in a new tab. If you request the Javadoc for a different method, the same tab is reused. Javadoc currently only works for the Java and Groovy standard libraries, and the Jira and Confluence APIs.
There are some limitations to the Code Editor; work is ongoing to reduce these limitations. As mentioned, Javadoc for Bitbucket and Bamboo APIs, and ScriptRunner’s API (e.g. Behaviours) is not available. However, completions and parameter hints are available for all.