Code::Blocks  SVN r11506
coderefactoring.cpp
Go to the documentation of this file.
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: 11350 $
6  * $Id: coderefactoring.cpp 11350 2018-03-27 22:00:39Z fuscated $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/plugins/codecompletion/coderefactoring.cpp $
8  */
9 
10 #include <sdk.h>
11 
12 #ifndef CB_PRECOMP
13  #include <wx/button.h>
14  #include <wx/image.h>
15  #include <wx/sizer.h>
16  #include <wx/statbmp.h>
17  #include <wx/stattext.h>
18 
19  #include <cbeditor.h>
20  #include <cbproject.h>
21  #include <editorcolourset.h>
22  #include <editormanager.h>
23  #include <logmanager.h>
24 #endif
25 
26 #include <wx/progdlg.h>
27 
28 #include <cbstyledtextctrl.h>
29 #include <encodingdetector.h>
30 #include <searchresultslog.h>
31 
32 #include "coderefactoring.h"
33 #include "nativeparser.h"
34 
35 #define CC_CODEREFACTORING_DEBUG_OUTPUT 0
36 
37 #if defined(CC_GLOBAL_DEBUG_OUTPUT)
38  #if CC_GLOBAL_DEBUG_OUTPUT == 1
39  #undef CC_CODEREFACTORING_DEBUG_OUTPUT
40  #define CC_CODEREFACTORING_DEBUG_OUTPUT 1
41  #elif CC_GLOBAL_DEBUG_OUTPUT == 2
42  #undef CC_CODEREFACTORING_DEBUG_OUTPUT
43  #define CC_CODEREFACTORING_DEBUG_OUTPUT 2
44  #endif
45 #endif
46 
47 #if CC_CODEREFACTORING_DEBUG_OUTPUT == 1
48  #define TRACE(format, args...) \
49  CCLogger::Get()->DebugLog(F(format, ##args))
50  #define TRACE2(format, args...)
51 #elif CC_CODEREFACTORING_DEBUG_OUTPUT == 2
52  #define TRACE(format, args...) \
53  do \
54  { \
55  if (g_EnableDebugTrace) \
56  CCLogger::Get()->DebugLog(F(format, ##args)); \
57  } \
58  while (false)
59  #define TRACE2(format, args...) \
60  CCLogger::Get()->DebugLog(F(format, ##args))
61 #else
62  #define TRACE(format, args...)
63  #define TRACE2(format, args...)
64 #endif
65 
66 class ScopeDialog : public wxDialog
67 {
68 public:
69  ScopeDialog(wxWindow* parent, const wxString& title) :
70  wxDialog(parent, wxID_ANY, title)
71  {
72  wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
73  wxBoxSizer* infoSizer = new wxBoxSizer(wxHORIZONTAL);
74  wxString findImgFile = ConfigManager::GetDataFolder() + _T("/images/filefind.png");
75  wxStaticBitmap* findIco = new wxStaticBitmap(this, wxID_ANY, wxBitmap(wxImage(findImgFile)));
76  infoSizer->Add(findIco, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
77  wxStaticText* scopeText = new wxStaticText(this, wxID_ANY, _("Please choose the find scope for search tokens"));
78  infoSizer->Add(scopeText, 1, wxALL | wxALIGN_CENTER_VERTICAL,
79  wxDLG_UNIT(this, wxSize(5, 0)).GetWidth());
80  sizer->Add(infoSizer, 1, wxALL | wxALIGN_CENTER_HORIZONTAL, 5);
81  wxBoxSizer* btnSizer = new wxBoxSizer(wxHORIZONTAL);
82  m_OpenFiles = new wxButton(this, ID_OPEN_FILES, _("&Open files"), wxDefaultPosition, wxDefaultSize, 0,
83  wxDefaultValidator, _T("ID_OPEN_FILES"));
84  m_OpenFiles->SetDefault();
85  btnSizer->Add(m_OpenFiles, 1, wxALL | wxALIGN_CENTER_VERTICAL, 5);
86  m_ProjectFiles = new wxButton(this, ID_PROJECT_FILES, _("&Project files"), wxDefaultPosition,
87  wxDefaultSize, 0, wxDefaultValidator, _T("ID_PROJECT_FILES"));
88  btnSizer->Add(m_ProjectFiles, 1, wxALL | wxALIGN_CENTER_VERTICAL, 5);
89  sizer->Add(btnSizer, 1, wxBOTTOM | wxLEFT | wxRIGHT | wxALIGN_CENTER_HORIZONTAL, 5);
90  SetSizer(sizer);
91  sizer->Fit(this);
92  sizer->SetSizeHints(this);
93  Center();
94 
95  Connect(ID_OPEN_FILES, wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&ScopeDialog::OnOpenFilesClick);
96  Connect(ID_PROJECT_FILES, wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&ScopeDialog::OnProjectFilesClick);
97  Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, (wxObjectEventFunction)&ScopeDialog::OnClose);
98  }
99 
100 public:
101  static const long ID_OPEN_FILES;
102  static const long ID_PROJECT_FILES;
103 
104 private:
105  void OnClose(cb_unused wxCloseEvent& event) { EndDialog(wxID_CLOSE); }
106  void OnOpenFilesClick(cb_unused wxCommandEvent& event) { EndDialog(ID_OPEN_FILES);}
107  void OnProjectFilesClick(cb_unused wxCommandEvent& event) { EndDialog(ID_PROJECT_FILES); }
108 
111 };
112 
113 const long ScopeDialog::ID_OPEN_FILES = wxNewId();
115 
117  m_NativeParser(np)
118 {
119 }
120 
122 {
123 }
124 
126 {
128  cbEditor* editor = edMan->GetBuiltinActiveEditor();
129  if (!editor)
130  return wxEmptyString;
131 
132  cbStyledTextCtrl* control = editor->GetControl();
133  const int style = control->GetStyleAt(control->GetCurrentPos());
134  if (control->IsString(style) || control->IsComment(style))
135  return wxEmptyString;
136 
137  if (!m_NativeParser.GetParser().Done())
138  {
139  wxString msg(_("The Parser is still parsing files."));
140  cbMessageBox(msg, _("Code Refactoring"), wxOK | wxICON_WARNING);
142  CCLogger::Get()->DebugLog(msg);
143 
144  return wxEmptyString;
145  }
146 
147  const int pos = editor->GetControl()->GetCurrentPos();
148  const int start = editor->GetControl()->WordStartPosition(pos, true);
149  const int end = editor->GetControl()->WordEndPosition(pos, true);
150  return editor->GetControl()->GetTextRange(start, end);
151 }
152 
154 {
156  if (!editor)
157  return false;
158 
159  const wxString targetText = GetSymbolUnderCursor();
160  if (targetText.IsEmpty())
161  return false;
162 
163  TokenIdxSet targetResult;
164  const int endOfWord = editor->GetControl()->WordEndPosition(editor->GetControl()->GetCurrentPos(), true);
165  m_NativeParser.MarkItemsByAI(targetResult, true, false, true, endOfWord);
166  if (targetResult.empty())
167  {
168  cbMessageBox(_("Symbol not found under cursor!"), _("Code Refactoring"), wxOK | wxICON_WARNING);
169  return false;
170  }
171 
172  // handle local variables
173  bool isLocalVariable = false;
174 
176 
178 
179  const Token* token = tree->at(*targetResult.begin());
180  if (token)
181  {
182  const Token* parent = tree->at(token->m_ParentIndex);
183  if (parent && parent->m_TokenKind == tkFunction)
184  isLocalVariable = true;
185  }
186 
188 
189  wxArrayString files;
190  cbProject* project = m_NativeParser.GetProjectByEditor(editor);
191  if (isLocalVariable || !project)
192  files.Add(editor->GetFilename());
193  else
194  {
195  ScopeDialog scopeDlg(Manager::Get()->GetAppWindow(), _("Code Refactoring"));
196  const int ret = scopeDlg.ShowModal();
197  if (ret == ScopeDialog::ID_OPEN_FILES)
198  GetOpenedFiles(files);
199  else if (ret == ScopeDialog::ID_PROJECT_FILES)
200  GetAllProjectFiles(files, project);
201  else
202  return false;
203  }
204 
205  if (files.IsEmpty())
206  return false;
207 
208  size_t count = SearchInFiles(files, targetText);
209  if (count)
210  count = VerifyResult(targetResult, targetText, isLocalVariable);
211 
212  return count != 0;
213 }
214 
216 {
217  if (Parse())
219 }
220 
222 {
223  const wxString targetText = GetSymbolUnderCursor();
224  if (targetText.IsEmpty())
225  return;
226 
227  wxString replaceText = cbGetTextFromUser(_("Rename symbols under cursor"),
228  _("Code Refactoring"),
229  targetText,
230  Manager::Get()->GetAppWindow());
231  if (!replaceText.IsEmpty() && replaceText != targetText && Parse())
232  {
233  DoRenameSymbols(targetText, replaceText);
235  }
236 }
237 
238 size_t CodeRefactoring::SearchInFiles(const wxArrayString& files, const wxString& targetText)
239 {
241  m_SearchDataMap.clear();
242 
243  // now that list is filled, we'll search
244  wxWindow* parent = edMan->GetBuiltinActiveEditor()->GetParent();
245  cbStyledTextCtrl* control = new cbStyledTextCtrl(parent, wxID_ANY, wxDefaultPosition, wxSize(0, 0));
246  control->Show(false);
247 
248  // let's create a progress dialog because it might take some time depending on the files count
249  wxProgressDialog* progress = new wxProgressDialog(_("Code Refactoring"),
250  _("Please wait while searching inside the project..."),
251  files.GetCount(),
254  PlaceWindow(progress);
255 
256  for (size_t i = 0; i < files.GetCount(); ++i)
257  {
258  // update the progress bar
259  if (!progress->Update(i))
260  break; // user pressed "Cancel"
261 
262  // check if the file is already opened in built-in editor and do search in it
263  cbEditor* ed = edMan->IsBuiltinOpen(files[i]);
264  if (ed)
265  control->SetText(ed->GetControl()->GetText());
266  else // else load the file in the control
267  {
268  EncodingDetector detector(files[i]);
269  if (!detector.IsOK())
270  continue; // failed
271  control->SetText(detector.GetWxStr());
272  }
273 
274  Find(control, files[i], targetText);
275  }
276 
277  delete control; // done with it
278  delete progress; // done here too
279 
280  return m_SearchDataMap.size();
281 }
282 
283 size_t CodeRefactoring::VerifyResult(const TokenIdxSet& targetResult, const wxString& targetText,
284  bool isLocalVariable)
285 {
287  cbEditor* editor = edMan->GetBuiltinActiveEditor();
288  if (!editor)
289  return 0;
290 
291  const Token* parentOfLocalVariable = nullptr;
292  if (isLocalVariable)
293  {
295 
297 
298  const Token* token = tree->at(*targetResult.begin());
299  parentOfLocalVariable = tree->at(token->m_ParentIndex);
300 
302  }
303 
304  // now that list is filled, we'll search
305  cbStyledTextCtrl* control = new cbStyledTextCtrl(editor->GetParent(), wxID_ANY, wxDefaultPosition,
306  wxSize(0, 0));
307  control->Show(false);
308 
309  // styled the text to support control->GetStyleAt()
310  cbEditor::ApplyStyles(control);
311  EditorColourSet edColSet;
312 
313  size_t totalCount = 0;
314  for (SearchDataMap::const_iterator it = m_SearchDataMap.begin(); it != m_SearchDataMap.end(); ++it)
315  totalCount += it->second.size();
316 
317  // let's create a progress dialog because it might take some time depending on the files count
318  wxProgressDialog* progress = new wxProgressDialog(_("Code Refactoring"),
319  _("Please wait while verifying result..."),
320  totalCount,
321  Manager::Get()->GetAppWindow(),
323  PlaceWindow(progress);
324 
325  size_t task = totalCount;
326  TokenIdxSet result;
327  bool userBreak = false;
328  for (SearchDataMap::iterator it = m_SearchDataMap.begin(); it != m_SearchDataMap.end();)
329  {
330  // check if the file is already opened in built-in editor and do search in it
331  cbEditor* ed = edMan->IsBuiltinOpen(it->first);
332  if (ed)
333  control->SetText(ed->GetControl()->GetText());
334  else // else load the file in the control
335  {
336  EncodingDetector detector(it->first);
337  if (!detector.IsOK())
338  {
339  task -= it->second.size();
340  m_SearchDataMap.erase(it++);
341  continue; // failed
342  }
343  control->SetText(detector.GetWxStr());
344  }
345 
346  // apply the corlor setting
347  edColSet.Apply(editor->GetLanguage(), control, false, true);
348 
349  ccSearchData searchData = { control, it->first };
350  for (SearchDataList::iterator itList = it->second.begin(); itList != it->second.end();)
351  {
352  // update the progress bar
353  if (!progress->Update(totalCount - (--task)))
354  {
355  userBreak = true;
356  break; // user pressed "Cancel"
357  }
358 
359  // skip string or comment
360  const int style = control->GetStyleAt(itList->pos);
361  if (control->IsString(style) || control->IsComment(style))
362  {
363  it->second.erase(itList++);
364  continue;
365  }
366 
367  // do cc search
368  const int endOfWord = itList->pos + targetText.Len();
369  control->GotoPos(endOfWord);
370  m_NativeParser.MarkItemsByAI(&searchData, result, true, false, true, endOfWord);
371  if (result.empty())
372  {
373  it->second.erase(itList++);
374  continue;
375  }
376 
377  // verify result
378  TokenIdxSet::const_iterator findIter = targetResult.begin();
379  for (; findIter != targetResult.end(); ++findIter)
380  {
381  if (result.find(*findIter) != result.end())
382  break;
383  }
384 
385  if (findIter == targetResult.end()) // not found
386  it->second.erase(itList++);
387  else
388  {
389  // handle for local variable
390  if (isLocalVariable)
391  {
392  bool do_continue = false;
393 
395 
397 
398  const Token* token = tree->at(*findIter);
399  if (token)
400  {
401  const Token* parent = tree->at(token->m_ParentIndex);
402  if (parent != parentOfLocalVariable)
403  {
404  it->second.erase(itList++);
405  do_continue = true;
406  }
407  }
408 
410 
411  if (do_continue) continue;
412  }
413 
414  ++itList;
415  }
416  }
417 
418  if (it->second.empty())
419  m_SearchDataMap.erase(it++);
420  else
421  ++it;
422 
423  if (userBreak)
424  break;
425  }
426 
427  delete control; // done with it
428  delete progress; // done here too
429 
430  return m_SearchDataMap.size();
431 }
432 
433 void CodeRefactoring::Find(cbStyledTextCtrl* control, const wxString& file, const wxString& target)
434 {
435  const int end = control->GetLength();
436  int start = 0;
437 
438  for (;;)
439  {
440  int endPos;
441  int pos = control->FindText(start, end, target, wxSCI_FIND_WHOLEWORD | wxSCI_FIND_MATCHCASE, &endPos);
442  if (pos != wxSCI_INVALID_POSITION)
443  {
444  start = endPos;
445  const int line = control->LineFromPosition(pos);
446  wxString text = control->GetLine(line).Trim(true).Trim(false);
447  m_SearchDataMap[file].push_back(crSearchData(pos, line + 1, text));
448  }
449  else
450  break;
451  }
452 }
453 
455 {
457  if (!editor)
458  return;
459 
461  if (!searchLog)
462  return;
463 
464  const wxString focusFile = editor->GetFilename();
465  const int focusLine = editor->GetControl()->GetCurrentLine() + 1;
466  wxFileName fn(focusFile);
467  const wxString basePath(fn.GetPath());
468  size_t index = 0;
469  size_t focusIndex = 0;
470 
471  searchLog->Clear();
472  searchLog->SetBasePath(basePath);
473 
474  for (SearchDataMap::iterator it = m_SearchDataMap.begin(); it != m_SearchDataMap.end(); ++it)
475  {
476  for (SearchDataList::iterator itList = it->second.begin(); itList != it->second.end(); ++itList)
477  {
478  if (it->first == focusFile && itList->line == focusLine)
479  focusIndex = index;
480 
481  wxArrayString values;
482  wxFileName curFn(it->first);
483  curFn.MakeRelativeTo(basePath);
484  values.Add(curFn.GetFullPath());
485  values.Add(wxString::Format(_T("%d"), itList->line));
486  values.Add(itList->text);
487  searchLog->Append(values, Logger::info);
488 
489  ++index;
490  }
491  }
492 
493  if (Manager::Get()->GetConfigManager(_T("message_manager"))->ReadBool(_T("/auto_show_search"), true))
494  {
495  CodeBlocksLogEvent evtSwitch(cbEVT_SWITCH_TO_LOG_WINDOW, searchLog);
497  Manager::Get()->ProcessEvent(evtSwitch);
498  Manager::Get()->ProcessEvent(evtShow);
499  }
500 
501  searchLog->FocusEntry(focusIndex);
502 }
503 
504 void CodeRefactoring::DoRenameSymbols(const wxString& targetText, const wxString& replaceText)
505 {
507  cbEditor* editor = edMan->GetBuiltinActiveEditor();
508  if (!editor)
509  return;
510 
511  cbProject* project = m_NativeParser.GetProjectByEditor(editor);
512  for (SearchDataMap::iterator it = m_SearchDataMap.begin(); it != m_SearchDataMap.end(); ++it)
513  {
514  // check if the file is already opened in built-in editor and do search in it
515  cbEditor* ed = edMan->IsBuiltinOpen(it->first);
516  if (!ed)
517  {
518  ProjectFile* pf = project ? project->GetFileByFilename(it->first) : 0;
519  ed = edMan->Open(it->first, it->second.front().pos, pf);
520  }
521 
522  cbStyledTextCtrl* control = ed->GetControl();
523  control->BeginUndoAction();
524 
525  for (SearchDataList::reverse_iterator rIter = it->second.rbegin(); rIter != it->second.rend(); ++rIter)
526  {
527  control->SetTargetStart(rIter->pos);
528  control->SetTargetEnd(rIter->pos + targetText.Len());
529  control->ReplaceTarget(replaceText);
530  // for find references
531  rIter->text.Replace(targetText, replaceText);
532  }
533 
534  control->EndUndoAction();
535  }
536 }
537 
539 {
540  if (!project)
541  return;
542 
543  // fill the search list with all the project files
544  for (FilesList::const_iterator it = project->GetFilesList().begin();
545  it != project->GetFilesList().end(); ++it)
546  {
547  ProjectFile* pf = *it;
548  if (!pf)
549  continue;
550 
552  if (ft != ParserCommon::ftOther)
553  files.Add(pf->file.GetFullPath());
554  }
555 }
556 
558 {
560  if (edMan)
561  {
562  for (int i = 0; i < edMan->GetEditorsCount(); ++i)
563  files.Add(edMan->GetEditor(i)->GetFilename());
564  }
565 }
ProjectFile * GetFileByFilename(const wxString &filename, bool isRelative=true, bool isUnixFilename=false)
Access a file of the project.
Definition: cbproject.cpp:1049
Search location combination, a pointer to cbStyledTextCtrl and a filename is enough.
Definition: nativeparser.h:36
wxSize Fit(wxWindow *window)
cbEditor * IsBuiltinOpen(const wxString &filename)
Definition: editormanager.h:92
wxMutex s_TokenTreeMutex
Definition: tokentree.cpp:49
void OnOpenFilesClick(cb_unused wxCommandEvent &event)
void Append(const wxString &msg, Logger::level lv=info) override
Definition: loggers.cpp:363
virtual bool Update(int value, const wxString &newmsg=wxEmptyString, bool *skip=NULL)
virtual ~CodeRefactoring()
int m_ParentIndex
Parent Token index.
Definition: token.h:265
int WordEndPosition(int pos, bool onlyWordCharacters)
Get position of end of word.
int wxNewId()
wxString relativeFilename
The relative (to the project) filename of this file.
Definition: projectfile.h:131
Token * at(int idx)
Definition: tokentree.h:51
#define wxICON_WARNING
NativeParser & m_NativeParser
static CCLogger * Get()
Definition: cclogger.cpp:60
const wxValidator wxDefaultValidator
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
Definition: manager.cpp:182
void OnProjectFilesClick(cb_unused wxCommandEvent &event)
bool IsComment(int style)
Is style classified as comment for current language?
void GetOpenedFiles(wxArrayString &files)
virtual FilesList & GetFilesList()
Provides an easy way to iterate all the files belonging in this target.
Definition: cbproject.h:685
DLLIMPORT wxString cbGetTextFromUser(const wxString &message, const wxString &caption=cbGetTextFromUserPromptStr, const wxString &default_value=wxEmptyString, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord, bool centre=true)
Definition: globals.cpp:1465
wxFileName file
The full filename of this file.
Definition: projectfile.h:126
#define wxSCI_FIND_WHOLEWORD
Definition: wxscintilla.h:257
size_t VerifyResult(const TokenIdxSet &targetResult, const wxString &targetText, bool isLocalVariable)
void OnClose(cb_unused wxCloseEvent &event)
Event used to request from the main app to add a log.
Definition: sdk_events.h:182
int ReplaceTarget(const wxString &text)
Replace the target text with the argument text.
a container class to hold all the Tokens getting from parsing stage
Definition: tokentree.h:37
void SetText(const wxString &text)
Replace the contents of the document with the argument text.
wxString GetLine(int line) const
Retrieve the contents of a line.
#define _T(string)
static const long ID_PROJECT_FILES
cbProject * GetProjectByEditor(cbEditor *editor)
return the C::B project containing the cbEditor pointer
#define wxPD_CAN_ABORT
Represents a file in a Code::Blocks project.
Definition: projectfile.h:39
void Find(cbStyledTextCtrl *control, const wxString &file, const wxString &target)
EFileType FileType(const wxString &filename, bool force_refresh=false)
return a file type, which can be either header files or implementation files or other files ...
void DebugLog(const wxString &msg)
Definition: cclogger.cpp:107
void SetBasePath(const wxString base)
wxWindow * GetAppWindow() const
Definition: manager.cpp:424
int WordStartPosition(int pos, bool onlyWordCharacters)
Get position of start of word.
void GetAllProjectFiles(wxArrayString &files, cbProject *project)
EditorManager * GetEditorManager() const
Definition: manager.cpp:434
size_t MarkItemsByAI(ccSearchData *searchData, TokenIdxSet &result, bool reallyUseAI=true, bool isPrefix=true, bool caseSensitive=false, int caretPos=-1)
collect tokens where a code suggestion list can be shown
Try to detect the encoding of a file on disk.
void Clear() override
Definition: loggers.cpp:399
void DoRenameSymbols(const wxString &targetText, const wxString &replaceText)
bool MakeRelativeTo(const wxString &pathBase=wxEmptyString, wxPathFormat format=wxPATH_NATIVE)
virtual const wxString & GetFilename() const
Get the editor&#39;s filename (if applicable).
Definition: editorbase.h:45
Represents a Code::Blocks project.
Definition: cbproject.h:96
int GetCurrentLine()
Manually declared methods.
a symbol found in the parsed files, it can be many kinds, such as a variable, a class and so on...
Definition: token.h:82
#define wxSCI_FIND_MATCHCASE
Definition: wxscintilla.h:258
cbStyledTextCtrl * GetControl() const
Returns a pointer to the underlying cbStyledTextCtrl object (which itself is the wxWindows implementa...
Definition: cbeditor.cpp:842
void FocusEntry(size_t index)
std::set< int, std::less< int > > TokenIdxSet
Definition: token.h:16
#define wxPD_AUTO_HIDE
wxSizerItem * Add(wxWindow *window, const wxSizerFlags &flags)
EFileType
the enum type of the file type
Definition: parser_base.h:25
ScopeDialog(wxWindow *parent, const wxString &title)
const wxSize wxDefaultSize
cbEditor * GetBuiltinActiveEditor()
Definition: editormanager.h:95
const wxPoint wxDefaultPosition
virtual wxString NotDoneReason()
Definition: parser_base.h:151
int FindText(int minPos, int maxPos, const wxString &text, int flags=0, int *findEnd=NULL)
Find some text in the document.
#define wxPD_APP_MODAL
int GetCurrentPos() const
Returns the position of the caret.
EVTIMPORT const wxEventType cbEVT_SWITCH_TO_LOG_WINDOW
Definition: sdk_events.cpp:165
bool IsString(int style)
Is style classified as string for current language?
int GetLength() const
Returns the number of bytes in the document.
bool IsEmpty() const
wxString GetWxStr() const
#define CC_LOCKER_TRACK_TT_MTX_UNLOCK(M)
Definition: cclogger.h:165
virtual int ShowModal()
wxString GetTextRange(int startPos, int endPos)
Retrieve a range of text.
wxButton * m_OpenFiles
wxString wxEmptyString
#define wxOK
cbEditor * Open(const wxString &filename, int pos=0, ProjectFile *data=nullptr)
const wxString & _(const wxString &string)
wxEventType wxEVT_CLOSE_WINDOW
wxString & Trim(bool fromRight=true)
wxButton * m_ProjectFiles
EditorBase * GetEditor(int index)
#define CC_LOCKER_TRACK_TT_MTX_LOCK(M)
Definition: cclogger.h:159
static void ApplyStyles(cbStyledTextCtrl *control)
Apply the editor defaults to any (possibly foreign) cbStyledTextCtrl.
Definition: cbeditor.cpp:1309
NativeParser class is just like a manager class to control Parser objects.
Definition: nativeparser.h:55
static wxString GetDataFolder(bool global=true)
ParserBase & GetParser()
return a reference to the currently active Parser object
Definition: nativeparser.h:65
SearchDataMap m_SearchDataMap
virtual bool Done()
Definition: parser_base.h:150
A file editor.
Definition: cbeditor.h:43
bool IsEmpty() const
DLLIMPORT void PlaceWindow(wxTopLevelWindow *w, cbPlaceDialogMode mode=pdlBest, bool enforce=false)
Definition: globals.cpp:1177
void EndUndoAction()
End a sequence of actions that is undone and redone as a unit.
wxString GetPath(int flags=wxPATH_GET_VOLUME, wxPathFormat format=wxPATH_NATIVE) const
size_t Len() const
wxString GetSymbolUnderCursor()
void GotoPos(int caret)
Set caret to a position and ensure it is visible.
#define wxSCI_INVALID_POSITION
Definition: wxscintilla.h:70
TokenKind m_TokenKind
See TokenKind class.
Definition: token.h:234
bool ProcessEvent(CodeBlocksEvent &event)
Definition: manager.cpp:246
void SetSizeHints(wxWindow *window)
general function, not constructor nor destructor
Definition: token.h:54
int GetStyleAt(int pos) const
Returns the style byte at the position.
size_t Add(const wxString &str, size_t copies=1)
void SetTargetStart(int start)
Sets the position that starts the target which is used for updating the document without affecting th...
cbSearchResultsLog * GetSearchResultLogger() const
Returns pointer to the search result logger, might be nullptr or hidden.
Definition: manager.h:161
int LineFromPosition(int pos) const
Retrieve the line containing a position.
wxString GetText() const
Retrieve all the text in the document.
size_t GetCount() const
virtual TokenTree * GetTokenTree() const
size_t SearchInFiles(const wxArrayString &files, const wxString &targetText)
void SetTargetEnd(int end)
Sets the position that ends the target which is used for updating the document without affecting the ...
HighlightLanguage Apply(cbEditor *editor, HighlightLanguage lang, bool colourise)
CodeRefactoring(NativeParser &np)
HighlightLanguage GetLanguage() const
Definition: cbeditor.h:292
void BeginUndoAction()
Start a sequence of actions that is undone and redone as a unit.
static const long ID_OPEN_FILES
wxString GetFullPath(wxPathFormat format=wxPATH_NATIVE) const
static wxString Format(const wxString &format,...)
DLLIMPORT int cbMessageBox(const wxString &message, const wxString &caption=wxEmptyString, int style=wxOK, wxWindow *parent=NULL, int x=-1, int y=-1)
wxMessageBox wrapper.
Definition: globals.cpp:1395
EVTIMPORT const wxEventType cbEVT_SHOW_LOG_MANAGER
Definition: sdk_events.cpp:167