Code::Blocks
SVN r11506
|
symbol browser panel is shown in the Management panel besides projects browser panel. More...
#include <classbrowser.h>
Public Member Functions | |
ClassBrowser (wxWindow *parent, NativeParser *np) | |
class constructor More... | |
virtual | ~ClassBrowser () |
class destructor More... | |
void | SetParser (ParserBase *parser) |
Set the Parser object associated with the class browser. More... | |
void | UpdateClassBrowserView (bool checkHeaderSwap=false) |
update or refresh the symbol browser trees More... | |
void | UpdateSash () |
update the position sash bar between top tree and the bottom tree, the position (percentage) of the two trees are saved in the C::B's configuration file. More... | |
Private Member Functions | |
void | OnTreeItemDoubleClick (wxTreeEvent &event) |
handler for the mouse double click on a tree item, we usually make a jump to the associated token's position. More... | |
void | OnTreeItemRightClick (wxTreeEvent &event) |
show a context menu More... | |
void | OnJumpTo (wxCommandEvent &event) |
the handler for jump to declaration or jump to definition menu item More... | |
void | OnRefreshTree (wxCommandEvent &event) |
force rebuilding the tree More... | |
void | OnForceReparse (wxCommandEvent &event) |
reparse the current project More... | |
void | OnCBViewMode (wxCommandEvent &event) |
user change the view mode (View Inheritance or View the bottom tree) More... | |
void | OnCBExpandNS (wxCommandEvent &event) |
whether automatically expand the namespace option switch More... | |
void | OnViewScope (wxCommandEvent &event) |
the view scope choice has changed, user can switch between view everything, view a single file, or view the project More... | |
void | OnDebugSmartSense (wxCommandEvent &event) |
whether print the debug log message More... | |
void | OnSetSortType (wxCommandEvent &event) |
sort type changed More... | |
void | OnSearch (wxCommandEvent &event) |
when user try to search a word in the symbols tree More... | |
bool | FoundMatch (const wxString &search, wxTreeCtrl *tree, const wxTreeItemId &item) |
string compare between the search and the token's name associated with item More... | |
wxTreeItemId | FindNext (const wxString &search, wxTreeCtrl *tree, const wxTreeItemId &start) |
get the next item of the "start" item, if no next item in the current level, go up one level More... | |
wxTreeItemId | FindChild (const wxString &search, wxTreeCtrl *tree, const wxTreeItemId &start, bool recurse=false, bool partialMatch=false) |
get a child of the parent item, which matches the "search" key More... | |
bool | RecursiveSearch (const wxString &search, wxTreeCtrl *tree, const wxTreeItemId &parent, wxTreeItemId &result) |
find an item whose item name matches the "search" key string in the sub-tree More... | |
void | ShowMenu (wxTreeCtrl *tree, wxTreeItemId id, const wxPoint &pt) |
build and show a context menu when user right click on the tree item "id" More... | |
void | ThreadedBuildTree (cbProject *activeProject) |
create a thread to update the symbol tree, if the thread is already created, just pause and resume the thread. More... | |
void | OnTreeItemExpanding (wxTreeEvent &event) |
expanding one node of top tree More... | |
void | OnTreeItemCollapsing (wxTreeEvent &event) |
collapse one node of the top tree More... | |
void | OnTreeSelChanged (wxTreeEvent &event) |
item selection changed in the top tree More... | |
void | OnThreadEvent (wxCommandEvent &event) |
class browser builder thread will send notification event to the parent, this is the event handler function currently, there are three kinds of events send from the builder thread More... | |
Private Attributes | |
NativeParser * | m_NativeParser |
the pointer to parser manager object More... | |
CCTreeCtrl * | m_CCTreeCtrl |
the top(main) level tree control, see above diagram for details More... | |
CCTreeCtrl * | m_CCTreeCtrlBottom |
the bottom tree control, mainly used to show the member variable and member functions More... | |
wxTreeCtrl * | m_TreeForPopupMenu |
remember the context menu is created from which tree control, the upper or the bottom More... | |
wxComboBox * | m_Search |
the search combobox in the header of the window More... | |
ParserBase * | m_Parser |
a pointer to the associated parser object More... | |
wxString | m_ActiveFilename |
source file name of active editor, used for filtering(if view option is Current file's symbols) More... | |
wxSemaphore | m_ClassBrowserSemaphore |
semaphore to synchronize the GUI(class browser) and the tree builder thread, when the GUI post the semaphore, the waiting thread start doing the job More... | |
ClassBrowserBuilderThread * | m_ClassBrowserBuilderThread |
a wxThread used to build the wxTreeCtrl for the top and bottom in the class(symbol) browser because it always take many seconds to build the trees, so those work were delegated to a worker thread. More... | |
symbol browser panel is shown in the Management panel besides projects browser panel.
It mainly has four parts, see the simple diagram below.
1, the view option is a list box to let user choose which tokens should be shown in the trees it can either show the tokens for the whole workspace, or only the active C::B project, or the active editor (source files) 2, search box, a combo-box lets user enter texts for searching a specific symbol 3, top tree, a wxTreeCtrl shows the mostly top level symbols, such as the global namespaces, macro definitions, class definition in global namesapces. 4, bottom tree, shows members of the select item in the top tree, e.g. if a user select a class, then, this tree will show all the member variables of the class. Note, this tree can be hidden by the user in CC's setting dialog, in this case only the top tree is shown on the panel.
Definition at line 53 of file classbrowser.h.
ClassBrowser::ClassBrowser | ( | wxWindow * | parent, |
NativeParser * | np | ||
) |
class constructor
parent | the parent window |
np | the NativeParser instance, which contains all the images for the wxTreeCtrl |
Definition at line 132 of file classbrowser.cpp.
References _T, bdfFile, wxXmlResource::Get(), Manager::Get(), wxSystemSettings::GetColour(), Manager::GetConfigManager(), wxXmlResource::LoadPanel(), ConfigManager::ReadInt(), wxSYS_COLOUR_BTNFACE, and wxTE_PROCESS_ENTER.
|
virtual |
class destructor
Definition at line 161 of file classbrowser.cpp.
References _T, Manager::Get(), Manager::GetConfigManager(), m_ClassBrowserBuilderThread, m_ClassBrowserSemaphore, NULL, wxSemaphore::Post(), ClassBrowserBuilderThread::RequestTermination(), SetParser(), wxThread::Wait(), and ConfigManager::Write().
|
private |
get a child of the parent item, which matches the "search" key
recurse | whether recursive search to the children of the children "search" key is the prefix of the item's text |
Definition at line 408 of file classbrowser.cpp.
References wxTreeCtrl::GetFirstChild(), wxTreeCtrl::GetItemText(), wxTreeCtrl::GetNextChild(), wxTreeItemId::IsOk(), wxTreeCtrl::ItemHasChildren(), m_CCTreeCtrl, wxString::StartsWith(), and wxTreeItemId::Unset().
Referenced by OnSearch().
|
private |
get the next item of the "start" item, if no next item in the current level, go up one level
Definition at line 393 of file classbrowser.cpp.
References wxTreeCtrl::GetItemParent(), wxTreeCtrl::GetNextSibling(), and wxTreeItemId::IsOk().
Referenced by RecursiveSearch().
|
private |
string compare between the search and the token's name associated with item
search | the search key |
tree | tree control |
item | the item id of the tree |
Definition at line 378 of file classbrowser.cpp.
References _T, wxTreeCtrl::GetItemData(), ClassTreeData::GetToken(), wxString::Lower(), Token::m_Name, and wxString::StartsWith().
Referenced by RecursiveSearch().
|
private |
whether automatically expand the namespace option switch
Definition at line 663 of file classbrowser.cpp.
References ParserBase::ClassBrowserOptions(), BrowserOptions::expandNS, idCBExpandNS, m_Parser, UpdateClassBrowserView(), and ParserBase::WriteOptions().
|
private |
user change the view mode (View Inheritance or View the bottom tree)
Definition at line 645 of file classbrowser.cpp.
References ParserBase::ClassBrowserOptions(), BrowserOptions::expandNS, idCBBottomTree, idCBExpandNS, idCBViewInheritance, m_Parser, BrowserOptions::showInheritance, BrowserOptions::treeMembers, UpdateClassBrowserView(), and ParserBase::WriteOptions().
|
private |
whether print the debug log message
Definition at line 702 of file classbrowser.cpp.
References s_DebugSmartSense.
|
private |
reparse the current project
Definition at line 639 of file classbrowser.cpp.
References m_NativeParser, and NativeParser::ReparseCurrentProject().
|
private |
the handler for jump to declaration or jump to definition menu item
Definition at line 484 of file classbrowser.cpp.
References wxFileName::Assign(), Manager::Get(), CompileTargetBase::GetBasePath(), wxArrayString::GetCount(), NativeParser::GetCurrentProject(), Manager::GetEditorManager(), Token::GetFilename(), wxFileName::GetFullPath(), Token::GetImplFilename(), ParserBase::GetIncludeDirs(), wxTreeCtrl::GetItemData(), NativeParser::GetProjectByParser(), wxTreeCtrl::GetSelection(), cbEditor::GotoTokenPosition(), idMenuJumpToImplementation, NativeParser::IsParserPerWorkspace(), wxArrayString::Item(), Token::m_ImplLine, Token::m_Line, Token::m_Name, m_NativeParser, m_Parser, CCTreeCtrlData::m_Token, m_TreeForPopupMenu, NormalizePath(), and EditorManager::Open().
|
private |
force rebuilding the tree
Definition at line 634 of file classbrowser.cpp.
References UpdateClassBrowserView().
|
private |
when user try to search a word in the symbols tree
Definition at line 726 of file classbrowser.cpp.
References _(), _T, wxArrayString::Add(), TokenTree::at(), cbGetSingleChoiceIndex(), cbMessageBox(), CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, Token::DisplayName(), wxTreeCtrl::Expand(), FindChild(), TokenTree::FindMatches(), Manager::Get(), wxArrayString::GetCount(), wxTreeCtrl::GetFirstChild(), wxTreeCtrl::GetItemData(), Token::GetNamespace(), wxTreeCtrl::GetNextChild(), wxTreeCtrl::GetRootItem(), ParserBase::GetTokenTree(), wxString::IsEmpty(), wxTreeItemId::IsOk(), m_CCTreeCtrl, m_CCTreeCtrlBottom, Token::m_Name, Token::m_ParentIndex, m_Parser, m_Search, CCTreeCtrlData::m_SpecialFolder, Token::m_TokenKind, s_TokenTreeMutex, wxTreeCtrl::SelectItem(), sfGFuncs, sfGVars, sfPreproc, sfTypedef, tkAnyContainer, wxICON_INFORMATION, and wxNOT_FOUND.
|
private |
sort type changed
Definition at line 707 of file classbrowser.cpp.
References _T, bstAlphabet, bstKind, bstLine, bstNone, bstScope, ParserBase::ClassBrowserOptions(), Manager::Get(), Manager::GetConfigManager(), idCBSortByAlpabet, idCBSortByKind, idCBSortByLine, idCBSortByScope, m_Parser, BrowserOptions::sortType, UpdateClassBrowserView(), ConfigManager::Write(), and ParserBase::WriteOptions().
|
private |
class browser builder thread will send notification event to the parent, this is the event handler function currently, there are three kinds of events send from the builder thread
Definition at line 972 of file classbrowser.cpp.
References ClassBrowserBuilderThread::buildTreeEnd, ClassBrowserBuilderThread::buildTreeStart, ParserBase::ClassBrowserOptions(), CCLogger::DebugLog(), CCLogger::Get(), m_ClassBrowserBuilderThread, m_Parser, ClassBrowserBuilderThread::selectItemRequired, ClassBrowserBuilderThread::SelectItemRequired(), BrowserOptions::treeMembers, and wxT.
|
private |
collapse one node of the top tree
Definition at line 952 of file classbrowser.cpp.
References ClassBrowserBuilderThread::CollapseItem(), wxTreeEvent::GetItem(), and m_ClassBrowserBuilderThread.
|
private |
handler for the mouse double click on a tree item, we usually make a jump to the associated token's position.
Definition at line 538 of file classbrowser.cpp.
References wxFileName::Assign(), CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, Manager::Get(), CompileTargetBase::GetBasePath(), wxArrayString::GetCount(), NativeParser::GetCurrentProject(), Manager::GetEditorManager(), Token::GetFilename(), wxFileName::GetFullPath(), Token::GetImplFilename(), ParserBase::GetIncludeDirs(), wxTreeCtrl::GetItemData(), NativeParser::GetProjectByParser(), cbEditor::GotoTokenPosition(), wxString::IsEmpty(), NativeParser::IsParserPerWorkspace(), wxArrayString::Item(), Token::m_ImplLine, Token::m_Line, Token::m_Name, m_NativeParser, m_Parser, CCTreeCtrlData::m_Token, Token::m_TokenKind, NormalizePath(), EditorManager::Open(), s_TokenTreeMutex, wxDialog::ShowModal(), tkAnyContainer, tkAnyFunction, tkClass, tkConstructor, tkDestructor, tkEnum, tkEnumerator, tkFunction, tkMacroDef, tkMacroUse, tkNamespace, tkTypedef, tkUndefined, tkVariable, wxGetKeyState(), WXK_CONTROL, and WXK_SHIFT.
|
private |
expanding one node of top tree
Definition at line 942 of file classbrowser.cpp.
References ClassBrowserBuilderThread::ExpandItem(), wxTreeEvent::GetItem(), and m_ClassBrowserBuilderThread.
|
private |
show a context menu
Definition at line 474 of file classbrowser.cpp.
References wxTreeEvent::GetItem(), wxTreeCtrl::SelectItem(), and ShowMenu().
|
private |
item selection changed in the top tree
Definition at line 960 of file classbrowser.cpp.
References ParserBase::ClassBrowserOptions(), wxTreeEvent::GetItem(), m_ClassBrowserBuilderThread, m_Parser, ClassBrowserBuilderThread::SelectItem(), BrowserOptions::treeMembers, and wxIsMainThread().
|
private |
the view scope choice has changed, user can switch between view everything, view a single file, or view the project
Definition at line 675 of file classbrowser.cpp.
References _(), _T, bdfProject, bdfWorkspace, cbMessageBox(), ParserBase::ClassBrowserOptions(), CCLogger::DebugLog(), BrowserOptions::displayFilter, CCLogger::Get(), Manager::Get(), Manager::GetConfigManager(), NativeParser::IsParserPerWorkspace(), m_NativeParser, m_Parser, UpdateClassBrowserView(), ConfigManager::Write(), ParserBase::WriteOptions(), wxICON_INFORMATION, and wxT.
|
private |
find an item whose item name matches the "search" key string in the sub-tree
parent | search will start from this parent item, and recursively to the sub-tree |
Definition at line 436 of file classbrowser.cpp.
References FindNext(), FoundMatch(), wxTreeCtrl::GetFirstChild(), wxTreeCtrl::GetNextChild(), wxTreeItemId::IsOk(), and wxTreeCtrl::ItemHasChildren().
void ClassBrowser::SetParser | ( | ParserBase * | parser | ) |
Set the Parser object associated with the class browser.
the browser tree must access to the TokenTree, so it needs a ParserBase pointer
parser | the Parser instance |
Definition at line 184 of file classbrowser.cpp.
References bdfProject, bdfWorkspace, ParserBase::ClassBrowserOptions(), CCLogger::DebugLog(), BrowserOptions::displayFilter, CCLogger::Get(), NativeParser::IsParserPerWorkspace(), m_NativeParser, m_Parser, UpdateClassBrowserView(), ParserBase::WriteOptions(), and wxT.
Referenced by NativeParser::CreateClassBrowser(), NativeParser::SetParser(), and ~ClassBrowser().
|
private |
build and show a context menu when user right click on the tree item "id"
Definition at line 268 of file classbrowser.cpp.
References _(), wxMenu::Append(), wxMenu::AppendCheckItem(), wxMenu::AppendSeparator(), bstAlphabet, bstKind, bstLine, bstNone, bstScope, wxMenu::Check(), ParserBase::ClassBrowserOptions(), BrowserOptions::expandNS, Token::GetImplFilename(), wxTreeCtrl::GetItemData(), wxMenu::GetMenuItemCount(), wxTreeCtrl::GetRootItem(), idCBBottomTree, idCBExpandNS, idCBNoSort, idCBSortByAlpabet, idCBSortByKind, idCBSortByLine, idCBSortByScope, idCBViewInheritance, idMenuDebugSmartSense, idMenuForceReparse, idMenuJumpToDeclaration, idMenuJumpToImplementation, idMenuRefreshTree, wxString::IsEmpty(), m_CCTreeCtrl, Token::m_ImplLine, m_Parser, CCTreeCtrlData::m_Token, Token::m_TokenKind, m_TreeForPopupMenu, s_DebugSmartSense, BrowserOptions::showInheritance, BrowserOptions::sortType, tkAnyContainer, tkAnyFunction, tkClass, tkConstructor, tkDestructor, tkEnum, tkEnumerator, tkFunction, tkMacroDef, tkMacroUse, tkNamespace, tkTypedef, tkUndefined, tkVariable, BrowserOptions::treeMembers, wxEmptyString, wxGetKeyState(), WXK_CONTROL, and WXK_SHIFT.
Referenced by OnTreeItemRightClick().
|
private |
create a thread to update the symbol tree, if the thread is already created, just pause and resume the thread.
Definition at line 871 of file classbrowser.cpp.
References ParserBase::ClassBrowserOptions(), wxThread::Create(), ParserBase::GetTokenTree(), idThreadEvent, ClassBrowserBuilderThread::Init(), wxThread::IsAlive(), Manager::IsAppShuttingDown(), wxThread::IsPaused(), wxThread::IsRunning(), m_ActiveFilename, m_CCTreeCtrl, m_CCTreeCtrlBottom, m_ClassBrowserBuilderThread, m_ClassBrowserSemaphore, m_NativeParser, m_Parser, wxThread::Pause(), wxSemaphore::Post(), wxThread::Resume(), wxThread::Run(), TRACE, wxMilliSleep(), and wxT.
Referenced by UpdateClassBrowserView().
void ClassBrowser::UpdateClassBrowserView | ( | bool | checkHeaderSwap = false | ) |
update or refresh the symbol browser trees
There are many cases the tree need to be updated. E.g. if the View option of the tree is the "Current file's symbols", the user switch the editor to a new source file, then the tree should be updated(rebuild).
checkHeaderSwap | if true, we should check if the new editor opened has the same base file as the old file. E.g. If you are currently viewing a file named A.cpp, and you switch to A.h in this case, the tree should not be updated, because tokens(symbols) in both files were already shown. False if you need to update the tree without such optimization. |
Definition at line 212 of file classbrowser.cpp.
References _T, wxString::AfterLast(), wxString::BeforeLast(), ParserBase::ClassBrowserOptions(), wxString::Clear(), CCLogger::DebugLog(), wxString::Find(), CCLogger::Get(), Manager::Get(), EditorManager::GetBuiltinActiveEditor(), NativeParser::GetCurrentProject(), Manager::GetEditorManager(), EditorBase::GetFilename(), NativeParser::GetProjectByParser(), Manager::IsAppShuttingDown(), NativeParser::IsParserPerWorkspace(), wxString::IsSameAs(), m_ActiveFilename, m_CCTreeCtrl, m_CCTreeCtrlBottom, m_NativeParser, m_Parser, wxSplitterWindow::SplitHorizontally(), ThreadedBuildTree(), TRACE, BrowserOptions::treeMembers, wxSplitterWindow::Unsplit(), wxString::wx_str(), wxNOT_FOUND, and wxT.
Referenced by OnCBExpandNS(), OnCBViewMode(), NativeParser::OnEditorActivated(), OnRefreshTree(), OnSetSortType(), OnViewScope(), SetParser(), and NativeParser::UpdateClassBrowser().
void ClassBrowser::UpdateSash | ( | ) |
update the position sash bar between top tree and the bottom tree, the position (percentage) of the two trees are saved in the C::B's configuration file.
Definition at line 205 of file classbrowser.cpp.
References _T, Manager::Get(), Manager::GetConfigManager(), and ConfigManager::ReadInt().
Referenced by NativeParser::CreateClassBrowser().
|
private |
source file name of active editor, used for filtering(if view option is Current file's symbols)
Definition at line 210 of file classbrowser.h.
Referenced by ThreadedBuildTree(), and UpdateClassBrowserView().
|
private |
the top(main) level tree control, see above diagram for details
Definition at line 195 of file classbrowser.h.
Referenced by FindChild(), OnSearch(), ShowMenu(), ThreadedBuildTree(), and UpdateClassBrowserView().
|
private |
the bottom tree control, mainly used to show the member variable and member functions
Definition at line 198 of file classbrowser.h.
Referenced by OnSearch(), ThreadedBuildTree(), and UpdateClassBrowserView().
|
private |
a wxThread used to build the wxTreeCtrl for the top and bottom in the class(symbol) browser because it always take many seconds to build the trees, so those work were delegated to a worker thread.
Definition at line 221 of file classbrowser.h.
Referenced by OnThreadEvent(), OnTreeItemCollapsing(), OnTreeItemExpanding(), OnTreeSelChanged(), ThreadedBuildTree(), and ~ClassBrowser().
|
private |
semaphore to synchronize the GUI(class browser) and the tree builder thread, when the GUI post the semaphore, the waiting thread start doing the job
Definition at line 215 of file classbrowser.h.
Referenced by ThreadedBuildTree(), and ~ClassBrowser().
|
private |
the pointer to parser manager object
Definition at line 192 of file classbrowser.h.
Referenced by OnForceReparse(), OnJumpTo(), OnTreeItemDoubleClick(), OnViewScope(), SetParser(), ThreadedBuildTree(), and UpdateClassBrowserView().
|
private |
a pointer to the associated parser object
Definition at line 207 of file classbrowser.h.
Referenced by OnCBExpandNS(), OnCBViewMode(), OnJumpTo(), OnSearch(), OnSetSortType(), OnThreadEvent(), OnTreeItemDoubleClick(), OnTreeSelChanged(), OnViewScope(), SetParser(), ShowMenu(), ThreadedBuildTree(), and UpdateClassBrowserView().
|
private |
the search combobox in the header of the window
Definition at line 204 of file classbrowser.h.
Referenced by OnSearch().
|
private |
remember the context menu is created from which tree control, the upper or the bottom
Definition at line 201 of file classbrowser.h.
Referenced by OnJumpTo(), and ShowMenu().