Camel-case / underscore based auto completion
JDT has this, for example when in a Java editor I type
CP<ctrl+space>
the JDT proposes ContentProposer,AL<ctrl+space>
suggests ArrayList, etc.It is currently not possible to do this with Spoofax because filtering is hard coded in the runtime.
Possibly the runtime can be changed to support camel-case separated words, underscore separated words, hyphen separated words, and anything else any DSL may ever need, or the completion API semantics must be changed to force the language developer to do the filtering on prefix (not a good idea IMHO).
Some possible solutions in between these two extremes would be to either make the filtering of completions an extension point, and provide a reasonable default (e.g., what we have now), or to add some syntax to the EditorService that allows one to specify declaratively what are word boundaries in the language, for example using a regular expression (best solution IMHO).
Submitted by Tobi Vollebregt on 5 October 2011 at 17:54
Issue Log
Interesting feature, I’ve never used this. The regular expression solution sounds nice. I don’t suppose we can device a general solution? i.e., hardcode word boundaries in the form of capital letters and word separator characters?
We can use this regex as default, that covers lowerCamelCase, UpperCamelCase, and any-non-alphanumeric-character-separated identifiers :P
(^[a-z0-9]+)|([A-Z][a-z0-9]*)|((?![^A-Za-z0-9]|^)[A-Za-z0-9]+(?=[^A-Za-z0-9]|$))
(Or actually separate it into a few readable ones and put them all in the generated comments so user can copy paste and adapt the right one.)
Perhaps. It seems like a feature few programmers use or know about, but it could be an interesting addition.
(Also, what about
(^|\b|(?=[A-Z]))([A-Za-z])
? Although I think regular expressions might pose a performance issue: filtering is already not that fast.)
@Lennart:
I know about this feature in Eclipse for Java. It’s great and I use it a lot. It works in a variety of fields as well (code completion, new class, open type, plug-in dependencies, etc.)
Interesting. I’ve never used it. I do use the wild cards a lot, which work in all kinds of dialogs (e.g., control-shift-R) and don’t depend on you thinking about the initial letters of the names. But for some reason those don’t work for content completion. Might be interesting. Also, isn’t it easier to type the first couple of letters, e.g. Arr instead of AIOOBE? It seems you only get the completion but not the discoverability with this feature… But I can see how it can be useful for common names.
@Lennart: that other regex takes only the first character. It wasn’t clear from the initial description, but in Eclipse/JDT you can actually type a part of each word. So basically it is doing filtering on the prefixes of all words at the same time, instead of filtering on a single prefix. For example, typing
ArrLi<ctrl+space>
also expands to ArrayList.
Log in to post comments