File indexing completed on 2024-05-12 04:39:08

0001 /*
0002     SPDX-FileCopyrightText: 2008 Hamish Rodda <rodda@kde.org>
0003     SPDX-FileCopyrightText: 2012 Miha Čančula <miha@noughmad.eu>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef CLANGCLASSHELPER_H
0009 #define CLANGCLASSHELPER_H
0010 
0011 #include "clangprivateexport.h"
0012 
0013 #include <language/interfaces/icreateclasshelper.h>
0014 #include <language/codegen/templateclassgenerator.h>
0015 
0016 class KDEVCLANGPRIVATE_EXPORT ClangClassHelper : public KDevelop::ICreateClassHelper
0017 {
0018 public:
0019     ClangClassHelper();
0020     ~ClangClassHelper() override;
0021 
0022     KDevelop::TemplateClassGenerator* createGenerator(const QUrl& baseUrl) override;
0023     QList<KDevelop::DeclarationPointer> defaultMethods(const QString& name) const override;
0024 };
0025 
0026 /**
0027  * @brief A C++ specific template class generator
0028  *
0029  * This class adds additional variables to the template context.
0030  * @sa extraVariables()
0031  *
0032  * Additionally, it attempts to add the class to a target after it is generated.
0033  */
0034 class ClangTemplateNewClass : public KDevelop::TemplateClassGenerator
0035 {
0036   public:
0037     explicit ClangTemplateNewClass(const QUrl& url);
0038     ~ClangTemplateNewClass() override;
0039 
0040     KDevelop::DocumentChangeSet generate() override;
0041 
0042 private:
0043     /**
0044      * In addition to the variables provided by the base class,
0045      * it groups member variables and functions by access policy.
0046      * The variables are of type VariableDescriptionList or FunctionDescriptionList
0047      * and are called @c private_members, @c public_functions, etc.
0048      *
0049      * Signals and slots are not included in the above variables. Instead, they are listed in
0050      * @c private_slots, @c protected_slots, @c public_slots and @c signals.
0051      *
0052      * For convenience, another variable named @c needs_qobject_macro is also provided.
0053      * It is set to @c true if the class contains at least one signal or slot, and @c false otherwise.
0054      *
0055      * It also adds a @c namespaces variable which holds a list of all namespaces
0056      * in which the class is nested. For a class identified by Foo::Bar::ExampleClass,
0057      * @c namespaces holds two strings: "Foo" and "Bar".
0058      */
0059     QVariantHash extraVariables() const;
0060 };
0061 
0062 #endif // CLANGCLASSHELPER_H