Difference between revisions of "CodeAssistant"

From Lianjapedia
Jump to: navigation, search
Line 1: Line 1:
 
''Under Construction''
 
''Under Construction''
 +
=See Also=
 +
[[Script Editor]]
  
''Coming soon in Lianja v3.4''
+
=The Lianja CodeAssistant for Lianja/VFP=
==Introducing the Lianja CodeAssistant for Lianja/VFP==
+
''Full CodeAssistant functionality coming soon in Lianja v3.4''
The Lianja CodeAssistant consists of:
+
  
* Intellisense
+
The Lianja CodeAssistant includes:
* IntelliTips
+
 
* Statement Completion
+
* [[#Intellisense|Intellisense]]
* Auto Indenting
+
* [[#IntelliTips|IntelliTips]]
* Code Snippets
+
* [[#Statement Completion|Statement Completion]]
* Code Beautifier
+
* [[#Auto Indenting|Auto Indenting]]
* Code Folding
+
* [[#Code Snippets|Code Snippets]]
 +
* [[#Code Beautifier|Code Beautifier]]
 +
* [[#Code Folding|Code Folding]]
 +
* [[#Integration with the Documentation Wiki|Integration with the Documentation Wiki]]
  
 
==Intellisense==
 
==Intellisense==
Line 23: Line 27:
 
[[{{ns:file}}:codeAssist1.png|link={{filepath:codeAssist1.png}}|Command Intellisense]]
 
[[{{ns:file}}:codeAssist1.png|link={{filepath:codeAssist1.png}}|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.
+
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.
  
 
[[{{ns:file}}:codeAssist2.png|link={{filepath:codeAssist2.png}}|Command Intellisense]]
 
[[{{ns:file}}:codeAssist2.png|link={{filepath:codeAssist2.png}}|Command Intellisense]]
Line 53: Line 57:
 
[[{{ns:file}}:codeAssist5.png|link={{filepath:codeAssist5.png}}|Program Scripts]]
 
[[{{ns:file}}:codeAssist5.png|link={{filepath:codeAssist5.png}}|Program Scripts]]
  
==Function Intellisense==
+
===Function Intellisense===
Typing a function name followed by an open bracket pops up an intellitip for the function.
+
Typing a function name followed by an open bracket pops up an intellitip for the function and auto-inserts the function template.
  
 
  s = substr(
 
  s = substr(
Line 111: Line 115:
 
Hovering the mouse over a column name will display a tooltip containing useful information regarding the column e.g. data type, width, decimals.
 
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.
+
You can toggle Intellisense on and off by pressing [Ctrl] + [Space].
  
 
==IntelliTips==
 
==IntelliTips==
 +
[[{{ns:file}}:command_intellitip.png|450px|thumb|left|link={{filepath:command_intellitip.png}}|Command Intellitip]]
 +
 +
 +
 +
 +
 
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 command while pressing the control key will popup the IntelliTip for the command.
 +
 +
<br clear=all>
 +
 +
[[{{ns:file}}:function_intellitip.png|450px|thumb|left|link={{filepath:function_intellitip.png}}|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.
 
Moving the mouse cursor over a function name followed by a ( while pressing the control key will popup the IntelliTip for the function.
 +
 +
<br clear=all>
 +
 +
[[{{ns:file}}:column_intellitip.png|450px|thumb|left|link={{filepath:column_intellitip.png}}|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.
 
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+/.
+
<br clear=all>
 +
 
 +
You can toggle IntelliTips on and off by pressing [Ctrl] + /.
  
 
==Statement Completion==
 
==Statement Completion==
Line 131: Line 159:
 
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.
 
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
+
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.
 
When a snippet is inserted it contains parameter insertion points e.g. Here is the snippet called ife for an if/else/endif statement.
Line 141: Line 169:
 
endif</pre>
 
endif</pre>
  
If the parameter insertion point contains a : (colon) pressing Ctrl+Return will insert the text following the :.   
+
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.
+
e.g. Here is the for/endfor snippet.  Pressing [Ctrl] + [Return] on the var and the start will insert i and 1 respectively.
  
 
<pre>for ${var:i} = ${start:1} to ${end}     
 
<pre>for ${var:i} = ${start:1} to ${end}     
Line 149: Line 177:
 
endfor</pre>
 
endfor</pre>
  
After typing in a parameter, press Ctrl+Return to move onto the next one.
+
After typing in a parameter, press [Ctrl] + [Return] to move onto the next one.
  
 
==Code Beautifier==
 
==Code Beautifier==
While editing you can press Ctrl+B to beautify your code with statement block indentation.  
+
While editing you can press [Ctrl] + b to beautify your code with statement block indentation.
 +
 
 +
==Code Folding==
 +
[[{{ns:file}}:fold1.png|450px|thumb|left|link={{filepath:fold1.png}}|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.
 +
 
 +
<br clear=all>
 +
 
 +
[[{{ns:file}}:fold2.png|450px|thumb|left|link={{filepath:fold2.png}}|Code Folding]]
 +
 
 +
 
 +
 
 +
 
 +
 
 +
Hovering with the mouse over a - icon highlights the whole code block by changing the background color.
 +
 
 +
<br clear=all>
 +
 
 +
[[{{ns:file}}:fold3.png|450px|thumb|left|link={{filepath:fold3.png}}|Code Folding]]
 +
 
 +
 
 +
 
 +
 
 +
 
 +
Hovering with the mouse over a + icon displays the folded code in an intellitip.
 +
 
 +
<br clear=all>
 +
 
 +
'''Code Folding Keyboard Reference'''
 +
 
 +
{| class="wikitable" width="100%"
 +
!width="20%"|Key Sequence
 +
!width="80%"|Description
 +
|-
 +
|valign="top"|[Alt] + f
 +
|valign="top"|Fold All
 +
|-
 +
|valign="top"|[Alt] + u
 +
|valign="top"|Unfold All
 +
|-
 +
|valign="top"|[Alt] + c
 +
|valign="top"|Toggle Code Folding on/off
 +
|-
 +
|}
 +
 
 +
===Custom Foldable Blocks===
 +
[[{{ns:file}}:region1.png|450px|thumb|left|link={{filepath:region1.png}}|Define custom foldable block]]
 +
 
 +
 
 +
 
 +
 
 +
 
 +
You can create your own foldable code block using regions.
 +
 
 +
Here, the usage information has been placed in a region.
 +
 
 +
<br clear=all>
 +
 
 +
Precede the block with the following line, giving it a helpful description:
 +
#region description
 +
 
 +
and terminate the block with:
 +
 
 +
endregion
 +
 
 +
[[{{ns:file}}:region2.png|450px|thumb|left|link={{filepath:region2.png}}|Folded custom foldable block]]
 +
 
 +
 
 +
 
 +
 
 +
 
 +
The indicator and hover actions are the same as for built-in code blocks.
 +
 
 +
Here, the block has been folded.
 +
 
 +
<br clear=all>
 +
 
 +
Note that regions cannot be nested.
 +
 
 +
==Integration with the Documentation Wiki==
 +
[[{{ns:file}}:wiki1.png|450px|thumb|left|link={{filepath:wiki1.png}}|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.
 +
 
 +
<br clear=all>
 +
 
 +
[[{{ns:file}}:wiki2.png|450px|thumb|left|link={{filepath:wiki2.png}}|Documentation wiki Integration]]
 +
 
 +
 
 +
 
 +
 
 +
 
 +
For commands with the same first word, follow the links to show the required command.
 +
 
 +
<br clear=all>
  
 
==Extending Lianja with your own Intellisense Definitions==
 
==Extending Lianja with your own Intellisense Definitions==
Line 175: Line 310:
  
 
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.
 
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.
 +
 +
[[Category:Lianja v3.4]]

Revision as of 05:58, 3 April 2017

Under Construction

See Also

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.