Results 1 to 1 of 1

Thread: [Answers] Intellisense and CodeAssistant

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135

    [Answers] Intellisense and CodeAssistant

    ...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:
    Code:
    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:
    Code:
    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.
    Code:
    ${name}
    or with a default value if <Return> is pressed when it is highlighted.
    Code:
    ${name:something}
    or for optional input
    Code:
    ${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


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





    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.



    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



    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.










    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.







    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.






    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
    Code:
    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.
    Code:
    local page1 as pagebuilder
    Not page.
    i provided to you.
    Code:
    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...
    Code:
    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:
    Code:
    local myobj as formitem myobj = Lianja.get("page1.section1.field3")
    then you type:
    Code:
    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.
    Code:
    list<space>


    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.




    Special command Intellisense

    Some commands have special picklists depending on context.
    Code:
    use<space>
    This will popup a picklist containing table names.



    Code:
    open database<space>
    This will popup a picklist containing database names.

    Code:
    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.
    Code:
    myvar = str(


    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.
    Code:
    myvar = str( source, at(


    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.
    Code:
    local|private|public|parameter|lparameter name as classname
    or
    Code:
    name = createObject("classname")
    or
    Code:
    obj.addObject("name","classname")
    or
    Code:
    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:
    Code:
    lianja<period>
    Pops up the intellisense for it.




    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:
    Code:
    customers.
    The columns in the customers table are displayed as a picklist.



    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.
    Code:
    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.




    All topics in [Answers] alphabetically: http://www.lianja.com/community/show...ll=1#post12352

    These answers are also systematized on the site "Lianja developer": https://lianjadeveloper.wordpress.co...codeassistant/
    Last edited by josipradnik; 2017-12-08 at 00:42.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us