CodeAssistant

From Lianjapedia
Revision as of 08:29, 10 April 2017 by Yvonne.milne (Talk | contribs)

Jump to: navigation, search

Under Construction

See Also

Category:Command Window CLI, Script Editor

The Lianja CodeAssistant for Lianja/VFP

Full CodeAssistant functionality coming soon in Lianja v3.4

The Lianja CodeAssistant includes:

Intellisense

Lianja provides Intellisense for commands, functions, object variables and cursors. Intellisense is implemented in a background thread so that it is kept up-to-date in real time.

Command Intellisense

Typing a command followed by a space pops up a context sensitive pick list of keywords and clauses for the command being typed.

list<space> 

Command Intellisense

Selecting a clause from the pick list e.g for <lExp> will guide you as you type in the statement. At any time you can type [Ctrl] + [Space] to enable/disable the command pick list.

Command Intellisense

Special Command Intellisense

Some commands have special pick lists depending on context.

open database<space>

This will popup a pick list containing database names.

Databases

use<space>

This will popup a pick list containing table names.

Tables

modify command<space> 

or

ed<space>

or

mc<space>

This will popup a pick list containing program script filenames.

Program Scripts

Function Intellisense

Typing a function name followed by an open bracket pops up an intellitip for the function and auto-inserts the function template.

s = substr(

Function Intellisense

After typing in the code for the highlighted argument, press Tab or Return to move on to the next argument.

Nested intellitips are stacked and unstacked when a ) is typed.

s = substr(products.productname, at( 

Function Intellisense

Object Variable Intellisense

Typing an object variable name followed by a . pops up a pick list of properties and methods for the object variable. Hovering the mouse over items in the pick list displays a tooltip with a short description of the item.

Object variable Intellisense requires any of the following to be present in the file being edited.

local|private|public|parameter|lparameter name as classname

or

name = createObject("classname")

or

obj.addObject("name","classname")

or

name = Lianja.getElementByID("Id")
name = Lianja.get("id")

In the latter case, the specified 'id' is introspected to identify the class based on the pages, sections and formitems in the currently open App.

Object Variable Intellisense

The Lianja system object is known to the script editor so now typing:

lianja.

Pops up the intellisense for it.

Lianja System Object

Cursor Intellisense

Tables that are open during editing are known to the editor so when for example you have the products table open and you type:

products.

The columns in the products table are displayed as a pick list.

Cursor Intellisense

Hovering the mouse over a column name will display a tooltip containing useful information regarding the column e.g. data type, width, decimals.

You can toggle Intellisense on and off by pressing [Ctrl] + [Space].

IntelliTips

Command Intellitip



Moving the mouse cursor over a command while pressing the control key will popup the IntelliTip for the command.


Function Intellitip



Moving the mouse cursor over a function name followed by a ( while pressing the control key will popup the IntelliTip for the function.


Column Intellitip



Moving the mouse cursor over a variable name or an objectname.propertyname or a cursorname.columnname while pressing the control key will popup a tooltip displaying the current value.


You can toggle IntelliTips on and off by pressing [Ctrl] + /.

Statement Completion

Pressing the return key on an empty line while typing in a statement block will close the statement block off for you and move the cursor onto the next line at the previous block indentation.

Auto Indenting

When you press the return key while typing commands the cursor will move onto the next line and auto indent for you.

Code Snippets

Code snippets are a productivity aid when coding. As you type a command, any code snippets that match it are displayed in a pick list. Press Return to insert the snippet.

You can edit your own snippets in the Snippet Manager by pressing Alt + s.

When a snippet is inserted it contains parameter insertion points e.g. Here is the snippet called ife for an if/else/endif statement.

if ${condition}
	${insert your code here}
else
	${insert your else code here}
endif

If the parameter insertion point contains a : (colon) pressing [Ctrl] + [Return] will insert the text following the :.

e.g. Here is the for/endfor snippet. Pressing [Ctrl] + [Return] on the var and the start will insert i and 1 respectively.

for ${var:i} = ${start:1} to ${end}    
    ${insert your code here}
endfor

After typing in a parameter, press [Ctrl] + [Return] to move onto the next one.

Code Beautifier

While editing you can press [Ctrl] + b to beautify your code with statement block indentation.

Code Folding

Code Folding



Code blocks such as if...endif, for...endfor, scan...endscan and do case...endcase are automatically indicated in the left margin with a small + or - icon at the start of the block and an arrow at the end.

Click the - icon to fold the code block.

Click the + icon to unfold a folded code block.


Code Folding



Hovering with the mouse over a - icon highlights the whole code block by changing the background color.


Code Folding



Hovering with the mouse over a + icon displays the folded code in an intellitip.


Code Folding Keyboard Reference

Key Sequence Description
[Alt] + f Fold All
[Alt] + u Unfold All
[Alt] + c Toggle Code Folding on/off

Custom Foldable Blocks

Define custom foldable block



You can create your own foldable code block using regions.

Here, the usage information has been placed in a region.


Precede the block with the following line, giving it a helpful description:

#region description

and terminate the block with:

#endregion
Folded custom foldable block



The indicator and hover actions are the same as for built-in code blocks.

Here, the block has been folded.


Note that regions cannot be nested.

Integration with the Documentation Wiki

Documentation Wiki Integration



Pressing [F1] fetches and displays the help page from the online Documentation Wiki for the command or function being typed or for the selected command.


Documentation wiki Integration



For commands with the same first word, follow the links to show the required command.


Extending Lianja with your own Intellisense Definitions

If you have existing libraries of classes or functions, you can place your own intellisense files in the lianja\help directory. If you look at the existing files in that directory you will see that they are just text files that are pre-loaded at startup. e.g.

intellitips_vfp_yourcompany.properties (for function definitions)

intellisense_vfp_yourcompany.properties (for class definitions)

Alternatively, you can create a file called references_vfp.config and place it in your app directory. This file can contain function and global variable type definitions that intellisense will use as hints.

The file should contain triple-slash comments like this:

/// <function="funcname(name as type, name2 as type ,[name3 as type]) returns type // description" />
/// <public="name as type" />

type can be any Lianja classname or Any, Character, Numeric, Logical, Date, Datetime, Currency, Array, Object

Any of the files you edit can also include type definitions by adding:

/// <reference path="filename" />

where filename should exist in the lianja help directory. Or alternatively, prefix the name with lib:/ or app:/ to reference definition files in an App or in the library.