News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Can code completion be made contextual?

Started by carra, July 06, 2012, 09:57:37 AM

Previous topic - Next topic

p2rkw

QuoteWhen you tried sorting, did you also have to modify Scintilla to allow non-alphabetical ordering?
No, I didn't.
Take a look at CodeCompletion::CodeComplete: tokens' indices generated by m_NativeParser.MarkItemsByAI() are stored in separate list called m_AutocompNameIdx. In my implementation this list wasn't sorted only by tokens name but also by other token properties.

Quoteyou get 16 suggestions for append() (and Append()), one for each function overload.  Is this intended behaviour?
Yes, it is. Overloaded functions can have different arguments, return value and documentation, so in my opinion they should be displayed as separated items.
But as you can see you can easily change this behaviour.

Wait a sec, I'll generate patch, so you will be able to test it.

p2rkw

Attached patch is bit dirty because you can change sort criteria only in code, but you can see the idea.
I tell you more: you can even use different criteria in different cases, for example you can detect is autocomplete was opened in global scope and apply different criteria.

Alpha

Quote from: p2rkw on March 10, 2013, 10:29:49 PM
Overloaded functions can have different arguments, return value and documentation, so in my opinion they should be displayed as separated items.
Maybe a more optimal way would be to only show overloads as separate items if you are in global scope and function argument completion is enabled.
The documentation window could have a link to each of the overloads, and by default, show the overload with the most documentation first.

Quote from: p2rkw on March 10, 2013, 10:29:49 PM
QuoteWhen you tried sorting, did you also have to modify Scintilla to allow non-alphabetical ordering?
No, I didn't.
I see.  The autocomp list jumps the selection as you type by searching the list for the given context with a binary search.  If the list is not alphabetized, the popup will often auto-cancel itself because it cannot find an entry (even though the entry exists).  (I had just been curious to see if you had come up with a cleaner solution than mine.)

Alpha

Quote from: Alpha on March 10, 2013, 06:18:17 PM
Quote from: MortenMacFly on March 10, 2013, 12:52:25 PM
I'm afraid the last CC commit broke this. :-(
Updated.
Just thought I should mention, if you value a non-crashing Code::Blocks, do not apply this patch...

ollydbg

Quoteif you value a non-crashing Code::Blocks, do not apply this patch
Which do you think cause the crash issue? The concurrently access to the tokentree?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Alpha

I tried to do some magic with dual purposing the same std::vector sorting it in a partitioned manor so the temp variables would end up first.  Unfortunately, std::sort() somehow (in a pattern I cannot predict) sends invalid wxStrings to static int SortCCList(const wxString& first, const wxString& second) when I do this.