Intellisense and CodeAssistant

I have now handled stepping over a character if the character under the cursor is that character e.g. ” ‘ ] or ). This makes it easier to type over some of the automatic completions that occur.

Typing commands is now a lot more powerful with full CodeAssist as you type, not just Intellisense.

Parameter hints for functions can take a default value, be [optional] or require a value. After typing press Return moves to the next parameter of if no more inserts a newline.

Also, in this build. Code folding and Snippet manager.

Alt+S for snippet manager
Alt+F to fold all code
Alt+U to unfold all code
Alt+C to toggle code folding on and off
Alt+I to toggle intellisense on and off

Many classes now have their intellisense in place e.g. Lianja, Form, TextBox… Others being added before final release.

Code Folding and Intellisense is now all done in a background worker thread to optimize UI performance.

Also note…

When typing a command e.g list you will see the pick list for all list commands such as

list status
list structure
list files

The Code Assistant now handles command abbreviations now, so if i type:

lif<Return>

list files will be placed in the command line replacing lif.

Similarly code snippets are all part of Intellisense now. So if i type:

dow<Return>

The code snippet for “do while” will be inserted and the cursor positioned on the first code insertion mark. Press Ctrl+Return to move to the next code insertion mark as you type.

You can now create collapsible blocks of code by placing the code in a “region”.

#region some description
#endregion

For anyone interested, the code snippets are in the lianja\help directory with a .snippet file extension.

Snippet files can be empty in which case the name of the file is inserted with _ replaced by a space. e.g. list_structure.snippet which cause “list structure” to be added to the pick list and if selected it will be inserted into the command line.

Snippets can contain code insertion marks.

${name}

or with a default value if <Return> is pressed when it is highlighted.

${name:something}

or for optional input

${name:}

${} is an invisible code insertion mark which causes the cursor to move to that position.

You can create your own code snippets and have them added to the intellisense database using the Snippet Manager ( Alt+S ).


 

e.g.

Code:
local tb as textbox

Name: Screen Shot 2017-04-10 at 2.34.16 PM.jpg Views: 92 Size: 41.4 KB

Then when editing if you type tb. this is what you see.

Name: Screen Shot 2017-04-10 at 2.34.37 PM.jpg Views: 91 Size: 44.1 KB

As you type the pick list is filtered by the characters you have typed. You can then press Tab to select that item and stay on the command line

or Return to select it and move to the next line. As you backspace the list changes.

Name: Screen Shot 2017-04-10 at 2.47.37 PM.jpg Views: 89 Size: 42.1 KB

Here is the list of classes we will provide intellisense for (you can add your own quite easily).

grid
cursoradaptor
actionbar
activex
application
camera
column
combobox
commandbutton
commandgroup
container
control
cursor
database
dataenvironment
datetextbox
datetimetextbox
editbox
editor
empty
field
pageframe
pictureflow
popupmenu
checkbox
collection
form
fields
formitem
formset
gadget
header
httpserver
hyperlink
image
label
labelengine
lcdnumber
line
listbox
menu
menubar
menuitem
networkmanager
optionbutton
optiongroup
page
pagebuilder
progressbar
recordset
reportengine
richeditbox
section
separator
session
shape
slider
spinner
splitter
systemsemaphore
systemtrayicon
textbox
timer
toolbar
toolbox
tree
treeitem
videoplayer
lianja
webview

My goal is to make you more productive so as you type pressing Tab on an incomplete command word or keyword will select that and place on the command line. Don’t worry if you don’t know all the LIanja/VFP commands as these are filtered as you type and pressing Return will select the currently highlighted command.

Name: Screen Shot 2017-04-10 at 2.53.32 PM.jpg Views: 89 Size: 43.8 KB

Name: Screen Shot 2017-04-10 at 2.53.46 PM.jpg Views: 89 Size: 41.0 KB

At any time you can press F1 and the help page for that command you are typing will be retrieved and displayed in a browser windows alongside the App Builder.

Name: Screen Shot 2017-04-10 at 2.57.01 PM.jpg Views: 89 Size: 84.2 KB

As you type if you press Return and the command requires keywords it will be underlined and when you hover the mouse over it, it will tell you what is wrong.

Name: Screen Shot 2017-04-10 at 2.59.42 PM.jpg Views: 90 Size: 41.7 KB


Q:

while we type this, plainly in an editor line?

Code:
page1.section1.

Intellisense to show us all UI elements of THAT standard section (at that hierarchy level), after typing the point?

fldAttribute
fldLabel1
fldMyField2

Of course, properties and methods of selected field, too.


Q:

I do not see the way to declare (temporary) anything similar to

local page1 as page

what will instruct Intellisense to give mi picklist of all sections in page1 of Lianja demo app example_gridfilter.

A:

You need to declare the variable type when using code such as page1.section1 as the type cannot be determined at editing time.

local page1 as pagebuilder

Not page.

i provided to you.

mypage_obj = Lianja.get(“page1”)
mysection_obj = Lianja.get(“page1.section1”)
myfield_obj = Lianja.get(“page1.section1.field1”)

Then intellisense kicks in.

Specifically on a section…

local sec as section

sec = Lianja.get(“page1.section1”)
sec.grid.filter = “”
sec.webview.html = “”
sec.tabview.enabled = .t.
sec.videoplayer.xxx = “”
etc

So if you do this:

local myobj as formitem
myobj = Lianja.get(“page1.section1.field3”)

then you type:

myobj.

You will see the properties/methods of the command button.


1. Hovering over a variable displays the value of that variable as a tooltip.

2. Hovering over a function displays a tooltip with contextual help.

3. Hovering over a command displays a tooltip with contextual help.

You toggle this functionality off and on by pressing Ctrl+/

4. As you type a command and press a space, contextual intellisense for the command is displayed. Certain commands e.g. OPEN DATABASE and USE display a popup database pick list and a popup table list respectively. You can navigate with the cursor up/down keys, double click an item, press spacebar, press Return or press the first letter of the item you want to select.

5. As you type a function followed by a bracket contextual intellisense for the function is displayed.

You toggle this functionality on and off by pressing Ctrl+Space

I will be adding object reflection of properties and methods in a forthcoming version.

And one last thing…

Intellisense is active in the console workspace, command window and the Lianja/VFP script editor.


in Lianja 3.4 we have a new CodeAssistant that will help you develop and edit Lianja/VFP scripts faster than ever before.

The Lianja CodeAssistant consists of:

  • Intellisense
  • IntelliTips
  • Statement completion
  • Context sensitive statement assistance while typing
  • Code suggestions
  • Function and method parameter hints
  • If you press Ctrl and hover over a command word “Quick Info” for the command will appear as a tooltip
  • If you press Ctrl and hover over a variable the “Quick Info” value of the variable will appear as a tooltip
  • Variable/word hilighting while typing
  • Code snippets
  • Code folding
  • Auto indenting
  • Code beautifier
  • Integrated with the Documentation wiki
  • + much more

Intellisense

Lianja now 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 picklist of keywords and clauses for the command being typed.

list<space>

Name: Screen Shot 2017-03-09 at 4.54.29 PM.jpg Views: 123 Size: 25.9 KB

Selecting a clause from the picklist 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 picklist.

Name: Screen Shot 2017-03-09 at 4.55.50 PM.jpg Views: 123 Size: 21.5 KB

Special command Intellisense 

Some commands have special picklists depending on context.

use<space>

This will popup a picklist containing table names.

Name: Screen Shot 2017-03-09 at 4.57.11 PM.jpg Views: 125 Size: 29.8 KB

open database<space>

This will popup a picklist containing database names.

Name: Screen Shot 2017-03-09 at 4.58.12 PM.jpg Views: 123 Size: 21.9 KB

modify command<space>
or
ed<space>
or
mc<space>

This will popup a picklist containing program script filenames.

Function Intellisense 

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

myvar = str(

Name: Screen Shot 2017-03-09 at 4.59.22 PM.jpg Views: 123 Size: 29.3 KB

After typing in the code for the hilited 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(

Name: Screen Shot 2017-03-09 at 5.00.13 PM.jpg Views: 121 Size: 29.9 KB

Object variable Intellisense.

Typing an object variable name followed by a . pops up a picklist of properties and methods for the object variable. Hovering the mouse over items in the picklist 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<period>

Pops up the intellisense for it.

Name: Screen Shot 2017-03-09 at 5.02.01 PM.jpg Views: 124 Size: 27.6 KB

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 picklist.

Name: Screen Shot 2017-03-09 at 5.09.14 PM.jpg Views: 121 Size: 24.5 KB

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.

Integrated with the Documentation Wiki

Pressing F1 when in the command window or the Lianja/VFP code editor will now fetch and display the help page from the Documentation Wiki for the command or function being typed.

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

 

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

 

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

You type in a parameter then 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 blocks are automatically indicated in the left margin with a small + or – icon. Click the icon to fold / unfold the code block for better code readability.

While editing you can press Alt+F and Alt+U to fold and unfold your code respectively..

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 preloaded at startup. e.g.

intellitips_vfp_yourcompany.properties contains function definitions
intellisense_vfp_yourcompany.properties contains 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.

My intention is to scan all files in an app in the background worker thread and recognize procedure and function statements with correctly defined arguments that use the “as” notation.

e.g.

proc myproc(arg1 as character, arg2 as numeric)
endproc


https://www.lianja.com/doc/index.php/Script_Editor#The_Lianja_CodeAssistant_for_Lianja.2FVFP


When typing a variable name followed by a . (dot), if the variable is untyped and it begins with “page” it is implied that it is a “pagebuilder” class and the picklist for that will be displayed.

Similarly, if the variable begins with “section” it is implied that it is a “section”,

and if the variable begins with “field” it is implied that it is a “formitem”.

If you follow the suggested format for naming object variables as described on MSDN then Lianja will use heuristics to determine the class of untyped object variables.