• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdevelop API Reference
  • KDE Home
  • Contact Us
 

kdevplatform/language/duchain

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • language
  • duchain
declarationid.h
Go to the documentation of this file.
1 /* This file is part of KDevelop
2  Copyright 2008 David Nolden <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef KDEVPLATFORM_DECLARATION_ID_H
20 #define KDEVPLATFORM_DECLARATION_ID_H
21 
22 #include "indexeddeclaration.h"
23 #include "identifier.h"
24 #include "instantiationinformation.h"
25 #include <language/util/kdevhash.h>
26 
27 //krazy:excludeall=dpointer
28 
29 namespace KDevelop {
30 class Declaration;
31 class TopDUContext;
32 
50 class KDEVPLATFORMLANGUAGE_EXPORT DeclarationId
51 {
52 public:
61  explicit DeclarationId(const IndexedQualifiedIdentifier& id = IndexedQualifiedIdentifier(),
62  uint additionalId = 0,
63  const IndexedInstantiationInformation& specialization = IndexedInstantiationInformation());
64 
72  explicit DeclarationId(const IndexedDeclaration& decl,
73  const IndexedInstantiationInformation& specialization = IndexedInstantiationInformation());
74 
75  DeclarationId(const DeclarationId& rhs);
76 
77  ~DeclarationId();
78 
79  DeclarationId& operator=(const DeclarationId& rhs);
80 
87  bool operator==(const DeclarationId& rhs) const
88  {
89  if (m_isDirect != rhs.m_isDirect)
90  return false;
91 
92  if (!m_isDirect)
93  return m_indirectData.identifier == rhs.m_indirectData.identifier
94  && m_indirectData.additionalIdentity == rhs.m_indirectData.additionalIdentity
95  && m_specialization == rhs.m_specialization;
96  else
97  return m_directData == rhs.m_directData && m_specialization == rhs.m_specialization;
98  }
99 
106  bool operator!=(const DeclarationId& rhs) const
107  {
108  return !operator==(rhs);
109  }
110 
114  bool isValid() const
115  {
116  return (m_isDirect && m_directData.isValid()) || m_indirectData.identifier.isValid();
117  }
118 
126  uint hash() const
127  {
128  if (m_isDirect)
129  return KDevHash() << m_directData.hash() << m_specialization.index();
130  else
131  return KDevHash() << m_indirectData.identifier.index() << m_indirectData.additionalIdentity <<
132  m_specialization.index();
133  }
134 
143  Declaration* declaration(const TopDUContext* context, bool instantiateIfRequired = true) const;
144 
149  KDevVarLengthArray<Declaration*> declarations(const TopDUContext* context) const;
150 
156  void setSpecialization(const IndexedInstantiationInformation& spec);
157 
163  IndexedInstantiationInformation specialization() const;
164 
171  bool isDirect() const;
172 
179  QualifiedIdentifier qualifiedIdentifier() const;
180 
181 private:
184  struct Indirect
185  {
186  IndexedQualifiedIdentifier identifier;
188  uint additionalIdentity;
189 
190  Indirect& operator=(const Indirect& rhs) = default;
191  };
192 
193  union {
194  Indirect m_indirectData;
195  IndexedDeclaration m_directData;
196  };
197  bool m_isDirect;
198 
199  // Can be used in a language-specific way to pick other versions of the declaration.
200  // When the declaration is found, pickSpecialization is called on the found declaration
201  // with this value, and the returned value is the actually found declaration.
202  IndexedInstantiationInformation m_specialization;
203 };
204 
205 inline uint qHash(const KDevelop::DeclarationId& id)
206 {
207  return id.hash();
208 }
209 }
210 
211 Q_DECLARE_TYPEINFO(KDevelop::DeclarationId, Q_MOVABLE_TYPE);
212 
213 #endif
KDevelop::DeclarationId::operator==
bool operator==(const DeclarationId &rhs) const
Equality operator.
Definition: declarationid.h:87
KDevelop::DeclarationId::isValid
bool isValid() const
Determine whether this declaration identifier references a valid declaration.
Definition: declarationid.h:114
KDevelop::IndexedQualifiedIdentifier
A helper-class to store an identifier by index in a type-safe way.
Definition: identifier.h:95
KDevelop::Declaration
Represents a single declaration in a definition-use chain.
Definition: declaration.h:51
KDevelop::IndexedDeclaration
Represents a declaration only by its global indices.
Definition: indexeddeclaration.h:33
identifier.h
KDevVarLengthArray
KDevelop::TopDUContext
The top context in a definition-use chain for one source file.
Definition: topducontext.h:113
instantiationinformation.h
KDevelop::DeclarationId
Allows clearly identifying a Declaration.
Definition: declarationid.h:50
KDevelop::DeclarationId::m_indirectData
Indirect m_indirectData
Definition: declarationid.h:194
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(KDevelop::DeclarationId, Q_MOVABLE_TYPE)
KDevelop::qHash
uint qHash(const KDevelop::DeclarationId &id)
Definition: declarationid.h:205
KDevelop::DeclarationId::operator!=
bool operator!=(const DeclarationId &rhs) const
Not equal operator.
Definition: declarationid.h:106
KDevelop::QualifiedIdentifier
Represents a qualified identifier.
Definition: identifier.h:245
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
KDevelop::DeclarationId::hash
uint hash() const
Hash function for this declaration identifier.
Definition: declarationid.h:126
indexeddeclaration.h
KDevelop::DeclarationId::m_directData
IndexedDeclaration m_directData
Definition: declarationid.h:195
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 23 2021 09:40:52 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/language/duchain

Skip menu "kdevplatform/language/duchain"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdevelop API Reference

Skip menu "kdevelop API Reference"
  • kdevplatform
  •   debugger
  •   documentation
  •   interfaces
  •   language
  •     assistant
  •     backgroundparser
  •     checks
  •     classmodel
  •     codecompletion
  •     codegen
  •     duchain
  •     editor
  •     highlighting
  •     interfaces
  •     util
  •   outputview
  •   project
  •   serialization
  •   shell
  •   sublime
  •   tests
  •   util
  •   vcs

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal