NEW Autocomplete & Live Errors in LiveCode 8.2

by Monte Goulding on September 13, 2017 13 comments

New Script Editor Features in LiveCode 8.2

  • LiveCode Community and above – Live script parser errors
  • LiveCode Community Plus and above – Autocomplete
  • LiveCode Indy and above – Autocomplete Pro

Live Errors

The live errors feature was made possible because of changes to the script editor required to implement autocomplete. A temporary object has always been used in order to extract details of the script, however, it is now compiled more often. To be exact every time you stop changing the script field for 200 milliseconds the script is compiled in the temporary object. This is always done with explicit variables set to false so you will not see explicit variable errors live. If there is an error in the script it is now presented immediately rather than having to apply the script to see it.

Autocomplete

While typing in the script editor a filtered list of available completions will appear below the selection. Use the following keys to navigate the completion list:

  • right arrow – apply the completion or move into a group of completions
  • left arrow – move out of a group of completions
  • up arrow – move up the list
  • down arrow – move down the list

Moving the mouse will hide the completion list to avoid it remaining in place over an area you would like to select. Completions include placeholder fields which you can navigate with the tab key. Some completions may have multiple placeholders with the same name which will be edited together. Clicking within a placeholder will select it.

The current automatic completion of control structures has not changed. Completions in LiveCode Community Plus are generated from the syntax statements in the documentation.

Autocomplete Pro

Autocomplete Pro provides the following additional features:

  • Completions generated dynamically by introspecting the object being edited and its message path
    • local and global variables declared in the script and/or current handler scope
    • constants declared in the script and/or current handler scope
    • private and public handlers of the script
    • public handlers in the message path of the object including fronts scripts, stack file hierarchy, relevant behaviors, back scripts and stacks in use
  • The Autocomplete Snippet Manager dialog is accessible from the script editor menubar to manage a custom set of completion snippets.

Autocomplete Snippet Manager

An autocomplete snippet provides the information required to match and complete some code in the script editor. The Autocomplete Snippet Manager allows the user to manage a custom set of completion snippets.

Create a new completion snippet by clicking the + icon and delete the currently selected snippet by clicking the icon.

The dialog allows entry of the following:

Display Name – choose a completion snippet to edit or change the display name of the current snippet.

Priority – A value between 1 and 100 indicating the order the completions should be matched in. Higher priorities will be listed before lower priorities.

Match Scope – Choose whether the completion should try and match when the selection is outside a handler, inside a handler or anywhere. A comment completion might be anywhere, a statement completion (unless local, global or constant) would be only inside a handler and a handler completion would be outside a handler.

Match Words – Choose whether to match only all the words of a line, just the word being written or either. A statement would be all the words on a line, an expression would be just the current word and a comment would be either.

Alternate Match String – When matching completion snippets the text of the completion is matched first but in some cases that is not suitable or another string would be better to match. Enter a string to try matching if the completion fails to match.

Summary – This field is optional and provides some detail below the completion in the script editor.

Completion – This is the string to be used when replacing the selection after choosing a completion. The completion may be any script and any length. Add placeholders to the completion in the following form:

${name:type}

Where:

  • name – is the text seen in the script editor
  • type – is used to filter the completions presented for the placeholder one of:
    • statement – any LiveCode command
    • expression – any LiveCode expression
    • identifier – a variable or handler name

Additionally, it is possible to include multiple placeholders with the same name. When a multiple placeholder is selected they are edited at the same time.

Example Completion Snippets

Adding the if condition as a comment after end if

In this example completion as the user enters the condition a comment is appended to the end if with the condition text.
Once the condition is complete the user may tab to the -- code line and enter a statement.

In the snippet manager the settings look like this. As you can see the scope is inside the handler and the match words are all words of the line.

Now here’s the completion snippet in action in the script editor.

A script local with getter and setter handlers

This example is a little bit of fun I had pushing the boundaries of multiple placeholders. Indeed after creating it I posted it on our internal IDE slack channel with the comment “This is fun 😉” because it it really is lovely to see so much typing handled automatically for you.

In the snippet manager the settings look like this. As you can see the scope is outside the handler and the match words are all words of the line.

Here’s the completion in action in the script editor.

Happy Snippeting!

I hope you enjoy these new features. I’m sure the LiveCode community will start sharing completion snippets and we will all write more robust software faster as a result. Feel free to share some completion snippets here that you are keen to use this feature for!

Monte GouldingNEW Autocomplete & Live Errors in LiveCode 8.2

13 comments

Join the conversation
  • Sam - September 13, 2017 reply

    Is this feature also in DP9? Or what version of DP 9?

    Monte Goulding - September 13, 2017 reply

    We will be releasing LiveCode 9 DP 9 ASAP with the feature included.

  • JimL - September 13, 2017 reply

    Wonderful!

  • Simon - September 13, 2017 reply

    SWEET!

  • Andy Piddock - September 13, 2017 reply

    Excellent work, auto complete is s must in a modern editor.
    The snippet manager is a big bonus.
    Big smile here today.

    Martin - September 13, 2017 reply

    Woot!

  • Ernst M. Reicher - September 14, 2017 reply

    wow – long awaited feature!!!!!
    perhaps I didn’t understand it all but is “variables autocomplete” integrated too??? 😉

    Monte Goulding - September 14, 2017 reply

    Yes in Autocomplete Pro (Indy & Business) we do object introspection on the script and the message path. This adds variables, constants, parameters, available handlers etc.

    bogs - January 21, 2018 reply

    Actually, a new form of a very old feature with some additions. There was an ‘autocomplete’ feature from RR2.x to 3, this is an improved version of its basic abilities.

  • Paul - September 14, 2017 reply

    Excellent work and very welcomed addition! I will not be disabling this feature at all.

  • MaxV - September 25, 2017 reply

    I’m using heh 9dp9, the live errors is frustrating and confusing. It shouldn’t work on the line where is the cursor.

    Monte Goulding - September 25, 2017 reply

    You can choose Edit > Options > Live Errors to turn it off if you find it unhelpful

  • Carlos - July 15, 2018 reply

    It is very slow, annoying and still has many problems, it makes programming much slower

Join the conversation

*