1 /* 2 SPDX-FileCopyrightText: 2015 Laszlo Kis-Adam 3 4 SPDX-License-Identifier: LGPL-2.0-or-later 5 */ 6 7 #ifndef IPROBLEM_H 8 #define IPROBLEM_H 9 10 #include <QExplicitlySharedDataPointer> 11 #include <QVector> 12 #include <QMetaType> 13 14 #include "interfacesexport.h" 15 16 class QIcon; 17 18 namespace KDevelop 19 { 20 class IAssistant; 21 class DocumentRange; 22 23 /// Interface for the Problem classes 24 class KDEVPLATFORMINTERFACES_EXPORT IProblem : public QSharedData 25 { 26 public: 27 using Ptr = QExplicitlySharedDataPointer<IProblem>; 28 29 /// The source of the problem. That is which tool / which part found this problem. 30 enum Source { 31 Unknown, 32 Disk, 33 Preprocessor, 34 Lexer, 35 Parser, 36 DUChainBuilder, 37 SemanticAnalysis, 38 ToDo, 39 Plugin /// The source is a problem checker plugin 40 }; 41 42 /// Severity of the problem. That is, how serious is the found problem. 43 enum Severity { 44 NoSeverity = 0, 45 Error = 1, 46 Warning = 2, 47 Hint = 4 48 }; 49 Q_DECLARE_FLAGS(Severities, Severity) 50 51 /// Final location mode of the problem. Used during highlighting. 52 enum FinalLocationMode 53 { 54 /// Location range used "As Is" 55 Range = 0, 56 57 /// Location range used to highlight whole line. 58 /// 59 /// Mode applied only if location range is wholly contained within one line 60 WholeLine, 61 62 /// Location range used to highlight only trimmed part of the line. 63 /// For example for the line: " int x = 0; \t" 64 /// only "int x = 0;" will be highlighted. 65 /// 66 /// Mode applied only if location range is wholly contained within one line 67 TrimmedLine 68 }; 69 70 static QIcon iconForSeverity(IProblem::Severity severity); 71 72 IProblem(); 73 virtual ~IProblem(); 74 75 /// Returns the source of the problem 76 virtual Source source() const = 0; 77 78 /// Sets the source of the problem 79 virtual void setSource(Source source) = 0; 80 81 /// Returns a string containing the source of the problem 82 virtual QString sourceString() const = 0; 83 84 /// Returns the location of the problem (path, line, column) 85 virtual KDevelop::DocumentRange finalLocation() const = 0; 86 87 /// Sets the location of the problem (path, line, column) 88 virtual void setFinalLocation(const KDevelop::DocumentRange& location) = 0; 89 90 /// Returns the final location mode of the problem 91 virtual FinalLocationMode finalLocationMode() const = 0; 92 93 /// Sets the final location mode of the problem 94 virtual void setFinalLocationMode(FinalLocationMode mode) = 0; 95 96 /// Returns the short description of the problem. 97 virtual QString description() const = 0; 98 99 /// Sets the short description of the problem 100 virtual void setDescription(const QString& description) = 0; 101 102 /// Returns the detailed explanation of the problem. 103 virtual QString explanation() const = 0; 104 105 /// Sets the detailed explanation of the problem 106 virtual void setExplanation(const QString& explanation) = 0; 107 108 /// Returns the severity of the problem 109 virtual Severity severity() const = 0; 110 111 /// Sets the severity of the problem 112 virtual void setSeverity(Severity severity) = 0; 113 114 /// Returns a string containing the severity of the problem 115 virtual QString severityString() const = 0; 116 117 /// Returns the diagnostics of the problem. 118 virtual QVector<Ptr> diagnostics() const = 0; 119 120 /// Sets the diagnostics of the problem 121 virtual void setDiagnostics(const QVector<Ptr> &diagnostics) = 0; 122 123 /// Adds a diagnostic line to the problem 124 virtual void addDiagnostic(const Ptr &diagnostic) = 0; 125 126 /// Clears all diagnostics 127 virtual void clearDiagnostics() = 0; 128 129 /// Returns a solution assistant for the problem, if applicable that is. 130 virtual QExplicitlySharedDataPointer<KDevelop::IAssistant> solutionAssistant() const = 0; 131 }; 132 133 Q_DECLARE_OPERATORS_FOR_FLAGS(IProblem::Severities) 134 135 } 136 137 Q_DECLARE_METATYPE(KDevelop::IProblem::Ptr) 138 139 #endif 140