File indexing completed on 2024-05-12 04:39:08
0001 /* 0002 SPDX-FileCopyrightText: 2009 David Nolden <david.nolden.kdevelop@art-master.de> 0003 SPDX-FileCopyrightText: 2014 Kevin Funk <kfunk@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #ifndef SIGNATUREASSISTANT_H 0009 #define SIGNATUREASSISTANT_H 0010 0011 #include "adaptsignatureaction.h" 0012 #include "clangprivateexport.h" 0013 0014 #include <language/assistant/staticassistant.h> 0015 #include <language/duchain/identifier.h> 0016 #include <language/duchain/topducontext.h> 0017 0018 #include <QPointer> 0019 0020 namespace KTextEditor { 0021 class View; 0022 } 0023 0024 class KDEVCLANGPRIVATE_EXPORT AdaptSignatureAssistant : public KDevelop::StaticAssistant 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 explicit AdaptSignatureAssistant(KDevelop::ILanguageSupport* supportedLanguage); 0030 0031 QString title() const override; 0032 void textChanged(KTextEditor::Document* doc, const KTextEditor::Range& invocationRange, const QString& removedText = QString()) override; 0033 bool isUseful() const override; 0034 KTextEditor::Range displayRange() const override; 0035 0036 private: 0037 ///Compare @a newSignature to m_oldSignature and put differences in @a oldPositions 0038 ///@returns whether or not there are any differences 0039 bool getSignatureChanges(const Signature &newSignature, QList<int> &oldPositions) const; 0040 ///Set default params in @a newSignature based on m_oldSignature's defaults and @a oldPositions 0041 void setDefaultParams(Signature &newSignature, const QList<int> &oldPositions) const; 0042 ///@returns RenameActions for each parameter in newSignature that has been renamed 0043 QList<KDevelop::RenameAction*> getRenameActions(const Signature &newSignature, const QList<int> &oldPositions) const; 0044 0045 // If this is true, the user is editing on the definition side, 0046 // and the declaration should be updated 0047 bool m_editingDefinition = false; 0048 KDevelop::Identifier m_declarationName; 0049 KDevelop::DeclarationId m_otherSideId; 0050 KDevelop::ReferencedTopDUContext m_otherSideTopContext; 0051 KDevelop::DUContextPointer m_otherSideContext; 0052 KTextEditor::Cursor m_lastEditPosition; 0053 //old signature of the _other_side 0054 Signature m_oldSignature; 0055 QPointer<KTextEditor::Document> m_document; 0056 QPointer<KTextEditor::View> m_view; 0057 0058 private Q_SLOTS: 0059 void updateReady(const KDevelop::IndexedString& document, const KDevelop::ReferencedTopDUContext& context) override; 0060 void reset(); 0061 }; 0062 0063 #endif // SIGNATUREASSISTANT_H