KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Method Editor Dot Notation Auto Complete
PRODUCT: 4D | VERSION: 16Rx | PLATFORM: Mac & Win
Published On: May 25, 2018

With the introduction of object notation to 4D's language, it would be helpful to have an auto complete to help find commands and quickly write code. The autocomplete works differently for dot notation. Instead it looks at the code written in any of the open form editors and if there are any uses of dot notation it will add it to a list of auto complete suggestions.

A helpful and possibly time saving task is to write a method lists out all of the dot notation commands, fields, and frequently used properties and open the method in the method editor on startup to populate the list of suggestions.

This can also help removing suggestions by allowing a restart to reset the list and quickly repopulating the suggestions.

Below is a sample code that contains all of the dot notaction functions as of v17.0 Beta

//Method: FunctionsList
IF(False)
C_COLLECTION($init)

//dataClass
$init.all()
$init.fromCollection()
$init.get()
$init.new()
$init.newSelection()
$init.query()

//dataClassAttribute
$init.kind()
$init.name()

//entity
$init.clone()
$init.diff()
$init.drop()
$init.first()
$init.fromObject()
$init.getKey()
$init.getStamp()
$init.indexOf()
$init.isNew()
$init.last()
$init.lock()
$init.next()
$init.previous()
$init.reload()
$init.save()
$init.toObject()
$init.touched()
$init.touchedAttributes()
$init.unlock()

//entitySelection
$init.queryPath()
$init.queryPlan()
$init.add()
$init.and()
$init.average()
$init.contains()
$init.count()
$init.distinct()
$init.drop()
$init.first()
$init.isOrdered()
$init.last()
$init.max()
$init.min()
$init.minus()
$init.or()
$init.orderBy()
$init.query()
$init.slice()
$init.sum()
$init.toCollection()
End if


Then calling the following on startup will load the functions into the auto complete list:
METHOD OPEN PATH("FunctionsList")


This can also be expanded for other commonly used attributes or fields.
Below is an example of some fields:
//Method: ListFields
C_OBJECT($init)

//Table_1

$init:=ds.Table_1.Field_2
$init:=ds.Table_1.Field_3
$init:=ds.Table_1.Field_4

//Table_2

$init:=ds.Table_2.Field_A
$init:=ds.Table_2.Field_B
$init:=ds.Table_2.Field_C

Commented by Steve Brown on May 15, 2019 at 10:13 PM
This created some major instability for us when used with 4D 17R3 and R4, Macintosh. We called this pretty early during our startup, before any application windows were open, and it caused duplicate instances of windows to be opened, and frequent but somewhat random crashes and freezes when manipulating windows (closing, moving, resizing), as well as virtually always a crash very late when quitting (manifest only because a crash report would be displayed sometimes about a minute or so after quitting). Has been reported as a bug.