35 #define CC_CODEREFACTORING_DEBUG_OUTPUT 0 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 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...) \ 55 if (g_EnableDebugTrace) \ 56 CCLogger::Get()->DebugLog(F(format, ##args)); \ 59 #define TRACE2(format, args...) \ 60 CCLogger::Get()->DebugLog(F(format, ##args)) 62 #define TRACE(format, args...) 63 #define TRACE2(format, args...) 79 wxDLG_UNIT(
this,
wxSize(5, 0)).GetWidth());
139 wxString msg(
_(
"The Parser is still parsing files."));
166 if (targetResult.empty())
173 bool isLocalVariable =
false;
179 const Token* token = tree->
at(*targetResult.begin());
184 isLocalVariable =
true;
191 if (isLocalVariable || !project)
210 count =
VerifyResult(targetResult, targetText, isLocalVariable);
228 _(
"Code Refactoring"),
231 if (!replaceText.
IsEmpty() && replaceText != targetText &&
Parse())
246 control->Show(
false);
250 _(
"Please wait while searching inside the project..."),
256 for (
size_t i = 0; i < files.
GetCount(); ++i)
269 if (!detector.
IsOK())
274 Find(control, files[i], targetText);
284 bool isLocalVariable)
291 const Token* parentOfLocalVariable =
nullptr;
298 const Token* token = tree->
at(*targetResult.begin());
307 control->Show(
false);
313 size_t totalCount = 0;
315 totalCount += it->second.size();
319 _(
"Please wait while verifying result..."),
325 size_t task = totalCount;
327 bool userBreak =
false;
337 if (!detector.
IsOK())
339 task -= it->second.size();
350 for (SearchDataList::iterator itList = it->second.begin(); itList != it->second.end();)
353 if (!progress->
Update(totalCount - (--task)))
360 const int style = control->
GetStyleAt(itList->pos);
363 it->second.erase(itList++);
368 const int endOfWord = itList->pos + targetText.
Len();
373 it->second.erase(itList++);
378 TokenIdxSet::const_iterator findIter = targetResult.begin();
379 for (; findIter != targetResult.end(); ++findIter)
381 if (result.find(*findIter) != result.end())
385 if (findIter == targetResult.end())
386 it->second.erase(itList++);
392 bool do_continue =
false;
398 const Token* token = tree->
at(*findIter);
402 if (parent != parentOfLocalVariable)
404 it->second.erase(itList++);
411 if (do_continue)
continue;
418 if (it->second.empty())
469 size_t focusIndex = 0;
476 for (SearchDataList::iterator itList = it->second.begin(); itList != it->second.end(); ++itList)
478 if (it->first == focusFile && itList->line == focusLine)
486 values.
Add(itList->text);
493 if (
Manager::Get()->GetConfigManager(
_T(
"message_manager"))->ReadBool(
_T(
"/auto_show_search"),
true))
519 ed = edMan->
Open(it->first, it->second.front().pos, pf);
525 for (SearchDataList::reverse_iterator rIter = it->second.rbegin(); rIter != it->second.rend(); ++rIter)
531 rIter->text.Replace(targetText, replaceText);
544 for (FilesList::const_iterator it = project->
GetFilesList().begin();
ProjectFile * GetFileByFilename(const wxString &filename, bool isRelative=true, bool isUnixFilename=false)
Access a file of the project.
Search location combination, a pointer to cbStyledTextCtrl and a filename is enough.
wxSize Fit(wxWindow *window)
cbEditor * IsBuiltinOpen(const wxString &filename)
void OnOpenFilesClick(cb_unused wxCommandEvent &event)
void Append(const wxString &msg, Logger::level lv=info) override
virtual bool Update(int value, const wxString &newmsg=wxEmptyString, bool *skip=NULL)
virtual ~CodeRefactoring()
int m_ParentIndex
Parent Token index.
int WordEndPosition(int pos, bool onlyWordCharacters)
Get position of end of word.
wxString relativeFilename
The relative (to the project) filename of this file.
NativeParser & m_NativeParser
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...
void OnProjectFilesClick(cb_unused wxCommandEvent &event)
void GetOpenedFiles(wxArrayString &files)
virtual FilesList & GetFilesList()
Provides an easy way to iterate all the files belonging in this target.
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)
wxFileName file
The full filename of this file.
#define wxSCI_FIND_WHOLEWORD
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.
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
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.
static const long ID_PROJECT_FILES
cbProject * GetProjectByEditor(cbEditor *editor)
return the C::B project containing the cbEditor pointer
Represents a file in a Code::Blocks project.
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)
void SetBasePath(const wxString base)
wxWindow * GetAppWindow() const
int WordStartPosition(int pos, bool onlyWordCharacters)
Get position of start of word.
void GetAllProjectFiles(wxArrayString &files, cbProject *project)
EditorManager * GetEditorManager() const
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 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's filename (if applicable).
Represents a Code::Blocks project.
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...
#define wxSCI_FIND_MATCHCASE
cbStyledTextCtrl * GetControl() const
Returns a pointer to the underlying cbStyledTextCtrl object (which itself is the wxWindows implementa...
void FocusEntry(size_t index)
std::set< int, std::less< int > > TokenIdxSet
wxSizerItem * Add(wxWindow *window, const wxSizerFlags &flags)
EFileType
the enum type of the file type
ScopeDialog(wxWindow *parent, const wxString &title)
const wxSize wxDefaultSize
cbEditor * GetBuiltinActiveEditor()
const wxPoint wxDefaultPosition
virtual wxString NotDoneReason()
int FindText(int minPos, int maxPos, const wxString &text, int flags=0, int *findEnd=NULL)
Find some text in the document.
int GetCurrentPos() const
Returns the position of the caret.
EVTIMPORT const wxEventType cbEVT_SWITCH_TO_LOG_WINDOW
bool IsString(int style)
Is style classified as string for current language?
int GetLength() const
Returns the number of bytes in the document.
wxString GetWxStr() const
#define CC_LOCKER_TRACK_TT_MTX_UNLOCK(M)
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)
static void ApplyStyles(cbStyledTextCtrl *control)
Apply the editor defaults to any (possibly foreign) cbStyledTextCtrl.
NativeParser class is just like a manager class to control Parser objects.
static wxString GetDataFolder(bool global=true)
ParserBase & GetParser()
return a reference to the currently active Parser object
SearchDataMap m_SearchDataMap
DLLIMPORT void PlaceWindow(wxTopLevelWindow *w, cbPlaceDialogMode mode=pdlBest, bool enforce=false)
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
wxString GetSymbolUnderCursor()
void GotoPos(int caret)
Set caret to a position and ensure it is visible.
#define wxSCI_INVALID_POSITION
TokenKind m_TokenKind
See TokenKind class.
bool ProcessEvent(CodeBlocksEvent &event)
void SetSizeHints(wxWindow *window)
general function, not constructor nor destructor
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.
int LineFromPosition(int pos) const
Retrieve the line containing a position.
wxString GetText() const
Retrieve all the text in the document.
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
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.
EVTIMPORT const wxEventType cbEVT_SHOW_LOG_MANAGER