48 #define CC_CLASS_BROWSER_DEBUG_OUTPUT 0 50 #if defined(CC_GLOBAL_DEBUG_OUTPUT) 51 #if CC_GLOBAL_DEBUG_OUTPUT == 1 52 #undef CC_CLASS_BROWSER_DEBUG_OUTPUT 53 #define CC_CLASS_BROWSER_DEBUG_OUTPUT 1 54 #elif CC_GLOBAL_DEBUG_OUTPUT == 2 55 #undef CC_CLASS_BROWSER_DEBUG_OUTPUT 56 #define CC_CLASS_BROWSER_DEBUG_OUTPUT 2 60 #if CC_CLASS_BROWSER_DEBUG_OUTPUT == 1 61 #define TRACE(format, args...) \ 62 CCLogger::Get()->DebugLog(F(format, ##args)) 63 #define TRACE2(format, args...) 64 #elif CC_CLASS_BROWSER_DEBUG_OUTPUT == 2 65 #define TRACE(format, args...) \ 68 if (g_EnableDebugTrace) \ 69 CCLogger::Get()->DebugLog(F(format, ##args)); \ 72 #define TRACE2(format, args...) \ 73 CCLogger::Get()->DebugLog(F(format, ##args)) 75 #define TRACE(format, args...) 76 #define TRACE2(format, args...) 103 #ifndef CC_NO_COLLAPSE_ITEM 105 #endif // CC_NO_COLLAPSE_ITEM 134 m_TreeForPopupMenu(0),
136 m_ClassBrowserSemaphore( 0, 1),
137 m_ClassBrowserBuilderThread(0)
140 m_Search = XRCCTRL(*
this,
"cmbSearch",
wxComboBox);
142 if (platform::windows)
146 m_CCTreeCtrl = XRCCTRL(*
this,
"treeAll",
CCTreeCtrl);
147 m_CCTreeCtrlBottom = XRCCTRL(*
this,
"treeMembers",
CCTreeCtrl);
151 XRCCTRL(*
this,
"cmbView",
wxChoice)->SetSelection(filter);
163 int pos = XRCCTRL(*
this,
"splitterWin",
wxSplitterWindow)->GetSashPosition();
192 int sel = XRCCTRL(*
this,
"cmbView",
wxChoice)->GetSelection();
208 XRCCTRL(*
this,
"splitterWin",
wxSplitterWindow)->SetSashPosition(pos,
false);
237 if ( oldShortName.
IsSameAs(newShortName) )
239 TRACE(
_T(
"ClassBrowser::UpdateClassBrowserView() match the old filename, return!"));
294 menu->
Append(idMenuJumpToImplementation,
_(
"Jump to &implementation"));
308 menu->
Append(idMenuJumpToDeclaration,
_(
"Jump to &declaration"));
321 menu->
Append (idMenuRefreshTree,
_(
"&Refresh tree"));
326 menu->
Append(idMenuForceReparse,
_(
"Re-parse now"));
351 menu->
Check(idCBSortByAlpabet,
true);
354 menu->
Check(idCBSortByKind,
true);
357 menu->
Check(idCBSortByScope,
true);
360 menu->
Check(idCBSortByLine,
true);
364 menu->
Check(idCBNoSort,
true);
413 wxTreeItemIdValue cookie;
418 if ( (!partialMatch && text == search)
419 || ( partialMatch && text.
StartsWith(search)) )
426 res =
FindChild(search, tree, res,
true, partialMatch);
438 if (!parent.
IsOk() || !tree)
448 wxTreeItemIdValue cookie;
515 for (
size_t i = 0; i < incDirs.
GetCount(); ++i)
611 for (
size_t i = 0; i < incDirs.
GetCount(); ++i)
655 options.
expandNS = event.IsChecked();
677 int sel =
event.GetSelection();
683 cbMessageBox(
_(
"This feature is not supported in combination with\n" 684 "the option \"one parser per whole workspace\"."),
687 XRCCTRL(*
this,
"cmbView",
wxChoice)->SetSelection(filter);
739 count = tree->
FindMatches(search, result,
false,
true);
744 const Token* token = 0;
755 token = tree->
at(*result.begin());
763 for (TokenIdxSet::iterator it = result.begin(); it != result.end(); ++it)
767 const Token* sel = tree->
at(*it);
771 int_selections.Add(*it);
785 token = tree->
at(int_selections[sel]);
789 else if (selections.
GetCount() == 1)
795 token = tree->
at(int_selections[0]);
811 wxTreeItemIdValue cookie;
837 while (tkz.HasMoreTokens())
876 TRACE(
wxT(
"ClassBrowser: ThreadedBuildTree started."));
879 bool thread_needs_run =
false;
884 thread_needs_run =
true;
887 if (!thread_needs_run)
889 TRACE(
wxT(
"ClassBrowser: Pausing ClassBrowserBuilderThread..."));
894 bool thread_needs_resume =
false;
895 while ( !thread_needs_run
900 thread_needs_resume =
true;
908 if (thread_needs_resume)
910 TRACE(
wxT(
"ClassBrowser: ClassBrowserBuilderThread: Paused."));
924 if (thread_needs_run)
926 TRACE(
wxT(
"ClassBrowser: Run ClassBrowserBuilderThread."));
930 else if (thread_needs_resume)
935 TRACE(
wxT(
"ClassBrowser: Resume ClassBrowserBuilderThread."));
946 #ifndef CC_NO_COLLAPSE_ITEM 948 #endif // CC_NO_COLLAPSE_ITEM 951 #ifndef CC_NO_COLLAPSE_ITEM 958 #endif // CC_NO_COLLAPSE_ITEM 967 #ifndef CC_NO_COLLAPSE_ITEM 969 #endif // CC_NO_COLLAPSE_ITEM
virtual wxTreeItemId GetNextChild(const wxTreeItemId &item, wxTreeItemIdValue &cookie) const
wxString AfterLast(wxUniChar ch) const
virtual BrowserOptions & ClassBrowserOptions()
destructor class member function
EThreadEvent
the builder threads' event sent to the GUI(class browser window)
BrowserSortType
specify the sort order of the symbol tree nodes
void OnViewScope(wxCommandEvent &event)
the view scope choice has changed, user can switch between view everything, view a single file...
int m_ParentIndex
Parent Token index.
constructor class member function
wxSemaphore m_ClassBrowserSemaphore
semaphore to synchronize the GUI(class browser) and the tree builder thread, when the GUI post the se...
void UpdateSash()
update the position sash bar between top tree and the bottom tree, the position (percentage) of the t...
virtual void WriteOptions()
write Parse options to configure file
virtual wxTreeItemId GetItemParent(const wxTreeItemId &item) const
ClassBrowserBuilderThread * m_ClassBrowserBuilderThread
a wxThread used to build the wxTreeCtrl for the top and bottom in the class(symbol) browser because i...
void Init(NativeParser *np, CCTreeCtrl *treeTop, CCTreeCtrl *treeBottom, const wxString &active_filename, void *user_data, const BrowserOptions &bo, TokenTree *tt, int idThreadEvent)
void Assign(const wxFileName &filepath)
ConfigManager * GetConfigManager(const wxString &name_space) const
int ReadInt(const wxString &name, int defaultVal=0)
virtual bool SplitHorizontally(wxWindow *window1, wxWindow *window2, int sashPosition=0)
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
wxString m_Name
Token's name, it can be searched in the TokenTree.
unsigned int m_ImplLine
function implementation line index
typedef, note typedefs are stored as classes inheriting from the typedef'd type, this takes advantage...
static bool IsAppShuttingDown()
CCTreeCtrl * m_CCTreeCtrl
the top(main) level tree control, see above diagram for details
void OnThreadEvent(wxCommandEvent &event)
class browser builder thread will send notification event to the parent, this is the event handler fu...
container like tokens, those tokens can have children tokens
void OnDebugSmartSense(wxCommandEvent &event)
whether print the debug log message
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 ...
wxString GetFilename() const
get a full path of the file which contains the current Token
bool GotoTokenPosition(int line, const wxString &tokenName)
Move the caret at the specified line.
#define wxTE_PROCESS_ENTER
DLLIMPORT bool NormalizePath(wxFileName &f, const wxString &base)
virtual wxTreeItemId GetSelection() const
SpecialFolder m_SpecialFolder
the node's kind, it could be "root", "normal token",
a container class to hold all the Tokens getting from parsing stage
bool showInheritance
whether the base class or derive class information is shown as a child node default: false ...
worker thread to build the symbol browser tree controls(both the top tree and the bottom tree) When t...
DLLIMPORT int cbGetSingleChoiceIndex(const wxString &message, const wxString &caption, const wxArrayString &choices, wxWindow *parent=NULL, const wxSize &size=wxSize(300, 300), int initialSelection=0)
void UpdateClassBrowserView(bool checkHeaderSwap=false)
update or refresh the symbol browser trees
unsigned int m_Line
Line index where the token was met, which is 1 based.
the thread is starting to (re)build the tree
wxString BeforeLast(wxUniChar ch, wxString *rest=NULL) const
wxThreadError Create(unsigned int stackSize=0)
ParserBase * m_Parser
a pointer to the associated parser object
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
void ThreadedBuildTree(cbProject *activeProject)
create a thread to update the symbol tree, if the thread is already created, just pause and resume th...
#define wxICON_INFORMATION
virtual wxTreeItemData * GetItemData(const wxTreeItemId &item) const
wxString GetNamespace() const
get a literal string presentation of the namespace.
virtual wxString GetItemText(const wxTreeItemId &item) const
cbProject * GetCurrentProject()
Get current project by active editor or just return active project.
wxString DisplayName() const
a short simple string to show the token information, this usually generate for show the tip message w...
void OnTreeItemDoubleClick(wxTreeEvent &event)
handler for the mouse double click on a tree item, we usually make a jump to the associated token's p...
void DebugLog(const wxString &msg)
void RequestTermination(bool terminate=true)
ask the worker thread to die Called from external: when the class browser window get destroyed ...
wxPanel * LoadPanel(wxWindow *parent, const wxString &name)
wxTreeItemId GetItem() const
EditorManager * GetEditorManager() const
NativeParser * m_NativeParser
the pointer to parser manager object
void OnForceReparse(wxCommandEvent &event)
reparse the current project
cbProject * GetProjectByParser(ParserBase *parser)
return the C::B project associated with Parser pointer
bool expandNS
whether a namespaces node is auto-expand auto-expand means the child of the namespace is automaticall...
const wxArrayString & GetIncludeDirs() const
Tree data associate with the symbol tree item.
virtual wxTreeItemId GetFirstChild(const wxTreeItemId &item, wxTreeItemIdValue &cookie) const
void Write(const wxString &name, const wxString &value, bool ignoreEmpty=false)
virtual const wxString & GetFilename() const
Get the editor's filename (if applicable).
wxString m_ActiveFilename
source file name of active editor, used for filtering(if view option is Current file's symbols) ...
void OnCBViewMode(wxCommandEvent &event)
user change the view mode (View Inheritance or View the bottom tree)
CCTreeCtrl * m_CCTreeCtrlBottom
the bottom tree control, mainly used to show the member variable and member functions ...
Represents a Code::Blocks project.
display symbols of current project
void OnTreeItemRightClick(wxTreeEvent &event)
show a context menu
a symbol found in the parsed files, it can be many kinds, such as a variable, a class and so on...
void OnRefreshTree(wxCommandEvent &event)
force rebuilding the tree
void OnJumpTo(wxCommandEvent &event)
the handler for jump to declaration or jump to definition menu item
std::set< int, std::less< int > > TokenIdxSet
display symbols of current file
Token * m_Token
a pointer to the associated Token instance in the TokenTree
virtual void SelectItem(const wxTreeItemId &item, bool select=true)
ExitCode Wait(wxThreadWait flags=wxTHREAD_WAIT_BLOCK)
void OnSetSortType(wxCommandEvent &event)
sort type changed
Options for the symbol browser, this specify how the symbol browser will shown.
cbEditor * GetBuiltinActiveEditor()
void OnCBExpandNS(wxCommandEvent &event)
whether automatically expand the namespace option switch
bool IsSameAs(const wxString &s, bool caseSensitive=true) const
static wxColour GetColour(wxSystemColour index)
wxString & Item(size_t nIndex)
bool Unsplit(wxWindow *toRemove=NULL)
virtual wxString GetBasePath() const
Read the target's base path, e.g. if GetFilename() returns "/usr/local/bin/xxx", base path will retur...
wxEventType wxEVT_COMMAND_ENTER
#define CC_LOCKER_TRACK_TT_MTX_UNLOCK(M)
const wxStringCharType * wx_str() const
void ReparseCurrentProject()
re-parse the active Parser (the project associated with m_Parser member variable
bool s_DebugSmartSense
if this option is enabled, there will be many log messages when doing semantic match ...
symbol browser panel is shown in the Management panel besides projects browser panel.
void CollapseItem(wxTreeItemId item)
remove the children of the tree item Called from external, BuildTree(), RemoveInvalidNodes(): ...
cbEditor * Open(const wxString &filename, int pos=0, ProjectFile *data=nullptr)
const wxString & _(const wxString &string)
#define CC_LOCKER_TRACK_TT_MTX_LOCK(M)
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
wxArray< int > wxArrayInt
NativeParser class is just like a manager class to control Parser objects.
virtual void Expand(const wxTreeItemId &item)
Actual data stored with each node in the symbol tree.
BrowserDisplayFilter displayFilter
token filter option
BrowserDisplayFilter
specify the scope of the shown symbols
bool treeMembers
show members in the bottom tree.
void SelectItemRequired()
virtual wxTreeItemId GetNextSibling(const wxTreeItemId &item) const
void SelectItem(wxTreeItemId item)
TokenKind m_TokenKind
See TokenKind class.
void wxMilliSleep(unsigned long milliseconds)
void OnTreeItemExpanding(wxTreeEvent &event)
expanding one node of top tree
general function, not constructor nor destructor
size_t Add(const wxString &str, size_t copies=1)
void OnTreeItemCollapsing(wxTreeEvent &event)
collapse one node of the top tree
BrowserSortType sortType
token sort option in the tree default: bstKind
bool StartsWith(const wxString &prefix, wxString *rest=NULL) const
virtual ~ClassBrowser()
class destructor
virtual wxTreeItemId GetRootItem() const
public, protected, private
bool FoundMatch(const wxString &search, wxTreeCtrl *tree, const wxTreeItemId &item)
string compare between the search and the token's name associated with item
size_t FindMatches(const wxString &query, TokenIdxSet &result, bool caseSensitive, bool is_prefix, TokenKind kindMask=tkUndefined)
find a collection of matched tokens
int Find(wxUniChar ch, bool fromEnd=false) const
virtual TokenTree * GetTokenTree() const
static wxXmlResource * Get()
int idThreadEvent
the event ID which will be sent from worker thread to ClassBrowser
macro definition, such as: #define AAA(x,y) f(x,y), where AAA is a token of tkMacroDef ...
wxString GetImplFilename() const
get a full path of the file which contains the function implementation.
void ExpandItem(wxTreeItemId item)
construct the children of the tree item Called from external, BuildTree():
wxString GetFullPath(wxPathFormat format=wxPATH_NATIVE) const
bool IsParserPerWorkspace() const
Return true if use one Parser per whole workspace.
bool wxGetKeyState(wxKeyCode key)
#define TRACE(format, args...)
DLLIMPORT int cbMessageBox(const wxString &message, const wxString &caption=wxEmptyString, int style=wxOK, wxWindow *parent=NULL, int x=-1, int y=-1)
wxMessageBox wrapper.
virtual bool ItemHasChildren(const wxTreeItemId &item) const
wxComboBox * m_Search
the search combobox in the header of the window
void OnSearch(wxCommandEvent &event)
when user try to search a word in the symbols tree
void SetParser(ParserBase *parser)
Set the Parser object associated with the class browser.
the usage of the macro, for example: AAA(1,2)
void OnTreeSelChanged(wxTreeEvent &event)
item selection changed in the top tree