File indexing completed on 2024-05-12 04:39:13
0001 /* 0002 SPDX-FileCopyrightText: 2014 Kevin Funk <kfunk@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #ifndef MACRODEFINITION_H 0008 #define MACRODEFINITION_H 0009 0010 #include "clangprivateexport.h" 0011 0012 #include <language/duchain/declaration.h> 0013 #include <language/duchain/duchainregister.h> 0014 #include <serialization/indexedstring.h> 0015 0016 class MacroDefinitionData; 0017 0018 /** 0019 * @brief Represents a single C/C++ macro definition in the DUCHain 0020 * 0021 * This declaration represents a single macro definition, such as: 0022 * @code 0023 * #define FOO_BAR(x) do_something_with(x) 0024 * @endcode 0025 * 0026 * In this example, the identifier is 'FOO_BAR', and the macro is function-like 0027 * 0028 * @note API designed after of https://clang.llvm.org/doxygen/classclang_1_1MacroInfo.html 0029 */ 0030 class KDEVCLANGPRIVATE_EXPORT MacroDefinition : public KDevelop::Declaration 0031 { 0032 public: 0033 using Ptr = KDevelop::DUChainPointer<MacroDefinition>; 0034 0035 MacroDefinition(const KDevelop::RangeInRevision& range, KDevelop::DUContext* context); 0036 explicit MacroDefinition(MacroDefinitionData& data); 0037 MacroDefinition(const MacroDefinition& rhs); 0038 ~MacroDefinition() override; 0039 0040 /** 0041 * The definition text of this macro 0042 * 0043 * Example: 0044 * @code 0045 * #define FOO_BAR(x) do_something_with(x) 0046 * @endcode 0047 * 0048 * Here, "do_something_with(x)" is the definition text 0049 */ 0050 KDevelop::IndexedString definition() const; 0051 void setDefinition(const KDevelop::IndexedString& definition); 0052 0053 /** 0054 * Whether this macro is a function or not 0055 * 0056 * Example: 0057 * @code 0058 * #define FOO_BAR(x) x // function-like 0059 * #define FOO_BAR x // not function-like 0060 * @endcode 0061 */ 0062 bool isFunctionLike() const; 0063 void setFunctionLike(bool isFunctionLike); 0064 0065 const KDevelop::IndexedString* parameters() const; 0066 unsigned int parametersSize() const; 0067 void addParameter(const KDevelop::IndexedString& str); 0068 void clearParameters(); 0069 0070 QString toString() const override; 0071 0072 enum { 0073 Identity = 143 0074 }; 0075 0076 private: 0077 DUCHAIN_DECLARE_DATA(MacroDefinition) 0078 }; 0079 0080 DUCHAIN_DECLARE_TYPE(MacroDefinition) 0081 0082 #endif // MACRODEFINITION_H