Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

Code completion with partial matching

<< < (4/9) > >>

oBFusCATed:

--- Quote from: Alpha on January 19, 2014, 10:01:31 pm ---
--- Quote from: dmoore on January 19, 2014, 07:13:08 am ---One more issue: in python cc, I think I need to be able to do async docstring calls. otherwise the gui can freeze for quite a while.

--- End quote ---
I have been attempting to work on that for a while (with cbThreadPool), however, I apparently do not understand threading nearly as well as I had thought; each of my tries immediately crashed while updating the GUI from a cbEVT_THREADTASK_ALLDONE handler.  Looks like more reading for me.

--- End quote ---
Have you tried to make the docstring API to be consisted of two steps/calls?
For example:
1. CCManager calls a plugin to to start gathering the data. No ui is shown to the user or empty UI is shown, so he can have a chance to cancel it.
2. The CC plugin has gathered the data and then calls CCManager to show the UI or fill the UI.

1 and 2 happen in the main thread. This way you leave the task of threading to the plugin.

dmoore:

--- Quote from: Alpha on January 20, 2014, 06:43:43 am ---
--- Quote from: dmoore on January 19, 2014, 10:20:01 pm ---Nice catch re wxString, just need to sort alphabetically for equal priority items?

--- End quote ---
The problem is, CalcValue() (which is tries to nearly replicate/quantify the algorithm YCM designed) gives wxString a worse value because its word boundary string is only "ws" (whereas wxSTRING_REVERSE_ITERATOR for example is "wsri", more closely matching the input).  (Items with equal priority *should* already be in alphabetical order, assuming my implementation works the way I think it does.)
Unfortunately, re-balancing the weighting algorithm would probably cause it to lose the benefit it gives in most other cases.  (I am tempted to hardcode a small score boost for wxString, because it is rather common in wxWidgets based code... but that could get even uglier if other similar problem tokens show up.)

--- End quote ---

There are almost certainly going to be similar problems, so don't hardcode. How about doing Acronym matching as a separate, alternative calculation that only gets used if it would create a higher score?

example: user types wxs, candidates (and their acronyms) are

wxString -> wS
wxStringHelper -> wSH
wantsXtraStr ->wxS
wxstring0 -> no acronym

You compute a score for wxString (3 matches at the start), a score for wS (no matches) and take the higher score => 3 prefix matches (I'm abstracting from the exact numeric score you might give this)
You compute a score for wxStringHelper (3 matches at the start), a score for wSH (no matches) and take the higher score => 3 prefix matches
You compute a score for wantsXtraStr (3 partial matches), a score for wxS (3 prefix matches) and take the higher score => 3 prefix matches
You compute a score for wxstring (3 matches at the start), there's no acronym so ignore => 3 prefix matches

So in this case all 3 would have an equal score, so they should appear alphabetically (you could also slightly penalize acronym match, because it isn't as intuitive as a straight prefix match).

Alpha:

--- Quote from: oBFusCATed on January 20, 2014, 10:32:09 am ---Have you tried to make the docstring API to be consisted of two steps/calls?
For example:
1. CCManager calls a plugin to to start gathering the data. No ui is shown to the user or empty UI is shown, so he can have a chance to cancel it.
2. The CC plugin has gathered the data and then calls CCManager to show the UI or fill the UI.

1 and 2 happen in the main thread. This way you leave the task of threading to the plugin.

--- End quote ---
Although that would work, I would be hesitant to use it as I have so far designed the interface such that individual CC plugins do not need to know that CCManager exists, nor to talk with it.  They only have to return data when requested.


--- Quote from: dmoore on January 20, 2014, 02:33:55 pm ---[...] How about doing Acronym matching as a separate, alternative calculation that only gets used if it would create a higher score?

--- End quote ---
Hmm, I will experimenting with that...

oBFusCATed:

--- Quote from: Alpha on January 20, 2014, 11:12:12 pm ---Although that would work, I would be hesitant to use it as I have so far designed the interface such that individual CC plugins do not need to know that CCManager exists, nor to talk with it.  They only have to return data when requested.

--- End quote ---
OK you can make a custom event cbEVT_CC_DOC_STRING_READY or something like that...

Alpha:

--- Quote from: oBFusCATed on January 21, 2014, 12:41:24 am ---OK you can make a custom event cbEVT_CC_DOC_STRING_READY or something like that...

--- End quote ---
I think that would be a reasonable solution.  (I was quite literally just typing that same thought, when I saw you had posted.)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version