Difference between revisions of "CodeAssistant"

From Lianjapedia
Redirect page
Jump to: navigation, search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
''Under Construction''
+
#REDIRECT [[Script_Editor#The_Lianja_CodeAssistant_for_Lianja.2FVFP]]
=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|Intellisense]]
+
* [[#IntelliTips|IntelliTips]]
+
* [[#Statement Completion|Statement Completion]]
+
* [[#Auto Indenting|Auto Indenting]]
+
* [[#Code Snippets|Code Snippets]]
+
* [[#Code Beautifier|Code Beautifier]]
+
* [[#Code Folding|Code Folding]]
+
* [[#Integration with the Documentation Wiki|Integration with the Documentation Wiki]]
+
 
+
==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>
+
 
+
[[{{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.
+
 
+
[[{{ns:file}}:codeAssist2.png|link={{filepath:codeAssist2.png}}|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.
+
 
+
[[{{ns:file}}:codeAssist3.png|link={{filepath:codeAssist3.png}}|Databases]]
+
 
+
use<space>
+
 
+
This will popup a pick list containing table names.
+
 
+
[[{{ns:file}}:codeAssist4.png|link={{filepath:codeAssist4.png}}|Tables]]
+
 
+
modify command<space>
+
or
+
ed<space>
+
or
+
mc<space>
+
 
+
This will popup a pick list containing program script filenames.
+
 
+
[[{{ns:file}}:codeAssist5.png|link={{filepath:codeAssist5.png}}|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(
+
 
+
[[{{ns:file}}:codeAssist6.png|link={{filepath:codeAssist6.png}}|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(
+
 
+
[[{{ns:file}}:codeAssist8.png|link={{filepath:codeAssist8.png}}|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.
+
 
+
[[{{ns:file}}:codeAssist10.png|link={{filepath:codeAssist10.png}}|Object Variable Intellisense]]
+
 
+
The [[Lianja]] system object is known to the script editor so now typing:
+
+
lianja.
+
 
+
Pops up the intellisense for it.
+
 
+
[[{{ns:file}}:codeAssist9.png|link={{filepath:codeAssist9.png}}|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.
+
 
+
[[{{ns:file}}:codeAssist7.png|link={{filepath:codeAssist7.png}}|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==
+
[[{{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.
+
 
+
<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.
+
 
+
<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.
+
 
+
<br clear=all>
+
 
+
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.
+
 
+
<pre>if ${condition}
+
${insert your code here}
+
else
+
${insert your else code here}
+
endif</pre>
+
 
+
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.
+
 
+
<pre>for ${var:i} = ${start:1} to ${end}   
+
    ${insert your code here}
+
endfor</pre>
+
 
+
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==
+
[[{{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==
+
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:
+
 
+
<pre>/// <function="funcname(name as type, name2 as type ,[name3 as type]) returns type // description" />
+
/// <public="name as type" /></pre>
+
 
+
''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:
+
 
+
<pre>/// <reference path="filename" /></pre>
+
 
+
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]]
 
[[Category:Lianja v3.4]]

Latest revision as of 08:45, 10 April 2017