1 /* This file is part of KDevelop
2 Copyright 2008 David Nolden <david.nolden.kdevelop@art-master.de>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #ifndef SPECIALIZATIONSTORE_H
20 #define SPECIALIZATIONSTORE_H
22 #include <QtCore/qhash.h>
23 #include "../languageexport.h"
32 * This class allows dynamic management of "current" specializations for declarations.
33 * The specializations will be applied in editors, and wherever it makes sense.
34 * For example, this is used in C++ to get code-completion and use-building within
35 * instantiated template-classes/functions.
37 class KDEVPLATFORMLANGUAGE_EXPORT SpecializationStore
{
39 static SpecializationStore
& self();
42 * Adds/updates the current specialization for the given declaration-id
44 void set(DeclarationId declaration
, uint specialization
);
46 * Gets the registered specialization for the given declaration-id, or zero.
48 uint
get(DeclarationId declaration
);
50 * Clears the specialization registered for the given declaration-id
52 void clear(DeclarationId declaration
);
54 * Clears all registered specializations
59 * Applies the known specializations for the given declaration using the Declaration::specialize() function.
60 * If no specializations are known, the original declaration is returned.
61 * @param declaration The declaration to specialize
62 * @param source The top-context from where to start searching
63 * @param recursive Whether parent-contexts should be checked for known specializations, and those applied.
64 * This is a bit more expensive then just doing a local check.
66 KDevelop::Declaration
* applySpecialization(KDevelop::Declaration
* declaration
, KDevelop::TopDUContext
* source
, bool recursive
= true);
68 * Applies the known specializations for the given context using the DUContext::specialize() function.
69 * If no specializations are known, returns the original context.
70 * @param context The context to specialize
71 * @param source The top-context from where to start searching
72 * @param recursive Whether parent-contexts should be checked for known specializations, and those applied.
73 * This is a bit more expensive then just doing a local check.
75 DUContext
* applySpecialization(KDevelop::DUContext
* context
, KDevelop::TopDUContext
* source
, bool recursive
= true);
78 SpecializationStore();
79 ~SpecializationStore();
80 QHash
<DeclarationId
, uint
> m_specializations
;