Semantic Content AssistanceΒΆ

The Eclipse auto-completion keyboard short-cut (usually CTRL-space) activates the Semantic Content Assist feature in Sunflower. This feature offers auto-completion and suggestion of appropriate content based on current context being edited. Below we will give some examples of the feature.

Scroll to the end of the Sunflower Text Editor window, type CTRL-space. A Semantic Content Assist menu pops up, offering Create a fact, Create a rule and Create a query as the top level input choices, as seen in Fig. 129.

Possible top level input choices in a list

Fig. 129 Possible top level input choices in a list

Select Create a fact and hit return. A line with the initial content fact. gets inserted in the Text Editor. Type CTRL-space again, a 2nd level Semantic Content Assist menu pops up, offering the next set of appropriate choices when creating a fact. These include create an instance of a class and create a subclass of a class, as shown in Fig. 130.

Possible context types after user specifies intent to create a fact

Fig. 130 Possible context types after user specifies intent to create a fact

Choose create an instance of with properties and hit return. A line which contains newIndividual : newClass [ ] is inserted in the Text Editor, with newIndividual highlighted, as shown in Fig. 131.

Initial **create an instance of** statement from Semantic Context Assist

Fig. 131 Initial create an instance of statement from Semantic Context Assist

The highlighted field indicates the Text Editor is ready for its input. Type Michael to replace newIndividual, followed by a tab character. The tab character advances the input focus to the next field newClass. With newClass as the new input field, Semantic Context Assist offers a menu of possible classes to choose from, as seen in Fig. 132. This list of possible classes is derived from the classes in the import closure.

Semantic Context Assist offers choices for a possible class

Fig. 132 Semantic Context Assist offers choices for a possible class

Choose Man and hit return. The input cursor advances to the inside of the frame symbol [ ]. Type CTRL-space to invoke Semantic Context Assist and see it offer a menu with the choice to add the first property to the instance we are creating, as shown in Fig. 133.

Semantic Context Assist offers choice to add first property

Fig. 133 Semantic Context Assist offers choice to add first property

Choose Add first property and hit return. A menu pops up with a list of properties for class Man, as well as a potential newProperty, as seen in Fig. 134. The property list offered depends on the class in context. Semantic Context Assist offers properties specifically for Man because we are creating an instance of class Man.

Semantic Context Assist lists all current properties of class **Man**

Fig. 134 Semantic Context Assist lists all current properties of class Man

Choose an existing property such as birthDate and hit return. The property name birthDate is added to the instance, and the cursor is advanced to the input position of the the property value, as shown in Fig. 135.

Property **birthDate** is inserted and cursor advances to property value input position

Fig. 135 Property birthDate is inserted and cursor advances to property value input position

Type in “1975-10-06”^^date for the value, followed by CTRL-space to call up the Semantic Context Assist menu choices again. This time the list of menu choices contains Add another property to allow another property to be added, as shown in Fig. 136.

After adding the first property, **CTRL-space** offers the choice of adding another property

Fig. 136 After adding the first property, CTRL-space offers the choice of adding another property

After specifying the value of the 2nd property, Semantic Context Assist can be invoked again with CTRL-space to add yet another property.

Note that the file being edited must be saved in order for Semantic Context Assist to pick up the changes made and offer them as updated menu choices.