MCPcopy Create free account
hub / github.com/KDE/kdevelop / startElement

Method startElement

plugins/cppcheck/parser.cpp:69–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69bool CppcheckParser::startElement()
70{
71 State newState = Unknown;
72
73 qCDebug(KDEV_CPPCHECK) << "CppcheckParser::startElement: elem: " << qPrintable(name().toString());
74
75 if (name() == QLatin1String("results")) {
76 newState = Results;
77 }
78
79 else if (name() == QLatin1String("cppcheck")) {
80 newState = CppCheck;
81 }
82
83 else if (name() == QLatin1String("errors")) {
84 newState = Errors;
85 }
86
87 else if (name() == QLatin1String("location")) {
88 newState = Location;
89 if (attributes().hasAttribute(QStringLiteral("file")) && attributes().hasAttribute(QStringLiteral("line"))) {
90 QString errorFile = attributes().value(QStringLiteral("file")).toString();
91
92 // Usually when "file0" attribute exists it associated with source and
93 // attribute "file" associated with header).
94 // But sometimes cppcheck produces errors with "file" and "file0" attributes
95 // both associated with same *source* file. In such cases attribute "file" contains
96 // only file name, without full path. Therefore we should use "file0" instead "file".
97 if (!QFile::exists(errorFile) && attributes().hasAttribute(QStringLiteral("file0"))) {
98 errorFile = attributes().value(QStringLiteral("file0")).toString();
99 }
100
101 m_errorFiles += errorFile;
102 m_errorLines += attributes().value(QStringLiteral("line")).toString().toInt();
103 }
104 }
105
106 else if (name() == QLatin1String("error")) {
107 newState = Error;
108 m_errorSeverity = QStringLiteral("unknown");
109 m_errorInconclusive = false;
110 m_errorFiles.clear();
111 m_errorLines.clear();
112 m_errorMessage.clear();
113 m_errorVerboseMessage.clear();
114
115 if (attributes().hasAttribute(QStringLiteral("msg"))) {
116 m_errorMessage = attributes().value(QStringLiteral("msg")).toString();
117 }
118
119 if (attributes().hasAttribute(QStringLiteral("verbose"))) {
120 m_errorVerboseMessage = verboseMessageToHtml(attributes().value(QStringLiteral("verbose")).toString());
121 }
122
123 if (attributes().hasAttribute(QStringLiteral("severity"))) {
124 m_errorSeverity = attributes().value(QStringLiteral("severity")).toString();
125 }
126

Callers

nothing calls this directly

Calls 8

nameFunction · 0.85
toIntMethod · 0.80
topMethod · 0.80
verboseMessageToHtmlFunction · 0.70
toStringMethod · 0.45
valueMethod · 0.45
clearMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected