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

Code completion plugin has those features: show tool-tip when the mouse hover over the variables/functions. More...

#include <codecompletion.h>

Inheritance diagram for CodeCompletion:
Collaboration diagram for CodeCompletion:

Classes

struct  FunctionScope
 Identify a function body's position, the underline data structure of the second wxChoice of CC's toolbar. More...
 
struct  FunctionsScopePerFile
 

Public Types

typedef std::vector< FunctionScopeFunctionsScopeVec
 vector containing all the function information of a single source file More...
 
typedef std::vector< int > ScopeMarksVec
 helper class to support FunctionsScopeVec More...
 
typedef std::map< wxString, FunctionsScopePerFileFunctionsScopeMap
 filename -> FunctionsScopePerFile map, contains all the opened files scope info More...
 
- Public Types inherited from cbCodeCompletionPlugin
enum  CCProviderStatus { ccpsInactive, ccpsActive, ccpsUniversal }
 Level of functionality a CC plugin is able to provide. More...
 

Public Member Functions

 CodeCompletion ()
 Constructor. More...
 
virtual ~CodeCompletion ()
 Destructor. More...
 
virtual void OnAttach ()
 Any descendent plugin should override this virtual method and perform any necessary initialization. More...
 
virtual void OnRelease (bool appShutDown)
 
virtual int GetConfigurationGroup () const
 Return the configuration group for this plugin. More...
 
virtual cbConfigurationPanelGetConfigurationPanel (wxWindow *parent)
 CC's config dialog. More...
 
virtual cbConfigurationPanelGetProjectConfigurationPanel (wxWindow *parent, cbProject *project)
 CC's config dialog which show in the project options panel. More...
 
virtual void BuildMenu (wxMenuBar *menuBar)
 build menus in the main frame More...
 
virtual void BuildModuleMenu (const ModuleType type, wxMenu *menu, const FileTreeData *data=0)
 build context popup menu More...
 
virtual bool BuildToolBar (wxToolBar *toolBar)
 build CC Toolbar More...
 
virtual int GetToolBarPriority ()
 toolbar priority value More...
 
virtual CCProviderStatus GetProviderStatusFor (cbEditor *ed)
 Does this plugin handle code completion for the editor ed? More...
 
virtual std::vector< CCTokenGetAutocompList (bool isAuto, cbEditor *ed, int &tknStart, int &tknEnd)
 Supply content for the autocompletion list. More...
 
virtual std::vector< CCCallTipGetCallTips (int pos, int style, cbEditor *ed, int &argsPos)
 Supply content for the calltip at the specified location. More...
 
virtual wxString GetDocumentation (const CCToken &token)
 Supply html formatted documentation for the passed token. More...
 
virtual std::vector< CCTokenGetTokenAt (int pos, cbEditor *ed, bool &allowCallTip)
 Supply the definition of the token at the specified location. More...
 
virtual void DoAutocomplete (const CCToken &token, cbEditor *ed)
 Callback for inserting the selected autocomplete entry into the editor. More...
 
wxArrayString GetLocalIncludeDirs (cbProject *project, const wxArrayString &buildTargets)
 Get the include paths setting (usually set by user for each C::B project). More...
 
wxArrayStringGetSystemIncludeDirs (cbProject *project, bool force)
 get the whole search dirs except the ones locally belong to the c::b project, note this function is used for auto suggestion for #include directives. More...
 
void GetAbsolutePath (const wxString &basePath, const wxArrayString &targets, wxArrayString &dirs)
 search target file names (mostly relative names) under basePath, then return the absolute dirs the result is "added" to parameter dirs (not replacement of any existing dirs) It just did the calculation below: "c:/ccc/ddd.cpp"(basePath) + "aaa/bbb.h"(target) => "c:/ccc/aaa/bbb.h"(dirs) More...
 
void EditorEventHook (cbEditor *editor, wxScintillaEvent &event)
 handle all the editor event More...
 
void RereadOptions ()
 read CC's options, mostly happens the user change some setting and press APPLY More...
 
- Public Member Functions inherited from cbCodeCompletionPlugin
 cbCodeCompletionPlugin ()
 
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 cbConfigurationPanelGetConfigurationPanel (cb_optional wxWindow *parent)
 Return plugin's configuration panel. More...
 
virtual cbConfigurationPanelGetProjectConfigurationPanel (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 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...
 

Private Types

typedef std::map< cbProject *, wxArrayStringReparsingMap
 map to record all re-parsing files More...
 

Private Member Functions

void UpdateToolBar ()
 update CC's ToolBar, the user may disable the first wxChoice, so we need to recreate the wxChoice and measure the best fit size More...
 
void OnUpdateUI (wxUpdateUIEvent &event)
 event handler for updating UI e.g. More...
 
void OnViewClassBrowser (wxCommandEvent &event)
 event handler when user click Menu->View->Symbols browser More...
 
void OnGotoFunction (wxCommandEvent &event)
 event handler when user click Menu->Search->Goto function More...
 
void OnGotoPrevFunction (wxCommandEvent &event)
 navigate to the previous function body More...
 
void OnGotoNextFunction (wxCommandEvent &event)
 navigate to the next function body More...
 
void OnClassMethod (wxCommandEvent &event)
 handle CC's context menu->insert "Class method declaration/implementation..." More...
 
void OnUnimplementedClassMethods (wxCommandEvent &event)
 handle CC's context menu->insert "All class methods without implementation..." More...
 
void OnGotoDeclaration (wxCommandEvent &event)
 handle both goto declaration and implementation event More...
 
void OnFindReferences (wxCommandEvent &event)
 CC's re-factoring function, find all the reference place. More...
 
void OnRenameSymbols (wxCommandEvent &event)
 CC's re-factoring function, rename a symbol. More...
 
void OnOpenIncludeFile (wxCommandEvent &event)
 open the include file under the caret position More...
 
void OnCurrentProjectReparse (wxCommandEvent &event)
 event handler when user select context menu->reparse file/projects More...
 
void OnSelectedProjectReparse (wxCommandEvent &event)
 
void OnSelectedFileReparse (wxCommandEvent &event)
 
void OnAppDoneStartup (CodeBlocksEvent &event)
 SDK event when application has started up. More...
 
void OnWorkspaceChanged (CodeBlocksEvent &event)
 SDK workspace related events. More...
 
void OnProjectActivated (CodeBlocksEvent &event)
 SDK project related events. More...
 
void OnProjectClosed (CodeBlocksEvent &event)
 
void OnProjectSaved (CodeBlocksEvent &event)
 
void OnProjectFileAdded (CodeBlocksEvent &event)
 
void OnProjectFileRemoved (CodeBlocksEvent &event)
 
void OnProjectFileChanged (CodeBlocksEvent &event)
 
void OnEditorSave (CodeBlocksEvent &event)
 SDK editor related events. More...
 
void OnEditorOpen (CodeBlocksEvent &event)
 
void OnEditorActivated (CodeBlocksEvent &event)
 
void OnEditorClosed (CodeBlocksEvent &event)
 
void OnCCLogger (CodeBlocksThreadEvent &event)
 CC's own logger, to handle log events sent from other worker threads or itself(the main GUI thread), the log messages will be printed in the "Code::Blocks" log panel. More...
 
void OnCCDebugLogger (CodeBlocksThreadEvent &event)
 CC's own debug logger, to handle log event sent from other worker threads or itself(the main GUI thread), the log messages will be printed in the "Code::Blocks Debug" log panel. More...
 
void OnParserStart (wxCommandEvent &event)
 batch parsing start event this event usually be fired when an Parser object try to start parsing tasks in the thread pool More...
 
void OnParserEnd (wxCommandEvent &event)
 batch parsing end event this event usually be fired when the task pool becomes empty More...
 
void OnSystemHeadersThreadMessage (CodeBlocksThreadEvent &event)
 receive event from SystemHeadersThread More...
 
void OnSystemHeadersThreadFinish (CodeBlocksThreadEvent &event)
 
void DoCodeComplete (int caretPos, cbEditor *ed, std::vector< CCToken > &tokens, bool preprocessorOnly=false)
 fill the tokens with correct code complete words More...
 
void DoCodeCompletePreprocessor (int tknStart, int tknEnd, cbEditor *ed, std::vector< CCToken > &tokens)
 fill the tokens with correct preprocessor directives, such as #i will prompt "if", "include" More...
 
void DoCodeCompleteIncludes (cbEditor *ed, int &tknStart, int tknEnd, std::vector< CCToken > &tokens)
 fill the tokens with correct include file names More...
 
int DoClassMethodDeclImpl ()
 ContextMenu->Insert-> declaration/implementation. More...
 
int DoAllMethodsImpl ()
 ContextMenu->Insert-> All class methods. More...
 
void MatchCodeStyle (wxString &str, int eolStyle=wxSCI_EOL_LF, const wxString &indent=wxEmptyString, bool useTabs=false, int tabSize=4)
 modify the string content to follow the current editor's code style The code style includes the EOL, TAB and indent More...
 
void FunctionPosition (int &scopeItem, int &functionItem) const
 helper method in finding the function position in the vector for the function containing the current line More...
 
void GotoFunctionPrevNext (bool next=false)
 navigate between function bodies More...
 
int NameSpacePosition () const
 find the namespace whose scope covers the current line the m_CurrentLine is used More...
 
void OnScope (wxCommandEvent &event)
 Toolbar select event. More...
 
void OnFunction (wxCommandEvent &event)
 Toolbar select event. More...
 
void ParseFunctionsAndFillToolbar ()
 normally the editor has changed, then CC need to parse the document again, and (re)construct the internal database, and refresh the toolbar(wxChoice's content) More...
 
void FindFunctionAndUpdate (int currentLine)
 the caret has changed, so the wxChoice need to be updated to indicates which scope and function in which the caret locates. More...
 
void UpdateFunctions (unsigned int scopeItem)
 the scope item has changed or becomes invalid, so the associated function wxChoice should be updated. More...
 
void EnableToolbarTools (bool enable=true)
 enable the two wxChoices More...
 
void DoParseOpenedProjectAndActiveEditor ()
 if C::B starts up with some projects opened, this function will be called to parse the already opened projects More...
 
void UpdateEditorSyntax (cbEditor *ed=NULL)
 highlight member variables More...
 
void OnToolbarTimer (wxTimerEvent &event)
 delayed for toolbar update More...
 
void OnRealtimeParsingTimer (wxTimerEvent &event)
 event fired from the edit event hook function to indicate parsing while editing More...
 
void OnProjectSavedTimer (wxTimerEvent &event)
 delayed running after saving project, while many projects' saving More...
 
void OnReparsingTimer (wxTimerEvent &event)
 delayed for re-parsing More...
 
void OnEditorActivatedTimer (wxTimerEvent &event)
 delayed running of editor activated event, only the last activated editor should be considered More...
 

Private Attributes

bool m_InitDone
 Indicates CC's initialization is done. More...
 
wxMenum_EditMenu
 menu pointers to the frame's main menu More...
 
wxMenum_SearchMenu
 
wxMenum_ViewMenu
 
wxMenum_ProjectMenu
 
NativeParser m_NativeParser
 this member will actually manage all the Parser instances More...
 
CodeRefactoring m_CodeRefactoring
 code re-factoring tool More...
 
int m_EditorHookId
 
wxTimer m_TimerRealtimeParsing
 timer triggered by editor hook function to delay the real-time parse More...
 
wxTimer m_TimerToolbar
 timer for toolbar we only show an updated item in CC's toolbar's item list when caret position is stable for a period of time. More...
 
wxTimer m_TimerProjectSaved
 delay after project saved event More...
 
wxTimer m_TimerReparsing
 delay after receive a project save/modified event More...
 
wxTimer m_TimerEditorActivated
 delay after receive editor activated event the reason we need a timer is that we want to get a stable editor activate information thus we will only handle the last editor activated editor The timer will be restart when an editor activated event happens. More...
 
cbEditorm_LastEditor
 the last valid editor it is saved in editor activated event handler, and will be verified in editor activated timer event handler More...
 
wxToolBarm_ToolBar
 the CC's toolbar More...
 
wxChoicem_Function
 function choice control of CC's toolbar, it is the second choice More...
 
wxChoicem_Scope
 namespace/scope choice control, it is the first choice control More...
 
FunctionsScopeVec m_FunctionsScope
 current active file's function body info More...
 
NameSpaceVec m_NameSpaces
 current active file's namespace/scope info More...
 
ScopeMarksVec m_ScopeMarks
 current active file's line info, helper member to access function scopes More...
 
FunctionsScopeMap m_AllFunctionsScopes
 this is a "filename->info" map containing all the opening files choice info More...
 
bool m_ToolbarNeedRefresh
 indicate whether the CC's toolbar need a refresh, this means the toolbar list will be reconstructed More...
 
bool m_ToolbarNeedReparse
 force to re-collect the CC toolbar's item information this means we will parse the buffer to collect the scope information and then rebuild the toolbar items More...
 
int m_CurrentLine
 current caret line, this is actually the saved caret line More...
 
wxString m_LastFile
 the file updating the toolbar info More...
 
bool m_LexerKeywordsToInclude [9]
 indicate whether the predefined keywords set should be added in the suggestion list More...
 
bool m_NeedReparse
 indicate the editor has modified by the user and a real-time parse should be start More...
 
int m_CurrentLength
 remember the number of bytes in the current editor/document this is actually the saved editor or file's size More...
 
bool m_NeedsBatchColour
 batch run UpdateEditorSyntax() after first parsing More...
 
size_t m_CCMaxMatches
 maximum allowed code-completion list entries More...
 
bool m_CCAutoAddParentheses
 whether add parentheses after user selects a function name in the code-completion suggestion list More...
 
bool m_CCDetectImplementation
 add function arguments' types and names when autocompleted outside function. More...
 
wxString m_CCFillupChars
 user defined characters that work like Tab (empty by Default). More...
 
bool m_CCEnableHeaders
 give code completion list for header files, it happens after the #include directive More...
 
bool m_CCEnablePlatformCheck
 do not allow code completion to add include files of projects/targets to the parser that are not supported by the current platform More...
 
SystemHeadersMap m_SystemHeadersMap
 
std::list< SystemHeadersThread * > m_SystemHeadersThreads
 thread to collect header file names, these header file names can be prompt for auto suggestion after #include < or #include " directives. More...
 
wxCriticalSection m_SystemHeadersThreadCS
 critical section to protect accessing m_SystemHeadersMap More...
 
ReparsingMap m_ReparsingMap
 all the files need to be parsed and their associated projects More...
 
DocumentationHelper m_DocHelper
 Provider of documentation for the popup window. More...
 

Friends

wxString DocumentationHelper::OnDocumentationLink (wxHtmlLinkEvent &, bool &)
 

Additional Inherited Members

- Protected Member Functions inherited from cbCodeCompletionPlugin
bool IsProviderFor (cbEditor *ed)
 Has this plugin been selected to provide content for the editor. More...
 
- Protected Member Functions inherited from cbPlugin
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...
 
- Protected Attributes inherited from cbPlugin
PluginType m_Type
 Holds the plugin's type. More...
 
bool m_IsAttached
 Holds the "attached" state. More...
 

Detailed Description

Code completion plugin has those features: show tool-tip when the mouse hover over the variables/functions.

show call-tip when you hit the ( after the function name automatically auto-completion lists prompted while entering code. navigate the source files, jump between declarations and implementations. find symbol usage, or even rename a symbol(code re-factoring).

We later use "CC" as an abbreviation of Code Completion plugin. See the general architecture of code completion plugin on wiki page http://wiki.codeblocks.org/index.php?title=Code_Completion_Design

Definition at line 44 of file codecompletion.h.


Class Documentation

◆ CodeCompletion::FunctionsScopePerFile

struct CodeCompletion::FunctionsScopePerFile

Definition at line 72 of file codecompletion.h.

Collaboration diagram for CodeCompletion::FunctionsScopePerFile:
Class Members
FunctionsScopeVec m_FunctionsScope
NameSpaceVec m_NameSpaces
bool parsed

Member Typedef Documentation

◆ FunctionsScopeMap

filename -> FunctionsScopePerFile map, contains all the opened files scope info

Definition at line 79 of file codecompletion.h.

◆ FunctionsScopeVec

vector containing all the function information of a single source file

Definition at line 66 of file codecompletion.h.

◆ ReparsingMap

map to record all re-parsing files

Here is an example how the ReparsingMap is used. Suppose you have two cbp opened: a.cbp, which contains a1.cpp, a2.cpp and a3.cpp b.cbp, which contains b1,cpp, b2,cpp and b3.cpp now, if a1,cpp and b2.cpp b3.cpp are modified, and the user press the Save all button Then CC receives event about project saved, then we store such information. ReparsingMap contains such two elements (a.cbp, (a1,cpp)) (b.cbp, (b2.cpp, b3.cpp)) there two elements will be passed to m_NativeParser, and m_NativeParser will distribute to each Parser objects

Definition at line 500 of file codecompletion.h.

◆ ScopeMarksVec

typedef std::vector<int> CodeCompletion::ScopeMarksVec

helper class to support FunctionsScopeVec

Definition at line 69 of file codecompletion.h.

Constructor & Destructor Documentation

◆ CodeCompletion()

CodeCompletion::CodeCompletion ( )

◆ ~CodeCompletion()

CodeCompletion::~CodeCompletion ( )
virtual

Member Function Documentation

◆ BuildMenu()

void CodeCompletion::BuildMenu ( wxMenuBar menuBar)
virtual

◆ BuildModuleMenu()

void CodeCompletion::BuildModuleMenu ( const ModuleType  type,
wxMenu menu,
const FileTreeData data = 0 
)
virtual

◆ BuildToolBar()

bool CodeCompletion::BuildToolBar ( wxToolBar toolBar)
virtual

build CC Toolbar

Definition at line 838 of file codecompletion.cpp.

References _T, Manager::AddonToolBar(), and Manager::Get().

Referenced by GetConfigurationGroup().

◆ DoAllMethodsImpl()

int CodeCompletion::DoAllMethodsImpl ( )
private

◆ DoAutocomplete()

void CodeCompletion::DoAutocomplete ( const CCToken token,
cbEditor ed 
)
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.

Parameters
tokenThe CCToken corresponding to the selected entry.
edThe editor to operate in.

Reimplemented from cbCodeCompletionPlugin.

Definition at line 1357 of file codecompletion.cpp.

References _T, wxString::Append(), CodeCompletionHelper::AutocompGetName(), cbCodeCompletionPlugin::CCToken::displayName, wxString::Find(), wxString::GetChar(), wxScintilla::GetCharAt(), cbEditor::GetControl(), wxScintilla::GetCurrentLine(), wxScintilla::GetCurrentPos(), wxScintilla::GetLine(), wxScintilla::GetLineEndPosition(), wxRegEx::GetMatch(), wxScintilla::GetStyleAt(), cbStyledTextCtrl::IsComment(), cbStyledTextCtrl::IsPreprocessor(), wxRegEx::Matches(), wxScintilla::WordStartPosition(), wxIsspace(), wxNOT_FOUND, and wxT.

Referenced by GetToolBarPriority().

◆ DoClassMethodDeclImpl()

int CodeCompletion::DoClassMethodDeclImpl ( )
private

◆ DoCodeComplete()

void CodeCompletion::DoCodeComplete ( int  caretPos,
cbEditor ed,
std::vector< CCToken > &  tokens,
bool  preprocessorOnly = false 
)
private

◆ DoCodeCompleteIncludes()

void CodeCompletion::DoCodeCompleteIncludes ( cbEditor ed,
int &  tknStart,
int  tknEnd,
std::vector< CCToken > &  tokens 
)
private

◆ DoCodeCompletePreprocessor()

void CodeCompletion::DoCodeCompletePreprocessor ( int  tknStart,
int  tknEnd,
cbEditor ed,
std::vector< CCToken > &  tokens 
)
private

fill the tokens with correct preprocessor directives, such as #i will prompt "if", "include"

Parameters
tknStartthe start of the completed word
tknEndcurrent caret location
edcurrent active editor
tokensresults storing all the suggesting texts

Definition at line 1089 of file codecompletion.cpp.

References wxScintilla::ClearRegisteredImages(), F(), FileTypeOf(), ftHeader, ftResource, ftSource, ftTemplateSource, cbEditor::GetControl(), wxScintilla::GetLexer(), EditorBase::GetShortName(), wxScintilla::GetTextRange(), wxString::IsEmpty(), PARSER_IMG_MACRO_DEF, wxScintilla::RegisterImage(), wxNOT_FOUND, wxSCI_LEX_CPP, and wxT.

Referenced by GetToolBarPriority().

◆ DoParseOpenedProjectAndActiveEditor()

void CodeCompletion::DoParseOpenedProjectAndActiveEditor ( )
private

if C::B starts up with some projects opened, this function will be called to parse the already opened projects

Definition at line 3323 of file codecompletion.cpp.

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

Referenced by GetToolBarPriority().

◆ EditorEventHook()

void CodeCompletion::EditorEventHook ( cbEditor editor,
wxScintillaEvent event 
)

◆ EnableToolbarTools()

void CodeCompletion::EnableToolbarTools ( bool  enable = true)
private

enable the two wxChoices

Definition at line 3315 of file codecompletion.cpp.

Referenced by GetToolBarPriority().

◆ FindFunctionAndUpdate()

void CodeCompletion::FindFunctionAndUpdate ( int  currentLine)
private

the caret has changed, so the wxChoice need to be updated to indicates which scope and function in which the caret locates.

Definition at line 3257 of file codecompletion.cpp.

References g_GlobalScope, wxChoice::SetSelection(), and wxPostEvent().

Referenced by GetToolBarPriority().

◆ FunctionPosition()

void CodeCompletion::FunctionPosition ( int &  scopeItem,
int &  functionItem 
) const
private

helper method in finding the function position in the vector for the function containing the current line

Definition at line 2860 of file codecompletion.cpp.

References CodeCompletion::FunctionScope::EndLine, and CodeCompletion::FunctionScope::StartLine.

Referenced by GetToolBarPriority().

◆ GetAbsolutePath()

void CodeCompletion::GetAbsolutePath ( const wxString basePath,
const wxArrayString targets,
wxArrayString dirs 
)

search target file names (mostly relative names) under basePath, then return the absolute dirs the result is "added" to parameter dirs (not replacement of any existing dirs) It just did the calculation below: "c:/ccc/ddd.cpp"(basePath) + "aaa/bbb.h"(target) => "c:/ccc/aaa/bbb.h"(dirs)

Parameters
[in]basePathalready located file path, this is usually the currently parsing file's location
[in]targetsthe relative filename, e.g. When you have #include "aaa/bbb.h", "aaa/bbb.h" is the target location
[out]dirsresult location of the targets in absolute file path format

Definition at line 1624 of file codecompletion.cpp.

References wxArrayString::Add(), wxFileName::AppendDir(), Manager::Get(), wxArrayString::GetCount(), wxFileName::GetDirCount(), wxFileName::GetDirs(), wxFileName::GetFullPath(), Manager::GetMacrosManager(), wxArrayString::Index(), wxFileName::IsAbsolute(), wxFileName::IsRelative(), MacrosManager::ReplaceMacros(), wxFileName::SetPath(), wxEmptyString, and wxNOT_FOUND.

Referenced by GetToolBarPriority().

◆ GetAutocompList()

std::vector< CodeCompletion::CCToken > CodeCompletion::GetAutocompList ( bool  isAuto,
cbEditor ed,
int &  tknStart,
int &  tknEnd 
)
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

#include <math.h>
int main()
{
float i = cos|------auto completion here
^ ^
}

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

struct AAA { int m_aaa1; };
int main()
{
AAA obj;
obj.|------auto completion here
^
}

Here, '^' are the positions of both tknStart and tknEnd.

Parameters
isAutoPassed 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.
edThe context of this codecompletion call.
[in,out]tknStartThe assumed beginning of the token to be autocompleted. Change this variable if the plugin calculates a different starting location.
[in,out]tknEndThe 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).
Returns
Completable tokens, or empty vector to cancel autocompletion.

Implements cbCodeCompletionPlugin.

Definition at line 876 of file codecompletion.cpp.

References _T, wxString::Find(), wxScintilla::GetCharAt(), cbEditor::GetControl(), wxScintilla::GetCurrentLine(), wxScintilla::GetLineIndentPosition(), wxScintilla::GetStyleAt(), wxScintilla::GetTextRange(), cbStyledTextCtrl::IsCharacter(), cbStyledTextCtrl::IsComment(), cbStyledTextCtrl::IsPreprocessor(), cbStyledTextCtrl::IsString(), wxScintilla::WordEndPosition(), wxScintilla::WordStartPosition(), wxNOT_FOUND, and wxT.

Referenced by GetToolBarPriority().

◆ GetCallTips()

std::vector< CodeCompletion::CCCallTip > CodeCompletion::GetCallTips ( int  pos,
int  style,
cbEditor ed,
int &  argsPos 
)
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:

int endOfWord = stc->WordEndPosition(pos, true);
^

Each returned CCCallTip is allowed to have embedded '\n' line breaks.

Parameters
posThe location in the editor that the calltip is requested for.
styleThe scintilla style of the cbStyledTextCtrl at the given location. (TODO: This is unusual, remove it?)
edThe context of this calltip request.
[out]argsPosThe location in the editor of the beginning of the argument list. Required.
Returns
Each entry in this vector is guaranteed either a new line or a separate page in the calltip. CCManager will decide if lines should be further split (for formatting to fit the monitor).

Implements cbCodeCompletionPlugin.

Definition at line 1278 of file codecompletion.cpp.

References wxArrayString::GetCount(), wxArrayString::IsEmpty(), wxSCI_C_WXSMITH, and wxSCI_INVALID_POSITION.

Referenced by GetToolBarPriority().

◆ GetConfigurationGroup()

virtual int CodeCompletion::GetConfigurationGroup ( ) const
inlinevirtual

Return the configuration group for this plugin.

Default is cgUnknown. Notice that you can logically AND more than one configuration groups, so you could set it, for example, as "cgCompiler | cgContribPlugin".

Reimplemented from cbPlugin.

Definition at line 89 of file codecompletion.h.

References BuildMenu(), BuildModuleMenu(), BuildToolBar(), cgEditor, GetConfigurationPanel(), and GetProjectConfigurationPanel().

◆ GetConfigurationPanel()

cbConfigurationPanel * CodeCompletion::GetConfigurationPanel ( wxWindow parent)
virtual

CC's config dialog.

Definition at line 647 of file codecompletion.cpp.

Referenced by GetConfigurationGroup().

◆ GetDocumentation()

wxString CodeCompletion::GetDocumentation ( const CCToken token)
virtual

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.

Parameters
tokenThe token to document.
Returns
Either an html document or an empty string (if no documentation available).

Implements cbCodeCompletionPlugin.

Definition at line 1305 of file codecompletion.cpp.

References cbCodeCompletionPlugin::CCToken::id.

Referenced by GetToolBarPriority().

◆ GetLocalIncludeDirs()

wxArrayString CodeCompletion::GetLocalIncludeDirs ( cbProject project,
const wxArrayString buildTargets 
)

Get the include paths setting (usually set by user for each C::B project).

If it finds some system level include search dirs which haven't been scanned, it will start a a new thread(SystemHeadersThread). this function internally adds all the system level dirs to scanning thread

Parameters
projectproject info
buildTargetstarget info
Returns
the local include paths
Note
This function is only called from CodeCompletion::DoCodeCompleteIncludes().
This function should be called with the m_SystemHeadersThreadCS locked.

Definition at line 1534 of file codecompletion.cpp.

References wxArrayString::Add(), CodeCompletionHelper::CompareStringLen(), and wxThread::Run().

Referenced by GetToolBarPriority().

◆ GetProjectConfigurationPanel()

cbConfigurationPanel * CodeCompletion::GetProjectConfigurationPanel ( wxWindow parent,
cbProject project 
)
virtual

CC's config dialog which show in the project options panel.

Definition at line 652 of file codecompletion.cpp.

Referenced by GetConfigurationGroup().

◆ GetProviderStatusFor()

CodeCompletion::CCProviderStatus CodeCompletion::GetProviderStatusFor ( cbEditor ed)
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.

Parameters
edThe editor being checked.
Returns
The level of functionality this plugin is able to supply.

Implements cbCodeCompletionPlugin.

Definition at line 857 of file codecompletion.cpp.

References ParserCommon::FileType(), ParserCommon::ftHeader, ParserCommon::ftOther, ParserCommon::ftSource, cbEditor::GetColourSet(), EditorBase::GetFilename(), EditorColourSet::GetHighlightLanguage(), cbEditor::GetLanguage(), and wxT.

Referenced by GetToolBarPriority().

◆ GetSystemIncludeDirs()

wxArrayString & CodeCompletion::GetSystemIncludeDirs ( cbProject project,
bool  force 
)

get the whole search dirs except the ones locally belong to the c::b project, note this function is used for auto suggestion for #include directives.

Parameters
forceif the value is false, just return a static (cached) wxArrayString to optimize the performance, if it is true, we try to update the cache by calculating the dirs and storing the value in the static wxArrayString variable.

Definition at line 1587 of file codecompletion.cpp.

References wxArrayString::Clear(), cbProject::GetCommonTopLevelPath(), wxArrayString::GetCount(), ParserBase::GetIncludeDirs(), Last, and wxArrayString::RemoveAt().

Referenced by GetToolBarPriority().

◆ GetTokenAt()

std::vector< CodeCompletion::CCToken > CodeCompletion::GetTokenAt ( int  pos,
cbEditor ed,
bool &  allowCallTip 
)
virtual

Supply the definition of the token at the specified location.

The token(s) returned by this function are used to display tooltips.

Parameters
posThe location being queried.
edThe context of the request.
[out]allowCallTipAllow CCManager to consider displaying a calltip if the results from this function are unsuitable/empty. True by default.
Returns
A list of the token(s) that match the specified location, an empty vector if none.

Implements cbCodeCompletionPlugin.

Definition at line 1310 of file codecompletion.cpp.

References TokenTree::at(), CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, Token::DisplayName(), cbEditor::GetControl(), wxScintilla::GetStyleAt(), cbStyledTextCtrl::IsCharacter(), cbStyledTextCtrl::IsComment(), cbStyledTextCtrl::IsPreprocessor(), cbStyledTextCtrl::IsString(), s_TokenTreeMutex, and wxScintilla::WordEndPosition().

Referenced by GetToolBarPriority().

◆ GetToolBarPriority()

virtual int CodeCompletion::GetToolBarPriority ( )
inlinevirtual

toolbar priority value

Reimplemented from cbPlugin.

Definition at line 102 of file codecompletion.h.

References DoAllMethodsImpl(), DoAutocomplete(), DoClassMethodDeclImpl(), DoCodeComplete(), DoCodeCompleteIncludes(), DoCodeCompletePreprocessor(), DoParseOpenedProjectAndActiveEditor(), EditorEventHook(), EnableToolbarTools(), FindFunctionAndUpdate(), FunctionPosition(), GetAbsolutePath(), GetAutocompList(), GetCallTips(), GetDocumentation(), GetLocalIncludeDirs(), GetProviderStatusFor(), GetSystemIncludeDirs(), GetTokenAt(), GotoFunctionPrevNext(), MatchCodeStyle(), NameSpacePosition(), NULL, OnAppDoneStartup(), OnCCDebugLogger(), OnCCLogger(), OnClassMethod(), OnCurrentProjectReparse(), OnDocumentationLink(), OnEditorActivated(), OnEditorActivatedTimer(), OnEditorClosed(), OnEditorOpen(), OnEditorSave(), OnFindReferences(), OnFunction(), OnGotoDeclaration(), OnGotoFunction(), OnGotoNextFunction(), OnGotoPrevFunction(), OnOpenIncludeFile(), OnParserEnd(), OnParserStart(), OnProjectActivated(), OnProjectClosed(), OnProjectFileAdded(), OnProjectFileChanged(), OnProjectFileRemoved(), OnProjectSaved(), OnProjectSavedTimer(), OnRealtimeParsingTimer(), OnRenameSymbols(), OnReparsingTimer(), OnScope(), OnSelectedFileReparse(), OnSelectedProjectReparse(), OnSystemHeadersThreadFinish(), OnSystemHeadersThreadMessage(), OnToolbarTimer(), OnUnimplementedClassMethods(), OnUpdateUI(), OnViewClassBrowser(), OnWorkspaceChanged(), ParseFunctionsAndFillToolbar(), RereadOptions(), UpdateEditorSyntax(), UpdateFunctions(), UpdateToolBar(), wxEmptyString, and wxSCI_EOL_LF.

◆ GotoFunctionPrevNext()

void CodeCompletion::GotoFunctionPrevNext ( bool  next = false)
private

◆ MatchCodeStyle()

void CodeCompletion::MatchCodeStyle ( wxString str,
int  eolStyle = wxSCI_EOL_LF,
const wxString indent = wxEmptyString,
bool  useTabs = false,
int  tabSize = 4 
)
private

modify the string content to follow the current editor's code style The code style includes the EOL, TAB and indent

Parameters
[in,out]strthe input string, but also the modified string
eolStylean int value to indicate the EOL style
indenta wxString containing the whole intent text
useTabswhether TAB is used
tabSizehow long is the TAB

Definition at line 2850 of file codecompletion.cpp.

References GetEOLStr(), wxString::IsEmpty(), wxString::Length(), wxString::RemoveLast(), wxString::Replace(), and wxT.

Referenced by GetToolBarPriority().

◆ NameSpacePosition()

int CodeCompletion::NameSpacePosition ( ) const
private

find the namespace whose scope covers the current line the m_CurrentLine is used

Returns
the found namespace index

Definition at line 2943 of file codecompletion.cpp.

References NameSpace::StartLine.

Referenced by GetToolBarPriority().

◆ OnAppDoneStartup()

void CodeCompletion::OnAppDoneStartup ( CodeBlocksEvent event)
private

SDK event when application has started up.

Definition at line 2290 of file codecompletion.cpp.

Referenced by GetToolBarPriority(), and OnAttach().

◆ OnAttach()

void CodeCompletion::OnAttach ( )
virtual

Any descendent plugin should override this virtual method and perform any necessary initialization.

This method is called by Code::Blocks (PluginManager actually) when the plugin has been loaded and should attach in Code::Blocks. When Code::Blocks starts up, it finds and loads all plugins but does not activate (attaches) them. It then activates all plugins that the user has selected to be activated on start-up.
This means that a plugin might be loaded but not activated...
Think of this method as the actual constructor...

Reimplemented from cbPlugin.

Definition at line 552 of file codecompletion.cpp.

References cbEVT_APP_STARTUP_DONE, cbEVT_EDITOR_ACTIVATED, cbEVT_EDITOR_CLOSE, cbEVT_EDITOR_OPEN, cbEVT_EDITOR_SAVE, cbEVT_PROJECT_ACTIVATE, cbEVT_PROJECT_CLOSE, cbEVT_PROJECT_FILE_ADDED, cbEVT_PROJECT_FILE_CHANGED, cbEVT_PROJECT_FILE_REMOVED, cbEVT_PROJECT_SAVE, cbEVT_WORKSPACE_CHANGED, EditorEventHook(), Manager::Get(), OnAppDoneStartup(), OnEditorActivated(), OnEditorClosed(), OnEditorOpen(), OnEditorSave(), OnProjectActivated(), OnProjectClosed(), OnProjectFileAdded(), OnProjectFileChanged(), OnProjectFileRemoved(), OnProjectSaved(), OnWorkspaceChanged(), Manager::RegisterEventSink(), and EditorHooks::RegisterHook().

◆ OnCCDebugLogger()

void CodeCompletion::OnCCDebugLogger ( CodeBlocksThreadEvent event)
private

CC's own debug logger, to handle log event sent from other worker threads or itself(the main GUI thread), the log messages will be printed in the "Code::Blocks Debug" log panel.

Definition at line 2532 of file codecompletion.cpp.

References LogManager::DebugLog(), Manager::Get(), Manager::GetLogManager(), and Manager::IsAppShuttingDown().

Referenced by CodeCompletion(), GetToolBarPriority(), and ~CodeCompletion().

◆ OnCCLogger()

void CodeCompletion::OnCCLogger ( CodeBlocksThreadEvent event)
private

CC's own logger, to handle log events sent from other worker threads or itself(the main GUI thread), the log messages will be printed in the "Code::Blocks" log panel.

Definition at line 2526 of file codecompletion.cpp.

References Manager::Get(), Manager::GetLogManager(), Manager::IsAppShuttingDown(), and LogManager::Log().

Referenced by CodeCompletion(), GetToolBarPriority(), and ~CodeCompletion().

◆ OnClassMethod()

void CodeCompletion::OnClassMethod ( wxCommandEvent event)
private

handle CC's context menu->insert "Class method declaration/implementation..."

Definition at line 1925 of file codecompletion.cpp.

Referenced by GetToolBarPriority().

◆ OnCurrentProjectReparse()

void CodeCompletion::OnCurrentProjectReparse ( wxCommandEvent event)
private

event handler when user select context menu->reparse file/projects

Definition at line 2250 of file codecompletion.cpp.

Referenced by GetToolBarPriority().

◆ OnDocumentationLink()

wxString CodeCompletion::OnDocumentationLink ( wxHtmlLinkEvent &  event,
bool &  dismissPopup 
)
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.

Parameters
eventThe generated event (it is the plugin's responsibility to Skip(), if desired).
[out]dismissPopupIf set to true, the popup will be hidden.
Returns
If non-empty, the popup's content will be set to this html formatted string.

Implements cbCodeCompletionPlugin.

Definition at line 1352 of file codecompletion.cpp.

Referenced by GetToolBarPriority().

◆ OnEditorActivated()

void CodeCompletion::OnEditorActivated ( CodeBlocksEvent event)
private

◆ OnEditorActivatedTimer()

void CodeCompletion::OnEditorActivatedTimer ( wxTimerEvent event)
private

delayed running of editor activated event, only the last activated editor should be considered

Definition at line 3556 of file codecompletion.cpp.

References Manager::Get(), EditorManager::GetBuiltinActiveEditor(), Manager::GetEditorManager(), EditorBase::GetFilename(), TOOLBAR_REFRESH_DELAY, TRACE, wxString::wx_str(), and wxTIMER_ONE_SHOT.

Referenced by CodeCompletion(), GetToolBarPriority(), and ~CodeCompletion().

◆ OnEditorClosed()

void CodeCompletion::OnEditorClosed ( CodeBlocksEvent event)
private

◆ OnEditorOpen()

void CodeCompletion::OnEditorOpen ( CodeBlocksEvent event)
private

◆ OnEditorSave()

void CodeCompletion::OnEditorSave ( CodeBlocksEvent event)
private

SDK editor related events.

Definition at line 2411 of file codecompletion.cpp.

References EDITOR_ACTIVATED_DELAY, CodeBlocksEvent::GetEditor(), ProjectManager::IsBusy(), TRACE, wxNOT_FOUND, and wxTIMER_ONE_SHOT.

Referenced by GetToolBarPriority(), and OnAttach().

◆ OnFindReferences()

void CodeCompletion::OnFindReferences ( wxCommandEvent event)
private

CC's re-factoring function, find all the reference place.

Definition at line 2156 of file codecompletion.cpp.

Referenced by GetToolBarPriority().

◆ OnFunction()

void CodeCompletion::OnFunction ( wxCommandEvent event)
private

◆ OnGotoDeclaration()

void CodeCompletion::OnGotoDeclaration ( wxCommandEvent event)
private

◆ OnGotoFunction()

void CodeCompletion::OnGotoFunction ( wxCommandEvent event)
private

◆ OnGotoNextFunction()

void CodeCompletion::OnGotoNextFunction ( wxCommandEvent event)
private

navigate to the next function body

Definition at line 1920 of file codecompletion.cpp.

Referenced by GetToolBarPriority().

◆ OnGotoPrevFunction()

void CodeCompletion::OnGotoPrevFunction ( wxCommandEvent event)
private

navigate to the previous function body

Definition at line 1915 of file codecompletion.cpp.

Referenced by GetToolBarPriority().

◆ OnOpenIncludeFile()

void CodeCompletion::OnOpenIncludeFile ( wxCommandEvent event)
private

◆ OnParserEnd()

void CodeCompletion::OnParserEnd ( wxCommandEvent event)
private

◆ OnParserStart()

void CodeCompletion::OnParserStart ( wxCommandEvent event)
private

batch parsing start event this event usually be fired when an Parser object try to start parsing tasks in the thread pool

Definition at line 2538 of file codecompletion.cpp.

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

Referenced by CodeCompletion(), GetToolBarPriority(), NativeParser::LastAIGlobalSearch(), and ~CodeCompletion().

◆ OnProjectActivated()

void CodeCompletion::OnProjectActivated ( CodeBlocksEvent event)
private

SDK project related events.

Definition at line 2328 of file codecompletion.cpp.

References bdfProject, cbProject::GetFilesCount(), and ProjectManager::IsBusy().

Referenced by GetToolBarPriority(), and OnAttach().

◆ OnProjectClosed()

void CodeCompletion::OnProjectClosed ( CodeBlocksEvent event)
private

Definition at line 2349 of file codecompletion.cpp.

Referenced by GetToolBarPriority(), and OnAttach().

◆ OnProjectFileAdded()

void CodeCompletion::OnProjectFileAdded ( CodeBlocksEvent event)
private

Definition at line 2382 of file codecompletion.cpp.

References CodeBlocksEvent::GetProject().

Referenced by GetToolBarPriority(), and OnAttach().

◆ OnProjectFileChanged()

void CodeCompletion::OnProjectFileChanged ( CodeBlocksEvent event)
private

Definition at line 2396 of file codecompletion.cpp.

References CCLogger::DebugLog(), and CCLogger::Get().

Referenced by GetToolBarPriority(), and OnAttach().

◆ OnProjectFileRemoved()

void CodeCompletion::OnProjectFileRemoved ( CodeBlocksEvent event)
private

Definition at line 2389 of file codecompletion.cpp.

References CodeBlocksEvent::GetProject().

Referenced by GetToolBarPriority(), and OnAttach().

◆ OnProjectSaved()

void CodeCompletion::OnProjectSaved ( CodeBlocksEvent event)
private

Definition at line 2371 of file codecompletion.cpp.

References CodeBlocksEvent::GetProject(), TRACE, and wxTIMER_ONE_SHOT.

Referenced by GetToolBarPriority(), and OnAttach().

◆ OnProjectSavedTimer()

void CodeCompletion::OnProjectSavedTimer ( wxTimerEvent event)
private

delayed running after saving project, while many projects' saving

Definition at line 3471 of file codecompletion.cpp.

References CCLogger::DebugLog(), CCLogger::Get(), Manager::Get(), Manager::GetProjectManager(), ProjectManager::GetProjects(), NULL, TRACE, and wxNOT_FOUND.

Referenced by CodeCompletion(), GetToolBarPriority(), and ~CodeCompletion().

◆ OnRealtimeParsingTimer()

void CodeCompletion::OnRealtimeParsingTimer ( wxTimerEvent event)
private

◆ OnRelease()

void CodeCompletion::OnRelease ( bool  appShutDown)
virtual

◆ OnRenameSymbols()

void CodeCompletion::OnRenameSymbols ( wxCommandEvent event)
private

CC's re-factoring function, rename a symbol.

Definition at line 2161 of file codecompletion.cpp.

Referenced by GetToolBarPriority().

◆ OnReparsingTimer()

void CodeCompletion::OnReparsingTimer ( wxTimerEvent event)
private

◆ OnScope()

void CodeCompletion::OnScope ( wxCommandEvent event)
private

Toolbar select event.

Definition at line 2962 of file codecompletion.cpp.

Referenced by GetToolBarPriority().

◆ OnSelectedFileReparse()

void CodeCompletion::OnSelectedFileReparse ( wxCommandEvent event)
private

◆ OnSelectedProjectReparse()

void CodeCompletion::OnSelectedProjectReparse ( wxCommandEvent event)
private

Definition at line 2256 of file codecompletion.cpp.

Referenced by GetToolBarPriority().

◆ OnSystemHeadersThreadFinish()

void CodeCompletion::OnSystemHeadersThreadFinish ( CodeBlocksThreadEvent event)
private

◆ OnSystemHeadersThreadMessage()

void CodeCompletion::OnSystemHeadersThreadMessage ( CodeBlocksThreadEvent event)
private

receive event from SystemHeadersThread

Definition at line 2600 of file codecompletion.cpp.

References CCLogger::DebugLog(), and CCLogger::Get().

Referenced by CodeCompletion(), GetToolBarPriority(), and ~CodeCompletion().

◆ OnToolbarTimer()

void CodeCompletion::OnToolbarTimer ( wxTimerEvent event)
private

delayed for toolbar update

Definition at line 3430 of file codecompletion.cpp.

References ProjectManager::IsBusy(), TOOLBAR_REFRESH_DELAY, TRACE, and wxTIMER_ONE_SHOT.

Referenced by CodeCompletion(), GetToolBarPriority(), and ~CodeCompletion().

◆ OnUnimplementedClassMethods()

void CodeCompletion::OnUnimplementedClassMethods ( wxCommandEvent event)
private

handle CC's context menu->insert "All class methods without implementation..."

Definition at line 1930 of file codecompletion.cpp.

Referenced by GetToolBarPriority().

◆ OnUpdateUI()

void CodeCompletion::OnUpdateUI ( wxUpdateUIEvent event)
private

◆ OnViewClassBrowser()

void CodeCompletion::OnViewClassBrowser ( wxCommandEvent event)
private

event handler when user click Menu->View->Symbols browser

Definition at line 1828 of file codecompletion.cpp.

References _(), cbEVT_HIDE_DOCK_WINDOW, cbEVT_SHOW_DOCK_WINDOW, cbMessageBox(), Manager::Get(), Manager::ProcessEvent(), CodeBlocksDockEvent::pWindow, and wxICON_INFORMATION.

Referenced by GetToolBarPriority().

◆ OnWorkspaceChanged()

void CodeCompletion::OnWorkspaceChanged ( CodeBlocksEvent event)
private

◆ ParseFunctionsAndFillToolbar()

void CodeCompletion::ParseFunctionsAndFillToolbar ( )
private

normally the editor has changed, then CC need to parse the document again, and (re)construct the internal database, and refresh the toolbar(wxChoice's content)

Here is the expansion of how the two wxChoices are constructed.

for a file have such contents below

Line 0 void g_func1(){
Line 1 }
Line 2
Line 3 void ClassA::func1(){
Line 4 }
Line 5
Line 6 void ClassA::func2(){
Line 7 }
Line 8
Line 9 void ClassB::func1(){
Line 10 }
Line 11
Line 12 void ClassB::func2(){
Line 13 }
Line 14
Line 15 namespace NamespaceA{
Line 16 void func3(){
Line 17 }
Line 18
Line 19 class ClassC {
Line 20
Line 21 void func4(){
Line 22 }
Line 23 }
Line 24 }
Line 25

The two key variable will be constructed like below

m_FunctionsScope is std::vector of length 9, capacity 9 =
{
{StartLine = 0, EndLine = 1, ShortName = L"g_func1", Name = L"g_func1() : void", Scope = L"<global>"},
{StartLine = 3, EndLine = 4, ShortName = L"func1", Name = L"func1() : void", Scope = L"ClassA::"},
{StartLine = 6, EndLine = 7, ShortName = L"func2", Name = L"func2() : void", Scope = L"ClassA::"},
{StartLine = 9, EndLine = 10, ShortName = L"func1", Name = L"func1() : void", Scope = L"ClassB::"},
{StartLine = 12, EndLine = 13, ShortName = L"func2", Name = L"func2() : void", Scope = L"ClassB::"},
{StartLine = 14, EndLine = 23, ShortName = L"", Name = L"", Scope = L"NamespaceA::"},
{StartLine = 16, EndLine = 17, ShortName = L"func3", Name = L"func3() : void", Scope = L"NamespaceA::"},
{StartLine = 19, EndLine = 23, ShortName = L"", Name = L"", Scope = L"NamespaceA::ClassC::"},
{StartLine = 21, EndLine = 22, ShortName = L"func4", Name = L"func4() : void", Scope = L"NamespaceA::ClassC::"}
}
m_NameSpaces is std::vector of length 1, capacity 1 =
{{Name = L"NamespaceA::", StartLine = 14, EndLine = 23}}
m_ScopeMarks is std::vector of length 5, capacity 8 = {0, 1, 3, 5, 7}
which is the start of Scope "<global>", Scope "ClassA::" and Scope "ClassB::",
"NamespaceA::" and "NamespaceA::ClassC::"

Then we have wxChoice Scopes and Functions like below

<global> ClassA:: ClassB::
|- g_func1() |- func1() |- func1()
|- func2() |- func2()
NamespaceA:: NamespaceA::ClassC::
|- func3() |- func4()

Definition at line 3050 of file codecompletion.cpp.

References CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, wxString::Clear(), CCLogger::DebugLog(), CodeCompletion::FunctionScope::EndLine, wxString::EndsWith(), CodeCompletionHelper::EqualFunctionScope(), F(), CodeCompletionHelper::GotoDeclarationItem::filename, g_GlobalScope, CCLogger::Get(), Manager::Get(), EditorManager::GetBuiltinActiveEditor(), cbEditor::GetControl(), wxScintilla::GetCurrentLine(), Manager::GetEditorManager(), EditorBase::GetFilename(), Token::GetFormattedArgs(), Token::GetNamespace(), wxScintilla::GetText(), wxString::IsEmpty(), wxString::length(), CodeCompletionHelper::LessFunctionScope(), CodeCompletionHelper::LessNameSpace(), Token::m_BaseType, CodeCompletion::FunctionsScopePerFile::m_FunctionsScope, Token::m_ImplFileIdx, Token::m_ImplLine, Token::m_ImplLineEnd, Token::m_Name, CodeCompletion::FunctionsScopePerFile::m_NameSpaces, Token::m_TokenKind, CodeCompletion::FunctionScope::Name, CodeCompletion::FunctionsScopePerFile::parsed, s_TokenTreeMutex, CodeCompletion::FunctionScope::Scope, CodeCompletion::FunctionScope::ShortName, CodeCompletion::FunctionScope::StartLine, wxString::substr(), tkAnyFunction, tkClass, tkEnum, tkNamespace, TRACE, wxString::wx_str(), wxEmptyString, and wxT.

Referenced by GetToolBarPriority().

◆ RereadOptions()

void CodeCompletion::RereadOptions ( )

◆ UpdateEditorSyntax()

void CodeCompletion::UpdateEditorSyntax ( cbEditor ed = NULL)
private

◆ UpdateFunctions()

void CodeCompletion::UpdateFunctions ( unsigned int  scopeItem)
private

the scope item has changed or becomes invalid, so the associated function wxChoice should be updated.

Parameters
scopeItemthe new item in scope wxChoice.

Definition at line 3300 of file codecompletion.cpp.

References wxString::Append().

Referenced by GetToolBarPriority().

◆ UpdateToolBar()

void CodeCompletion::UpdateToolBar ( )
private

update CC's ToolBar, the user may disable the first wxChoice, so we need to recreate the wxChoice and measure the best fit size

Definition at line 1753 of file codecompletion.cpp.

References Manager::Get(), Manager::GetConfigManager(), ConfigManager::ReadBool(), and ConfigManager::ReadInt().

Referenced by GetToolBarPriority().

Friends And Related Function Documentation

◆ DocumentationHelper::OnDocumentationLink

wxString DocumentationHelper::OnDocumentationLink ( wxHtmlLinkEvent &  ,
bool &   
)
friend

Member Data Documentation

◆ m_AllFunctionsScopes

FunctionsScopeMap CodeCompletion::m_AllFunctionsScopes
private

this is a "filename->info" map containing all the opening files choice info

Definition at line 413 of file codecompletion.h.

◆ m_CCAutoAddParentheses

bool CodeCompletion::m_CCAutoAddParentheses
private

whether add parentheses after user selects a function name in the code-completion suggestion list

Definition at line 452 of file codecompletion.h.

◆ m_CCDetectImplementation

bool CodeCompletion::m_CCDetectImplementation
private

add function arguments' types and names when autocompleted outside function.

The default value is false.

Definition at line 457 of file codecompletion.h.

◆ m_CCEnableHeaders

bool CodeCompletion::m_CCEnableHeaders
private

give code completion list for header files, it happens after the #include directive

Definition at line 465 of file codecompletion.h.

◆ m_CCEnablePlatformCheck

bool CodeCompletion::m_CCEnablePlatformCheck
private

do not allow code completion to add include files of projects/targets to the parser that are not supported by the current platform

Definition at line 470 of file codecompletion.h.

◆ m_CCFillupChars

wxString CodeCompletion::m_CCFillupChars
private

user defined characters that work like Tab (empty by Default).

They will be inserted with the selected item.

Definition at line 462 of file codecompletion.h.

◆ m_CCMaxMatches

size_t CodeCompletion::m_CCMaxMatches
private

maximum allowed code-completion list entries

Definition at line 449 of file codecompletion.h.

◆ m_CodeRefactoring

CodeRefactoring CodeCompletion::m_CodeRefactoring
private

code re-factoring tool

Definition at line 349 of file codecompletion.h.

◆ m_CurrentLength

int CodeCompletion::m_CurrentLength
private

remember the number of bytes in the current editor/document this is actually the saved editor or file's size

Definition at line 441 of file codecompletion.h.

◆ m_CurrentLine

int CodeCompletion::m_CurrentLine
private

current caret line, this is actually the saved caret line

Definition at line 427 of file codecompletion.h.

◆ m_DocHelper

DocumentationHelper CodeCompletion::m_DocHelper
private

Provider of documentation for the popup window.

Definition at line 506 of file codecompletion.h.

◆ m_EditMenu

wxMenu* CodeCompletion::m_EditMenu
private

menu pointers to the frame's main menu

Definition at line 340 of file codecompletion.h.

◆ m_EditorHookId

int CodeCompletion::m_EditorHookId
private

Definition at line 351 of file codecompletion.h.

◆ m_Function

wxChoice* CodeCompletion::m_Function
private

function choice control of CC's toolbar, it is the second choice

Definition at line 393 of file codecompletion.h.

◆ m_FunctionsScope

FunctionsScopeVec CodeCompletion::m_FunctionsScope
private

current active file's function body info

See also
CodeCompletion::ParseFunctionsAndFillToolbar for more details about how the data structure of the CC's toolbar is constructed

Definition at line 401 of file codecompletion.h.

◆ m_InitDone

bool CodeCompletion::m_InitDone
private

Indicates CC's initialization is done.

Definition at line 337 of file codecompletion.h.

◆ m_LastEditor

cbEditor* CodeCompletion::m_LastEditor
private

the last valid editor it is saved in editor activated event handler, and will be verified in editor activated timer event handler

Definition at line 387 of file codecompletion.h.

◆ m_LastFile

wxString CodeCompletion::m_LastFile
private

the file updating the toolbar info

Definition at line 430 of file codecompletion.h.

◆ m_LexerKeywordsToInclude

bool CodeCompletion::m_LexerKeywordsToInclude[9]
private

indicate whether the predefined keywords set should be added in the suggestion list

Definition at line 433 of file codecompletion.h.

◆ m_NameSpaces

NameSpaceVec CodeCompletion::m_NameSpaces
private

current active file's namespace/scope info

Definition at line 404 of file codecompletion.h.

◆ m_NativeParser

NativeParser CodeCompletion::m_NativeParser
private

this member will actually manage all the Parser instances

Definition at line 346 of file codecompletion.h.

Referenced by DocumentationHelper::OnDocumentationLink().

◆ m_NeedReparse

bool CodeCompletion::m_NeedReparse
private

indicate the editor has modified by the user and a real-time parse should be start

Definition at line 436 of file codecompletion.h.

◆ m_NeedsBatchColour

bool CodeCompletion::m_NeedsBatchColour
private

batch run UpdateEditorSyntax() after first parsing

Definition at line 444 of file codecompletion.h.

◆ m_ProjectMenu

wxMenu* CodeCompletion::m_ProjectMenu
private

Definition at line 343 of file codecompletion.h.

◆ m_ReparsingMap

ReparsingMap CodeCompletion::m_ReparsingMap
private

all the files need to be parsed and their associated projects

Definition at line 503 of file codecompletion.h.

◆ m_Scope

wxChoice* CodeCompletion::m_Scope
private

namespace/scope choice control, it is the first choice control

Definition at line 395 of file codecompletion.h.

◆ m_ScopeMarks

ScopeMarksVec CodeCompletion::m_ScopeMarks
private

current active file's line info, helper member to access function scopes

See also
CodeCompletion::ParseFunctionsAndFillToolbar for more details about how the data structure of the CC's toolbar is constructed

Definition at line 410 of file codecompletion.h.

◆ m_SearchMenu

wxMenu* CodeCompletion::m_SearchMenu
private

Definition at line 341 of file codecompletion.h.

◆ m_SystemHeadersMap

SystemHeadersMap CodeCompletion::m_SystemHeadersMap
private

Definition at line 477 of file codecompletion.h.

◆ m_SystemHeadersThreadCS

wxCriticalSection CodeCompletion::m_SystemHeadersThreadCS
private

critical section to protect accessing m_SystemHeadersMap

Definition at line 485 of file codecompletion.h.

◆ m_SystemHeadersThreads

std::list<SystemHeadersThread*> CodeCompletion::m_SystemHeadersThreads
private

thread to collect header file names, these header file names can be prompt for auto suggestion after #include < or #include " directives.

Definition at line 482 of file codecompletion.h.

◆ m_TimerEditorActivated

wxTimer CodeCompletion::m_TimerEditorActivated
private

delay after receive editor activated event the reason we need a timer is that we want to get a stable editor activate information thus we will only handle the last editor activated editor The timer will be restart when an editor activated event happens.

Definition at line 381 of file codecompletion.h.

◆ m_TimerProjectSaved

wxTimer CodeCompletion::m_TimerProjectSaved
private

delay after project saved event

Definition at line 371 of file codecompletion.h.

◆ m_TimerRealtimeParsing

wxTimer CodeCompletion::m_TimerRealtimeParsing
private

timer triggered by editor hook function to delay the real-time parse

Definition at line 354 of file codecompletion.h.

◆ m_TimerReparsing

wxTimer CodeCompletion::m_TimerReparsing
private

delay after receive a project save/modified event

Definition at line 374 of file codecompletion.h.

◆ m_TimerToolbar

wxTimer CodeCompletion::m_TimerToolbar
private

timer for toolbar we only show an updated item in CC's toolbar's item list when caret position is stable for a period of time.

Definition at line 360 of file codecompletion.h.

◆ m_ToolBar

wxToolBar* CodeCompletion::m_ToolBar
private

the CC's toolbar

Definition at line 391 of file codecompletion.h.

◆ m_ToolbarNeedRefresh

bool CodeCompletion::m_ToolbarNeedRefresh
private

indicate whether the CC's toolbar need a refresh, this means the toolbar list will be reconstructed

Definition at line 418 of file codecompletion.h.

◆ m_ToolbarNeedReparse

bool CodeCompletion::m_ToolbarNeedReparse
private

force to re-collect the CC toolbar's item information this means we will parse the buffer to collect the scope information and then rebuild the toolbar items

Definition at line 424 of file codecompletion.h.

◆ m_ViewMenu

wxMenu* CodeCompletion::m_ViewMenu
private

Definition at line 342 of file codecompletion.h.


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