CodeAssistant

From Lianjapedia
Revision as of 07:48, 21 March 2017 by Yvonne.milne (Talk | contribs)

Jump to: navigation, search

Under Construction

Introducing the Lianja CodeAssistant for Lianja/VFP

The Lianja CodeAssistant consists of:

  • Intellisense
  • IntelliTips
  • Statement Completion
  • Auto Indenting
  • Code Snippets
  • Code Beautifier
  • Code Folding

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> 

screenshot

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.

screenshot

Special Command Intellisense

Some commands have special pick lists depending on context.

use<space>

This will popup a pick list containing table names.

screenshot

open database<space>

This will popup a pick list containing database names.

screenshot

modify command<space> 

or

ed<space>

or

mc<space>

This will popup a pick list containing program script filenames.

Function Intellisense

Typing a function name followed by an open bracket pops up an intellitip for the function.

myvar = str(

screenshot

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.

myvar = str(source, at( 

screenshot

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.

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

lianja.

Pops up the intellisense for it.

screenshot

Cursor Intellisense

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

customers.

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

screenshot

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

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

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

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+K

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.

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.