Code::Blocks  SVN r11506
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
CCManager Class Reference

Code Completion Plugin Manager. More...

#include <ccmanager.h>

Inheritance diagram for CCManager:
Collaboration diagram for CCManager:

Public Member Functions

cbCodeCompletionPluginGetProviderFor (cbEditor *ed=nullptr)
 Get the ccPlugin instant for the cbEditor. More...
 
void RegisterCallTipChars (const wxString &chars, cbCodeCompletionPlugin *registrant)
 Register a new set of characters that, when typed, invoke calltip requests. More...
 
void RegisterAutoLaunchChars (const wxString &chars, cbCodeCompletionPlugin *registrant)
 Register a new set of characters that, when typed, auto-launch codecomplete requests. More...
 
void NotifyDocumentation ()
 Let CCManager know that new results are available from cbCodeCompletionPlugin::GetDocumentation(). More...
 
void NotifyPluginStatus ()
 Let CCManager know that a change (e.g. More...
 
void InjectAutoCompShow (int lenEntered, const wxString &itemList)
 If for some reason you need to use wxScintilla::AutoCompShow(), call this instead so CCManager does not step on you. More...
 
bool ProcessArrow (int key)
 Used by cbStyledTextCtrl to process ArrowUp and ArrowDown key press. More...
 
void UpdateEnvSettings ()
 Called after env settings have changed, so the changes can be applied. More...
 

Private Types

enum  Direction { Previous, Next }
 User click the next or previous small button of the tip window. More...
 
typedef std::map< cbCodeCompletionPlugin *, std::set< wxChar > > CCPluginCharMap
 
typedef std::vector< cbCodeCompletionPlugin::CCCallTipCallTipVec
 

Private Member Functions

 CCManager ()
 
 ~CCManager () override
 
void OnCompleteCode (CodeBlocksEvent &event)
 Event handler to list the suggestion, when a user press Ctrl-space (by default). More...
 
void OnDeactivateApp (CodeBlocksEvent &event)
 Event handler to avoid tooltips getting stuck active. More...
 
void OnDeactivateEd (CodeBlocksEvent &event)
 Event handler to avoid tooltips getting stuck active. More...
 
void OnEditorOpen (CodeBlocksEvent &event)
 Event handler to avoid tooltips getting stuck active. More...
 
void OnEditorClose (CodeBlocksEvent &event)
 Event handler to avoid tooltips getting stuck active. More...
 
void OnEditorHook (cbEditor *ed, wxScintillaEvent &event)
 Hook to the editor. More...
 
void OnEditorTooltip (CodeBlocksEvent &event)
 Mouse hover event. More...
 
void OnShowCallTip (CodeBlocksEvent &event)
 Event handler to show the call tip, when user press Ctrl-Shift-Space. More...
 
void OnAutocompleteSelect (wxListEvent &event)
 Event handler to show documentation, when user changes autocomplete selection. More...
 
void OnAutocompleteHide (wxShowEvent &event)
 Event handler to tear down documentation, when autocomplete closes. More...
 
void OnDeferredCallTipShow (wxCommandEvent &event)
 Defer showing the calltip to avoid a crash issue. More...
 
void OnDeferredCallTipCancel (wxCommandEvent &event)
 Defer canceling the calltip to avoid a crash issue. More...
 
void OnPopupScroll (wxMouseEvent &event)
 Intercept cbStyledTextCtrl scroll events and forward to autocomplete/documentation popups. More...
 
void OnTimer (wxTimerEvent &event)
 Grouped event handler for several timers. More...
 
void OnMenuSelect (wxCommandEvent &event)
 Handle the CC related menu click. More...
 
void DoBufferedCC (cbStyledTextCtrl *stc)
 CC launched in the same state as last run, display via cached data. More...
 
void DoHidePopup ()
 Hide the documentation popup. More...
 
void DoShowDocumentation (cbEditor *ed)
 Show the documentation popup. More...
 
void DoUpdateCallTip (cbEditor *ed)
 Update which tip to show next and where to show it. More...
 
void AdvanceTip (Direction direction)
 Switch the tip window to the next item. More...
 
void DoShowTips (const wxStringVec &tips, cbStyledTextCtrl *stc, int pos, int argsPos, int hlStart, int hlEnd)
 Format tips by breaking long lines at (hopefully) logical places. More...
 
void CallSmartIndentCCDone (cbEditor *ed)
 Code completion as just insert some text in the editor, ask the smart indent plugin to adjust the indent. More...
 

Private Attributes

CCPluginCharMap m_CallTipChars
 Chars each plugin is interested in for calltip state. More...
 
CCPluginCharMap m_AutoLaunchChars
 Chars each plugin is interested in for autocomplete. More...
 
int m_EditorHookID
 
int m_AutocompPosition
 Location of caret when autocomplete timer starts, if caret is still there, launch autocomplete. More...
 
int m_CallTipActive
 Is CCManager currently displaying a calltip, and if so, where. More...
 
int m_LastAutocompIndex
 Index of currently selected entry in autocomplete popup. More...
 
int m_LastTipPos
 Last location a tool/call tip was displayed. More...
 
int m_WindowBound
 Right-most boundary the documentation popup is allowed to stretch to. More...
 
bool m_OwnsAutocomp
 Do we control the current autocomplete popup? More...
 
CallTipVec m_CallTips
 Cached calltips. More...
 
CallTipVec::const_iterator m_CurCallTip
 Remember current choice. More...
 
std::map< int, size_t > m_CallTipChoiceDict
 Remember past choices. More...
 
std::map< int, size_t > m_CallTipFuzzyChoiceDict
 Remember past choices based on prefix. More...
 
wxTimer m_CallTipTimer
 
wxTimer m_AutoLaunchTimer
 
wxTimer m_AutocompSelectTimer
 
wxSize m_DocSize
 Size of the documentation popup. More...
 
wxPoint m_DocPos
 Location of the documentation popup. More...
 
wxListViewm_pAutocompPopup
 a handle to the autocomplete list window created by (wx)scintilla, needed under Windows to determine its dimensions (so the scroll event can be sent to it, if relevant) More...
 
cbEditorm_pLastEditor
 Last editor operated on. More...
 
cbCodeCompletionPluginm_pLastCCPlugin
 The plugin handling m_pLastEditor. More...
 
UnfocusablePopupWindowm_pPopup
 Container for documentation popup. More...
 
wxHtmlWindowm_pHtml
 Documentation popup. More...
 
int m_LastACLaunchState [2]
 
std::vector< cbCodeCompletionPlugin::CCTokenm_AutocompTokens
 Cached autocomplete list. More...
 

Friends

class Mgr< CCManager >
 
class Manager
 

Additional Inherited Members

- Static Public Member Functions inherited from Mgr< CCManager >
static bool Valid ()
 
static CCManagerGet ()
 
static void Free ()
 
- Protected Member Functions inherited from Mgr< CCManager >
 Mgr ()
 
virtual ~Mgr ()
 

Detailed Description

Code Completion Plugin Manager.

This class manages all kinds of code completion plugins. For example, the native C/C++ code completion plugin, the Fortran code completion plugin and Python code completion plugin. The ccmanager asks some informations from the managed ccplugins. The major value passes from the ccmanager and the ccplugins are CCCallTip and CCToken.

The CCToken is needed when ccmanager needs to fill a code suggestion list, it is the ccplugin's duty to supply a collection of CCTokens.

When user is entering some function call statement, CCCallTip is used to show the function information, and especially it can highlight the current function argument.

Another kind of tip is the tooltip, this is the tip window shown when mouse hover on a specified token(such as variable token), ccmanager queries this information by asking CCToken information from ccplugin.

Note: Under Windows, scroll events are always directed to the window in focus, making it difficult to scroll the autocomplete list and the doxygen popup with the mouse. So, under Windows we catch scroll requests to the cbStyledTextCtrl, and run them through CCManager::OnPopupScroll(). This filters the event, and if the mouse is over the autocomplete list or the doxygen popup, the scroll event is instead sent there (and skipped for the editor window).

Definition at line 47 of file ccmanager.h.

Member Typedef Documentation

◆ CallTipVec

Definition at line 182 of file ccmanager.h.

◆ CCPluginCharMap

typedef std::map< cbCodeCompletionPlugin*, std::set<wxChar> > CCManager::CCPluginCharMap
private

Definition at line 172 of file ccmanager.h.

Member Enumeration Documentation

◆ Direction

enum CCManager::Direction
private

User click the next or previous small button of the tip window.

Enumerator
Previous 
Next 

Definition at line 161 of file ccmanager.h.

Constructor & Destructor Documentation

◆ CCManager()

CCManager::CCManager ( )
private

◆ ~CCManager()

CCManager::~CCManager ( )
overrideprivate

Member Function Documentation

◆ AdvanceTip()

void CCManager::AdvanceTip ( Direction  direction)
private

Switch the tip window to the next item.

Definition at line 430 of file ccmanager.cpp.

◆ CallSmartIndentCCDone()

void CCManager::CallSmartIndentCCDone ( cbEditor ed)
private

Code completion as just insert some text in the editor, ask the smart indent plugin to adjust the indent.

Definition at line 1432 of file ccmanager.cpp.

References cbEVT_EDITOR_CC_DONE, Manager::Get(), and Manager::ProcessEvent().

◆ DoBufferedCC()

void CCManager::DoBufferedCC ( cbStyledTextCtrl stc)
private

◆ DoHidePopup()

void CCManager::DoHidePopup ( )
private

Hide the documentation popup.

Definition at line 1255 of file ccmanager.cpp.

References OnPopupScroll(), and wxEVT_MOUSEWHEEL.

◆ DoShowDocumentation()

void CCManager::DoShowDocumentation ( cbEditor ed)
private

◆ DoShowTips()

void CCManager::DoShowTips ( const wxStringVec tips,
cbStyledTextCtrl stc,
int  pos,
int  argsPos,
int  hlStart,
int  hlEnd 
)
private

◆ DoUpdateCallTip()

void CCManager::DoUpdateCallTip ( cbEditor ed)
private

◆ GetProviderFor()

cbCodeCompletionPlugin * CCManager::GetProviderFor ( cbEditor ed = nullptr)

Get the ccPlugin instant for the cbEditor.

If the editor opened a c/c++ file, then it returns the native c/c++ ccPlugin.

Parameters
edinput editor, uses active editor if one is not passed; has (minimal) cache optimization

Definition at line 367 of file ccmanager.cpp.

References cbCodeCompletionPlugin::ccpsActive, cbCodeCompletionPlugin::ccpsUniversal, Manager::Get(), EditorManager::GetBuiltinActiveEditor(), PluginManager::GetCodeCompletionOffers(), Manager::GetEditorManager(), Manager::GetPluginManager(), lsCaretStart, and wxSCI_INVALID_POSITION.

◆ InjectAutoCompShow()

void CCManager::InjectAutoCompShow ( int  lenEntered,
const wxString itemList 
)

If for some reason you need to use wxScintilla::AutoCompShow(), call this instead so CCManager does not step on you.

Definition at line 417 of file ccmanager.cpp.

References wxScintilla::AutoCompShow(), Manager::Get(), EditorManager::GetBuiltinActiveEditor(), cbEditor::GetControl(), and Manager::GetEditorManager().

◆ NotifyDocumentation()

void CCManager::NotifyDocumentation ( )

Let CCManager know that new results are available from cbCodeCompletionPlugin::GetDocumentation().

Definition at line 404 of file ccmanager.cpp.

References Manager::Get(), EditorManager::GetBuiltinActiveEditor(), and Manager::GetEditorManager().

◆ NotifyPluginStatus()

void CCManager::NotifyPluginStatus ( )

Let CCManager know that a change (e.g.

active lexer is switched) may invalidate cached active ccPlugin.

Definition at line 411 of file ccmanager.cpp.

Referenced by PluginsConfigurationDlg::EndModal(), and MainFrame::OnEditHighlightMode().

◆ OnAutocompleteHide()

void CCManager::OnAutocompleteHide ( wxShowEvent event)
private

Event handler to tear down documentation, when autocomplete closes.

Definition at line 1088 of file ccmanager.cpp.

References CALLTIP_REFRESH_DELAY, wxEVT_SHOW, and wxTIMER_ONE_SHOT.

Referenced by OnAutocompleteSelect().

◆ OnAutocompleteSelect()

void CCManager::OnAutocompleteSelect ( wxListEvent event)
private

◆ OnCompleteCode()

void CCManager::OnCompleteCode ( CodeBlocksEvent event)
private

◆ OnDeactivateApp()

void CCManager::OnDeactivateApp ( CodeBlocksEvent event)
private

Event handler to avoid tooltips getting stuck active.

Definition at line 600 of file ccmanager.cpp.

References wxScintilla::CallTipActive(), Manager::Get(), EditorManager::GetBuiltinActiveEditor(), cbEditor::GetControl(), Manager::GetEditorManager(), and wxSCI_INVALID_POSITION.

Referenced by CCManager().

◆ OnDeactivateEd()

void CCManager::OnDeactivateEd ( CodeBlocksEvent event)
private

◆ OnDeferredCallTipCancel()

void CCManager::OnDeferredCallTipCancel ( wxCommandEvent event)
private

Defer canceling the calltip to avoid a crash issue.

See also
CCManager::OnDeferredCallTipShow

Definition at line 1111 of file ccmanager.cpp.

References Manager::Get(), EditorManager::GetBuiltinActiveEditor(), cbEditor::GetControl(), and Manager::GetEditorManager().

Referenced by CCManager().

◆ OnDeferredCallTipShow()

void CCManager::OnDeferredCallTipShow ( wxCommandEvent event)
private

Defer showing the calltip to avoid a crash issue.

Launching this event directly seems to be a candidate for race condition and crash in OnShowCallTip() so we attempt to serialize it.

Definition at line 1100 of file ccmanager.cpp.

References cbEVT_SHOW_CALL_TIP, Manager::Get(), and Manager::ProcessEvent().

Referenced by CCManager().

◆ OnEditorClose()

void CCManager::OnEditorClose ( CodeBlocksEvent event)
private

Event handler to avoid tooltips getting stuck active.

Definition at line 671 of file ccmanager.cpp.

References Manager::Get(), EditorManager::GetBuiltinEditor(), cbEditor::GetControl(), CodeBlocksEvent::GetEditor(), Manager::GetEditorManager(), and OnAutocompleteSelect().

Referenced by CCManager().

◆ OnEditorHook()

void CCManager::OnEditorHook ( cbEditor ed,
wxScintillaEvent event 
)
private

◆ OnEditorOpen()

void CCManager::OnEditorOpen ( CodeBlocksEvent event)
private

Event handler to avoid tooltips getting stuck active.

Definition at line 643 of file ccmanager.cpp.

References Manager::Get(), EditorManager::GetBuiltinEditor(), cbEditor::GetControl(), CodeBlocksEvent::GetEditor(), Manager::GetEditorManager(), OnAutocompleteSelect(), and setupColours().

Referenced by CCManager().

◆ OnEditorTooltip()

void CCManager::OnEditorTooltip ( CodeBlocksEvent event)
private

◆ OnHtmlLink()

void CCManager::OnHtmlLink ( wxHtmlLinkEvent &  event)
private

A link is clicked in the document window.

Definition at line 1131 of file ccmanager.cpp.

References wxString::IsEmpty(), and cbCodeCompletionPlugin::OnDocumentationLink().

Referenced by CCManager(), and ~CCManager().

◆ OnMenuSelect()

void CCManager::OnMenuSelect ( wxCommandEvent event)
private

◆ OnPopupScroll()

void CCManager::OnPopupScroll ( wxMouseEvent event)
private

Intercept cbStyledTextCtrl scroll events and forward to autocomplete/documentation popups.

Definition at line 1119 of file ccmanager.cpp.

References wxMouseEvent::GetPosition(), and wxMouseEvent::GetWheelRotation().

Referenced by DoHidePopup(), and DoShowDocumentation().

◆ OnShowCallTip()

void CCManager::OnShowCallTip ( CodeBlocksEvent event)
private

◆ OnTimer()

void CCManager::OnTimer ( wxTimerEvent event)
private

◆ ProcessArrow()

bool CCManager::ProcessArrow ( int  key)

Used by cbStyledTextCtrl to process ArrowUp and ArrowDown key press.

This is not intended to be called by ccPlugins.

Definition at line 450 of file ccmanager.cpp.

References wxScintilla::CallTipActive(), Manager::Get(), EditorManager::GetBuiltinActiveEditor(), cbEditor::GetControl(), Manager::GetEditorManager(), WXK_DOWN, and WXK_UP.

Referenced by cbStyledTextCtrl::OnKeyDown().

◆ RegisterAutoLaunchChars()

void CCManager::RegisterAutoLaunchChars ( const wxString chars,
cbCodeCompletionPlugin registrant 
)

Register a new set of characters that, when typed, auto-launch codecomplete requests.

Use this if the default set is not appropriate.

Definition at line 398 of file ccmanager.cpp.

References wxString::begin(), and wxString::end().

◆ RegisterCallTipChars()

void CCManager::RegisterCallTipChars ( const wxString chars,
cbCodeCompletionPlugin registrant 
)

Register a new set of characters that, when typed, invoke calltip requests.

Use this if the default set is not appropriate.

Definition at line 392 of file ccmanager.cpp.

References wxString::begin(), and wxString::end().

◆ UpdateEnvSettings()

void CCManager::UpdateEnvSettings ( )

Friends And Related Function Documentation

◆ Manager

friend class Manager
friend

Definition at line 51 of file ccmanager.h.

◆ Mgr< CCManager >

friend class Mgr< CCManager >
friend

Definition at line 50 of file ccmanager.h.

Member Data Documentation

◆ m_AutocompPosition

int CCManager::m_AutocompPosition
private

Location of caret when autocomplete timer starts, if caret is still there, launch autocomplete.

Definition at line 176 of file ccmanager.h.

◆ m_AutocompSelectTimer

wxTimer CCManager::m_AutocompSelectTimer
private

Definition at line 189 of file ccmanager.h.

◆ m_AutocompTokens

std::vector<cbCodeCompletionPlugin::CCToken> CCManager::m_AutocompTokens
private

Cached autocomplete list.

It is the data CCManager uses to populate the (wx)scintilla autocomplete list window

Definition at line 219 of file ccmanager.h.

◆ m_AutoLaunchChars

CCPluginCharMap CCManager::m_AutoLaunchChars
private

Chars each plugin is interested in for autocomplete.

Definition at line 174 of file ccmanager.h.

◆ m_AutoLaunchTimer

wxTimer CCManager::m_AutoLaunchTimer
private

Definition at line 188 of file ccmanager.h.

◆ m_CallTipActive

int CCManager::m_CallTipActive
private

Is CCManager currently displaying a calltip, and if so, where.

Definition at line 177 of file ccmanager.h.

◆ m_CallTipChars

CCPluginCharMap CCManager::m_CallTipChars
private

Chars each plugin is interested in for calltip state.

Definition at line 173 of file ccmanager.h.

◆ m_CallTipChoiceDict

std::map<int, size_t> CCManager::m_CallTipChoiceDict
private

Remember past choices.

Definition at line 185 of file ccmanager.h.

◆ m_CallTipFuzzyChoiceDict

std::map<int, size_t> CCManager::m_CallTipFuzzyChoiceDict
private

Remember past choices based on prefix.

Definition at line 186 of file ccmanager.h.

◆ m_CallTips

CallTipVec CCManager::m_CallTips
private

Cached calltips.

Definition at line 183 of file ccmanager.h.

◆ m_CallTipTimer

wxTimer CCManager::m_CallTipTimer
private

Definition at line 187 of file ccmanager.h.

◆ m_CurCallTip

CallTipVec::const_iterator CCManager::m_CurCallTip
private

Remember current choice.

Definition at line 184 of file ccmanager.h.

◆ m_DocPos

wxPoint CCManager::m_DocPos
private

Location of the documentation popup.

Definition at line 191 of file ccmanager.h.

◆ m_DocSize

wxSize CCManager::m_DocSize
private

Size of the documentation popup.

Definition at line 190 of file ccmanager.h.

◆ m_EditorHookID

int CCManager::m_EditorHookID
private

Definition at line 175 of file ccmanager.h.

◆ m_LastACLaunchState

int CCManager::m_LastACLaunchState[2]
private

Definition at line 214 of file ccmanager.h.

◆ m_LastAutocompIndex

int CCManager::m_LastAutocompIndex
private

Index of currently selected entry in autocomplete popup.

Definition at line 178 of file ccmanager.h.

◆ m_LastTipPos

int CCManager::m_LastTipPos
private

Last location a tool/call tip was displayed.

Definition at line 179 of file ccmanager.h.

◆ m_OwnsAutocomp

bool CCManager::m_OwnsAutocomp
private

Do we control the current autocomplete popup?

Definition at line 181 of file ccmanager.h.

◆ m_pAutocompPopup

wxListView* CCManager::m_pAutocompPopup
private

a handle to the autocomplete list window created by (wx)scintilla, needed under Windows to determine its dimensions (so the scroll event can be sent to it, if relevant)

Definition at line 197 of file ccmanager.h.

◆ m_pHtml

wxHtmlWindow* CCManager::m_pHtml
private

Documentation popup.

it is the rendered doxygen documentation to display in the popup

Definition at line 212 of file ccmanager.h.

◆ m_pLastCCPlugin

cbCodeCompletionPlugin* CCManager::m_pLastCCPlugin
private

The plugin handling m_pLastEditor.

Definition at line 201 of file ccmanager.h.

◆ m_pLastEditor

cbEditor* CCManager::m_pLastEditor
private

Last editor operated on.

Definition at line 200 of file ccmanager.h.

◆ m_pPopup

UnfocusablePopupWindow* CCManager::m_pPopup
private

Container for documentation popup.

the window for the doxygen popup, with properties so it is always on top, but cannot be focused.

Definition at line 207 of file ccmanager.h.

◆ m_WindowBound

int CCManager::m_WindowBound
private

Right-most boundary the documentation popup is allowed to stretch to.

Definition at line 180 of file ccmanager.h.


The documentation for this class was generated from the following files: