Changeset View
Changeset View
Standalone View
Standalone View
shell/problem.h
Show All 22 Lines | |||||
23 | #include <interfaces/iproblem.h> | 23 | #include <interfaces/iproblem.h> | ||
24 | 24 | | |||
25 | #include <shell/shellexport.h> | 25 | #include <shell/shellexport.h> | ||
26 | #include <language/editor/documentrange.h> | 26 | #include <language/editor/documentrange.h> | ||
27 | #include <QString> | 27 | #include <QString> | ||
28 | #include <QList> | 28 | #include <QList> | ||
29 | 29 | | |||
30 | struct DetectedProblemPrivate; | 30 | struct DetectedProblemPrivate; | ||
31 | struct PluginProblemPrivate; | ||||
31 | 32 | | |||
32 | namespace KDevelop | 33 | namespace KDevelop | ||
33 | { | 34 | { | ||
34 | 35 | | |||
35 | /** | 36 | /** | ||
36 | * @brief Represents a problem as one unit with the IProblem interface so can be used with anything that can handle IProblem. | 37 | * @brief Represents a problem as one unit with the IProblem interface so can be used with anything that can handle IProblem. | ||
37 | * | 38 | * | ||
38 | * You should have it wrapped in an IProblem::Ptr which is a shared pointer for it. | 39 | * You should have it wrapped in an IProblem::Ptr which is a shared pointer for it. | ||
39 | * It is basically a mirror of DUChain's Problem class. | 40 | * It is basically a mirror of DUChain's Problem class. | ||
40 | * However that class is strongly coupled with DUChain's internals due to DUChain's needs (special serialization). | 41 | * However that class is strongly coupled with DUChain's internals due to DUChain's needs (special serialization). | ||
41 | * | 42 | * | ||
42 | * Usage example: | 43 | * Usage example: | ||
43 | * @code | 44 | * @code | ||
44 | * IProblem::Ptr problem(new DetectedProblem()); | 45 | * IProblem::Ptr problem(new DetectedProblem()); | ||
45 | * problem->setSource(IProblem::Plugin); | 46 | * problem->setSource(IProblem::Plugin); | ||
46 | * problem->setSeverity(IProblem::Error); | 47 | * problem->setSeverity(IProblem::Warning); | ||
47 | * problem->setDescription(QStringLiteral("Error message")); | 48 | * problem->setDescription(QStringLiteral("Warning message")); | ||
48 | * problem->setExplanation(QStringLiteral("Error explanation")); | 49 | * problem->setExplanation(QStringLiteral("Warning explanation")); | ||
49 | * | 50 | * | ||
50 | * DocumentRange range; | 51 | * DocumentRange range; | ||
51 | * range.document = IndexedString("/path/to/source/file"); | 52 | * range.document = IndexedString("/path/to/source/file"); | ||
52 | * range.setBothLines(1337); | 53 | * range.setBothLines(1337); | ||
53 | * range.setBothColumns(12); | 54 | * range.setBothColumns(12); | ||
54 | * problem->setFinalLocation(range); | 55 | * problem->setFinalLocation(range); | ||
55 | * @endcode | 56 | * @endcode | ||
56 | * | 57 | * | ||
57 | */ | 58 | */ | ||
58 | class KDEVPLATFORMSHELL_EXPORT DetectedProblem : public IProblem | 59 | class KDEVPLATFORMSHELL_EXPORT DetectedProblem : public IProblem | ||
59 | { | 60 | { | ||
60 | public: | 61 | public: | ||
62 | /// Creates new empty DetectedProblem with default properties: | ||||
63 | /// severity - KDevelop::IProblem::Error; | ||||
64 | /// source - KDevelop::IProblem::Unknown; | ||||
65 | /// finalLocationMode - KDevelop::IProblem::Range. | ||||
61 | DetectedProblem(); | 66 | DetectedProblem(); | ||
62 | virtual ~DetectedProblem(); | 67 | | ||
68 | /// Creates new DetectedProblem, produced by some plugin, for example by analyzer plugins | ||||
69 | /// like cppcheck/clang-tydy/valgrind/etc. | ||||
70 | /// Default values of problem properties are: | ||||
71 | /// severity - KDevelop::IProblem::Error; | ||||
72 | /// source - KDevelop::IProblem::Plugin; | ||||
73 | /// sourceString - passed pluginName parameter; | ||||
74 | /// finalLocationMode - KDevelop::IProblem::Range. | ||||
75 | DetectedProblem(const QString& pluginName); | ||||
76 | | ||||
77 | ~DetectedProblem() override; | ||||
63 | 78 | | |||
64 | Source source() const override; | 79 | Source source() const override; | ||
65 | void setSource(Source source) override; | 80 | void setSource(Source source) override; | ||
66 | QString sourceString() const override; | 81 | QString sourceString() const override; | ||
67 | 82 | | |||
68 | DocumentRange finalLocation() const override; | 83 | DocumentRange finalLocation() const override; | ||
69 | void setFinalLocation(const DocumentRange& location) override; | 84 | void setFinalLocation(const DocumentRange& location) override; | ||
70 | 85 | | |||
Show All 19 Lines | |||||
90 | 105 | | |||
91 | private: | 106 | private: | ||
92 | QScopedPointer<DetectedProblemPrivate> d; | 107 | QScopedPointer<DetectedProblemPrivate> d; | ||
93 | }; | 108 | }; | ||
94 | 109 | | |||
95 | } | 110 | } | ||
96 | 111 | | |||
97 | #endif | 112 | #endif | ||
98 | 113 | | |||
kfunk: I'm wondering if we should just merge `PluginProblem` with `DetectedProblem`...
Just add… |
I'm wondering if we should just merge PluginProblem with DetectedProblem...
Just add DetectedProblem::DetectedProblem(const QString& pluginName) and set source = Plugin in that case).
DetectedProblem::sourceString then returns the custom plugin name if source == Plugin.
PluginProblem does not really add much to DetectedProblem this looks like unnecessary code bloat. Other opinions?