Code Completion
Code completion is a feature that most modern development environments have that can predict how to complete a given token in an expression as you are typing it. The advantage of this is that it can save numerous keystrokes over time, as well as freeing you from the burden of having to remember the exact name of all the methods and classes that you use in your programming vocabulary.
Code completion, in general, must strike an interesting balance in order to be effective to you, the programmer. On one hand, code completion should strive to offer an accurate and generally complete set of suggestions. While on the other hand, too many suggestions may lead to cognitive overload, which can have an adverse effect on your ability to program. The code completion engine in VA Assist Pro attempts to achieve this balance by performing real-time code analysis in order to assemble a smaller set of more relevant suggestions. The code completion offered in VA Assist Pro is a customizable experience that can be tailored to better fit your programming style.
Code Completion Contexts
Code completion is available in four basic contexts. These contexts are Smalltalk browsers, inspectors, workspaces and debuggers. Code completion provides unique capabilities for each context.
•Browsers - Code completion is available in many of the Smalltalk browsers. When browsing classes, implementors, senders and so on, these browsers contain state which code completion uses to derive the classes and methods that are visible. This is useful if you only want to see classes and methods visible in the prerequisite application chain.
•Workspaces - Workspaces don't have a sense of visibility in the same way browsers do. In workspaces, everything in the system is visible. The code completion engine will not attempt any sort of deep context analysis from the content in a workspace in order to provide highly accurate suggestions. This is because workspace content is not required to be well-formed structured code. In fact, it's not required to be code at all. Therefore, code completion will provide all possible suggestions of any type such as methods and classes.
•Inspectors - Code completion hooks into the text editors available inside a VA Assist inspector. The code completion engine uses the additional runtime information available in an inspector to provide more accurate suggestions. Similar to workspace, Inspectors will not attempt any sort of deep context analysis from the inspector content. This is because the contents of the inspector are not required to be well-formed structured code. Code completion will provide all possible suggestions of any type such as methods and classes.
•Debuggers - Code completion even hooks into the debugger. In addition to all the capability provided by a general Smalltalk browser, code completion will use the runtime information available to resolve types of variables and arguments.
Code Completion Configuration Options
Configuration options for code completion are stored in the ENVY manager repository by user. This means that each user will have access to their unique set of configurations from any Smalltalk client connected to an ENVY manager instance.
Code completion configuration options can be accessed by (Options | Code Assist | Configure...) in any browser menu and selecting "Code Completion" from the Feature combo box in the Configuration UI. Because there are so many available options that allow you to customize your experience using Code Completion, a Filter combo box has been provided that shows the various options in logical categories. A complete description of each configuration option will be provided below.
The configuration UI allows you to restore the default settings for the configuration items that are in view. This gives you the ability to restore just the settings in a particular category, without affecting the settings in other categories. If you would like to restore all settings, select the "All" category in the filter combo box and press the "Restore All Defaults" button on the bottom-left of the configuration UI.
The configuration UI also gives you access to a summary of the current key bindings that can be used for various code completion actions. To see a description of these, press the "Key Bindings" button located on the bottom-right of the configuration UI.
Tip: If you would like a reminder of what an option does, you can hover the mouse pointer over the option name and a tooltip will show with a brief description. AbtEwHoverHelp class must be loaded in the image for tooltip support.
Basic Configuration Options
The options in this category provide ways to tweak the Code Completion experience in a course-grained fashion, and serve as a good starting point to customizing your experience. Many of these options are supported, in various flavors, by other popular development environments that offer code completion.
•Enable Code Completion - Enable/Disable code completion in the global development environment.
Default: true
•Request Code Completion - Key sequence used to explicitly activate code completion. Many development environments use <Ctrl+Space> to activate code completion, and so this is the default. However, <Alt+Down> has been provided as an additional option for those who work with Microsoft Excel and prefer this method of opening up a popup list.
Default: <Ctrl+Space>
•Auto Completion Popup Enabled - If set to true, then the popup will show automatically after you have typed a specified number of characters (defined by "Auto Completion Popup Threshold") within a specified amount of time (defined by "Auto Completion Popup Delay (ms)"). If set to false, then you must explicitly request code completion by typing the key sequence (defined by "Request Code Completion").
Default: true.
•Auto Completion Popup Threshold - The minimum number of characters you must type before auto popup is eligible to activate. This is only valid if auto popup is enabled.
Default: 2
•Auto Completion Popup Delay (ms) - The amount of time (in milliseconds) that must elapse before auto popup is eligible to activate once the user has typed the specified number of characters (defined by "Auto Popup Threshold").
Default: 250
•Auto Complete On Single Suggestion - If set to true, and it is found that only one possible suggestion exists when you request code completion, then the popup list is bypassed and the completion suggestion is automatically applied to the text editor.
Default: true
•Accept Suggestion Key - This is the key used to accept a suggestion from the popup. Some folks have strong feelings about which key should be used to accept a suggestion. Furthermore, depending on what other development environments developers have experience with, their muscle memory has them pressing this familiar key without even thinking about it. For this reason, the available choices are <Tab> and <Enter>, which covers what is seen in other popular development environments which support code completion.
Default: <Enter>
•Enable Suggestion DragNDrop - If set to true, then completion suggestions can be dragged out of the popup and dropped anywhere outside. In doing so, a relevant Smalltalk browser will be displayed where the drop occurred. The type of browser displayed will depend on the type of completion. If the <Ctrl> key is NOT held during the drop, then a Class/Implementors browser will be displayed for the suggestion. If the <Ctrl> key IS held during the drop, then a References/Senders browser will be displayed.
Default: true
Note: Local Variable and Character completions do not support DragNDrop.
•Completion Insert Policy - The default policy to use when applying a completion to the text editor. Because there are only two policies, you may hold down the <Ctrl> key when applying a completion and the other (non-default) insert policy will be used instead.
•Append - When a completion is applied, it is inserted at the cursor point without overwriting any of the characters after the cursor
•Overwrite - When a completion is applied, it is inserted at the cursor point and will overwrite any additional characters after the cursor up to, what is perceived as, a word boundary.
Default: Append
•Smart Space After Insert Policy - This policy describes the type of completions that should have a space appended to them when applied to the text editor. However, if it is found that an additional separator already exists after the insert point in the editor, then the additional space will not be appended. You can specify that this policy applies to any combination of Classes, Variables and Methods.
Default: Classes
•Prefix Match Policy - This policy describes how prefix matching is configured. Prefix matching algorithms will attempt to match the partial string in the text editor with the prefix of candidate completion suggestions according to the policies described below:
•Disabled - Do not allow prefix matching
•Case Sensitive - The characters in the partial string must exactly match (same case) the characters that make up the prefix of candidate completions.
•Case Insensitive - The characters in the partial string must have a case-insensitive equivalence (same character) with the characters that make up the prefix of candidate completions.
Default: Case Insensitive
Tip: Why would you ever disable prefix matches? As you will see, code completion has support for other, often more powerful, types of match algorithms. Some developers may wish to only rely on code completion using non-prefix match algorithms. This has the effect of further reducing the overall number of suggestions in the completion popup, which is always a target goal.
•CamelCase Match Policy - This policy describes how CamelCase matching is configured. CamelCase matching allows for a flexible way to filter completion suggestions by aligning the characters in the partial string with "camel humps" found in candidate completion strings. "Camel humps" are the uppercase characters in a camel-case name. For example, the letters 'O' and 'C' are "camel humps" in the method name "asOrderedCollection". One of many patterns to match this method name using camel-case matching would be the pattern "aOC". The CamelCase Matching algorithm is configured based on the policies described below.
•Disabled - Do not allow camel-case matching
•Very Strict - Uppercase characters in the partial string are REQUIRED to match "camel humps" in the candidate string. Furthermore, the number of "camel humps" in the partial string is REQUIRED to have the same number of "camel humps" in a given candidate completion.
Example: "ReadWriteStream" can be matched by typing "RWS", but not "rws" or "RW"
•Strict - Uppercase characters in the partial string are REQUIRED to match "camel humps" in the candidate string. However, the number of "camel humps" in the partial string is NOT REQUIRED to have the same number of "camel humps" in a given candidate completion.
Example: "ReadWriteStream" can be matched by typing "RW" or "ReWr", but not "rws"
•Lenient - Shiftless CamelCase. Uppercase characters in the partial string are NOT REQUIRED to match "camel humps" in the candidate string, though it must be the same letter (No shift required). Furthermore, the number of "camel humps" in the partial string is REQUIRED to have the same number of "camel humps" in a given candidate completion.
Example: "ReadWriteStream" can be matched by typing "rws", but not "rwri"
•Very Lenient - Shiftless CamelCase. Uppercase characters in the partial string are NOT REQUIRED to match "camel humps" in the candidate string, though it must be the same letter (No shift required). Furthermore, the number of "camel humps" in the partial string is NOT REQUIRED to have the same number of "camel humps" in a given candidate completion.
Example: "ReadWriteStream" can be matched with "rw", "rwri" or "rws"
Default: Very Lenient
•Method Visibility Policy - This policy describes which method suggestions should be shown based on their visibility (i.e. Public, Private or both (All)). This is only applicable when a method suggestion can be mapped to a single method.
Default: All
Live Filtering Support: When the completion popup is visible, and showing public/private methods, you can press <Ctrl+Shift+P> to cycle through the various method visibility policies. When performing live filtering, adjustments to the policy will only be retained while the popup is visible. Once the popup is closed, the original policy defined by your configuration will be reinstated.
•Application Visibility Policy - This policy describes the application visibility rules to use when computing completion suggestions for the browsers and debuggers. This policy evaluates concepts such as prerequisite chains, and therefore will have no impact on what is shown in an inspector or workspace.
Because of the flexibility of Smalltalk browsers, answering a seemingly simple question such as "What applications can I see?" is actually non-trivial. A combination of methods, classes and applications currently selected in a browser is used to come up with an initial answer. However, the algorithm also detects to see if you're modifying just the body of a selected method, or the method signature as well. This information is used to assemble a prerequisite application chain.
The algorithm tries to take the conservative approach and assemble the largest set of visible applications when faced with ambiguity.
The prerequisite algorithm is mostly modeled after what would happen if you modify a method in a browser and pressed save. To get an idea of the ambiguity that exists, if showing inherited methods in a class hierarchy browser, and you completely rewrite the method signature and body of a selected inherited method, upon pressing "save" the browser will ask a series of questions about what object and application it should be saved to. The set of all visible applications should include all possibilities.
The following is a description of the available policies:
•All - All Objects and Methods will be considered when computing completion suggestions.
•Prerequisites - Only Objects and Methods that are perceived as being in the prerequisite chain will be available when computing completion suggestions.
Default: Prerequisites
Live Filtering Support: When the completion popup is visible in a browser or debugger, you can press <Ctrl+Shift+U> to cycle through the various application visibility policies. When performing live filtering, adjustments to the policy will only be retained while the popup is visible. Once the popup is closed, the original policy defined by your configuration will be reinstated.
•Object Application Visibility Policy - This policy provides an additional refinement to prerequisite application visibilities, and therefore is only applicable if the "Application Visibility Policy" is set to prerequisites.
•Prerequisites - This is the default policy, and has no perceivable impact since the "Application Visibility Policy" is also set to prerequisites.
•Kernel Application and SubApplications - With this policy, method completions, whose defining class is Object, will be filtered out UNLESS the method is defined in Kernel or any of Kernel's SubApplications. In the interest of being pragmatic, method extensions to Object in, what is determined to be, the current root application will also be included.
Default: Prerequisites
Tip: When would you use this? Object has a lot of methods. If you are finding that the completion popup is being cluttered up with Object methods in your prerequisite chain that you don't generally use, try setting this option to "Kernel Application and SubApplications" to reduce the overall size of the completion list.
Advanced Configuration Options
The options in this category provide finer-grained tweaks that you may, or may not, be interested in. These options provide some additional ways to customize the code completion experience.
•AutoPopup Traversal Key Enabled - If set to false, and the completion popup is displayed automatically (i.e. "Auto Completion Popup Enabled" is set to true), then using the traversal keys (Up, Down, Left, Right Arrows, PageUp and PageDown) will force the popup to close, and those keys will perform their appropriate action in the text editor. In order to scroll through selections in the completion list, you may hold down the <Ctrl> key and press any of the traversal keys, except for Left and Right arrows, since <Ctrl-Left> and <Ctrl-Right> are reserved for cursor placement behavior in the text editors. This option will have no effect on completion popups that are shown in response to a user request
Default: true
Tip: When would you use this? If you find that you generally only accept completions when they are at (or near) the top of the completion list (or you prefer to use a mouse click), and find it annoying that the traversal keys you meant for the editor are getting intercepted by the popup, then you may want to try setting this option to false. Remember that you can still select items in the popup using these keys...you just need to hold the <Ctrl> key down during the key press.
•AutoPopup Select First Suggestion - If set to false, and the completion popup is displayed automatically (i.e. "Auto Completion Popup Enabled" is true), then the completion popup will show with no pre-selected completion suggestion. You can press the Down arrow key to highlight the first suggestion. This option will have no effect on completion popups that are shown in response to a user request.
Default: true
Tip: When would you use this? If you find that you like having the completion popup automatically show, but you feel strongly that pressing either <Enter> or <Tab> (depending on your "Accept Suggestion Key" setting) should actually be applied to the text editor until you're read to tell it otherwise, try setting this option to false. This means that there is one additional keystroke (Down arrow) to get an item selected, and at this point you can press your "Accept Suggestion Key".
•Wrap Completion Popup Selections - Wraps selections in the completion popup once the top or bottom of the list is reached.
Default: true
•Method Receiver Sort Policy - Because code completion considers all possible precedence levels when requesting completion of a partial method selector, you may see method suggestions in the popup with a left arrow or double left arrow icon.
Method suggestions with a single left arrow icon imply the suggestion is meant for an outer receiver 1 level out from the inner receiver. A completion suggestion with a double left arrow implies the completion is meant for the receiver 2 levels out from the inner receiver. The distinction is important because it makes auto-parentheses insertion an unambiguous operation. By selecting a given completion, you are simultaneously specifying the intended precedence level, and code completion will take care of where the parentheses, if any, should go.
With this overview in mind, it is now appropriate to say that this policy describes the order in which method suggestions, with the various receiver levels, will be sorted in the completion popup. The following is a description of the policies available:
Inner First - Method suggestions intended for the inner receiver will be sorted before method suggestions intended for any outer receivers.
Outer First - Method suggestions intended for the outer receivers will be sorted before method suggestions intended for the inner receiver.
Inner First Unless Binary Outer Exists - The preference here is to sort with an Inner First sort policy, unless the inner receiver is part of a (outer) binary expression, in which case an Outer First sort policy will be used.
Default: Inner First Unless Binary Outer Exists
Live Filtering Support: When the completion popup is visible in a workspace, inspector, browser or debugger, you can press <Ctrl+Shift+I> to cycle through the Inner/Outer First sort policies. When performing live filtering, adjustments to the policy will only be retained while the popup is visible. Once the popup is closed, the original policy defined by your configuration will be reinstated.
Tip: When would you use "Inner First Unless Binary Outer Exists"? While it would be difficult to formally prove, it was noticed that after requesting code completion after a binary expressions, such as "x = y", the completion suggestions of interest tended to be those that referred to the outer binary expression, rather than the inner receiver (which in this example is "y"). Of course, there are many cases where you actually want to refer to the inner receiver, and wish those would show first. If you find this to be universally true, you may adjust this sort policy to Inner First, or if it's just in a few cases, you can take advantage of live filtering and have it sorted the way you want by pressing the live filter hotkey described above.
•Prefer Class Hierarchy Method Sort - If set to true, method completions for receivers, whose object type can be narrowed down to a single type, will be sorted in the popup according to the method's defining class position in the class hierarchy (ordered by most concrete to most abstract). A lexicographical sort is the standard sort policy used if not using a hierarchy sort.
Default: true
Live Filtering Support: When the completion popup is visible in a workspace, inspector, browser or debugger, you can press <Ctrl+Shift+H> to toggle between hierarchy and lexicographical sort. This will have no effect if a hierarchy sort it not possible because the receiver's object type is not narrow enough. When performing live filtering, adjustments to this setting will only be retained while the popup is visible. Once the popup is closed, the original policy defined by your configuration will be reinstated.
•Enable Variable Completions - Allows you to control if completion suggestions for a variable will be shown in the completion popup.
Default: true
•Enable Pool Variable Completions - Allows you to control if completion suggestions for pool variables will be shown in the completion popup.
Default: true
•Enable Global Namespace Completions - Allows you to control if completion suggestions for global namespace items (Classes/Globals/Pool Dictionaries) will be shown in the completion popup.
Default: true
•Enable Symbol Completions - Allows you to control if completion suggestions for Symbols and Atoms will be shown in the completion popup.
Default: true
•Enable Method Completions - Allows you to control if completion suggestions for Methods will be shown in the completion popup.
Default: true
•Enable Block Argument Detection - If this is set to true, then the code completion engine will attempt to identify block-arguments of a keyword method completion suggestion. If any are found, "[]" will be inserted in their associated argument positions once the completion suggestion is applied to the text editor.
Default: true
•Apply Filters to Empty Partials - If this is set to true, then a single suggestion will show when requesting code completion on an empty partial. This suggestion acts as a filter so huge quantities of suggestions are not drawn which is performance intensive. Accepting this filter suggestion will simply redraw all suggestions.
Default: true
Look And Feel Configuration Options
The options in this category provide settings to customize the look and feel of code completion. With these settings, you can create a customized theme for the completion popup, as well as take advantage of match highlighting.
Assuming you use code completion, you are going to be seeing the completion popup a lot! This is especially true if you have "Auto Completion Popup Enabled". Therefore, you should have some ability to control how the popup looks...and we provide that capability with an extensive set of theming options.
Being able to control the visual appearance of the completion popup can have a lot of appeal. However, we felt it was also important to find ways to use visual appearance to help increase the usability of code completion. With this in mind, code completion offers a "Match Highlighting" engine that provides visual cues for matched and unmatched regions of a candidate completion suggestion in the popup. These visual cues allow you to quickly see why completions are in the popup, what the next character to press should be and what remaining portion of a given completion in the popup has yet to be matched.
Note: Match Highlighting functionality is only available when using enhanced list widgets with the extended list widget style, which is one of the settings provided. However, some of the basic theme settings will still be available even when you're not using enhanced list widgets.
With the exception of fonts, look and feel configuration options are designed to be shared across all VAST Platform supported operating systems. Fonts require some special handling because font availability is not just operating system dependent, it can also be machine dependent. Typically, you will see more font variation between the windows and *nix systems, instead of within a given family of systems. Because of this, font configurations are stored by operating system type. While this scheme doesn't solve the issue completely, it does capture the majority of cases where, for example, you need to specify one type of font for a Linux client and another type of font for a Windows client. Even though the font setting is stored by operating system type, there are certainly situations where a specified font may not be available. For example, if you specify your font setting for code assist in a Windows 7 client, with a font only available in Windows 7, and then open a Windows XP client connected to the same ENVY manager (and as the same ENVY user), upon opening the Look And Feel configuration options for Code Completion in Windows XP you will see that it falls back to using the 'Default' font for that particular font setting. Additionally, you will see that 'Default' is drawn in red, so you will be aware that it was unable to locate the specified font. At this point, you may just go with the default, or you may wish to change the font to one that is available on Windows XP and Windows 7.
The pictures below show some examples of different combinations of theme and match highlight settings. Some of these would probably be ridiculous choices in practice, but it demonstrates some of the visual elements you will have control over:
All the settings related to look and feel are described in detail below:
•Use Enhanced List Widgets - Controls if the code completion widgets will be using enhanced list widgets. Enhanced list widgets will always be available for use because they are a core part of the development environment (ExtendedWidgets). The fundamental reason this choice was made available is that, by default, code completion tries to maintain the look and feel of the VAST environment. If the development environment is not using enhanced list widgets, then by default, neither will code completion. This setting is provided so you are free to override whatever the default is.
•Default - Defers to the global setting of the environment "Use Enhanced List Widgets" to determine if enhanced list widgets should be enabled.
•true - Use enhanced list widgets
•false - Do not use enhanced list widgets
Default: Default
•Enhanced List Widget Style - The code completion list widget style to use.
•Extended - Completion list widget is drawn using VAST's Extended Widget's framework
•Scintilla - Completion list widget is drawn and managed by Scintilla.
Default: Extended
•Max Visible Suggestions - The maximum number of visible suggestions to display in the completion popup. This effectively determines the height of the popup and will be constrained by the overall height of the screen.
Default: 10
•Completion Popup Layout Policy - This policy describes the placement of the completion popup.
•Align with Text - When the completion popup is shown, it will anchor itself to the starting location of the partial string the user has entered. Even as the user types additional characters, the popup will maintain its initial location.
•Align with Cursor - When the completion popup is shown, it will show relative to the cursor's current location. As the cursor moves, the completion popup will move with it.
Default: Align with Text
•Completion Popup Font - The font used for completion suggestions that are rendered in the popup, unless overridden with matched/unmatched region font settings. If "Default" is specified, then the text editor font will be used.
Default: Default
•Completion Popup Background - The background color used for the completion popup (non-selected region). The default color will be the enhanced list widgets color defined for the system by VA Assist Pro. If this is not set, then the default background will be white.
Default: Default
•Completion Popup Foreground - The foreground color used for the completion popup (non-selected region). The default color will be the computed inverse of the "Completion Popup Background" color.
Default: Default
•Selected Suggestion Background - The background color used for a selected suggestion in the completion popup. The default color will be the selected background color defined by the system. (see CwList>>selectionBackgroundColor)
Default: Default
•Selected Suggestion Foreground - The foreground color used for a selected suggestion in the completion popup. The default color will be the selected foreground color defined by the system (see CwList>>selectionForegroundColor)
Default: Default
•Enable Match Highlighting - If set to true, then completion suggestions rendered in the popup will be stylized according to the settings described below.
Default: Default
•Matched Region Font - The font used for regions of a completion suggestions that match the current partial string in the text editor. If "Default" is specified, then the "Completion Popup Font" will be used.
•Default: Default
•Matched Region Color - The color used for regions of an unselected completion suggestion that matches the current partial string in the text editor. If "Default" is specified, then the "Completion Popup Foreground" color will be used.
Default: Default
•Selected Matched Region Color - The color used for regions of a selected completion suggestion that matches the current partial string in the text editor. If "Default" is specified, then the "Selected Suggestion Foreground" color will be used.
Default: Default
•Unmatched Region Font - The font used for regions of a completion suggestions that have yet to matched by the partial string pattern. If "Default" is specified, then the "Completion Popup Font" will be used.
Default: Default
•Unmatched Region Color - The color used for regions of an unselected completion suggestion that are still unmatched by the current partial string in the text editor. If "Default" is specified, then the "Completion Popup Foreground" color will be used.
Default: Default
•Selected Unmatched Region Color - The color used for regions of a selected completion suggestion that are still unmatched by the current partial string in the text editor. If "Default" is specified, then the "Selected Suggestion Foreground" color will be used.
Default: Default
•Highlight Distinct Matched Regions - If set to true, then matched regions in a completion suggestion will be highlighted independently of each other. This can be a useful visual cue to show completions that have been prefix or camel-case matched. If set to false, then all the matched regions will be combined into one contiguous match region.
Default: false
•Highlight Next Character To Match - If set to true, then an underline will be rendered under the next character to match in a given completion suggestion. This could also be interpreted as underlining the first unmatched character in a given completion suggestion.
Default: true
Code Completion Suggestions
In VA Assist Pro, code completion provides you with a set of "suggestions" for completing the word that you're typing. These completion suggestions come in various flavors to help you complete the different constructs available in the Smalltalk language. Code completion in VA Assist Pro is context sensitive, and can use the information from the current context to provide you with relevant suggestions. For example, if you are typing a method selector and activate code completion, it knows to only provide you with selectors that successfully complete what you're typing, and not classes and variables that happen to match your partial selector. Code completion provides suggestions to you with icons to help you quickly identify what to look for. The following is the list of constructs that can be completed, along with examples of their associated icons. In many cases, the code completion engine is able to identify the type of the object being suggested dynamically (i.e. Number, String...), and will use the icon associated with that type.
• Local Variables
• Instance Variables
• Class and Class Instance Variables
• Pool Variables
(Uses Dynamic Icons) • Pseudo Variables
(self, super, nil, true, false) • Classes
• Pool Dictionaries
• Globals
(Uses Dynamic Icons) • Symbols/Atoms
• Characters
• Methods
(Uses Dynamic Icons) • Text manipulation
Most suggestion types are self-explanatory for a Smalltalk programmer, however there are a few suggestion types that are worth describing in more detail.
Symbol Suggestions: VAST's code completion has support for completing symbol literals. Suggestions for symbol literals are created from the Smalltalk symbol table, which is often very large. While code completion is more than happy to show you all symbols available in the system, you should understand that this is a pretty expensive operation and will take some time (which implies a second or so, instead of 100 milliseconds). You can see all symbols in the system by typing '#' and requesting code completion. You will notice that a filter notice will popup. At this point all the symbol suggestions have been prepared, they just have not been rendered in the popup yet. You may either accept the filter notice to show them in the completion popup, or you can just continue to type and it will filter on the prepared items and show the filtered suggestions in the completion popup.
Character Literal Suggestions: One of the goals of code completion is to show useful information in the completion popup at all points. While you certainly don't need assistance in typing a single character, it may be useful for you to see a set of suggestions that describes the ASCII table. This can be achieved by typing '$' followed by a request for code completion. What you will be looking at is the non-extended ASCII table, in suggestion form, and you will be able to search by name or ASCII value. This is also helpful for completing some of the non-printable characters, which are usually referenced by pool variables. Code completion is aware of what pool variables are visible in your current context and will provide a full scoped reference to a character pool variable if necessary. The following shows an example of what character literal suggestions look like.
Method Suggestions: Code completion has a unique ability to display suggestions for all possible receivers of a method. Visual cues are provided in the completion popup that allow you to tell which receiver a completion suggestion refers to. Once a method suggestion is accepted, code completion will not only apply the completion to the editor, but also auto-insert parentheses where needed. Code completion is able to do this because the selection you make tells it what the intended precedence level is, and therefore where parentheses need to be inserted so the completion will refer to the intended receiver. The following picture below shows an example of the completion popup containing method suggestions for all three precedence levels to complete the partial 'aft'. The first suggestion is a camel-case match that refers to the variable receiver 'max'. The second suggestion is a camel-case match that refers to the binary expression receiver 'min < max'. We know this because there is one yellow left arrow icon to indicate that this completion is for the receiver one level out. Finally, we have two prefix-matched suggestions that refer to the receiver 'OrderedCollection new'. Notice that there are two yellow left arrows for these suggestions, which specifies that it is intended for the receiver two levels out.
Text Manipulation Suggestions: Some other VA Assist Pro features, such as refactoring, hook into code completion which can make it easier to initiate the refactoring. Some examples of this are generating accessors and declaring an undefined temporary. These are discussed in more detail in the Refactoring section below.
Effective Search using Code Completion
Code Completion has powerful matching algorithms that allow you to narrow down the completion list to just the completions you are interested in. This section will walk through the matching algorithms that are available in VAST and describe how they work so you can search most effectively.
When completion matching is talked about, what is implied is that the user has typed a small part of a larger name that the user would like assistance completing. The part that the user has typed in will be referred to as the 'partial string'. Code completion will attempt to match the partial string against longer names that might be suitable candidates for completion. These longer names will be referred to as 'candidate completions' and these are the items that the user sees in the completion popup.
A key point to understand is that the partial string represents a pattern, and it is up to the matching algorithms to understand how to interpret that pattern. Most developers who have used code completion with other development environments are pretty comfortable with the fact that the partial string typically represents the prefix of the intended completion. So for example, if a developer wanted to complete the name 'OrderedCollection', they may type 'Ord' and request code completion with the expectation that 'OrderedCollection' will be an available candidate completion (and therefore will be an item in the completion popup). While this remains true, we will also see that VAST has matching algorithms that interpret the partial string as a pattern that describes more than just the prefix of an intended completion. This leads to more powerful searching capabilities, but these matching algorithms have their own rules which you must learn in order to use them most effectively.
Prefix Matching: Prefix matching implies that the partial string represents the prefix of an intended completion. Therefore, the candidate completions that are successfully matched using this method will have the partial string as their prefix.
In VAST Platform, you have the option of specifying that prefix matching is case-sensitive or case-insensitive. While case-insensitive means you don't have to press the <Shift> key to match uppercase characters, the trade-off is that you will most likely see more candidate completions in the popup since there may be both uppercase and lowercase matches.
CamelCase Matching: VAST Platform supports a powerful multi-mode algorithm that interprets the partial string as a pattern which can be used to match names that conform to the rules of camel case. The camel case rule set is only loosely-defined, but fairly easy to understand with some examples which will be provided. The algorithm has a few modes which can be decided by you. See the 'CamelCase Match Policy' configuration section for more information.
CamelCasing is a way to represent multiple words or phrases as a single word. This is done by removing the spaces between the discrete words, which joins them together, and then taking the first letter from each word and making it an uppercase. This last step is so you can visually tell the separation between the words since spaces are no longer present. This is far easier to describe with some simple examples, and if you program in Smalltalk, you are probably very comfortable with this concept already. Consider the Smalltalk class name 'OrderedCollection'. In this example, the adjective 'Ordered' has been joined with the noun 'Collection'. Notice that the 'C' in 'Collection' is uppercase. This uppercase character is often referred to as a 'Camel hump' in a CamelCase name. These 'Camel humps' are used as part of the partial string to specify to the algorithm that if a prefix match fails at a certain character, then jump to the next 'Camel hump' and try to continue from there. Lets look at some examples. On the left will be the pattern, or the partial string that the user has typed into the text editor. On the right will be one potential candidate string that could match the pattern:
•OrdCol -> OrderedCollection
•OC -> OrderedCollection
•ReWStr -> ReadWriteStream
•mVar -> myVariable
As you can see, the partial strings are much smaller, but also convey a lot more information than just simple prefix matching. VAST Plaform takes it even one step further. Notice in the above examples that the user must type an uppercase character in the pattern to represent the 'Camel hump' of a CamelCase name. This means pressing the <Shift> key a lot in short succession. VAST Plaform will happily use this rule set, but the user may also adjust the CamelCase matching policy to 'Lenient' and let Code Completion figure out where the 'Camel humps' are supposed to be. By doing so, the above example could be modified as follows:
•ordcol -> OrderedCollection
•oc -> OrderedCollection
•rewstr -> ReadWriteStream
•mvar -> myVariable
The CamelCase matching algorithm also provides a unique way to search Smalltalk keyword selectors. Typing the ':' is completely optional, and multi-keyword selectors can be searched using CamelCase. The following are some examples shown using the Lenient variant of the algorithm:
•aoc -> asOrderedCollection
•asorcol -> asSortedCollection:
•adafin -> add:afterIndex:
•a:beind -> add:beforeIndex:
•wwww -> with:with:with:with: