kdevplatform/language/duchain
declaration.cpp
Go to the documentation of this file.
69 static Repositories::StringRepository commentRepositoryObject(QStringLiteral("Comment Repository"));
146 //Only perform the actions when the top-context isn't being deleted, or when it hasn't been stored to disk
158 // always delete the declaration, to not create crashes within more complex code like C++ template stuff.
442 //Take the top-context from the other side. We need to allocate an index, so we can safely call setOwner(..)
468 return QStringLiteral("%3 %4").arg(abstractType() ? abstractType()->toString() : QStringLiteral(
590 if (decl->kind() == Declaration::Type && (decl->type<StructureType>() || dynamic_cast<ClassDeclaration*>(decl)))
709 for (QMap<IndexedString, QMap<RangeInRevision, bool>>::const_iterator it = tempUses.constBegin();
714 for (QMap<RangeInRevision, bool>::const_iterator it2 = (*it).constBegin(); it2 != (*it).constEnd(); ++it2)
746 bool ret = idx != std::numeric_limits<int>::max() && (idx >= 0 || hasDeclarationUse(topContext(), idx)); //hasLocalUses
794 for (QMap<IndexedString, QMap<KTextEditor::Range, bool>>::const_iterator it = tempUses.constBegin();
799 for (QMap<KTextEditor::Range, bool>::const_iterator it2 = (*it).constBegin(); it2 != (*it).constEnd();
Allows simple indirect access to top-contexts with on-demand loading.
Definition: indexedtopducontext.h:35
const_iterator constBegin() const
void addItem(const IndexedString &file, const IndexedQualifiedIdentifier &id, CodeModelItem::Kind kind)
There can only be one item for each identifier.
Definition: codemodel.cpp:196
bool inSymbolTable() const
Returns whether this context is listed in the symbol table (Namespaces and classes)
Definition: ducontext.cpp:1448
bool isDeprecated() const
Determine whether the declaration is deprecated.
Definition: declaration.cpp:497
Definition: codemodel.h:45
static PersistentSymbolTable & self()
Definition: persistentsymboltable.cpp:494
QMap< IndexedString, QVector< KTextEditor::Range > > usesCurrentRevision() const
Returns a map of files to use-ranges.
Definition: declaration.cpp:760
Definition: codemodel.h:44
void setSpecialization(const IndexedInstantiationInformation &spec)
Set the specialization index (see class documentation).
Definition: declarationid.cpp:87
int indexForUsedDeclaration(Declaration *declaration, bool create=true)
Retrieves or creates a local index that is to be used for referencing the given.
Definition: topducontext.cpp:1159
A type is declared, like a class-declaration or function-declaration, or a typedef("class MyClass {};...
Definition: declaration.h:64
REGISTER_DUCHAIN_ITEM(AliasDeclaration)
const IndexedIdentifier & indexedIdentifier() const
Access this declaration's identifier.
Definition: declaration.cpp:210
void clearOwnIndex()
Clear the index for this declaration in the top context that was allocated with allocateOwnIndex().
Definition: declaration.cpp:338
void initDeclarationRepositories()
Definition: declaration.cpp:73
void setContext(DUContext *context, bool anonymous=false)
Set the context in which this declaration occurs.
Definition: declaration.cpp:290
static Repositories::StringRepository & commentRepository()
Definition: declaration.cpp:67
bool isAutoDeclaration() const
Determine whether this declaration is implicitly created or not.
Definition: declaration.cpp:487
static SpecializationStore & self()
Definition: specializationstore.cpp:33
const Declaration * logicalDeclaration(const TopDUContext *topContext) const
This is a convenience function to determine the resolved declaration, if this is a forward declaratio...
Definition: declaration.cpp:372
virtual bool isFunctionDeclaration() const
Determine whether this declaration is a function declaration.
Definition: declaration.cpp:655
KTextEditor::Cursor transformFromLocalRevision(const CursorInRevision &cursor) const
A helper-class to store an identifier by index in a type-safe way.
Definition: identifier.h:55
bool isDirect() const
Determine whether this DeclarationId directly references a Declaration by indices,...
Definition: declarationid.cpp:82
virtual QString toString() const
Determine this declaration as a string.
Definition: declaration.cpp:466
uint allocateDeclarationIndex(Declaration *decl, bool temporary)
Allocates an index for the given declaration in this top-context.
Definition: topducontextdynamicdata.cpp:801
Declaration * declarationForIndex(uint index) const
Definition: topducontextdynamicdata.cpp:848
Represents a single declaration in a definition-use chain.
Definition: declaration.h:51
void setOwner(Declaration *decl)
Sets the declaration/definition, and also updates it's internal context (they are strictly paired tog...
Definition: ducontext.cpp:492
virtual bool inDUChain() const
Determine whether this declaration is accessible through the du-chain.
Definition: declaration.cpp:91
bool hasUses(const DeclarationId &id) const
Checks whether the given DeclarationID is is used.
Definition: uses.cpp:189
bool equalScopeIdentifier(const DUContext *rhs) const
Returns true if this context has the same scope identifier as the given one.
Definition: ducontext.cpp:1092
void setIsTypeAlias(bool typeAlias)
Set whether this declaration is a type alias.
Definition: declaration.cpp:544
QByteArray comment() const
Returns the comment associated to this declaration in the source-code, or an invalid string if there ...
Definition: declaration.cpp:177
Represents a position in a document where a specific declaration is used.
Definition: use.h:47
bool isTypeAlias() const
Determine if this declaration is a type-alias (in c++ typedef).
Definition: declaration.cpp:538
bool isAnonymous() const
Whether this declaration has been inserted anonymously into its parent-context.
Definition: declaration.cpp:285
bool isExplicitlyDeleted() const
Determine whether this declaration is "explicitly deleted" or not.
Definition: declaration.cpp:517
friend class IndexedDeclaration
Definition: declaration.h:580
#define ENSURE_CAN_WRITE
Like the ENSURE_CHAIN_WRITE_LOCKED and .._READ_LOCKED, except that this should be used in items that ...
Definition: duchainlock.h:184
QVector< RangeInRevision > allUses(DUContext *context, int declarationIndex, bool noEmptyUses)
Collects all uses of the given declarationIndex.
Definition: ducontext.cpp:1519
void addDeclaration(Declaration *declaration)
Definition: ducontext.cpp:204
IndexedType indexedType() const
Return an indexed form of this declaration's type.
Definition: declaration.cpp:238
const IndexedString identifier() const
Definition: identifier.cpp:520
bool equalQualifiedIdentifier(const Declaration *rhs) const
Compares the qualified identifier of this declaration with the other one, without needing to compute ...
Definition: declaration.cpp:665
void setDeclarationIsDefinition(bool dd)
Set whether this declaration is also a definition.
Definition: declaration.cpp:480
An instance of a type is declared("MyClass m;")
Definition: declaration.h:65
RangeInRevision range() const
Returns the range assigned to this object, in the document revision when this document was last parse...
Definition: duchainbase.cpp:152
QByteArray toUtf8() const
TypePtr< T > type() const
Convenience function to return this declaration's type dynamically casted to T.
Definition: declaration.h:305
TopDUContext * topContext() const override
Determine the top context to which this object belongs.
Definition: declaration.cpp:633
void clearDeclarationIndex(Declaration *decl)
Definition: topducontextdynamicdata.cpp:864
bool inSymbolTable() const
Access whether this declaration is in the symbol table.
Definition: declaration.cpp:573
The top context in a definition-use chain for one source file.
Definition: topducontext.h:113
virtual IndexedInstantiationInformation specialization() const
TODO document.
Definition: declaration.cpp:550
static Uses * uses()
Returns the structure that manages mapping between declarations, and which top level contexts contain...
Definition: duchain.cpp:1689
void removeItem(const IndexedString &file, const IndexedQualifiedIdentifier &id)
Definition: codemodel.cpp:305
DUContext * context() const
Access the parent context of this declaration.
Definition: declaration.cpp:279
void setAlwaysForceDirect(bool direct)
Changes whether this declaration must be direct in all cases or not.
Definition: declaration.cpp:512
void setExplicitlyTyped(bool explicitlyTyped)
Changes whether this declaration is explicitly typed.
Definition: declaration.cpp:532
KDevVarLengthArray< IndexedTopDUContext > uses(const DeclarationId &id) const
Gets the top-contexts of all users assigned to the declaration-id.
Definition: uses.cpp:198
void removeDeclaration(const IndexedQualifiedIdentifier &id, const IndexedDeclaration &declaration)
Adds declaration declaration with id id to the symbol table.
Definition: persistentsymboltable.cpp:259
void setInternalContext(DUContext *context)
Set the internal context for this declaration.
Definition: declaration.cpp:431
const Key key(const T &value) const
bool isTemporaryDeclarationIndex(uint index) const
Definition: topducontextdynamicdata.cpp:831
virtual DeclarationId id(bool forceDirect=false) const
Definition: declaration.cpp:564
Definition: declarationdata.h:35
void push(const IndexedIdentifier &id)
Append id to this qualified identifier.
Definition: identifier.cpp:995
QVector< DUContext * > childContexts() const
Returns the list of immediate child contexts for this context.
Definition: ducontext.cpp:479
bool inDUChain() const override
Returns true if this object is registered in the du-chain. If it is not, all sub-objects(context,...
Definition: topducontext.cpp:1114
uint ownIndex() const
Returns an index that uniquely identifies this declaration within its surrounding top-context.
Definition: declaration.cpp:114
Declaration * clone() const
Returns a clone of this declaration, with the difference that the returned declaration has no context...
Definition: declaration.cpp:643
QualifiedIdentifier qualifiedIdentifier() const
Determine the global qualified identifier of this declaration.
Definition: declaration.cpp:267
void setAutoDeclaration(bool _auto)
Changes whether this declaration is "implicitly created".
Definition: declaration.cpp:492
bool isEmpty() const
void allocateOwnIndex()
Create an index to this declaration from the topContext().
Definition: declaration.cpp:354
virtual bool isForwardDeclaration() const
Determine whether this declaration is a forward declaration.
Definition: declaration.cpp:650
Definition: codemodel.h:42
CodeModelItem::Kind kindForDeclaration(Declaration *decl)
Definition: declaration.cpp:579
const char * constData() const
bool hasUses() const
Determines whether the declaration has any uses or not.
Definition: declaration.cpp:742
virtual DUContext * logicalInternalContext(const TopDUContext *topContext) const
Determine the logical internal context for the resolved form of this declaration.
Definition: declaration.cpp:396
void setIdentifier(const Identifier &identifier)
Set this declaration's identifier.
Definition: declaration.cpp:225
void setComment(const QByteArray &str)
Sets the comment for this declaration.
Definition: declaration.cpp:186
Definition: abstractfunctiondeclaration.cpp:27
A single context in source code, represented as a node in a directed acyclic graph.
Definition: ducontext.h:72
bool persistentlyDestroying() const
Returns true if this declaration is being currently destroyed persistently, which means that it shoul...
Definition: declaration.cpp:134
bool deleting() const
Returns true if this object is being deleted, otherwise false.
Definition: topducontext.cpp:958
int usesCount() const
Returns the count of uses that can be accessed through uses()
Definition: ducontext.cpp:1333
bool hasDeclarationUse(DUContext *context, int declIdx)
Definition: declaration.cpp:722
virtual void activateSpecialization()
Signalized that among multiple possible specializations, this one should be used in the UI from now o...
Definition: declaration.cpp:555
static Declaration * definition(const Declaration *decl)
Find the definition for the given declaration, if one exists.
Definition: functiondefinition.cpp:85
virtual void setInSymbolTable(bool inSymbolTable)
Adds or removes this declaration to/from the symbol table.
Definition: declaration.cpp:614
Definition: codemodel.h:43
DUContext * internalContext() const
Retrieve the context that is opened by this declaration, if one exists.
Definition: declaration.cpp:425
void addDeclaration(const IndexedQualifiedIdentifier &id, const IndexedDeclaration &declaration)
Adds declaration declaration with id id to the symbol table.
Definition: persistentsymboltable.cpp:208
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
int length() const
AbstractType::Ptr abstractType() const
Access this declaration's type.
Definition: declaration.cpp:243
Declaration * owner() const
If this context was opened by a declaration or definition, this returns that item.
Definition: ducontext.cpp:486
const Use * uses() const
Uses: A "Use" represents any position in a document where a Declaration is used literally.
Definition: ducontext.cpp:1321
void set(const DeclarationId &declaration, const IndexedInstantiationInformation &specialization)
Adds/updates the current specialization for the given declaration-id.
Definition: specializationstore.cpp:39
virtual Declaration * specialize(const IndexedInstantiationInformation &specialization, const TopDUContext *topContext, int upDistance=0)
Retrieve the declaration which is specialized with the given specialization index as seen from topCon...
Definition: declaration.cpp:259
void setExplicitlyDeleted(bool deleted)
Changes whether this declaration is "explicitly deleted", i.e.
Definition: declaration.cpp:522
bool isOnDisk() const
Whether this top-context has a stored version on disk.
Definition: topducontext.cpp:1125
QMap< IndexedString, QVector< RangeInRevision > > uses() const
Returns a map of files to use-ranges.
Definition: declaration.cpp:675
void setDeprecated(bool deprecated)
Set whether the declaration is deprecated.
Definition: declaration.cpp:502
virtual void setAbstractType(AbstractType::Ptr type)
Set this declaration's type.
Definition: declaration.cpp:249
class TopDUContextDynamicData * m_dynamicData
Definition: topducontext.h:381
virtual uint additionalIdentity() const
This hash-value should differentiate between multiple different declarations that have the same quali...
Definition: declaration.cpp:660
Definition: codemodel.h:47
bool isExplicitlyTyped() const
Determine whether this declaration is explicitly typed.
Definition: declaration.cpp:527
bool alwaysForceDirect() const
Determine whether this declaration must always be direct.
Definition: declaration.cpp:507
void updateItem(const IndexedString &file, const IndexedQualifiedIdentifier &id, CodeModelItem::Kind kind)
Updates the kind for the given item.
Definition: codemodel.cpp:264
QualifiedIdentifier scopeIdentifier(bool includeClasses=false) const
Calculate the fully qualified scope identifier.
Definition: ducontext.cpp:1082
bool isDefinition() const
Determine whether this declaration is also a definition.
Definition: declaration.cpp:472
virtual void rebuildDynamicData(DUContext *parent, uint ownIndex)
Called after loading to rebuild the dynamic data. If this is a context, this should recursively work ...
Definition: duchainbase.cpp:126
Declaration(const RangeInRevision &range, DUContext *parentContext)
Constructor.
Definition: declaration.cpp:102
bool removeDeclaration(Declaration *declaration)
Removes the declaration from localDeclarations.
Definition: ducontext.cpp:241
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Mar 3 2021 00:37:28 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Mar 3 2021 00:37:28 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.