1 /*
2     SPDX-FileCopyrightText: 2002-2005 Roberto Raggi <roberto@kdevelop.org>
3     SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org>
4     SPDX-FileCopyrightText: 2007 David Nolden <david.nolden.kdevelop@art-master.de>
5     SPDX-FileCopyrightText: 2010 Milian Wolff <mail@milianw.de>
6     SPDX-FileCopyrightText: 2014 Kevin Funk <kfunk@kde.org>
7 
8     SPDX-License-Identifier: LGPL-2.0-only
9 */
10 
11 #ifndef KDEVPLATFORM_DUCHAINDUMPER_H
12 #define KDEVPLATFORM_DUCHAINDUMPER_H
13 
14 #include <language/languageexport.h>
15 
16 #include <QFlags>
17 #include <QScopedPointer>
18 
19 class QTextStream;
20 
21 namespace KDevelop {
22 class DUContext;
23 class DUChainDumperPrivate;
24 
25 /**
26  * @brief Debugging utility function to dump a DUContext including contained declarations.
27  */
28 class KDEVPLATFORMLANGUAGE_EXPORT DUChainDumper
29 {
30 public:
31     enum Feature {
32         NoFeatures =        0,
33         DumpContext =       1 << 0,
34         DumpProblems =      1 << 1
35     };
36     Q_DECLARE_FLAGS(Features, Feature)
37 
38     explicit DUChainDumper(Features features = DumpContext);
39     ~DUChainDumper();
40 
41     /**
42      * Dump DUChain context to stdout
43      *
44      * NOTE: The DUChain must be readlocked when this is called.
45      *
46      * @param context The context to dump
47      * @param allowedDepth How deep the dump will go into imported contexts, printing all the contents.
48      */
49     void dump(DUContext* context, int allowedDepth = 0);
50 
51     void dump(DUContext* context, int allowedDepth, QTextStream& out);
52 
53 private:
54     const QScopedPointer<class DUChainDumperPrivate> d_ptr;
55     Q_DECLARE_PRIVATE(DUChainDumper)
56 };
57 }
58 #endif // KDEVPLATFORM_DUCHAINDUMPER_H
59