File: iproblem.h

package info (click to toggle)
kdevelop 4%3A22.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 70,096 kB
  • sloc: cpp: 284,635; javascript: 3,558; python: 3,422; sh: 1,319; ansic: 685; xml: 331; php: 95; lisp: 66; makefile: 39; sed: 12
file content (139 lines) | stat: -rw-r--r-- 4,007 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
    SPDX-FileCopyrightText: 2015 Laszlo Kis-Adam

    SPDX-License-Identifier: LGPL-2.0-or-later
*/

#ifndef IPROBLEM_H
#define IPROBLEM_H

#include <QExplicitlySharedDataPointer>
#include <QVector>
#include <QMetaType>

#include "interfacesexport.h"

class QIcon;

namespace KDevelop
{
class IAssistant;
class DocumentRange;

/// Interface for the Problem classes
class KDEVPLATFORMINTERFACES_EXPORT IProblem : public QSharedData
{
public:
    using Ptr = QExplicitlySharedDataPointer<IProblem>;

    /// The source of the problem. That is which tool / which part found this problem.
    enum Source {
        Unknown,
        Disk,
        Preprocessor,
        Lexer,
        Parser,
        DUChainBuilder,
        SemanticAnalysis,
        ToDo,
        Plugin             /// The source is a problem checker plugin
    };

    /// Severity of the problem. That is, how serious is the found problem.
    enum Severity {
        NoSeverity = 0,
        Error = 1,
        Warning = 2,
        Hint = 4
    };
    Q_DECLARE_FLAGS(Severities, Severity)

    /// Final location mode of the problem. Used during highlighting.
    enum FinalLocationMode
    {
        /// Location range used "As Is"
        Range = 0,

        /// Location range used to highlight whole line.
        ///
        /// Mode applied only if location range is wholly contained within one line
        WholeLine,

        /// Location range used to highlight only trimmed part of the line.
        /// For example for the line: "   int x = 0;  \t"
        /// only "int x = 0;" will be highlighted.
        ///
        /// Mode applied only if location range is wholly contained within one line
        TrimmedLine
    };

    static QIcon iconForSeverity(IProblem::Severity severity);

    IProblem();
    virtual ~IProblem();

    /// Returns the source of the problem
    virtual Source source() const = 0;

    /// Sets the source of the problem
    virtual void setSource(Source source) = 0;

    /// Returns a string containing the source of the problem
    virtual QString sourceString() const = 0;

    /// Returns the location of the problem (path, line, column)
    virtual KDevelop::DocumentRange finalLocation() const = 0;

    /// Sets the location of the problem (path, line, column)
    virtual void setFinalLocation(const KDevelop::DocumentRange& location) = 0;

    /// Returns the final location mode of the problem
    virtual FinalLocationMode finalLocationMode() const = 0;

    /// Sets the final location mode of the problem
    virtual void setFinalLocationMode(FinalLocationMode mode) = 0;

    /// Returns the short description of the problem.
    virtual QString description() const = 0;

    /// Sets the short description of the problem
    virtual void setDescription(const QString& description) = 0;

    /// Returns the detailed explanation of the problem.
    virtual QString explanation() const = 0;

    /// Sets the detailed explanation of the problem
    virtual void setExplanation(const QString& explanation) = 0;

    /// Returns the severity of the problem
    virtual Severity severity() const = 0;

    /// Sets the severity of the problem
    virtual void setSeverity(Severity severity) = 0;

    /// Returns a string containing the severity of the problem
    virtual QString severityString() const = 0;

    /// Returns the diagnostics of the problem.
    virtual QVector<Ptr> diagnostics() const = 0;

    /// Sets the diagnostics of the problem
    virtual void setDiagnostics(const QVector<Ptr> &diagnostics) = 0;

    /// Adds a diagnostic line to the problem
    virtual void addDiagnostic(const Ptr &diagnostic) = 0;

    /// Clears all diagnostics
    virtual void clearDiagnostics() = 0;

    /// Returns a solution assistant for the problem, if applicable that is.
    virtual QExplicitlySharedDataPointer<KDevelop::IAssistant> solutionAssistant() const = 0;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(IProblem::Severities)

}

Q_DECLARE_METATYPE(KDevelop::IProblem::Ptr)

#endif