Seriously don't know why you guys love git/github so much. Just needlessly built the master branch Thought I had "git clone"d the cc branch by switching from master to cc branch in the github interface and copying the clone link, only to learn that I needed to "git checkout cc_interface" because clone grabs everything.
Sorry, that might be partially my fault (this is my first time with git). I think I may have unnecessarily created a master branch in my fork.
1. Am I understanding correctly that the framework now handles the completion, calltip and doc popups, and the plugin just needs to provide data?
That is how I am intending it to work. Your plugin can also send
cbEVT_SHOW_CALL_TIP,
cbEVT_EDITOR_TOOLTIP and
cbEVT_COMPLETE_CODE events for specialized situations (that the (hopefully more generic) CCManager does not handle).
2. It looks like the framework expects the plugin to decide whether the caret is in the appropriate place (e.g. don't want to show popups in a comment line) and then immediately return the tokens. Is that right? The current version of the python plugin does the caret check then makes an asynchronous request to a remote python process for the CC tokens because we don't want to cause a potentially long freeze in the editor. How do I handle this case? EDIT: Maybe initially return nothing, but make the async call and then when it returns send a cbEVT_COMPLETE_CODE event to re-call the handler?
Yes. Returning an empty vector will cancel code completion, and sending the event (once your plugin is prepared) will start it up again. (Although, you may consider first testing to see if it creates a noticeable lag when done synchronously.)
Can the same be done for Doc strings?
Not with the current API. However, CCManager tries to only request documentation be generated when the user pauses in scrolling through options, so a short freeze here is unlikely to be noticed (at least, that is the theory).
3. What is the plugin supposed to do in the DoAutoComplete functions and why are there two? (CC plugin appears to place text for the selected token into the editor and do any needed reparsing/formatting/showing additional calls tips?
The function
DoAutocomplete(const wxString& token, cbEditor* ed) technically never will be called, however I added it to the code because I cannot guarantee that. It will only be called if, for some unknown reason, CCManager is unable to return the
CCToken equivalent that was selected.
Its purpose is to give the plugin a chance to insert/replace the token into the editor in a more advanced way than simply inserting (for example, also adding argument lists).
Shouldn't there be a default implementation that just does what Scintilla does by default??)
Probably. The default implementation would be:
void cbCodeCompletionPlugin::DoAutocomplete(const CCToken& /*token*/, cbEditor* /*ed*/)
{
return;
}
As long as you do not call
ed->GetControl()->AutoCompCancel() in this function, default autocomplete action will occur.
4. Is there any delay before showing a popup or is this up to the plugin to implement? (e.g. if user is typing fast don't show a popup until they slow down.)
I intend CCManager to handle that (however, it is currently hardcoded at 10ms, and synchronous if the user types three characters in a row).
EDIT: 5. What is GetTokenAt for?
I think I will need to rename that; it is currently called to supply tooltips when the user hovers the mouse over a token.