File indexing completed on 2024-05-26 04:41:07
0001 /* 0002 SPDX-FileCopyrightText: 2007 David Nolden <david.nolden.kdevelop@art-master.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #ifndef KDEVPLATFORM_ABSTRACTDECLARATIONNAVIGATIONCONTEXT_H 0008 #define KDEVPLATFORM_ABSTRACTDECLARATIONNAVIGATIONCONTEXT_H 0009 0010 #include "abstractnavigationcontext.h" 0011 #include "../declaration.h" 0012 #include "../duchainpointer.h" 0013 #include "../types/abstracttype.h" 0014 0015 namespace KDevelop { 0016 class IdentifiedType; 0017 class Identifier; 0018 class QualifiedIdentifier; 0019 class AbstractDeclarationNavigationContextPrivate; 0020 0021 class KDEVPLATFORMLANGUAGE_EXPORT AbstractDeclarationNavigationContext 0022 : public AbstractNavigationContext 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 AbstractDeclarationNavigationContext(const DeclarationPointer& decl, const TopDUContextPointer& topContext, 0028 AbstractNavigationContext* previousContext = nullptr); 0029 ~AbstractDeclarationNavigationContext() override; 0030 0031 QString name() const override; 0032 0033 DeclarationPointer declaration() const; 0034 0035 ///Execute an action. For example "show_uses" shows the uses of the declaration. 0036 ///Returns the context pointer for the new state. 0037 NavigationContextPointer executeKeyAction(const QString& key) override; 0038 0039 QString html(bool shorten = false) override; 0040 0041 protected: 0042 ///Should returns a stripped version of the declarations qualified identifier, with all implicit/redundant parts removed 0043 virtual QualifiedIdentifier prettyQualifiedIdentifier(const DeclarationPointer& decl) const; 0044 ///Returns a stripped version of the declarations identifier, using prettyQualifiedIdentifier 0045 Identifier prettyIdentifier(const DeclarationPointer& decl) const; 0046 /// @return String version of the qualified identifier of @p decl, "<anonymous>" on an invalid QID 0047 QString prettyQualifiedName(const DeclarationPointer& decl) const; 0048 0049 /** 0050 * Return a rich-text version of the identifier @p identifier representing the declaration @p decl 0051 * 0052 * @note In case @p declaration is deprecated, the resulting string will get a special formatting 0053 */ 0054 QString identifierHighlight(const QString& identifier, const DeclarationPointer& decl) const; 0055 0056 static QString stringFromAccess(Declaration::AccessPolicy access); 0057 static QString stringFromAccess(const DeclarationPointer& decl); 0058 QString declarationName(const DeclarationPointer& decl) const; 0059 static QStringList declarationDetails(const DeclarationPointer& decl); 0060 static QString declarationSizeInformation(const DeclarationPointer& decl, const TopDUContext* topContext); 0061 0062 ///This can be used for example to resolve typedefs within the type. 0063 ///All types that are visualized in the navigation-context are/should be mangled through this. 0064 ///The default-implementation returns the original type. 0065 virtual AbstractType::Ptr typeToShow(AbstractType::Ptr type); 0066 0067 ///Print the function-signature in a way that return-type and argument can be jumped to 0068 virtual void htmlFunction(); 0069 ///Navigation for additional less important links, like what function was overloaded etc. 0070 virtual void htmlAdditionalNavigation(); 0071 0072 virtual void htmlClass(); 0073 virtual void htmlIdentifiedType(AbstractType::Ptr type, const IdentifiedType* idType); 0074 0075 ///Creates and registers a link for the given type that jumps to its declaration and to the template-argument declarations 0076 virtual void eventuallyMakeTypeLinks(KDevelop::AbstractType::Ptr type); 0077 0078 ///Creates a link that triggers a recomputation of this context with m_fullBackwardSearch set to true 0079 void createFullBackwardSearchLink(const QString& string); 0080 0081 private: 0082 const QScopedPointer<class AbstractDeclarationNavigationContextPrivate> d_ptr; 0083 Q_DECLARE_PRIVATE(AbstractDeclarationNavigationContext) 0084 }; 0085 } 0086 0087 #endif