View RSS Feed

Development Team Blog

CodeSense Improvements

Rate this Entry
Note: This information applies to Visual DataFlex 2008 and higher

During development of 12.0 and 12.1 we received feedback with several suggestions for improving CodeSense. Many of those suggestions, along with some other ideas we had during development, were out of scope for 12.0, so we logged them in our bugtracker database as either bugs/suggestions. During development of 12.1 we fixed a lot of the pure bugs and performance issues, but we didn't have time to address some of the other CodeSense issues that were technically more like suggestions because they required bigger changes, even though they were often viewed as bugs or shortcomings in 12.0.

Now time has come for these CodeSense improvements in Visual DataFlex 2008. I will try to explain these improvements and changes, as well as the rationale behind them. I will go through these changes in chronological order rather than order of importance or impact, to give you a better idea of our rationale behind them.

Improvements with Enum Lists
You have probably seen the Quick Info feature, where you see the value of a constant as you hover the cursor over any use of that defined constant. This is very useful information. But there was a problem with this feature when you hover over an enum list constant, where it didn't display the value. This would occur when the value was not directly specified in code, but instead automatically computed at compile time. Of course, that's almost always the case with enum values, where you only specify the name of the constant and let the enum list figure out the constant number it should represent.

This has been improved in Visual DataFlex 2008, and the Studio parser now correctly computes the values automatically. This allows QuickInfo to display the constant number represented by the enum symbol. It even resolves symbols recursively, just like the compiler. So if an enum list constant refers to another defined constant, QuickInfo will still display the appropriate value.

Improvements with Use Statements
CodeSense with Use statements is in principle quite straightforward. It lists the source files and directories available in your make path. However, file names are slightly different compared to regular symbols such as variable names. In particular, file names and directories may contain embedded spaces. In addition, file names usually have file extensions, so they typically include a dot. This presents some desired differences in behavior of CodeSense for Use (and #Include) statements.

We decided to improve the behavior of CodeSense for Use (and #Include) statements in Visual DataFlex 2008. First, when you type a file path with embedded spaces, it now automatically surrounds the path in quotes as you type. This obviously only occurs if necessary, so that file names without embedded spaces are not automatically surrounded in quotes. But it doesn't add quotes immediately when the developer is typing a space, as that would lead to false positives. For example, you could type Use xyz.pkg followed by a space and then a comment. For this reason it defers adding the quotes until it sees that it's really an embedded space in the file name or path, and not just a trailing space on the line. This means that when you type Use My File.pkg, it automatically surrounds it with quotes as soon as it detects it's necessary, which is after you have typed the first character after the space.

The second improvement with Use statements is related to the use of dot in filenames, and wouldn't really turn up much in practice. But when it happens, it's very noticeable. If you invoked CodeSense for an existing Use statement, it wouldn't replace the the file extension when you selected an item from the list. This has now been improved so that it always considers the whole file name, including the extension, when selecting an item from the list. A related issue with embedded spaces has also been addressed. When a file name or directory contained spaces, it wouldn't match properly in the CodeSense list as you typed, because it didn't take the space into consideration. Again, this has now been addressed, and CodeSense takes all of these special file name considerations into account when in a Use or #Include statement.

Semi-Automatic Lists
This is perhaps the most exciting CodeSense change in Visual DataFlex 2008. In prior revisions there were basically two kinds of CodeSense lists, manual lists and automatic lists. A manual list is when you have to press Ctrl+Space to display the list. Basically, although the contents of the list is always context sensitive, you have to invoke it manually for the list to appear. Automatic lists are displayed automatically when you type space, to position the caret in specific command arguments. For example, when typing 'Object oBar is a' followed by space, the list of classes appears automatically without pressing Ctrl+Space.

We have now introduced a third kind of list in addition to the manual and automatic lists, our internal name for it is semi-automatic lists, which in most cases removes the need for typing Ctrl+Space at all. You may not realize it at first, but after a while you notice that even though codesense was present before, and you used it very often, there were still situations where you didn't take advantage of it because you had to press Ctrl+Space. With semi-automatic lists, the list is always there right when you need it.

Virtually all manual CodeSense lists in prior versions of Visual DataFlex are now semi-automatic. Technically speaking, the list is displayed automatically when you type the first character. This ensures that the list is not displayed when you type constants, or string literals etc., while it's always displayed when you're typing a variable name or something like that. This makes it almost seem like magic how the list comes up whenever it's needed, while at the same time it remains hidden when you don't want it to appear. You can of course also still bring up the list manually using Ctrl+Space without typing a character.

Try this out and see how it feels. I'm sure your first reaction will be that you're kind of surprised when the list pops up all the time. But as you start to use it, we think you'll find that it works really well, and that it's a productivity enhancing change. This has been the general experience for everyone trying out the internal builds here at DAW.

General CodeSense List Improvements
One thing we realized as soon as we added semi-automatic lists, was that many keywords were missing from existing lists. This became very noticeable when the list would come up automatically in locations where you previously didn't bother typing Ctrl+Space. For example, Get foo of, where of wasn't present in the list. CodeSense for more than 20 different commands, such as Get, Direct_Input, Read etc. have been enhanced with these additional keywords.

We have also added some additional CodeSense lists for certain commands. For example Forward where Send, Get and Set are now available in CodeSense. Many more commands have been enhanced in a similar fashion.