~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/codecompletion/parser/ccdebuginfo.cpp

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
4
 *
 
5
 * $Revision: 10265 $
 
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 $
 
8
 */
 
9
 
 
10
#include <sdk.h>
 
11
 
 
12
#ifndef CB_PRECOMP
 
13
    #include <wx/object.h>
 
14
    #include <wx/string.h>
 
15
    #include <wx/choicdlg.h> // wxGetSingleChoiceIndex
 
16
    #include <wx/file.h>
 
17
    #include <wx/filedlg.h>
 
18
    #include <wx/utils.h>    // wxWindowDisabler
 
19
 
 
20
    //(*InternalHeaders(CCDebugInfo)
 
21
    #include <wx/string.h>
 
22
    #include <wx/intl.h>
 
23
    //*)
 
24
 
 
25
    #include <cbeditor.h>
 
26
    #include <editormanager.h>
 
27
    #include <logmanager.h>
 
28
#endif
 
29
 
 
30
#include <wx/busyinfo.h>
 
31
#include <wx/tokenzr.h>
 
32
 
 
33
#include "ccdebuginfo.h"
 
34
#include "parser.h"
 
35
 
 
36
#define CC_DEBUGINFO_DEBUG_OUTPUT 0
 
37
 
 
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
 
45
    #endif
 
46
#endif
 
47
 
 
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...)                                              \
 
54
        do                                                                      \
 
55
        {                                                                       \
 
56
            if (g_EnableDebugTrace)                                             \
 
57
                CCLogger::Get()->DebugLog(F(format, ##args));                   \
 
58
        }                                                                       \
 
59
        while (false)
 
60
    #define TRACE2(format, args...) \
 
61
        CCLogger::Get()->DebugLog(F(format, ##args))
 
62
#else
 
63
    #define TRACE(format, args...)
 
64
    #define TRACE2(format, args...)
 
65
#endif
 
66
 
 
67
namespace CCDebugInfoHelper
 
68
{
 
69
    inline void SaveCCDebugInfo(const wxString& fileDesc, const wxString& content)
 
70
    {
 
71
        wxString fname;
 
72
        wxFileDialog dlg (Manager::Get()->GetAppWindow(),
 
73
                        fileDesc,
 
74
                        _T(""),
 
75
                        _T(""),
 
76
                        _T("Text files (*.txt)|*.txt|Any file (*)|*"),
 
77
                        wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
 
78
        PlaceWindow(&dlg);
 
79
        if (dlg.ShowModal() != wxID_OK)
 
80
            return;
 
81
 
 
82
        // Opening the file migth have failed, verify:
 
83
        wxFile f(dlg.GetPath(), wxFile::write);
 
84
        if (f.IsOpened())
 
85
        {
 
86
            f.Write(content); // write buffer to file
 
87
            f.Close();        // release file handle
 
88
        }
 
89
        else
 
90
            cbMessageBox(_("Cannot create file ") + fname, _("CC Debug Info"));
 
91
    }
 
92
}// namespace CCDebugInfoHelper
 
93
 
 
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();
 
134
//*)
 
135
 
 
136
BEGIN_EVENT_TABLE(CCDebugInfo,wxScrollingDialog)
 
137
    //(*EventTable(CCDebugInfo)
 
138
    //*)
 
139
END_EVENT_TABLE()
 
140
 
 
141
CCDebugInfo::CCDebugInfo(wxWindow* parent, ParserBase* parser, Token* token) :
 
142
    m_Parser(parser),
 
143
    m_Token(token)
 
144
{
 
145
    //(*Initialize(CCDebugInfo)
 
146
    wxStaticText* lblParent;
 
147
    wxFlexGridSizer* FlexGridSizer1;
 
148
    wxStaticText* lblArgs;
 
149
    wxPanel* Panel1;
 
150
    wxBoxSizer* BoxSizer3;
 
151
    wxStaticLine* StaticLine2;
 
152
    wxButton* btnGoParent;
 
153
    wxStaticText* lblID;
 
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;
 
163
    wxPanel* Panel2;
 
164
    wxButton* btnFind;
 
165
    wxStaticText* lblIsConst;
 
166
    wxBoxSizer* BoxSizer9;
 
167
    wxStaticText* lblIsLocal;
 
168
    wxButton* btnGoAsc;
 
169
    wxStaticLine* StaticLine1;
 
170
    wxBoxSizer* BoxSizer4;
 
171
    wxStaticText* lblChildren;
 
172
    wxPanel* Panel3;
 
173
    wxStaticText* lblImplfile;
 
174
    wxBoxSizer* BoxSizer8;
 
175
    wxButton* btnGoDesc;
 
176
    wxBoxSizer* BoxSizer1;
 
177
    wxStaticText* lblIsTemp;
 
178
    wxStaticText* lblScope;
 
179
    wxNotebook* Notebook1;
 
180
    wxStaticText* lblArgsStripped;
 
181
    wxStaticText* lblFullType;
 
182
    wxStaticText* lblDeclFile;
 
183
    wxButton* btnGoDecl;
 
184
    wxStaticText* lblNameSpace;
 
185
    wxStaticText* lblUserData;
 
186
    wxButton* btnGoImpl;
 
187
    wxStaticText* StaticText29;
 
188
    wxStaticText* lblTemplateArg;
 
189
    wxBoxSizer* BoxSizer6;
 
190
    wxStdDialogButtonSizer* StdDialogButtonSizer1;
 
191
    wxButton* btnGoChildren;
 
192
    wxStaticText* lblBaseType;
 
193
    wxStaticText* lblIsNoExcept;
 
194
 
 
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);
 
367
    SetSizer(BoxSizer1);
 
368
    BoxSizer1->Fit(this);
 
369
    BoxSizer1->SetSizeHints(this);
 
370
    Center();
 
371
 
 
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);
 
381
    //*)
 
382
}
 
383
 
 
384
CCDebugInfo::~CCDebugInfo()
 
385
{
 
386
    //(*Destroy(CCDebugInfo)
 
387
    //*)
 
388
}
 
389
 
 
390
void CCDebugInfo::FillFiles()
 
391
{
 
392
    TokenTree* tree = m_Parser->GetTokenTree();
 
393
    if (!tree) return;
 
394
 
 
395
    lstFiles->Freeze();
 
396
    lstFiles->Clear();
 
397
 
 
398
    for (size_t i = 0; i < tree->m_FilenameMap.size(); ++i)
 
399
    {
 
400
        wxString file = tree->m_FilenameMap.GetString(i);
 
401
        if (!file.IsEmpty())
 
402
            lstFiles->Append(file);
 
403
    }
 
404
 
 
405
    lstFiles->Thaw();
 
406
}
 
407
 
 
408
void CCDebugInfo::FillDirs()
 
409
{
 
410
    lstDirs->Freeze();
 
411
    lstDirs->Clear();
 
412
 
 
413
    const wxArrayString& dirs = m_Parser->GetIncludeDirs();
 
414
    for (size_t i = 0; i < dirs.GetCount(); ++i)
 
415
    {
 
416
        const wxString& file = dirs[i];
 
417
        if (!file.IsEmpty())
 
418
            lstDirs->Append(file);
 
419
    }
 
420
 
 
421
    lstDirs->Thaw();
 
422
}
 
423
 
 
424
void CCDebugInfo::FillMacros()
 
425
{
 
426
    lstMacros->Freeze();
 
427
    lstMacros->Clear();
 
428
 
 
429
    wxStringTokenizer tknzr(m_Parser->GetPredefinedMacros(), wxT("#"));
 
430
    while ( tknzr.HasMoreTokens() )
 
431
    {
 
432
        wxString macro = tknzr.GetNextToken();
 
433
        if (!macro.IsEmpty())
 
434
            lstMacros->Append(wxT("#") + macro);
 
435
    }
 
436
 
 
437
    lstMacros->Thaw();
 
438
}
 
439
 
 
440
void CCDebugInfo::DisplayTokenInfo()
 
441
{
 
442
    if (!m_Token)
 
443
    {
 
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);
 
462
        return;
 
463
    }
 
464
 
 
465
    TokenTree* tree = m_Parser->GetTokenTree();
 
466
    if (!tree) return;
 
467
 
 
468
    const Token* parent = tree->at(m_Token->m_ParentIndex);
 
469
    tree->RecalcInheritanceChain(m_Token);
 
470
 
 
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;
 
475
 
 
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);
 
481
 
 
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));
 
498
 
 
499
    FillChildren();
 
500
    FillAncestors();
 
501
    FillDescendants();
 
502
 
 
503
    if (!m_Token->GetFilename().IsEmpty())
 
504
        txtDeclFile->SetLabel(wxString::Format(_T("%s : %u"), m_Token->GetFilename().c_str(), m_Token->m_Line));
 
505
    else
 
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));
 
509
    else
 
510
        txtImplFile->SetLabel(wxEmptyString);
 
511
    txtUserData->SetLabel(wxString::Format(_T("0x%p"), m_Token->m_UserData));
 
512
}
 
513
 
 
514
void CCDebugInfo::FillChildren()
 
515
{
 
516
    TokenTree* tree = m_Parser->GetTokenTree();
 
517
    if (!tree) return;
 
518
 
 
519
    cmbChildren->Clear();
 
520
 
 
521
    for (TokenIdxSet::const_iterator it = m_Token->m_Children.begin(); it != m_Token->m_Children.end(); ++it)
 
522
    {
 
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));
 
526
    }
 
527
    cmbChildren->SetSelection(0);
 
528
}
 
529
 
 
530
void CCDebugInfo::FillAncestors()
 
531
{
 
532
    TokenTree* tree = m_Parser->GetTokenTree();
 
533
    if (!tree) return;
 
534
 
 
535
    cmbAncestors->Clear();
 
536
 
 
537
    for (TokenIdxSet::const_iterator it = m_Token->m_Ancestors.begin(); it != m_Token->m_Ancestors.end(); ++it)
 
538
    {
 
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));
 
542
    }
 
543
    cmbAncestors->SetSelection(0);
 
544
}
 
545
 
 
546
void CCDebugInfo::FillDescendants()
 
547
{
 
548
    TokenTree* tree = m_Parser->GetTokenTree();
 
549
    if (!tree) return;
 
550
 
 
551
    cmbDescendants->Clear();
 
552
 
 
553
    for (TokenIdxSet::const_iterator it = m_Token->m_Descendants.begin(); it != m_Token->m_Descendants.end(); ++it)
 
554
    {
 
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));
 
558
    }
 
559
    cmbDescendants->SetSelection(0);
 
560
}
 
561
 
 
562
void CCDebugInfo::OnInit(cb_unused wxInitDialogEvent& event)
 
563
{
 
564
    if (!m_Parser || !m_Parser->GetTokenTree())
 
565
        return;
 
566
 
 
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())));
 
570
 
 
571
    DisplayTokenInfo();
 
572
    FillFiles();
 
573
    FillDirs();
 
574
    FillMacros();
 
575
 
 
576
    txtFilter->SetFocus();
 
577
}
 
578
 
 
579
void CCDebugInfo::OnFindClick(cb_unused wxCommandEvent& event)
 
580
{
 
581
    TokenTree* tree = m_Parser->GetTokenTree();
 
582
    if (!tree) return;
 
583
 
 
584
    wxString search = txtFilter->GetValue();
 
585
 
 
586
    m_Token = 0;
 
587
 
 
588
    // first determine if the user entered an ID or a search mask
 
589
    long unsigned id;
 
590
    if (search.ToULong(&id, 10))
 
591
    {
 
592
        // easy; ID
 
593
        m_Token = tree->at(id);
 
594
    }
 
595
    else
 
596
    {
 
597
        // find all matching tokens
 
598
        TokenIdxSet result;
 
599
        for (size_t i = 0; i < tree->size(); ++i)
 
600
        {
 
601
            const Token* token = tree->at(i);
 
602
            if (token && token->m_Name.Matches(search))
 
603
                result.insert(i);
 
604
        }
 
605
 
 
606
        // a single result?
 
607
        if (result.size() == 1)
 
608
            m_Token = tree->at(*(result.begin()));
 
609
        else
 
610
        {
 
611
            // fill a list and ask the user which token to display
 
612
            wxArrayString arr;
 
613
            wxArrayInt intarr;
 
614
            for (TokenIdxSet::const_iterator it = result.begin(); it != result.end(); ++it)
 
615
            {
 
616
                const Token* token = tree->at(*it);
 
617
                arr.Add(token->DisplayName());
 
618
                intarr.Add(*it);
 
619
            }
 
620
            int sel = wxGetSingleChoiceIndex(_("Please make a selection:"), _("Multiple matches"), arr, this);
 
621
            if (sel == -1)
 
622
                return;
 
623
 
 
624
            m_Token = tree->at(intarr[sel]);
 
625
        }
 
626
    }
 
627
 
 
628
    DisplayTokenInfo();
 
629
}
 
630
 
 
631
void CCDebugInfo::OnGoAscClick(cb_unused wxCommandEvent& event)
 
632
{
 
633
    int idx = cmbAncestors->GetSelection();
 
634
    if (!m_Token || idx == -1)
 
635
        return;
 
636
 
 
637
    int count = 0;
 
638
    for (TokenIdxSet::const_iterator it = m_Token->m_Ancestors.begin(); it != m_Token->m_Ancestors.end(); ++it)
 
639
    {
 
640
        if (count == idx)
 
641
            m_Token = m_Parser->GetTokenTree()->at(*it);
 
642
        {
 
643
            DisplayTokenInfo();
 
644
            break;
 
645
        }
 
646
        ++count;
 
647
    }
 
648
}
 
649
 
 
650
void CCDebugInfo::OnGoDescClick(cb_unused wxCommandEvent& event)
 
651
{
 
652
    int idx = cmbDescendants->GetSelection();
 
653
    if (!m_Token || idx == -1)
 
654
        return;
 
655
 
 
656
    int count = 0;
 
657
    for (TokenIdxSet::const_iterator it = m_Token->m_Descendants.begin(); it != m_Token->m_Descendants.end(); ++it)
 
658
    {
 
659
        if (count == idx)
 
660
        {
 
661
            m_Token = m_Parser->GetTokenTree()->at(*it);
 
662
            DisplayTokenInfo();
 
663
            break;
 
664
        }
 
665
        ++count;
 
666
    }
 
667
}
 
668
 
 
669
void CCDebugInfo::OnGoParentClick(cb_unused wxCommandEvent& event)
 
670
{
 
671
    if (!m_Token || m_Token->m_ParentIndex == -1)
 
672
        return;
 
673
 
 
674
    m_Token = m_Parser->GetTokenTree()->at(m_Token->m_ParentIndex);
 
675
    DisplayTokenInfo();
 
676
}
 
677
 
 
678
void CCDebugInfo::OnGoChildrenClick(cb_unused wxCommandEvent& event)
 
679
{
 
680
    int idx = cmbChildren->GetSelection();
 
681
    if (!m_Token || idx == -1)
 
682
        return;
 
683
 
 
684
    int count = 0;
 
685
    for (TokenIdxSet::const_iterator it = m_Token->m_Children.begin(); it != m_Token->m_Children.end(); ++it)
 
686
    {
 
687
        if (count == idx)
 
688
        {
 
689
            m_Token = m_Parser->GetTokenTree()->at(*it);
 
690
            DisplayTokenInfo();
 
691
            break;
 
692
        }
 
693
        ++count;
 
694
    }
 
695
}
 
696
 
 
697
void CCDebugInfo::OnSave(cb_unused wxCommandEvent& event)
 
698
{
 
699
    TokenTree* tree = m_Parser->GetTokenTree();
 
700
 
 
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"));
 
707
 
 
708
    int sel = wxGetSingleChoiceIndex(_("What do you want to save?"),
 
709
                                     _("CC Debug Info"), saveWhat, this);
 
710
 
 
711
    switch (sel)
 
712
    {
 
713
        case -1:
 
714
            // cancelled
 
715
            return;
 
716
 
 
717
        case 0:
 
718
            {
 
719
                wxString tt;
 
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());
 
724
 
 
725
                    tt = tree->m_Tree.dump();
 
726
                }
 
727
                CCDebugInfoHelper::SaveCCDebugInfo(_("Save tokens tree"), tt);
 
728
            }
 
729
            break;
 
730
        case 1:
 
731
            {
 
732
                wxString tt_ser;
 
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());
 
737
 
 
738
                    tt_ser = tree->m_Tree.Serialize();
 
739
                }
 
740
                CCDebugInfoHelper::SaveCCDebugInfo(_("Save serialised tokens tree"), tt_ser);
 
741
            }
 
742
            break;
 
743
        case 2:
 
744
            {
 
745
                wxString files;
 
746
                for (size_t i = 0; i < tree->m_FilenameMap.size(); ++i)
 
747
                {
 
748
                    wxString file = tree->m_FilenameMap.GetString(i);
 
749
                    if (!file.IsEmpty())
 
750
                        files += file + _T("\r\n");
 
751
                }
 
752
 
 
753
                CCDebugInfoHelper::SaveCCDebugInfo(_("Save file list"), files);
 
754
            }
 
755
            break;
 
756
        case 3:
 
757
            {
 
758
                wxString dirs;
 
759
                const wxArrayString& dirsArray = m_Parser->GetIncludeDirs();
 
760
                for (size_t i = 0; i < dirsArray.GetCount(); ++i)
 
761
                {
 
762
                    const wxString& dir = dirsArray[i];
 
763
                    if (!dir.IsEmpty())
 
764
                        dirs += dir + _T("\r\n");
 
765
                }
 
766
                CCDebugInfoHelper::SaveCCDebugInfo(_("Save list of include directories"), dirs);
 
767
            }
 
768
            break;
 
769
        case 4:
 
770
            {
 
771
                wxString fileTokens;
 
772
                {
 
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)
 
777
                    {
 
778
                        const wxString file = tree->m_FilenameMap.GetString(i);
 
779
                        if (!file.IsEmpty())
 
780
                        {
 
781
                            fileTokens += file + _T("\r\n");
 
782
 
 
783
                            TokenIdxSet result;
 
784
                            tree->FindTokensInFile(file, result, tkUndefined);
 
785
                            for (TokenIdxSet::const_iterator it = result.begin(); it != result.end(); ++it)
 
786
                            {
 
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");
 
791
                                else
 
792
                                    fileTokens << token->DisplayName() << _T("\t");
 
793
                                fileTokens << _T("[") << token->m_Line << _T(",") << token->m_ImplLine << _T("]");
 
794
                                fileTokens << _T("\r\n");
 
795
                            }
 
796
                        }
 
797
                        fileTokens += _T("\r\n");
 
798
                    }
 
799
                }
 
800
 
 
801
                CCDebugInfoHelper::SaveCCDebugInfo(_("Save token list of files"), fileTokens);
 
802
            }
 
803
            break;
 
804
        default:
 
805
            cbMessageBox(_("Invalid selection."), _("CC Debug Info"));
 
806
    }
 
807
}
 
808
 
 
809
void CCDebugInfo::OnGoDeclClick(cb_unused wxCommandEvent& event)
 
810
{
 
811
    wxString file;
 
812
    int line;
 
813
 
 
814
    if (m_Token && !m_Token->GetFilename().IsEmpty())
 
815
    {
 
816
        file = m_Token->GetFilename();
 
817
        line = m_Token->m_Line;
 
818
    }
 
819
    else
 
820
        return;
 
821
 
 
822
    cbEditor* ed = (cbEditor*)Manager::Get()->GetEditorManager()->IsBuiltinOpen(file);
 
823
    if (!ed)
 
824
        ed = Manager::Get()->GetEditorManager()->Open(file);
 
825
 
 
826
    if (ed)
 
827
    {
 
828
        ed->Activate();
 
829
        ed->GotoLine(line);
 
830
    }
 
831
}
 
832
 
 
833
void CCDebugInfo::OnGoImplClick(cb_unused wxCommandEvent& event)
 
834
{
 
835
    wxString file;
 
836
    int line;
 
837
 
 
838
    if (m_Token && !m_Token->GetImplFilename().IsEmpty())
 
839
    {
 
840
        file = m_Token->GetImplFilename();
 
841
        line = m_Token->m_ImplLine;
 
842
    }
 
843
    else
 
844
        return;
 
845
 
 
846
    cbEditor* ed = (cbEditor*)Manager::Get()->GetEditorManager()->IsBuiltinOpen(file);
 
847
    if (!ed)
 
848
        ed = Manager::Get()->GetEditorManager()->Open(file);
 
849
 
 
850
    if (ed)
 
851
    {
 
852
        ed->Activate();
 
853
        ed->GotoLine(line);
 
854
    }
 
855
}