File indexing completed on 2024-05-12 04:37:41
0001 /* 0002 SPDX-FileCopyrightText: 2012 Olivier de Gaalon <olivier.jg@gmail.com> 0003 SPDX-FileCopyrightText: 2014 Kevin Funk <kfunk@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #ifndef KDEVPLATFORM_RENAMEACTION_H 0009 #define KDEVPLATFORM_RENAMEACTION_H 0010 0011 #include <interfaces/iassistant.h> 0012 #include <language/editor/rangeinrevision.h> 0013 #include <language/backgroundparser/documentchangetracker.h> 0014 #include <language/languageexport.h> 0015 0016 namespace KDevelop { 0017 class Identifier; 0018 class RenameActionPrivate; 0019 0020 /** 0021 * A HACK to circumvent the bad RangeInRevision API without rewriting everything. 0022 * 0023 * The RangeInRevision is actually just blindly assuming that it belongs to 0024 * the revision the file was parsed in the last time. But if the file is 0025 * reparsed in between (due to changes) the ranges might be wrong. Due to that 0026 * we must store the ranges and their actual revision... Stupid! 0027 * 0028 * See also: https://bugs.kde.org/show_bug.cgi?id=295707 0029 */ 0030 struct KDEVPLATFORMLANGUAGE_EXPORT RevisionedFileRanges 0031 { 0032 KDevelop::IndexedString file; 0033 KDevelop::RevisionReference revision; 0034 QVector<KDevelop::RangeInRevision> ranges; 0035 0036 static QVector<RevisionedFileRanges> convert(const QMap<KDevelop::IndexedString, 0037 QVector<KDevelop::RangeInRevision>>& uses); 0038 }; 0039 0040 class KDEVPLATFORMLANGUAGE_EXPORT RenameAction 0041 : public KDevelop::IAssistantAction 0042 { 0043 Q_OBJECT 0044 0045 public: 0046 RenameAction(const KDevelop::Identifier& oldDeclarationName, const QString& newDeclarationName, 0047 const QVector<RevisionedFileRanges>& oldDeclarationUses); 0048 ~RenameAction() override; 0049 0050 QString description() const override; 0051 void execute() override; 0052 0053 QString newDeclarationName() const; 0054 QString oldDeclarationName() const; 0055 0056 private: 0057 const QScopedPointer<class RenameActionPrivate> d_ptr; 0058 Q_DECLARE_PRIVATE(RenameAction) 0059 }; 0060 } 0061 0062 Q_DECLARE_TYPEINFO(KDevelop::RevisionedFileRanges, Q_MOVABLE_TYPE); 0063 0064 #endif