Changeset View
Changeset View
Standalone View
Standalone View
pythonstylechecking.cpp
Show All 23 Lines | |||||
24 | #include <QTimer> | 24 | #include <QTimer> | ||
25 | #include <QStandardPaths> | 25 | #include <QStandardPaths> | ||
26 | #include <QRegularExpression> | 26 | #include <QRegularExpression> | ||
27 | 27 | | |||
28 | #include <language/duchain/problem.h> | 28 | #include <language/duchain/problem.h> | ||
29 | #include <interfaces/icore.h> | 29 | #include <interfaces/icore.h> | ||
30 | #include <shell/documentcontroller.h> | 30 | #include <shell/documentcontroller.h> | ||
31 | 31 | | |||
32 | #include "pythondebug.h" | ||||
32 | #include "pythonparsejob.h" | 33 | #include "pythonparsejob.h" | ||
33 | #include "helpers.h" | 34 | #include "helpers.h" | ||
34 | 35 | | |||
35 | namespace Python { | 36 | namespace Python { | ||
36 | 37 | | |||
37 | StyleChecking::StyleChecking(QObject* parent) | 38 | StyleChecking::StyleChecking(QObject* parent) | ||
38 | : QObject(parent) | 39 | : QObject(parent) | ||
39 | { | 40 | { | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 95 | { | |||
98 | for ( const auto& error : errors ) { | 99 | for ( const auto& error : errors ) { | ||
99 | QRegularExpressionMatch match; | 100 | QRegularExpressionMatch match; | ||
100 | if ( (match = errorFormat.match(error)).hasMatch() ) { | 101 | if ( (match = errorFormat.match(error)).hasMatch() ) { | ||
101 | bool lineno_ok = false; | 102 | bool lineno_ok = false; | ||
102 | bool colno_ok = false; | 103 | bool colno_ok = false; | ||
103 | int lineno = match.captured(2).toInt(&lineno_ok); | 104 | int lineno = match.captured(2).toInt(&lineno_ok); | ||
104 | int colno = match.captured(3).toInt(&colno_ok); | 105 | int colno = match.captured(3).toInt(&colno_ok); | ||
105 | if ( ! lineno_ok || ! colno_ok ) { | 106 | if ( ! lineno_ok || ! colno_ok ) { | ||
106 | qDebug() << "invalid line / col number"; | 107 | qCDebug(KDEV_PYTHON) << "invalid line / col number"; | ||
107 | continue; | 108 | continue; | ||
108 | } | 109 | } | ||
109 | QString error = match.captured(4); | 110 | QString error = match.captured(4); | ||
110 | KDevelop::Problem* p = new KDevelop::Problem(); | 111 | KDevelop::Problem* p = new KDevelop::Problem(); | ||
111 | p->setFinalLocation(DocumentRange(document, KTextEditor::Range(lineno - 1, qMax(colno - 4, 0), | 112 | p->setFinalLocation(DocumentRange(document, KTextEditor::Range(lineno - 1, qMax(colno - 4, 0), | ||
112 | lineno - 1, colno + 4))); | 113 | lineno - 1, colno + 4))); | ||
113 | p->setSource(KDevelop::IProblem::Preprocessor); | 114 | p->setSource(KDevelop::IProblem::Preprocessor); | ||
114 | p->setSeverity(error.startsWith('W') ? KDevelop::IProblem::Hint : KDevelop::IProblem::Warning); | 115 | p->setSeverity(error.startsWith('W') ? KDevelop::IProblem::Hint : KDevelop::IProblem::Warning); | ||
115 | p->setDescription(i18n("PEP8 checker error: %1", error)); | 116 | p->setDescription(i18n("PEP8 checker error: %1", error)); | ||
116 | ProblemPointer ptr(p); | 117 | ProblemPointer ptr(p); | ||
117 | m_currentlyChecking->addProblem(ptr); | 118 | m_currentlyChecking->addProblem(ptr); | ||
118 | } | 119 | } | ||
119 | else { | 120 | else { | ||
120 | qDebug() << "invalid pep8 error line:" << error; | 121 | qCDebug(KDEV_PYTHON) << "invalid pep8 error line:" << error; | ||
121 | } | 122 | } | ||
122 | } | 123 | } | ||
123 | 124 | | |||
124 | m_currentlyChecking->setFeatures((TopDUContext::Features) ( m_currentlyChecking->features() | ParseJob::PEP8Checking )); | 125 | m_currentlyChecking->setFeatures((TopDUContext::Features) ( m_currentlyChecking->features() | ParseJob::PEP8Checking )); | ||
125 | } | 126 | } | ||
126 | 127 | | |||
127 | void StyleChecking::processOutputStarted() | 128 | void StyleChecking::processOutputStarted() | ||
128 | { | 129 | { | ||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |