language/duchain
KDevelop::DeclarationId Class Reference
Allows clearly identifying a Declaration. More...
#include <declarationid.h>
Public Member Functions | |
| DeclarationId (const IndexedDeclaration &decl, IndexedInstantiationInformation specialization=IndexedInstantiationInformation()) | |
| DeclarationId (const IndexedQualifiedIdentifier &id=IndexedQualifiedIdentifier(), uint additionalId=0, IndexedInstantiationInformation specialization=IndexedInstantiationInformation()) | |
| Declaration * | getDeclaration (const TopDUContext *context) const |
| KDevVarLengthArray< Declaration * > | getDeclarations (const TopDUContext *context) const |
| uint | hash () const |
| bool | isDirect () const |
| bool | isValid () const |
| bool | operator!= (const DeclarationId &rhs) const |
| bool | operator== (const DeclarationId &rhs) const |
| QualifiedIdentifier | qualifiedIdentifier () const |
| void | setSpecialization (IndexedInstantiationInformation specialization) |
| 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 55 of file declarationid.h.
Constructor & Destructor Documentation
| KDevelop::DeclarationId::DeclarationId | ( | const IndexedQualifiedIdentifier & | id = IndexedQualifiedIdentifier(), |
|
| uint | additionalId = 0, |
|||
| 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:
-
id Identifier for this declaration id. additionalId Additional index to disambiguate specialization Specialization index (see class documentation).
Definition at line 32 of file declarationid.cpp.
| KDevelop::DeclarationId::DeclarationId | ( | const IndexedDeclaration & | decl, | |
| IndexedInstantiationInformation | specialization = IndexedInstantiationInformation() | |||
| ) | [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 40 of file declarationid.cpp.
Member Function Documentation
| Declaration * KDevelop::DeclarationId::getDeclaration | ( | const TopDUContext * | context | ) | 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.
- 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 124 of file declarationid.cpp.
| KDevVarLengthArray< Declaration * > KDevelop::DeclarationId::getDeclarations | ( | const TopDUContext * | context | ) | const |
Same as getDeclaration(..), 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 69 of file declarationid.cpp.
| 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 115 of file declarationid.h.
| 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 56 of file declarationid.cpp.
| bool KDevelop::DeclarationId::isValid | ( | ) | const [inline] |
Determine whether this declaration identifier references a valid declaration.
Definition at line 105 of file declarationid.h.
| bool KDevelop::DeclarationId::operator!= | ( | const DeclarationId & | rhs | ) | const [inline] |
Not equal operator.
- Parameters:
-
rhs declaration identifier to compare.
- Returns:
- true if not equal, otherwise false.
Definition at line 98 of file declarationid.h.
| bool KDevelop::DeclarationId::operator== | ( | const DeclarationId & | rhs | ) | const [inline] |
Equality operator.
- Parameters:
-
rhs declaration identifier to compare.
- Returns:
- true if equal, otherwise false.
Definition at line 82 of file declarationid.h.
| 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 178 of file declarationid.cpp.
| void KDevelop::DeclarationId::setSpecialization | ( | IndexedInstantiationInformation | specialization | ) |
Set the specialization index (see class documentation).
- Parameters:
-
specializationIndex the new specialization index.
Definition at line 61 of file declarationid.cpp.
| IndexedInstantiationInformation KDevelop::DeclarationId::specialization | ( | ) | const |
Retrieve the specialization index (see class documentation).
- Returns:
- the specialization index.
Definition at line 65 of file declarationid.cpp.
The documentation for this class was generated from the following files:
KDE 4.4 API Reference