| 1 | /* |
| 2 | * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com) |
| 3 | * |
| 4 | * This program is free software: you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation, either version 3 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | #ifndef CPPREFACTER_H |
| 18 | #define CPPREFACTER_H |
| 19 | |
| 20 | #include <QObject> |
| 21 | #include "parser/parserutils.h" |
| 22 | #include "widgets/searchresultview.h" |
| 23 | #include "parser/cppparser.h" |
| 24 | |
| 25 | class Editor; |
| 26 | namespace QSynedit { |
| 27 | struct BufferCoord; |
| 28 | } |
| 29 | class Project; |
| 30 | class CppRefacter : public QObject |
| 31 | { |
| 32 | Q_OBJECT |
| 33 | public: |
| 34 | explicit CppRefacter(QObject *parent = nullptr); |
| 35 | |
| 36 | bool findOccurence(Editor * editor, const QSynedit::BufferCoord& pos); |
| 37 | bool findOccurence(const QString& statementFullname, SearchFileScope scope); |
| 38 | |
| 39 | void renameSymbol(Editor* editor, const QSynedit::BufferCoord& pos, const QString& newWord); |
| 40 | private: |
| 41 | void doFindOccurenceInEditor(PStatement statement, Editor* editor, const PCppParser& parser); |
| 42 | void doFindOccurenceInProject(PStatement statement, std::shared_ptr<Project> project, const PCppParser& parser); |
| 43 | PSearchResultTreeItem findOccurenceInFile( |
| 44 | const QString& filename, |
| 45 | const PStatement& statement, |
| 46 | const PCppParser& parser); |
| 47 | void renameSymbolInFile( |
| 48 | const QString& filename, |
| 49 | const PStatement& statement, |
| 50 | const QString& newWord, |
| 51 | const PCppParser& parser); |
| 52 | }; |
| 53 | |
| 54 | #endif // CPPREFACTER_H |
| 55 | |