1
/* This file is part of KDevelop
2
Copyright 2007 Hamish Rodda <rodda@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
Boston, MA 02110-1301, USA.
21
#include <duchain/duchainregister.h>
22
#include <interfaces/iassistant.h>
23
#include <klocalizedstring.h>
26
REGISTER_DUCHAIN_ITEM(Problem);
29
using namespace KDevelop;
32
: DUChainBase(*new ProblemData)
34
d_func_dynamic()->setClassId(this);
37
KDevelop::Problem::Problem(KDevelop::ProblemData& data) : DUChainBase(data) {
40
KDevelop::Problem::~Problem() {
43
KDevelop::IndexedString KDevelop::Problem::url() const
48
DocumentRange Problem::finalLocation() const
50
return DocumentRange(d_func()->url, rangeInCurrentRevision());
53
void Problem::setFinalLocation(const DocumentRange & location)
55
setRange(transformToLocalRevision(location));
56
d_func_dynamic()->url = location.document;
59
QStack< DocumentCursor > Problem::locationStack() const
61
return QStack< DocumentCursor >();
62
// return d_func()->locationStack;
65
void Problem::addLocation(const DocumentCursor & cursor)
68
// d_func()->locationStack.push(DocumentCursor(cursor));
71
void Problem::clearLocationStack()
73
// d_func()->locationStack.clear();
76
void Problem::setLocationStack(const QStack< DocumentCursor > & locationStack)
78
Q_UNUSED(locationStack);
79
// d_func()->locationStack = locationStack;
82
QString Problem::description() const
84
return d_func()->description.str();
87
void Problem::setDescription(const QString & description)
89
d_func_dynamic()->description = IndexedString(description);
92
QString Problem::explanation() const
94
return d_func()->explanation.str();
97
void Problem::setExplanation(const QString & explanation)
99
d_func_dynamic()->explanation = IndexedString(explanation);
102
ProblemData::Source Problem::source() const
104
return d_func()->source;
107
void Problem::setSource(ProblemData::Source source)
109
d_func_dynamic()->source = source;
112
KSharedPtr< KDevelop::IAssistant > KDevelop::Problem::solutionAssistant() const {
116
void KDevelop::Problem::setSolutionAssistant(KSharedPtr< KDevelop::IAssistant > assistant) {
117
m_solution = assistant;
120
KDevelop::ProblemData::Severity KDevelop::Problem::severity() const {
121
return d_func()->severity;
124
void KDevelop::Problem::setSeverity(ProblemData::Severity severity) {
125
d_func_dynamic()->severity = severity;
128
QString Problem::sourceString() const
131
case ProblemData::Disk:
133
case ProblemData::Preprocessor:
134
return i18n("Preprocessor");
135
case ProblemData::Lexer:
136
return i18n("Lexer");
137
case ProblemData::Parser:
138
return i18n("Parser");
139
case ProblemData::DUChainBuilder:
140
return i18n("Definition-Use Chain");
141
case ProblemData::SemanticAnalysis:
142
return i18n("Semantic Analysis");
143
case ProblemData::ToDo:
145
case ProblemData::Unknown:
147
return i18n("Unknown");
151
QString Problem::toString() const
153
return QString("%1:%2 in %3:[(%4,%5),(%6,%7)] %8")
157
.arg(range().start.line)
158
.arg(range().start.column)
159
.arg(range().end.line)
160
.arg(range().end.column)
164
QDebug operator<<(QDebug s, const Problem& problem)
166
s.nospace() << problem.toString();
170
QDebug operator<<(QDebug s, const ProblemPointer& problem)
172
s.nospace() << problem->toString();