• 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
declaration.h
Go to the documentation of this file.
1 /* This file is part of KDevelop
2  Copyright 2006 Hamish Rodda <[email protected]>
3  Copyright 2007-2008 David Nolden <[email protected]>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef KDEVPLATFORM_DECLARATION_H
21 #define KDEVPLATFORM_DECLARATION_H
22 
23 #include <QList>
24 #include <QMap>
25 
26 #include "types/abstracttype.h"
27 #include "duchainbase.h"
28 #include "instantiationinformation.h"
29 #include "identifier.h"
30 #include "indexeddeclaration.h"
31 
32 class QByteArray;
33 
34 namespace KDevelop {
35 class AbstractType;
36 class DUContext;
37 class IndexedString;
38 class DeclarationData;
39 class DeclarationId;
40 class Declaration;
41 class IndexedTopDUContext;
42 class TopDUContext;
43 
51 class KDEVPLATFORMLANGUAGE_EXPORT Declaration
52  : public DUChainBase
53 {
54 public:
56  enum AccessPolicy : quint8 {
57  Public ,
58  Protected ,
59  Private ,
60  DefaultAccess
61  };
63  enum Kind : quint8 {
64  Type ,
65  Instance ,
66  NamespaceAlias ,
67  Alias,
68  Namespace,
69  Import,
70  Macro
71  };
72 
82  Declaration(const RangeInRevision& range, DUContext* parentContext);
84  Declaration(const Declaration& rhs);
86  ~Declaration() override;
88  explicit Declaration(DeclarationData& dd);
89 
90  Declaration& operator=(const Declaration& rhs) = delete;
91 
92  TopDUContext* topContext() const override;
93 
99  virtual bool isForwardDeclaration() const;
100 
106  virtual bool isFunctionDeclaration() const;
107 
117  virtual bool inDUChain() const;
118 
124  bool isDefinition() const;
130  void setDeclarationIsDefinition(bool dd);
131 
137  bool isTypeAlias() const;
143  void setIsTypeAlias(bool typeAlias);
144 
148  bool isDeprecated() const;
154  void setDeprecated(bool deprecated);
155 
163  void setAlwaysForceDirect(bool direct);
167  bool alwaysForceDirect() const;
168 
179  void setAutoDeclaration(bool _auto);
183  bool isAutoDeclaration() const;
184 
190  void setExplicitlyDeleted(bool deleted);
194  bool isExplicitlyDeleted() const;
195 
208  void setExplicitlyTyped(bool explicitlyTyped);
212  bool isExplicitlyTyped() const;
213 
225  virtual Declaration* specialize(const IndexedInstantiationInformation& specialization,
226  const TopDUContext* topContext, int upDistance = 0);
227 
238  DUContext* internalContext() const;
239 
245  void setInternalContext(DUContext* context);
246 
260  virtual DUContext* logicalInternalContext(const TopDUContext* topContext) const;
261 
268  const Declaration* logicalDeclaration(const TopDUContext* topContext) const;
269 
271  Declaration* logicalDeclaration(const TopDUContext* topContext);
272 
277  DUContext* context() const;
278 
297  void setContext(DUContext* context, bool anonymous = false);
298 
304  template <class T>
305  TypePtr<T> type() const { return TypePtr<T>::dynamicCast(abstractType()); }
306 
313  AbstractType::Ptr abstractType() const;
314 
320  template <class T>
321  void setType(TypePtr<T> type) { setAbstractType(AbstractType::Ptr::staticCast(type)); }
322 
328  virtual void setAbstractType(AbstractType::Ptr type);
329 
336  IndexedType indexedType() const;
337 
343  void setIdentifier(const Identifier& identifier);
344 
350  Identifier identifier() const;
351 
358  const IndexedIdentifier& indexedIdentifier() const;
359 
366  QualifiedIdentifier qualifiedIdentifier() const;
367 
375  bool equalQualifiedIdentifier(const Declaration* rhs) const;
376 
380  Kind kind() const;
381 
387  void setKind(Kind kind);
388 
395  QByteArray comment() const;
396 
402  void setComment(const QByteArray& str);
406  void setComment(const QString& str);
407 
413  bool inSymbolTable() const;
414 
420  virtual void setInSymbolTable(bool inSymbolTable);
421 
428  bool operator==(const Declaration& other) const;
429 
433  virtual QString toString() const;
434 
448  QMap<IndexedString, QVector<RangeInRevision>> uses() const;
449 
455  bool hasUses() const;
456 
469  QMap<IndexedString, QVector<KTextEditor::Range>> usesCurrentRevision() const;
470 
478  virtual uint additionalIdentity() const;
479 
483  virtual IndexedInstantiationInformation specialization() const;
484 
493  virtual DeclarationId id(bool forceDirect = false) const;
494 
506  uint ownIndex() const;
507 
511  bool isAnonymous() const;
512 
516  void clearOwnIndex();
517 
521  void allocateOwnIndex();
522 
532  Declaration* clone() const;
533 
540  virtual void activateSpecialization();
541 
542  enum {
543  Identity = 7
544  };
545 
546 protected:
547 
554  Declaration(DeclarationData& dd, const RangeInRevision& range);
555 
562  bool persistentlyDestroying() const;
563 
564  DUCHAIN_DECLARE_DATA(Declaration)
565 
566 private:
573  virtual Declaration* clonePrivate() const;
574 
575  void updateCodeModel();
576 
577  void rebuildDynamicData(DUContext* parent, uint ownIndex) override;
578 
579  friend class DUContext;
580  friend class IndexedDeclaration;
581  friend class LocalIndexedDeclaration;
582  friend class TopDUContextDynamicData;
583 
584  DUContext* m_context = nullptr;
585  TopDUContext* m_topContext = nullptr;
586  int m_indexInTopContext = 0;
587 };
588 }
589 
590 #endif // KDEVPLATFORM_DECLARATION_H
KDevelop::Declaration::Alias
This is an alias-declaration.
Definition: declaration.h:67
KDevelop::DUChainBase
Base class for definition-use chain objects.
Definition: duchainbase.h:131
KDevelop::TypePtr::dynamicCast
static TypePtr< T > dynamicCast(const TypePtr< U > &o)
Convert TypePtr to TypePtr<T>, using a dynamic_cast.
Definition: typepointer.h:88
KDevelop::Declaration::Import
Declaration marks the Import of a file.
Definition: declaration.h:69
KDevelop::Declaration::Namespace
Declaration of a namespace.
Definition: declaration.h:68
KDevelop::IndexedIdentifier
A helper-class to store an identifier by index in a type-safe way.
Definition: identifier.h:55
KDevelop::TypePtr
QExplicitlySharedDataPointer wrapper with convenience functions attached.
Definition: typepointer.h:39
DUCHAIN_DECLARE_DATA
#define DUCHAIN_DECLARE_DATA(Class)
Use this to declare the data functions in your DUChainBase based class.
Definition: duchainbase.h:41
KDevelop::TypePtr< AbstractType >::staticCast
static TypePtr< AbstractType > staticCast(const TypePtr< U > &o)
Convert TypePtr to TypePtr<T>, using a static_cast.
Definition: typepointer.h:72
KDevelop::Declaration
Represents a single declaration in a definition-use chain.
Definition: declaration.h:51
KDevelop::TopDUContextDynamicData
This class contains dynamic data of a top-context, and also the repository that contains all the data...
Definition: topducontextdynamicdata.h:37
KDevelop::Declaration::setType
void setType(TypePtr< T > type)
Set this declaration's type.
Definition: declaration.h:321
KDevelop::IndexedDeclaration
Represents a declaration only by its global indices.
Definition: indexeddeclaration.h:33
KDevelop::Declaration::Kind
Kind
Enumeration of the types of declarations.
Definition: declaration.h:63
QString
identifier.h
KDevelop::Declaration::type
TypePtr< T > type() const
Convenience function to return this declaration's type dynamically casted to T.
Definition: declaration.h:305
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::Identifier
Represents a single unqualified identifier.
Definition: identifier.h:150
KDevelop::Declaration::AccessPolicy
AccessPolicy
Access types.
Definition: declaration.h:56
KDevelop::DeclarationData
Definition: declarationdata.h:35
QMap
KDevelop::LocalIndexedDeclaration
Represents a declaration only by its index within the top-context.
Definition: localindexeddeclaration.h:32
KDevelop::QualifiedIdentifier
Represents a qualified identifier.
Definition: identifier.h:245
abstracttype.h
KDevelop::IndexedType
Indexed type pointer.
Definition: indexedtype.h:36
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
KDevelop::DUContext
A single context in source code, represented as a node in a directed acyclic graph.
Definition: ducontext.h:72
indexeddeclaration.h
QByteArray
duchainbase.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Jan 19 2021 23:36:33 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