File indexing completed on 2024-05-12 04:38:05

0001 /*
0002     SPDX-FileCopyrightText: 2008 David Nolden <david.nolden.kdevelop@art-master.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #ifndef KDEVPLATFORM_USES_H
0008 #define KDEVPLATFORM_USES_H
0009 
0010 #include <language/languageexport.h>
0011 #include <util/kdevvarlengtharray.h>
0012 
0013 namespace KDevelop {
0014 class DeclarationId;
0015 class IndexedTopDUContext;
0016 
0017 /**
0018  * Global mapping of Declaration-Ids to top-contexts, protected through DUChainLock.
0019  *
0020  * To retrieve the actual uses, query the duchain for the files.
0021  * */
0022 class KDEVPLATFORMLANGUAGE_EXPORT Uses
0023 {
0024     Q_DISABLE_COPY_MOVE(Uses)
0025 public:
0026     Uses();
0027     /**
0028      * Adds a top-context to the users-list of the given id
0029      * */
0030     void addUse(const DeclarationId& id, const IndexedTopDUContext& use);
0031     /**
0032      * Removes the given top-context from the list of uses
0033      * */
0034     void removeUse(const DeclarationId& id, const IndexedTopDUContext& use);
0035     /**
0036      * Checks whether the given DeclarationID is used
0037      * */
0038     bool hasUses(const DeclarationId& id) const;
0039 
0040     ///Gets the top-contexts of all users assigned to the declaration-id
0041     KDevVarLengthArray<IndexedTopDUContext> uses(const DeclarationId& id) const;
0042 };
0043 }
0044 
0045 #endif