Code::Blocks
SVN r11506
|
Base class for code-completion plugins. More...
#include <cbplugin.h>
Classes | |
struct | CCCallTip |
Structure representing an individual calltip with an optional highlighted range. More... | |
struct | CCToken |
Structure representing a generic token, passed between CC plugins and CCManager. More... | |
Public Types | |
enum | CCProviderStatus { ccpsInactive, ccpsActive, ccpsUniversal } |
Level of functionality a CC plugin is able to provide. More... | |
Public Member Functions | |
cbCodeCompletionPlugin () | |
virtual CCProviderStatus | GetProviderStatusFor (cbEditor *ed)=0 |
Does this plugin handle code completion for the editor ed ? More... | |
virtual std::vector< CCToken > | GetAutocompList (bool isAuto, cbEditor *ed, int &tknStart, int &tknEnd)=0 |
Supply content for the autocompletion list. More... | |
virtual wxString | GetDocumentation (const CCToken &token)=0 |
Supply html formatted documentation for the passed token. More... | |
virtual std::vector< CCCallTip > | GetCallTips (int pos, int style, cbEditor *ed, int &argsPos)=0 |
Supply content for the calltip at the specified location. More... | |
virtual std::vector< CCToken > | GetTokenAt (int pos, cbEditor *ed, bool &allowCallTip)=0 |
Supply the definition of the token at the specified location. More... | |
virtual wxString | OnDocumentationLink (wxHtmlLinkEvent &event, bool &dismissPopup)=0 |
Callback to handle a click on a link in the documentation popup. More... | |
virtual void | DoAutocomplete (const CCToken &token, cbEditor *ed) |
Callback for inserting the selected autocomplete entry into the editor. More... | |
virtual void | DoAutocomplete (const wxString &token, cbEditor *ed) |
Callback for inserting the selected autocomplete entry into the editor. More... | |
Public Member Functions inherited from cbPlugin | |
cbPlugin () | |
In default cbPlugin's constructor the associated PluginInfo structure is filled with default values. More... | |
~cbPlugin () override | |
cbPlugin destructor. More... | |
virtual PluginType | GetType () const |
The plugin must return its type on request. More... | |
virtual int | GetConfigurationPriority () const |
Return the plugin's configuration priority. More... | |
virtual int | GetConfigurationGroup () const |
Return the configuration group for this plugin. More... | |
virtual cbConfigurationPanel * | GetConfigurationPanel (cb_optional wxWindow *parent) |
Return plugin's configuration panel. More... | |
virtual cbConfigurationPanel * | GetProjectConfigurationPanel (cb_optional wxWindow *parent, cb_optional cbProject *project) |
Return plugin's configuration panel for projects. More... | |
virtual void | BuildMenu (cb_optional wxMenuBar *menuBar) |
This method is called by Code::Blocks and is used by the plugin to add any menu items it needs on Code::Blocks's menu bar. More... | |
virtual void | BuildModuleMenu (cb_optional const ModuleType type, cb_optional wxMenu *menu, cb_optional const FileTreeData *data=nullptr) |
This method is called by Code::Blocks core modules (EditorManager, ProjectManager etc) and is used by the plugin to add any menu items it needs in the module's popup menu. More... | |
virtual bool | BuildToolBar (cb_optional wxToolBar *toolBar) |
This method is called by Code::Blocks and is used by the plugin to add any toolbar items it needs on Code::Blocks's toolbar. More... | |
virtual int | GetToolBarPriority () |
This method return the priority of the plugin's toolbar, the less value indicates a more preceding position when C::B starts with no configuration file. More... | |
virtual void | CreateStatusField (cbStatusBar *statusBar) |
This method is called by Code::Blocks and is used by the plugin to add a field on Code::Blocks's statusbar. More... | |
bool | IsAttached () const |
See whether this plugin is attached or not. More... | |
virtual bool | CanDetach () const |
See whether this plugin can be detached (unloaded) or not. More... | |
Protected Member Functions | |
bool | IsProviderFor (cbEditor *ed) |
Has this plugin been selected to provide content for the editor. More... | |
Protected Member Functions inherited from cbPlugin | |
virtual void | OnAttach () |
Any descendent plugin should override this virtual method and perform any necessary initialization. More... | |
virtual void | OnRelease (cb_optional bool appShutDown) |
Any descendent plugin should override this virtual method and perform any necessary de-initialization. More... | |
virtual void | NotImplemented (const wxString &log) const |
This method logs a "Not implemented" message and is provided for convenience only. More... | |
Additional Inherited Members | |
Protected Attributes inherited from cbPlugin | |
PluginType | m_Type |
Holds the plugin's type. More... | |
bool | m_IsAttached |
Holds the "attached" state. More... | |
Base class for code-completion plugins.
The main operations of a code-completion plugin are executed by CCManager at the appropriate times. Smaller CC plugins should not have need to register very many (if any) events/editor hooks.
Definition at line 732 of file cbplugin.h.
Level of functionality a CC plugin is able to provide.
Enumerator | |
---|---|
ccpsInactive | CC plugin provides no functionality. |
ccpsActive | CC plugin provides specialized functionality. |
ccpsUniversal | CC plugin provides generic functionality. |
Definition at line 738 of file cbplugin.h.
cbCodeCompletionPlugin::cbCodeCompletionPlugin | ( | ) |
Definition at line 1004 of file cbplugin.cpp.
References DoAutocomplete(), cbPlugin::m_Type, and ptCodeCompletion.
|
virtual |
Callback for inserting the selected autocomplete entry into the editor.
The default implementation executes (wx)Scintilla's insert. Override and call ed->GetControl()->AutoCompCancel()
for different wxEVT_SCI_AUTOCOMP_SELECTION
behaviour.
token | The CCToken corresponding to the selected entry. |
ed | The editor to operate in. |
Reimplemented in CodeCompletion.
Referenced by cbCodeCompletionPlugin(), and CCManager::OnEditorHook().
Callback for inserting the selected autocomplete entry into the editor.
This function is only called if CCManager fails to retrieve the CCToken associated with the selection (which should never happen). The default implementation creates a CCToken and passes it to DoAutocomplete(const CCToken&, cbEditor*)
Override for different behaviour.
token | A string corresponding to the selected entry. |
ed | The editor to operate in. |
Definition at line 1014 of file cbplugin.cpp.
|
pure virtual |
Supply content for the autocompletion list.
CCManager takes care of calling this during most relevant situations. If the autocompletion mechanism is required at a time that CCManager does not initiate, call
In this case, the parameter isAuto is passed as false value.
Here is an example
This is the case the user has just enter the chars "cos", now to get a suggestion list. The first '^' is the position of tknStart, and the second '^' is the position of tknEnd In this case, the cc plugin would supply a CCToken vectors, which could contains "cos", "cosh" and "cosh"... In some special cases, the tknStart tknEnd may point to the same position, such as
Here, '^' are the positions of both tknStart and tknEnd.
isAuto | Passed as true if autocompletion was launched by typing an 'interesting' character such as '> ' (for '-> '). It is the plugin's job to filter out incorrect calls of this. | |
ed | The context of this codecompletion call. | |
[in,out] | tknStart | The assumed beginning of the token to be autocompleted. Change this variable if the plugin calculates a different starting location. |
[in,out] | tknEnd | The current position/end of the known part of the token to be completed. The plugin is allowed to change this (but it is not recommended). |
Implemented in CodeCompletion.
Referenced by CCManager::OnCompleteCode().
|
pure virtual |
Supply content for the calltip at the specified location.
The output parameter argsPos
is required to be set to the same (but unique) position for each unique calltip. This position is the location corresponding to the beginning of the argument list:
Each returned CCCallTip is allowed to have embedded '\n' line breaks.
pos | The location in the editor that the calltip is requested for. | |
style | The scintilla style of the cbStyledTextCtrl at the given location. (TODO: This is unusual, remove it?) | |
ed | The context of this calltip request. | |
[out] | argsPos | The location in the editor of the beginning of the argument list. Required. |
Implemented in CodeCompletion.
Referenced by CCManager::OnEditorTooltip(), and CCManager::OnShowCallTip().
Supply html formatted documentation for the passed token.
Refer to http://docs.wxwidgets.org/stable/overview_html.html#overview_html_supptags for the available formatting. When selecting colours, prefer use of the ones CCManager has registered with ColourManager, which are (TODO: register colours). Returning an empty string will cancel the documentation popup.
token | The token to document. |
Implemented in CodeCompletion.
Referenced by CCManager::DoShowDocumentation().
|
pure virtual |
Does this plugin handle code completion for the editor ed
?
The plugin should check the lexer, the HighlightLanguage
, the file extension, or some combination of these. Do not call CCManager::GetProviderFor()
from this function.
ed | The editor being checked. |
Implemented in CodeCompletion.
|
pure virtual |
Supply the definition of the token at the specified location.
The token(s) returned by this function are used to display tooltips.
pos | The location being queried. | |
ed | The context of the request. | |
[out] | allowCallTip | Allow CCManager to consider displaying a calltip if the results from this function are unsuitable/empty. True by default. |
Implemented in CodeCompletion.
Referenced by CCManager::OnEditorTooltip().
|
protected |
Has this plugin been selected to provide content for the editor.
Convenience function; asks CCManager if this plugin is granted jurisdiction over the editor.
ed | The editor to check. |
Definition at line 1019 of file cbplugin.cpp.
References Manager::Get().
|
pure virtual |
Callback to handle a click on a link in the documentation popup.
Handle a link command by, for example, showing the definition of a member function, or opening an editor to the location of the declaration.
event | The generated event (it is the plugin's responsibility to Skip(), if desired). | |
[out] | dismissPopup | If set to true, the popup will be hidden. |
Implemented in CodeCompletion.
Referenced by CCManager::OnHtmlLink().