2
* This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3
* http://www.gnu.org/licenses/gpl-3.0.html
6
* $Id: ccdebuginfo.cpp 10265 2015-05-15 10:56:43Z jenslody $
7
* $HeadURL: http://svn.code.sf.net/p/codeblocks/code/branches/release-16.xx/src/plugins/codecompletion/parser/ccdebuginfo.cpp $
13
#include <wx/object.h>
14
#include <wx/string.h>
15
#include <wx/choicdlg.h> // wxGetSingleChoiceIndex
17
#include <wx/filedlg.h>
18
#include <wx/utils.h> // wxWindowDisabler
20
//(*InternalHeaders(CCDebugInfo)
21
#include <wx/string.h>
26
#include <editormanager.h>
27
#include <logmanager.h>
30
#include <wx/busyinfo.h>
31
#include <wx/tokenzr.h>
33
#include "ccdebuginfo.h"
36
#define CC_DEBUGINFO_DEBUG_OUTPUT 0
38
#if defined(CC_GLOBAL_DEBUG_OUTPUT)
39
#if CC_GLOBAL_DEBUG_OUTPUT == 1
40
#undef CC_DEBUGINFO_DEBUG_OUTPUT
41
#define CC_DEBUGINFO_DEBUG_OUTPUT 1
42
#elif CC_GLOBAL_DEBUG_OUTPUT == 2
43
#undef CC_DEBUGINFO_DEBUG_OUTPUT
44
#define CC_DEBUGINFO_DEBUG_OUTPUT 2
48
#if CC_DEBUGINFO_DEBUG_OUTPUT == 1
49
#define TRACE(format, args...) \
50
CCLogger::Get()->DebugLog(F(format, ##args))
51
#define TRACE2(format, args...)
52
#elif CC_DEBUGINFO_DEBUG_OUTPUT == 2
53
#define TRACE(format, args...) \
56
if (g_EnableDebugTrace) \
57
CCLogger::Get()->DebugLog(F(format, ##args)); \
60
#define TRACE2(format, args...) \
61
CCLogger::Get()->DebugLog(F(format, ##args))
63
#define TRACE(format, args...)
64
#define TRACE2(format, args...)
67
namespace CCDebugInfoHelper
69
inline void SaveCCDebugInfo(const wxString& fileDesc, const wxString& content)
72
wxFileDialog dlg (Manager::Get()->GetAppWindow(),
76
_T("Text files (*.txt)|*.txt|Any file (*)|*"),
77
wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
79
if (dlg.ShowModal() != wxID_OK)
82
// Opening the file migth have failed, verify:
83
wxFile f(dlg.GetPath(), wxFile::write);
86
f.Write(content); // write buffer to file
87
f.Close(); // release file handle
90
cbMessageBox(_("Cannot create file ") + fname, _("CC Debug Info"));
92
}// namespace CCDebugInfoHelper
94
//(*IdInit(CCDebugInfo)
95
const long CCDebugInfo::ID_TEXTCTRL1 = wxNewId();
96
const long CCDebugInfo::ID_BUTTON1 = wxNewId();
97
const long CCDebugInfo::ID_STATICTEXT18 = wxNewId();
98
const long CCDebugInfo::ID_STATICTEXT2 = wxNewId();
99
const long CCDebugInfo::ID_STATICTEXT10 = wxNewId();
100
const long CCDebugInfo::ID_STATICTEXT12 = wxNewId();
101
const long CCDebugInfo::ID_STATICTEXT4 = wxNewId();
102
const long CCDebugInfo::ID_STATICTEXT6 = wxNewId();
103
const long CCDebugInfo::ID_STATICTEXT8 = wxNewId();
104
const long CCDebugInfo::ID_STATICTEXT37 = wxNewId();
105
const long CCDebugInfo::ID_STATICTEXT41 = wxNewId();
106
const long CCDebugInfo::ID_STATICTEXT14 = wxNewId();
107
const long CCDebugInfo::ID_STATICTEXT16 = wxNewId();
108
const long CCDebugInfo::ID_STATICTEXT33 = wxNewId();
109
const long CCDebugInfo::ID_STATICTEXT39 = wxNewId();
110
const long CCDebugInfo::ID_STATICTEXT1 = wxNewId();
111
const long CCDebugInfo::ID_STATICTEXT20 = wxNewId();
112
const long CCDebugInfo::ID_STATICTEXT24 = wxNewId();
113
const long CCDebugInfo::ID_BUTTON4 = wxNewId();
114
const long CCDebugInfo::ID_COMBOBOX3 = wxNewId();
115
const long CCDebugInfo::ID_BUTTON5 = wxNewId();
116
const long CCDebugInfo::ID_COMBOBOX2 = wxNewId();
117
const long CCDebugInfo::ID_BUTTON3 = wxNewId();
118
const long CCDebugInfo::ID_COMBOBOX1 = wxNewId();
119
const long CCDebugInfo::ID_BUTTON2 = wxNewId();
120
const long CCDebugInfo::ID_STATICTEXT26 = wxNewId();
121
const long CCDebugInfo::ID_BUTTON7 = wxNewId();
122
const long CCDebugInfo::ID_STATICTEXT28 = wxNewId();
123
const long CCDebugInfo::ID_BUTTON8 = wxNewId();
124
const long CCDebugInfo::ID_STATICTEXT35 = wxNewId();
125
const long CCDebugInfo::ID_PANEL1 = wxNewId();
126
const long CCDebugInfo::ID_LISTBOX1 = wxNewId();
127
const long CCDebugInfo::ID_PANEL2 = wxNewId();
128
const long CCDebugInfo::ID_LISTBOX2 = wxNewId();
129
const long CCDebugInfo::ID_PANEL3 = wxNewId();
130
const long CCDebugInfo::ID_LISTBOX3 = wxNewId();
131
const long CCDebugInfo::ID_PANEL4 = wxNewId();
132
const long CCDebugInfo::ID_NOTEBOOK1 = wxNewId();
133
const long CCDebugInfo::ID_BUTTON6 = wxNewId();
136
BEGIN_EVENT_TABLE(CCDebugInfo,wxScrollingDialog)
137
//(*EventTable(CCDebugInfo)
141
CCDebugInfo::CCDebugInfo(wxWindow* parent, ParserBase* parser, Token* token) :
145
//(*Initialize(CCDebugInfo)
146
wxStaticText* lblParent;
147
wxFlexGridSizer* FlexGridSizer1;
148
wxStaticText* lblArgs;
150
wxBoxSizer* BoxSizer3;
151
wxStaticLine* StaticLine2;
152
wxButton* btnGoParent;
154
wxBoxSizer* BoxSizer10;
155
wxStaticText* lblIsOp;
156
wxStaticText* lblName;
157
wxBoxSizer* BoxSizer7;
158
wxStaticText* lblKind;
159
wxStaticText* lblAncestors;
160
wxBoxSizer* BoxSizer13;
161
wxStaticText* lblDescendants;
162
wxBoxSizer* BoxSizer2;
165
wxStaticText* lblIsConst;
166
wxBoxSizer* BoxSizer9;
167
wxStaticText* lblIsLocal;
169
wxStaticLine* StaticLine1;
170
wxBoxSizer* BoxSizer4;
171
wxStaticText* lblChildren;
173
wxStaticText* lblImplfile;
174
wxBoxSizer* BoxSizer8;
176
wxBoxSizer* BoxSizer1;
177
wxStaticText* lblIsTemp;
178
wxStaticText* lblScope;
179
wxNotebook* Notebook1;
180
wxStaticText* lblArgsStripped;
181
wxStaticText* lblFullType;
182
wxStaticText* lblDeclFile;
184
wxStaticText* lblNameSpace;
185
wxStaticText* lblUserData;
187
wxStaticText* StaticText29;
188
wxStaticText* lblTemplateArg;
189
wxBoxSizer* BoxSizer6;
190
wxStdDialogButtonSizer* StdDialogButtonSizer1;
191
wxButton* btnGoChildren;
192
wxStaticText* lblBaseType;
193
wxStaticText* lblIsNoExcept;
195
Create(parent, wxID_ANY, _("Code-completion debug tool"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL, _T("wxID_ANY"));
196
BoxSizer1 = new wxBoxSizer(wxVERTICAL);
197
Notebook1 = new wxNotebook(this, ID_NOTEBOOK1, wxDefaultPosition, wxDefaultSize, 0, _T("ID_NOTEBOOK1"));
198
Panel1 = new wxPanel(Notebook1, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
199
BoxSizer2 = new wxBoxSizer(wxVERTICAL);
200
BoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
201
StaticText29 = new wxStaticText(Panel1, wxID_ANY, _("Find:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
202
BoxSizer4->Add(StaticText29, 0, wxALIGN_CENTER_VERTICAL, 5);
203
txtFilter = new wxTextCtrl(Panel1, ID_TEXTCTRL1, _("*"), wxDefaultPosition, wxSize(401,21), 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
204
BoxSizer4->Add(txtFilter, 1, wxLEFT|wxALIGN_CENTER_VERTICAL, 5);
205
btnFind = new wxButton(Panel1, ID_BUTTON1, _("Find"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
206
btnFind->SetDefault();
207
BoxSizer4->Add(btnFind, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 5);
208
BoxSizer2->Add(BoxSizer4, 0, wxTOP|wxLEFT|wxRIGHT|wxEXPAND, 5);
209
StaticLine1 = new wxStaticLine(Panel1, wxID_ANY, wxDefaultPosition, wxSize(10,-1), wxLI_HORIZONTAL, _T("wxID_ANY"));
210
BoxSizer2->Add(StaticLine1, 0, wxALL|wxEXPAND, 5);
211
FlexGridSizer1 = new wxFlexGridSizer(0, 2, 5, 5);
212
FlexGridSizer1->AddGrowableCol(1);
213
lblID = new wxStaticText(Panel1, wxID_ANY, _("ID:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
214
FlexGridSizer1->Add(lblID, 0, wxALIGN_TOP, 0);
215
txtID = new wxStaticText(Panel1, ID_STATICTEXT18, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT18"));
216
FlexGridSizer1->Add(txtID, 0, wxALIGN_TOP, 0);
217
lblName = new wxStaticText(Panel1, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
218
FlexGridSizer1->Add(lblName, 0, wxALIGN_TOP, 0);
219
txtName = new wxStaticText(Panel1, ID_STATICTEXT2, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
220
FlexGridSizer1->Add(txtName, 0, wxALIGN_TOP, 0);
221
lblKind = new wxStaticText(Panel1, wxID_ANY, _("Kind:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
222
FlexGridSizer1->Add(lblKind, 0, wxALIGN_TOP, 0);
223
txtKind = new wxStaticText(Panel1, ID_STATICTEXT10, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT10"));
224
FlexGridSizer1->Add(txtKind, 0, wxALIGN_TOP, 0);
225
lblScope = new wxStaticText(Panel1, wxID_ANY, _("Scope:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
226
FlexGridSizer1->Add(lblScope, 0, wxALIGN_TOP, 0);
227
txtScope = new wxStaticText(Panel1, ID_STATICTEXT12, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT12"));
228
FlexGridSizer1->Add(txtScope, 0, wxALIGN_TOP, 0);
229
lblFullType = new wxStaticText(Panel1, wxID_ANY, _("Full type:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
230
FlexGridSizer1->Add(lblFullType, 0, wxALIGN_TOP, 0);
231
txtFullType = new wxStaticText(Panel1, ID_STATICTEXT4, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
232
FlexGridSizer1->Add(txtFullType, 0, wxALIGN_TOP, 0);
233
lblBaseType = new wxStaticText(Panel1, wxID_ANY, _("Base type:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
234
FlexGridSizer1->Add(lblBaseType, 0, wxALIGN_TOP, 0);
235
txtBaseType = new wxStaticText(Panel1, ID_STATICTEXT6, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
236
FlexGridSizer1->Add(txtBaseType, 0, wxALIGN_TOP, 0);
237
lblArgs = new wxStaticText(Panel1, wxID_ANY, _("Arguments:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
238
FlexGridSizer1->Add(lblArgs, 0, wxALIGN_TOP, 0);
239
txtArgs = new wxStaticText(Panel1, ID_STATICTEXT8, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT8"));
240
FlexGridSizer1->Add(txtArgs, 0, wxALIGN_TOP, 0);
241
lblArgsStripped = new wxStaticText(Panel1, wxID_ANY, _("Arguments (str.):"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
242
FlexGridSizer1->Add(lblArgsStripped, 0, wxALIGN_TOP, 0);
243
txtArgsStripped = new wxStaticText(Panel1, ID_STATICTEXT37, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT37"));
244
FlexGridSizer1->Add(txtArgsStripped, 0, wxALIGN_TOP, 0);
245
lblTemplateArg = new wxStaticText(Panel1, wxID_ANY, _("Templ. args:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
246
FlexGridSizer1->Add(lblTemplateArg, 0, wxALIGN_TOP, 0);
247
txtTemplateArg = new wxStaticText(Panel1, ID_STATICTEXT41, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT41"));
248
FlexGridSizer1->Add(txtTemplateArg, 0, wxALIGN_TOP, 0);
249
lblIsOp = new wxStaticText(Panel1, wxID_ANY, _("Is operator\?"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
250
FlexGridSizer1->Add(lblIsOp, 0, wxALIGN_TOP, 0);
251
txtIsOp = new wxStaticText(Panel1, ID_STATICTEXT14, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT14"));
252
FlexGridSizer1->Add(txtIsOp, 0, wxALIGN_TOP, 0);
253
lblIsLocal = new wxStaticText(Panel1, wxID_ANY, _("Is local\?"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
254
FlexGridSizer1->Add(lblIsLocal, 0, wxALIGN_TOP, 0);
255
txtIsLocal = new wxStaticText(Panel1, ID_STATICTEXT16, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT16"));
256
FlexGridSizer1->Add(txtIsLocal, 0, wxALIGN_TOP, 0);
257
lblIsTemp = new wxStaticText(Panel1, wxID_ANY, _("Is temp\?"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
258
FlexGridSizer1->Add(lblIsTemp, 0, wxALIGN_TOP, 0);
259
txtIsTemp = new wxStaticText(Panel1, ID_STATICTEXT33, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT33"));
260
FlexGridSizer1->Add(txtIsTemp, 0, wxALIGN_TOP, 0);
261
lblIsConst = new wxStaticText(Panel1, wxID_ANY, _("Is const\?"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
262
FlexGridSizer1->Add(lblIsConst, 0, wxALIGN_TOP, 0);
263
txtIsConst = new wxStaticText(Panel1, ID_STATICTEXT39, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT39"));
264
FlexGridSizer1->Add(txtIsConst, 0, wxALIGN_TOP, 0);
265
lblIsNoExcept = new wxStaticText(Panel1, wxID_ANY, _("Is noexcept\?"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
266
FlexGridSizer1->Add(lblIsNoExcept, 0, wxALIGN_TOP, 0);
267
txtIsNoExcept = new wxStaticText(Panel1, ID_STATICTEXT1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
268
FlexGridSizer1->Add(txtIsNoExcept, 0, wxALIGN_TOP, 0);
269
lblNameSpace = new wxStaticText(Panel1, wxID_ANY, _("Namespace:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
270
FlexGridSizer1->Add(lblNameSpace, 0, wxALIGN_TOP, 0);
271
txtNamespace = new wxStaticText(Panel1, ID_STATICTEXT20, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT20"));
272
FlexGridSizer1->Add(txtNamespace, 0, wxALIGN_TOP, 0);
273
lblParent = new wxStaticText(Panel1, wxID_ANY, _("Parent:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
274
FlexGridSizer1->Add(lblParent, 0, wxALIGN_CENTER_VERTICAL, 0);
275
BoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
276
txtParent = new wxStaticText(Panel1, ID_STATICTEXT24, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT24"));
277
BoxSizer7->Add(txtParent, 1, wxALIGN_CENTER_VERTICAL, 0);
278
btnGoParent = new wxButton(Panel1, ID_BUTTON4, _("Go"), wxDefaultPosition, wxSize(36,23), 0, wxDefaultValidator, _T("ID_BUTTON4"));
279
BoxSizer7->Add(btnGoParent, 0, wxALIGN_CENTER_VERTICAL, 0);
280
FlexGridSizer1->Add(BoxSizer7, 0, wxEXPAND, 0);
281
lblChildren = new wxStaticText(Panel1, wxID_ANY, _("Children:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
282
FlexGridSizer1->Add(lblChildren, 0, wxALIGN_CENTER_VERTICAL, 0);
283
BoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
284
cmbChildren = new wxComboBox(Panel1, ID_COMBOBOX3, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_READONLY, wxDefaultValidator, _T("ID_COMBOBOX3"));
285
BoxSizer8->Add(cmbChildren, 1, wxALIGN_CENTER_VERTICAL, 0);
286
btnGoChildren = new wxButton(Panel1, ID_BUTTON5, _("Go"), wxDefaultPosition, wxSize(36,23), 0, wxDefaultValidator, _T("ID_BUTTON5"));
287
BoxSizer8->Add(btnGoChildren, 0, wxALIGN_CENTER_VERTICAL, 0);
288
FlexGridSizer1->Add(BoxSizer8, 0, wxEXPAND, 0);
289
lblAncestors = new wxStaticText(Panel1, wxID_ANY, _("Ancestors:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
290
FlexGridSizer1->Add(lblAncestors, 0, wxALIGN_CENTER_VERTICAL, 0);
291
BoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
292
cmbAncestors = new wxComboBox(Panel1, ID_COMBOBOX2, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_READONLY, wxDefaultValidator, _T("ID_COMBOBOX2"));
293
BoxSizer6->Add(cmbAncestors, 1, wxALIGN_CENTER_VERTICAL, 0);
294
btnGoAsc = new wxButton(Panel1, ID_BUTTON3, _("Go"), wxDefaultPosition, wxSize(36,23), 0, wxDefaultValidator, _T("ID_BUTTON3"));
295
BoxSizer6->Add(btnGoAsc, 0, wxALIGN_CENTER_VERTICAL, 0);
296
FlexGridSizer1->Add(BoxSizer6, 0, wxEXPAND, 0);
297
lblDescendants = new wxStaticText(Panel1, wxID_ANY, _("Descendants:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
298
FlexGridSizer1->Add(lblDescendants, 0, wxALIGN_CENTER_VERTICAL, 0);
299
BoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
300
cmbDescendants = new wxComboBox(Panel1, ID_COMBOBOX1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_READONLY, wxDefaultValidator, _T("ID_COMBOBOX1"));
301
BoxSizer5->Add(cmbDescendants, 1, wxALIGN_CENTER_VERTICAL, 0);
302
btnGoDesc = new wxButton(Panel1, ID_BUTTON2, _("Go"), wxDefaultPosition, wxSize(36,23), 0, wxDefaultValidator, _T("ID_BUTTON2"));
303
BoxSizer5->Add(btnGoDesc, 0, wxALIGN_CENTER_VERTICAL, 0);
304
FlexGridSizer1->Add(BoxSizer5, 0, wxEXPAND, 0);
305
lblDeclFile = new wxStaticText(Panel1, wxID_ANY, _("Decl. filename:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
306
FlexGridSizer1->Add(lblDeclFile, 0, wxALIGN_TOP, 0);
307
BoxSizer11 = new wxBoxSizer(wxHORIZONTAL);
308
txtDeclFile = new wxStaticText(Panel1, ID_STATICTEXT26, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT26"));
309
BoxSizer11->Add(txtDeclFile, 1, wxALIGN_CENTER_VERTICAL, 0);
310
btnGoDecl = new wxButton(Panel1, ID_BUTTON7, _("Go"), wxDefaultPosition, wxSize(36,23), 0, wxDefaultValidator, _T("ID_BUTTON7"));
311
BoxSizer11->Add(btnGoDecl, 0, wxALIGN_CENTER_VERTICAL, 0);
312
FlexGridSizer1->Add(BoxSizer11, 0, wxEXPAND, 0);
313
lblImplfile = new wxStaticText(Panel1, wxID_ANY, _("Impl. filename:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
314
FlexGridSizer1->Add(lblImplfile, 0, wxALIGN_TOP, 0);
315
BoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
316
txtImplFile = new wxStaticText(Panel1, ID_STATICTEXT28, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT28"));
317
BoxSizer12->Add(txtImplFile, 1, wxALIGN_CENTER_VERTICAL, 0);
318
btnGoImpl = new wxButton(Panel1, ID_BUTTON8, _("Go"), wxDefaultPosition, wxSize(36,23), 0, wxDefaultValidator, _T("ID_BUTTON8"));
319
BoxSizer12->Add(btnGoImpl, 0, wxALIGN_CENTER_VERTICAL, 0);
320
FlexGridSizer1->Add(BoxSizer12, 0, wxEXPAND, 0);
321
lblUserData = new wxStaticText(Panel1, wxID_ANY, _("User data:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
322
FlexGridSizer1->Add(lblUserData, 0, wxALIGN_TOP, 0);
323
txtUserData = new wxStaticText(Panel1, ID_STATICTEXT35, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT35"));
324
FlexGridSizer1->Add(txtUserData, 0, wxALIGN_TOP, 0);
325
BoxSizer2->Add(FlexGridSizer1, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5);
326
Panel1->SetSizer(BoxSizer2);
327
BoxSizer2->Fit(Panel1);
328
BoxSizer2->SetSizeHints(Panel1);
329
Panel2 = new wxPanel(Notebook1, ID_PANEL2, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL2"));
330
BoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
331
lstFiles = new wxListBox(Panel2, ID_LISTBOX1, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_LISTBOX1"));
332
BoxSizer3->Add(lstFiles, 1, wxALL|wxEXPAND, 5);
333
Panel2->SetSizer(BoxSizer3);
334
BoxSizer3->Fit(Panel2);
335
BoxSizer3->SetSizeHints(Panel2);
336
Panel3 = new wxPanel(Notebook1, ID_PANEL3, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL3"));
337
BoxSizer9 = new wxBoxSizer(wxHORIZONTAL);
338
lstDirs = new wxListBox(Panel3, ID_LISTBOX2, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_LISTBOX2"));
339
BoxSizer9->Add(lstDirs, 1, wxALL|wxEXPAND, 5);
340
Panel3->SetSizer(BoxSizer9);
341
BoxSizer9->Fit(Panel3);
342
BoxSizer9->SetSizeHints(Panel3);
343
Panel4 = new wxPanel(Notebook1, ID_PANEL4, wxPoint(170,6), wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL4"));
344
BoxSizer13 = new wxBoxSizer(wxHORIZONTAL);
345
lstMacros = new wxListBox(Panel4, ID_LISTBOX3, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_LISTBOX3"));
346
BoxSizer13->Add(lstMacros, 1, wxALL|wxEXPAND, 5);
347
Panel4->SetSizer(BoxSizer13);
348
BoxSizer13->Fit(Panel4);
349
BoxSizer13->SetSizeHints(Panel4);
350
Notebook1->AddPage(Panel1, _("Tokens"), false);
351
Notebook1->AddPage(Panel2, _("Files list"), false);
352
Notebook1->AddPage(Panel3, _("Search dirs"), false);
353
Notebook1->AddPage(Panel4, _("Predefined macros"), false);
354
BoxSizer1->Add(Notebook1, 1, wxALL|wxEXPAND, 5);
355
BoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
356
txtInfo = new wxStaticText(this, wxID_ANY, _("The parser contains 0 tokens found in 0 files"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
357
BoxSizer10->Add(txtInfo, 1, wxLEFT|wxALIGN_CENTER_VERTICAL, 5);
358
btnSave = new wxButton(this, ID_BUTTON6, _("Save"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON6"));
359
BoxSizer10->Add(btnSave, 0, wxLEFT|wxALIGN_BOTTOM, 5);
360
BoxSizer1->Add(BoxSizer10, 0, wxEXPAND, 5);
361
StaticLine2 = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxSize(10,-1), wxLI_HORIZONTAL, _T("wxID_ANY"));
362
BoxSizer1->Add(StaticLine2, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5);
363
StdDialogButtonSizer1 = new wxStdDialogButtonSizer();
364
StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_CANCEL, _("Close")));
365
StdDialogButtonSizer1->Realize();
366
BoxSizer1->Add(StdDialogButtonSizer1, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxALIGN_CENTER_HORIZONTAL, 5);
368
BoxSizer1->Fit(this);
369
BoxSizer1->SetSizeHints(this);
372
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CCDebugInfo::OnFindClick);
373
Connect(ID_BUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CCDebugInfo::OnGoParentClick);
374
Connect(ID_BUTTON5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CCDebugInfo::OnGoChildrenClick);
375
Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CCDebugInfo::OnGoAscClick);
376
Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CCDebugInfo::OnGoDescClick);
377
Connect(ID_BUTTON7,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CCDebugInfo::OnGoDeclClick);
378
Connect(ID_BUTTON8,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CCDebugInfo::OnGoImplClick);
379
Connect(ID_BUTTON6,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CCDebugInfo::OnSave);
380
Connect(wxID_ANY,wxEVT_INIT_DIALOG,(wxObjectEventFunction)&CCDebugInfo::OnInit);
384
CCDebugInfo::~CCDebugInfo()
386
//(*Destroy(CCDebugInfo)
390
void CCDebugInfo::FillFiles()
392
TokenTree* tree = m_Parser->GetTokenTree();
398
for (size_t i = 0; i < tree->m_FilenameMap.size(); ++i)
400
wxString file = tree->m_FilenameMap.GetString(i);
402
lstFiles->Append(file);
408
void CCDebugInfo::FillDirs()
413
const wxArrayString& dirs = m_Parser->GetIncludeDirs();
414
for (size_t i = 0; i < dirs.GetCount(); ++i)
416
const wxString& file = dirs[i];
418
lstDirs->Append(file);
424
void CCDebugInfo::FillMacros()
429
wxStringTokenizer tknzr(m_Parser->GetPredefinedMacros(), wxT("#"));
430
while ( tknzr.HasMoreTokens() )
432
wxString macro = tknzr.GetNextToken();
433
if (!macro.IsEmpty())
434
lstMacros->Append(wxT("#") + macro);
440
void CCDebugInfo::DisplayTokenInfo()
444
txtID->SetLabel(wxEmptyString);
445
txtName->SetLabel(wxEmptyString);
446
txtKind->SetLabel(wxEmptyString);
447
txtScope->SetLabel(wxEmptyString);
448
txtFullType->SetLabel(wxEmptyString);
449
txtBaseType->SetLabel(wxEmptyString);
450
txtArgs->SetLabel(wxEmptyString);
451
txtArgsStripped->SetLabel(wxEmptyString);
452
txtTemplateArg->SetLabel(wxEmptyString);
453
txtIsOp->SetLabel(wxEmptyString);
454
txtIsLocal->SetLabel(wxEmptyString);
455
txtNamespace->SetLabel(wxEmptyString);
456
txtParent->SetLabel(wxEmptyString);
457
cmbChildren->Clear();
458
cmbAncestors->Clear();
459
cmbDescendants->Clear();
460
txtDeclFile->SetLabel(wxEmptyString);
461
txtImplFile->SetLabel(wxEmptyString);
465
TokenTree* tree = m_Parser->GetTokenTree();
468
const Token* parent = tree->at(m_Token->m_ParentIndex);
469
tree->RecalcInheritanceChain(m_Token);
471
wxString args = m_Token->GetFormattedArgs();
472
wxString argsStr = m_Token->m_BaseArgs;
473
wxString tmplArg = m_Token->m_TemplateArgument;
474
wxString fullType = m_Token->m_FullType;
476
// so they can be displayed in wxStaticText
477
args.Replace(_T("&"), _T("&&"), true);
478
argsStr.Replace(_T("&"), _T("&&"), true);
479
tmplArg.Replace(_T("&"), _T("&&"), true);
480
fullType.Replace(_T("&"), _T("&&"), true);
482
txtID->SetLabel(wxString::Format(_T("%d"), m_Token->m_Index));
483
txtName->SetLabel(m_Token->m_Name);
484
txtKind->SetLabel(m_Token->GetTokenKindString());
485
txtScope->SetLabel(m_Token->GetTokenScopeString());
486
txtFullType->SetLabel(fullType);
487
txtBaseType->SetLabel(m_Token->m_BaseType);
488
txtArgs->SetLabel(args);
489
txtArgsStripped->SetLabel(argsStr);
490
txtTemplateArg->SetLabel(tmplArg);
491
txtIsOp->SetLabel(m_Token->m_IsOperator ? _("Yes") : _("No"));
492
txtIsLocal->SetLabel(m_Token->m_IsLocal ? _("Yes") : _("No"));
493
txtIsTemp->SetLabel(m_Token->m_IsTemp ? _("Yes") : _("No"));
494
txtIsConst->SetLabel(m_Token->m_IsConst ? _("Yes") : _("No"));
495
txtIsNoExcept->SetLabel(m_Token->m_IsNoExcept ? _("Yes") : _("No"));
496
txtNamespace->SetLabel(m_Token->GetNamespace());
497
txtParent->SetLabel(wxString::Format(_T("%s (%d)"), parent ? parent->m_Name.c_str() : (const wxChar*)_("<Global namespace>"), m_Token->m_ParentIndex));
503
if (!m_Token->GetFilename().IsEmpty())
504
txtDeclFile->SetLabel(wxString::Format(_T("%s : %u"), m_Token->GetFilename().c_str(), m_Token->m_Line));
506
txtDeclFile->SetLabel(wxEmptyString);
507
if (!m_Token->GetImplFilename().IsEmpty())
508
txtImplFile->SetLabel(wxString::Format(_("%s : %u (code lines: %u to %u)"), m_Token->GetImplFilename().c_str(), m_Token->m_ImplLine, m_Token->m_ImplLineStart, m_Token->m_ImplLineEnd));
510
txtImplFile->SetLabel(wxEmptyString);
511
txtUserData->SetLabel(wxString::Format(_T("0x%p"), m_Token->m_UserData));
514
void CCDebugInfo::FillChildren()
516
TokenTree* tree = m_Parser->GetTokenTree();
519
cmbChildren->Clear();
521
for (TokenIdxSet::const_iterator it = m_Token->m_Children.begin(); it != m_Token->m_Children.end(); ++it)
523
const Token* child = tree->at(*it);
524
const wxString msgInvalidToken = _("<invalid token>");
525
cmbChildren->Append(wxString::Format(_T("%s (%d)"), child ? child->m_Name.wx_str() : msgInvalidToken.wx_str(), *it));
527
cmbChildren->SetSelection(0);
530
void CCDebugInfo::FillAncestors()
532
TokenTree* tree = m_Parser->GetTokenTree();
535
cmbAncestors->Clear();
537
for (TokenIdxSet::const_iterator it = m_Token->m_Ancestors.begin(); it != m_Token->m_Ancestors.end(); ++it)
539
const Token* ancestor = tree->at(*it);
540
const wxString msgInvalidToken = _("<invalid token>");
541
cmbAncestors->Append(wxString::Format(_T("%s (%d)"), ancestor ? ancestor->m_Name.wx_str() : msgInvalidToken.wx_str(), *it));
543
cmbAncestors->SetSelection(0);
546
void CCDebugInfo::FillDescendants()
548
TokenTree* tree = m_Parser->GetTokenTree();
551
cmbDescendants->Clear();
553
for (TokenIdxSet::const_iterator it = m_Token->m_Descendants.begin(); it != m_Token->m_Descendants.end(); ++it)
555
const Token* descendant = tree->at(*it);
556
const wxString msgInvalidToken = _("<invalid token>");
557
cmbDescendants->Append(wxString::Format(_T("%s (%d)"), descendant ? descendant->m_Name.wx_str() : msgInvalidToken.wx_str(), *it));
559
cmbDescendants->SetSelection(0);
562
void CCDebugInfo::OnInit(cb_unused wxInitDialogEvent& event)
564
if (!m_Parser || !m_Parser->GetTokenTree())
567
txtInfo->SetLabel(wxString::Format(_("The parser contains %lu tokens, found in %lu files"),
568
static_cast<unsigned long>(m_Parser->GetTokenTree()->size()),
569
static_cast<unsigned long>(m_Parser->GetTokenTree()->m_FileMap.size())));
576
txtFilter->SetFocus();
579
void CCDebugInfo::OnFindClick(cb_unused wxCommandEvent& event)
581
TokenTree* tree = m_Parser->GetTokenTree();
584
wxString search = txtFilter->GetValue();
588
// first determine if the user entered an ID or a search mask
590
if (search.ToULong(&id, 10))
593
m_Token = tree->at(id);
597
// find all matching tokens
599
for (size_t i = 0; i < tree->size(); ++i)
601
const Token* token = tree->at(i);
602
if (token && token->m_Name.Matches(search))
607
if (result.size() == 1)
608
m_Token = tree->at(*(result.begin()));
611
// fill a list and ask the user which token to display
614
for (TokenIdxSet::const_iterator it = result.begin(); it != result.end(); ++it)
616
const Token* token = tree->at(*it);
617
arr.Add(token->DisplayName());
620
int sel = wxGetSingleChoiceIndex(_("Please make a selection:"), _("Multiple matches"), arr, this);
624
m_Token = tree->at(intarr[sel]);
631
void CCDebugInfo::OnGoAscClick(cb_unused wxCommandEvent& event)
633
int idx = cmbAncestors->GetSelection();
634
if (!m_Token || idx == -1)
638
for (TokenIdxSet::const_iterator it = m_Token->m_Ancestors.begin(); it != m_Token->m_Ancestors.end(); ++it)
641
m_Token = m_Parser->GetTokenTree()->at(*it);
650
void CCDebugInfo::OnGoDescClick(cb_unused wxCommandEvent& event)
652
int idx = cmbDescendants->GetSelection();
653
if (!m_Token || idx == -1)
657
for (TokenIdxSet::const_iterator it = m_Token->m_Descendants.begin(); it != m_Token->m_Descendants.end(); ++it)
661
m_Token = m_Parser->GetTokenTree()->at(*it);
669
void CCDebugInfo::OnGoParentClick(cb_unused wxCommandEvent& event)
671
if (!m_Token || m_Token->m_ParentIndex == -1)
674
m_Token = m_Parser->GetTokenTree()->at(m_Token->m_ParentIndex);
678
void CCDebugInfo::OnGoChildrenClick(cb_unused wxCommandEvent& event)
680
int idx = cmbChildren->GetSelection();
681
if (!m_Token || idx == -1)
685
for (TokenIdxSet::const_iterator it = m_Token->m_Children.begin(); it != m_Token->m_Children.end(); ++it)
689
m_Token = m_Parser->GetTokenTree()->at(*it);
697
void CCDebugInfo::OnSave(cb_unused wxCommandEvent& event)
699
TokenTree* tree = m_Parser->GetTokenTree();
701
wxArrayString saveWhat;
702
saveWhat.Add(_("Dump the tokens tree"));
703
saveWhat.Add(_("Dump the serialised tokens tree"));
704
saveWhat.Add(_("Dump the file list"));
705
saveWhat.Add(_("Dump the list of include directories"));
706
saveWhat.Add(_("Dump the token list of files"));
708
int sel = wxGetSingleChoiceIndex(_("What do you want to save?"),
709
_("CC Debug Info"), saveWhat, this);
720
{ // life time of wxWindowDisabler/wxBusyInfo
721
wxWindowDisabler disableAll;
722
wxBusyInfo running(_("Obtaining tokens tree... please wait (this may take several seconds)..."),
723
Manager::Get()->GetAppWindow());
725
tt = tree->m_Tree.dump();
727
CCDebugInfoHelper::SaveCCDebugInfo(_("Save tokens tree"), tt);
733
{ // life time of wxWindowDisabler/wxBusyInfo
734
wxWindowDisabler disableAll;
735
wxBusyInfo running(_("Serialising tokens tree... please wait (this may take several seconds)..."),
736
Manager::Get()->GetAppWindow());
738
tt_ser = tree->m_Tree.Serialize();
740
CCDebugInfoHelper::SaveCCDebugInfo(_("Save serialised tokens tree"), tt_ser);
746
for (size_t i = 0; i < tree->m_FilenameMap.size(); ++i)
748
wxString file = tree->m_FilenameMap.GetString(i);
750
files += file + _T("\r\n");
753
CCDebugInfoHelper::SaveCCDebugInfo(_("Save file list"), files);
759
const wxArrayString& dirsArray = m_Parser->GetIncludeDirs();
760
for (size_t i = 0; i < dirsArray.GetCount(); ++i)
762
const wxString& dir = dirsArray[i];
764
dirs += dir + _T("\r\n");
766
CCDebugInfoHelper::SaveCCDebugInfo(_("Save list of include directories"), dirs);
773
wxWindowDisabler disableAll;
774
wxBusyInfo running(_("Obtaining tokens tree... please wait (this may take several seconds)..."),
775
Manager::Get()->GetAppWindow());
776
for (size_t i = 0; i < tree->m_FilenameMap.size(); ++i)
778
const wxString file = tree->m_FilenameMap.GetString(i);
781
fileTokens += file + _T("\r\n");
784
tree->FindTokensInFile(file, result, tkUndefined);
785
for (TokenIdxSet::const_iterator it = result.begin(); it != result.end(); ++it)
787
const Token* token = tree->at(*it);
788
fileTokens << token->GetTokenKindString() << _T(" ");
789
if (token->m_TokenKind == tkFunction)
790
fileTokens << token->m_Name << token->GetFormattedArgs() << _T("\t");
792
fileTokens << token->DisplayName() << _T("\t");
793
fileTokens << _T("[") << token->m_Line << _T(",") << token->m_ImplLine << _T("]");
794
fileTokens << _T("\r\n");
797
fileTokens += _T("\r\n");
801
CCDebugInfoHelper::SaveCCDebugInfo(_("Save token list of files"), fileTokens);
805
cbMessageBox(_("Invalid selection."), _("CC Debug Info"));
809
void CCDebugInfo::OnGoDeclClick(cb_unused wxCommandEvent& event)
814
if (m_Token && !m_Token->GetFilename().IsEmpty())
816
file = m_Token->GetFilename();
817
line = m_Token->m_Line;
822
cbEditor* ed = (cbEditor*)Manager::Get()->GetEditorManager()->IsBuiltinOpen(file);
824
ed = Manager::Get()->GetEditorManager()->Open(file);
833
void CCDebugInfo::OnGoImplClick(cb_unused wxCommandEvent& event)
838
if (m_Token && !m_Token->GetImplFilename().IsEmpty())
840
file = m_Token->GetImplFilename();
841
line = m_Token->m_ImplLine;
846
cbEditor* ed = (cbEditor*)Manager::Get()->GetEditorManager()->IsBuiltinOpen(file);
848
ed = Manager::Get()->GetEditorManager()->Open(file);