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

kdevplatform/language/duchain

  • KDevelop
  • DeclarationId
Public Member Functions | List of all members
KDevelop::DeclarationId Class Reference

#include <declarationid.h>

Public Member Functions

 DeclarationId (const DeclarationId &rhs)
 
 DeclarationId (const IndexedDeclaration &decl, const IndexedInstantiationInformation &specialization=IndexedInstantiationInformation())
 
 DeclarationId (const IndexedQualifiedIdentifier &id=IndexedQualifiedIdentifier(), uint additionalId=0, const IndexedInstantiationInformation &specialization=IndexedInstantiationInformation())
 
 ~DeclarationId ()
 
Declaration * declaration (const TopDUContext *context, bool instantiateIfRequired=true) const
 
KDevVarLengthArray< Declaration * > declarations (const TopDUContext *context) const
 
uint hash () const
 
bool isDirect () const
 
bool isValid () const
 
bool operator!= (const DeclarationId &rhs) const
 
DeclarationId & operator= (const DeclarationId &rhs)
 
bool operator== (const DeclarationId &rhs) const
 
QualifiedIdentifier qualifiedIdentifier () const
 
void setSpecialization (const IndexedInstantiationInformation &spec)
 
IndexedInstantiationInformation specialization () const
 

Detailed Description

Allows clearly identifying a Declaration.

DeclarationId is needed to uniquely address Declarations that are in another top-context, because there may be multiple parsed versions of a file.

There are two forms of DeclarationId, one indirect and one direct. The direct form holds a reference to the Declaration instance, whereas the indirect form stores the qualified identifier and an additional index to disambiguate instances of multiple declarations with the same identifier.

Both forms also have a specialization index. It can be used in a language-specific way to pick other versions of the declaration. When the declaration is found, Declaration::specialize() is called on the found declaration with this value, and the returned value is the actually found declaration.

Note
This only works when the Declaration is in the symbol table.

Definition at line 50 of file declarationid.h.

Constructor & Destructor Documentation

◆ DeclarationId() [1/3]

KDevelop::DeclarationId::DeclarationId ( const IndexedQualifiedIdentifier &  id = IndexedQualifiedIdentifier(),
uint  additionalId = 0,
const IndexedInstantiationInformation &  specialization = IndexedInstantiationInformation() 
)
explicit

Constructor for indirect access to a declaration.

The resulting DeclarationId will not have a direct reference to the Declaration, but will look it up as needed.

Parameters
idIdentifier for this declaration id.
additionalIdAdditional index to disambiguate
specializationSpecialization index (see class documentation).

Definition at line 31 of file declarationid.cpp.

◆ DeclarationId() [2/3]

KDevelop::DeclarationId::DeclarationId ( const IndexedDeclaration &  decl,
const IndexedInstantiationInformation &  specialization = IndexedInstantiationInformation() 
)
explicit

Constructor for direct access to a declaration.

The resulting DeclarationId will directly reference the Declaration

Parameters
declDeclaration to reference.
specializationSpecialization index (see class documentation).

Definition at line 39 of file declarationid.cpp.

◆ DeclarationId() [3/3]

KDevelop::DeclarationId::DeclarationId ( const DeclarationId &  rhs)

Definition at line 47 of file declarationid.cpp.

◆ ~DeclarationId()

KDevelop::DeclarationId::~DeclarationId ( )

Definition at line 60 of file declarationid.cpp.

Member Function Documentation

◆ declaration()

Declaration * KDevelop::DeclarationId::declaration ( const TopDUContext *  context,
bool  instantiateIfRequired = true 
) const

Retrieve the declaration, from the perspective of context.

In order to be retrievable, the declaration must be in the symbol table.

Parameters
contextContext in which to search for the Declaration.
instantiateIfRequiredWhether the declaration should be instantiated if required
Returns
the referenced Declaration, or null if none was found.
Todo:
think this over once we don't pull in all imported top-context any more

Definition at line 154 of file declarationid.cpp.

◆ declarations()

KDevVarLengthArray< Declaration * > KDevelop::DeclarationId::declarations ( const TopDUContext *  context) const

Same as declaration(..), but returns all matching declarations if there are multiple.

This also returns found forward-declarations.

Todo:
think this over once we don't pull in all imported top-context any more

Definition at line 97 of file declarationid.cpp.

◆ hash()

uint KDevelop::DeclarationId::hash ( ) const
inline

Hash function for this declaration identifier.

Warning
This may return different hashes for the same declaration, depending on whether the id is direct or indirect, and thus you cannot compare hashes for declaration equality (use operator==() instead)

Definition at line 126 of file declarationid.h.

◆ isDirect()

bool KDevelop::DeclarationId::isDirect ( ) const

Determine whether this DeclarationId directly references a Declaration by indices, or if it uses identifiers and other data to reference the Declaration.

Returns
true if direct, false if indirect.

Definition at line 82 of file declarationid.cpp.

◆ isValid()

bool KDevelop::DeclarationId::isValid ( ) const
inline

Determine whether this declaration identifier references a valid declaration.

Definition at line 114 of file declarationid.h.

◆ operator!=()

bool KDevelop::DeclarationId::operator!= ( const DeclarationId &  rhs) const
inline

Not equal operator.

Parameters
rhsdeclaration identifier to compare.
Returns
true if not equal, otherwise false.

Definition at line 106 of file declarationid.h.

◆ operator=()

DeclarationId & KDevelop::DeclarationId::operator= ( const DeclarationId &  rhs)

Definition at line 67 of file declarationid.cpp.

◆ operator==()

bool KDevelop::DeclarationId::operator== ( const DeclarationId &  rhs) const
inline

Equality operator.

Parameters
rhsdeclaration identifier to compare.
Returns
true if equal, otherwise false.

Definition at line 87 of file declarationid.h.

◆ qualifiedIdentifier()

QualifiedIdentifier KDevelop::DeclarationId::qualifiedIdentifier ( ) const

Return the qualified identifier for this declaration.

Warning
This is relatively expensive, and not 100% correct in all cases(actually a top-context would be needed to resolve this correctly), so avoid using this, except for debugging purposes.

Definition at line 217 of file declarationid.cpp.

◆ setSpecialization()

void KDevelop::DeclarationId::setSpecialization ( const IndexedInstantiationInformation &  spec)

Set the specialization index (see class documentation).

Parameters
specthe new specialization index.

Definition at line 87 of file declarationid.cpp.

◆ specialization()

IndexedInstantiationInformation KDevelop::DeclarationId::specialization ( ) const

Retrieve the specialization index (see class documentation).

Returns
the specialization index.

Definition at line 92 of file declarationid.cpp.

Member Data Documentation

◆ m_directData

IndexedDeclaration KDevelop::DeclarationId::m_directData

Definition at line 195 of file declarationid.h.

◆ m_indirectData

Indirect KDevelop::DeclarationId::m_indirectData

Definition at line 194 of file declarationid.h.


The documentation for this class was generated from the following files:
  • declarationid.h
  • declarationid.cpp
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