Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Improving code completion to a usable state

(1/2) > >>

I don't know what are your current plan about improving the code
completion, but this is what I could try to do (please tell me if I'm

Current state:
 -  For the code editor you are using wxStyledTextCtrl which, in
turns, uses Scintilla. I've already used Scintilla a while ago, and
I'm familiar with its syntax.
-  For the code completion, you are parsing the source code by
yourself with a home made parser.

What is currently lacking (from my point of view):
 - The code editor could have a lot of features from the last
Scintilla turned on (like brace matching, code block vertical lines,
better coloring)
 - The parsing is quite limited. Maybe you could see for
a more complete parser (which still lacks preprocessing).
 - The code completion is really boring to use (if not counter intuitive)

What I could try to do:
1 - Use the parser, when available, to feed a new list of colored
keywords to Scintilla, so that class members, local variables,
functions can have a different style.
2 - Provide a useful code completion, by not only triggering it after
having typed '.' or '->' but also while typing any text (based on
mostly occurring text)
3 - Select the code completion box when pressing right arrow (not only enter or tab)
4 - Add a tooltip when typing a function (what is already called
CallTip by Scintilla) that show the function prototype (like shown in
the current code completion) which highlight the current argument
being typed. I don't know if it is currently possible to quickly get
the comment before the function declaration.
5 - (Harder) provide a go shortcut (or button) that directly goes to
the item-under-the-cursor's declaration. (this is linked with the
previous remark)
6 - (Harder) provide a context sub menu to quickly jump to symbol
declaration in the current file
This requires being able to only parse the current file (or filter the
token list by filename)

Tell me if you've already done this.
For 1), I think I could append some code in the parser OnThreadEnd
method (so that opening the code window is still very quick when no
parsing information is available), and in EditorManager :: Open (or
cdEditor constructor, let me know what is best)). This code will
simply add the list of names to scintilla text editor with a new style
based on their types. The SetKeyWords method of wxStyledTextCtrl
allows creating a new set of styled keyword. Then we should call the
StyleSetxxx methods to change it. I don't want to deal too much with
the dialog boxes, so maybe you will have to add new a configuration
item in the style list editor dialog.
Of course, every time the parser finishes a new step, it will update
the view (maybe there will be flicker here, I don't know, this
requires testing).

For 2), this doesn't requires parsing the current file again. The idea
is to fill a list of already typed word (like English words) sorted by
first letter, and frequency of occurring. When the user start typing a
word (after pressing whitespace like ' ', enter key, tab, etc...), the
list is parsed and if the current typed characters are found in a word
from the list, a tooltip is displayed with the suggested word. What is
cool here, is that because of frequency information, it is possible to
have the best possible match for the user.
This will also require implementing the calltip calling in cbEditor.

3) This is a simple line of code to add the right arrow character to
the selection in the autocomplete thanks to SetFillsUp method of
Scintilla. Currently I don't see that method in wxStyledTextCtrl, so
maybe we will have to add it, or directly call scintilla object

4) I need your comment for this
5) This could be done by adding code in the shortcut handler to parse
the parser token list in order to find the same token, or if numerous
token are available, fill a popup menu with each possible token.
6) Same thing as above.

Please tell me what you think about this

takeshi miya:
I think that if you manage to implement all the things that the parser of Visual Assist X do, there isn't need for more.

If you haven't seen you want to take a look, it's a codecompletion plugin for MS Visual C 6/7/.NET and also other languages.

The best and most complete codecompletion plugin that I know, the only drawback it's that is only for MS Visual Studio and isn't opensource.

Here is the site: It's recommended by wxWidgets team indeed.

Someone who used Visual Assist X would never want to develop without it :D

takeshi miya:
I'm very interested in this

So do I, but no moderator/developper responded to X-Ryl669's suggestion :(


[0] Message Index

[#] Next page

Go to full version