Warning, file /kdevelop/kdev-python/duchain/types/hintedtype.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2011 Sven Brauch <svenbrauch@googlemail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef HINTEDTYPE_H
0008 #define HINTEDTYPE_H
0009 
0010 #include "pythonduchainexport.h"
0011 
0012 #include <language/duchain/types/structuretype.h>
0013 #include <language/duchain/types/typesystem.h>
0014 #include <language/duchain/types/typesystemdata.h>
0015 #include <language/duchain/types/typealiastype.h>
0016 #include <language/duchain/use.h>
0017 #include <language/duchain/topducontext.h>
0018 #include <language/editor/modificationrevision.h>
0019 
0020 using namespace KDevelop;
0021 
0022 namespace Python {
0023 
0024 class KDEVPYTHONDUCHAIN_EXPORT HintedTypeData : public KDevelop::TypeAliasTypeData
0025 {
0026 public:
0027     /// Constructor
0028     HintedTypeData()
0029         : KDevelop::TypeAliasTypeData(), m_createdByContext((TopDUContext*) nullptr), m_modificationRevision()
0030     {
0031     }
0032     /// Copy constructor. \param rhs data to copy
0033     HintedTypeData( const HintedTypeData& rhs )
0034         : KDevelop::TypeAliasTypeData(rhs), m_createdByContext(rhs.m_createdByContext)
0035         , m_modificationRevision(rhs.m_modificationRevision)
0036     {
0037     }
0038     
0039     HintedTypeData(const TypeAliasTypeData& rhs)
0040         : KDevelop::TypeAliasTypeData(rhs), m_createdByContext((TopDUContext*) nullptr), m_modificationRevision()
0041     {
0042     };
0043     
0044     IndexedTopDUContext m_createdByContext;
0045     ModificationRevision m_modificationRevision;
0046 };
0047 
0048 
0049 /**
0050 * Describes a type which is a hint, and thus kept between parser passes and only deleted if the context which created it
0051 * goes away or is reparsed (it'll create a new one in case the hint still exists)
0052 **/
0053 class KDEVPYTHONDUCHAIN_EXPORT HintedType : public KDevelop::TypeAliasType
0054 {
0055 public:
0056     typedef TypePtr<HintedType> Ptr;
0057 
0058     HintedType();
0059     HintedType(const HintedType& rhs);
0060     HintedType(TypeAliasTypeData& data);
0061 
0062     /**
0063      * @brief Sets the creating topDUContext for this type hint.
0064      * Also uses that contexts current modification revision as creation time.
0065      *
0066      * @param context the topDUContext to use
0067      **/
0068     void setCreatedBy(TopDUContext* context, const ModificationRevision& revision);
0069     /** @return the creating TopDUContext for this type hint. */
0070     IndexedTopDUContext createdBy() const;
0071     AbstractType* clone() const override;
0072     uint hash() const override;
0073 
0074     /**
0075      * @brief Checks whether this hint is still valid, and returns false if it is not
0076      * @warning The DUChain must be at least read-locked for this
0077      *
0078      * @return bool true if valid, false otherwise
0079      **/
0080     bool isValid();
0081 
0082     bool equals(const AbstractType* rhs) const override;
0083     enum {
0084         Identity = 62
0085     };
0086 
0087     typedef HintedTypeData Data;
0088 
0089 protected:
0090     TYPE_DECLARE_DATA(HintedType);
0091 };
0092 
0093 }
0094 
0095 #endif // VARIABLELENGTHCONTAINER_H