kdevplatform/language/duchain
#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]
|
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
-
id Identifier for this declaration id. additionalId Additional index to disambiguate specialization Specialization index (see class documentation).
Definition at line 31 of file declarationid.cpp.
◆ DeclarationId() [2/3]
|
explicit |
Constructor for direct access to a declaration.
The resulting DeclarationId will directly reference the Declaration
- Parameters
-
decl Declaration to reference. specialization Specialization 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
-
context Context in which to search for the Declaration. instantiateIfRequired Whether 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()
|
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()
|
inline |
Determine whether this declaration identifier references a valid declaration.
Definition at line 114 of file declarationid.h.
◆ operator!=()
|
inline |
Not equal operator.
- Parameters
-
rhs declaration 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==()
|
inline |
Equality operator.
- Parameters
-
rhs declaration 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
-
spec the 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:
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Apr 15 2021 23:30:11 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.