Thor IntellisenseX

Introduction

IntellisenseX refers to a suite of Thor Tools that provide functionality similar to native Intellisense. These tools display lists of available variable names, field names, or members (properties, events, methods, and objects) while you type code, just like Intellisense. However, they cover those areas that Intellisense forgot (such as the list of field names in a table when editing in a code window) and provide new capabilities, available through customization, such as displaying the list of field names in an SQL table, as shown below

SNAGHTMLf871ea8_thumb1

Videos

  1. Getting started (5:23)
  2. Using and configuring the dropdown box (4:01)
  3. Fields from tables (9:29)
  4. Properties and methods from objects (5:14)
  5. Indirect table and object references and the Alias directive (3:51)
  6. Variables (LOCAL and otherwise) list (5:28)
  7. Constants (#Defines) list (3:18)
  8. Setting ControlSource in PEM Editor (2:25)
  9. Known issues (7:00)
  10. “IntellisenseX by Dot” vs “IntellisenseX by Hot Key” (3:29)
  11. Managing Plug-Ins: OpenTable and Intellisense (5:34)

Installation Instructions

IntellisenseX is downloaded and installed as part of the Check For Updates process for Thor.

Thor Tools

IntellisenseX is implemented through the use of four tools:

  • IntellisenseX by Dot is the main tool. Once executed, IntellisenseX is activated any time you press a period (dot), the same as for native Intellisense. The tool is actually a toggle. If you execute it a second time, the On Key Label is removed, and typing a dot simply works like normal. (Unfortunately, there is an undesirable side effect to this technique of executing code when you press a dot, which is why you may want to turn off Intellisense by Dot from time to time. See glitch when using Intellisense by Dot. )
  • IntellisenseX by Hot Key is the twin of IntellisenseX by Dot, except that it is activated differently, by using a hot key (which you define in Thor) instead of a dot. To activate the tool, press the hot key after you press the dot. This tool is available because of the glitch when using Intellisense by Dot.
  • Dropdown Variables List provides a list of local variables for those who do not use MDot (m.)
  • Dropdown Constants List provides a list of constants (created by #Define and #Include)

Like all Thor tools, these tools can be executed in a number of different ways, such as by using the Tool Launcher, as shown below, or by user-assigned hot keys.

image_thumb31

Examples of IntellisenseX

Unless otherwise noted, all examples provided are enabled by a single execution of the tool “IntellisenseX by dot”.

The following is a summary of the different types of dropdown lists available:

Field names:

Property and Method names (PEMs) from objects:

Indirect references:

Variables (local and otherwise):

Other:

Configuration Options

Customization


Fields from an open table (or view)

If a table (or view) is open, the dropdown list shows the list of fields as well as their data type and field width.

SNAGHTML655319b_thumb1

Back to top

Fields from an table that is not open (but is in the path)

If the alias for the table is not in use, the path is searched for a DBF of that name; if found, the table is opened and its fields are listed.

This particular algorithm for opening tables might not be sufficient for your needs (you might, for instance, open tables from a folder not in the path during development). If so, you can customize the way that tables are opened; see the OpenTable PRG in Thor Plug-In Prgs.

SNAGHTML65a1036_thumb1

Back to top

Fields from a local_alias in an SQL statement

If a local_alias is used in an SQL statement, the fields from the actual table (or alias) are shown. This does not apply to sub-queries (yet).

SNAGHTML664d1b1_thumb1

Back to top

Fields from a SQL Server table

The fields from an SQL Server table (“soheader” in the example below) can be displayed. This requires customization of a plug-in PRG (managed by Thor) that accesses the structure of the table. This can be done a few different ways, including using SQLColumns() or accessing a dictionary of the fields and in an SQL database.

This feature is only available if you do some customization so that you can return to Intellisense a list of field names associated with a given SQL table name (“soheader” in the example). See the Intellisense PRG in Thor Plug-In Prgs.

SNAGHTMLf871ea8_thumb2

Back to top

Fields from a Data Object

IntellisenseX can be used to display the fields from data objects that are based on an underlying table in a business object or in a form or visual class based on an underlying table, although doing so requires customization on your part.

The sample below accesses the underlying table that the current class is based on (found in “This.cAlias”) whenever “This.oData.” is entered.

This feature is only available if you do some customization so that Intellisense can associate a code snippet(“This.odata” in the example) with a table alias (“MasterPartsList”).  See the Intellisense PRG in Thor Plug-In Prgs.

image_thumb3

Back to top

PEMs for objects referenced between WITH / ENDWITH

When using a “WITH” phrase (“With loObject”), if you do not use “as” (“With loObject as Textbox”), the only object for which FoxPro provides Intellisense in methods for visual classes is THIS:

SNAGHTML130f05dd_thumb1

This feels like an incomplete implementation, as there are a number of other objects for which it would seem that Intellisense would work:

  • With ThisForm
  • With This.Parent
  • With This.Parent.cboMaintTable
  • With Thisform.PageFrame.Pages[1]

These are all provided for by IntellisenseX, as shown in the following image:

SNAGHTML13106da4_thumb1

Note as well the parameters list that appears in the second column. Once you have selected a method from the listbox, pressing Ctrl+Enter will insert both the method name and parameters into your code.

In addition, IntellisenseX also recognizes a number of other references to objects that follow WITH: see Fields from a Data Object, Indirect object references, and *#Alias directive for tables and objects.

SNAGHTML131db30d_thumb1

Back to top

PEMS referenced in PRG-based classes

FoxPro provides Intellisense for THIS in PRG-based classes in a limited way: it might not show custom properties or methods in the class being edited at all (as shown below), if it does will not display them in the same case as they are defined, and the list is not updated as new properties or methods are added.

SNAGHTML143d7097_thumb[1]

IntellisenseX provides an alternative that shows only the properties and methods defined in the current class (no inherited or native properties or methods, unless defined in the class), in their correct case. This list is always current as properties or methods are added. (Depending on interest, this list may be extended to include inherited properties and methods.)

This feature is disabled by default; to enable it, see Configuration Options.

SNAGHTML14521dc7_thumb[1]

Back to top

Indirect object references

IntellisenseX recognizes the use of variables that are assigned as objects in code, as shown below. The objects referenced may be either objects in the form or class, or a Data Object.

SNAGHTML145a23a1_thumb[1]

Back to top

*#Alias directive for tables and objects

It may happen that a variable (that actually refers to a specific object) or alias (that actually refers to a specific table) is not defined in code in such a way the one can tell what it refers to, even if the developer knows exactly what it refers to. In this case the *#Alias directive can be used to inform Intellisense how to interpret the variable or alias.

In the example below, the second line informs Intellisense that the variable toData actually refers to the object ThisForm.grdGrid, so that referring to toData later in the code displays the dropdown list of properties and methods for that grid. This works for form objects (as in the example), Data Objects, and aliases.

SNAGHTML14653608_thumb[1]

Back to top

Variables (local and otherwise) from MDot

Typing "m" and then a dot (period) will drop down a list of all variables in a procedure or method that are local, private, public, or are assigned values anywhere in the procedure (even after the current line of code).

image_thumb1

Back to top

Variables (local and otherwise) using a hot key

For those who do not use M-Dot notation, the same list of all variables in a procedure or method that are local, private, public, or are assigned values anywhere in the procedure. can be obtained by a hot key. (This hot key is selectable in Thor). See also Auto-completion on single match.

SNAGHTML64ada77_thumb2

Back to top

Listing Constants (created by #Define and #Include)

The Thor tool Dropdown Constants List creates a dropdown list of all #Define’d constants. This list is created using the same code as is used by ZDEF, which traverses all #Include files. The second column in the display shows the value of each constant. (Note that “match anywhere” applies to the this second column as well.) See also Auto-completion on single match.

SNAGHTML14745903_thumb[1]

Back to top

Setting ControlSources in PEM Editor

PEM Editor has been enhanced to recognize most of the IntellisenseX capabilities described here when entering a ControlSource. It will recognize:

  • Object references (Thisform, e.g., as shown below)
  • Table or alias references (PartsList)
  • Data Objects (This.oData)

Note that if you set the ControlSource to a property of Thisform that does not exist, you will be asked if you want it to be created.

SNAGHTML147a41fa_thumb[1]

Back to top

Customization

There are three areas of customization available:

Using the IntellisenseX dropdown

The dropdown listbox from IntellisenseX is designed to work like the dropdown from native FoxPro Intellisense, as much as that is possible, but there are differences.  See Description.

Acknowledgements

IntellisenseX is built on ISX.PRG, written by Christof Wollenhaupt (and a host of others) from 1999-2010. The concept of extending Intellisense began with ISX.PRG and even after modifying it to fit within Thor and extending it to some new areas, the vast majority of code from ISX.PRG remains unchanged. Thanks so much to Christof (and the others) for providing such a worthy tool as a starting place.

Thanks also to Matt Slay for asking the right question at the right time to get this project started.

Last edited Oct 1, 2012 at 4:43 AM by JimRNelson, version 51

Comments

No comments yet.