diff options
Diffstat (limited to 'src/plugins/projectexplorer/linuxiccparser.cpp')
-rw-r--r-- | src/plugins/projectexplorer/linuxiccparser.cpp | 124 |
1 files changed, 61 insertions, 63 deletions
diff --git a/src/plugins/projectexplorer/linuxiccparser.cpp b/src/plugins/projectexplorer/linuxiccparser.cpp index 95ccb4dfce..82799fecd6 100644 --- a/src/plugins/projectexplorer/linuxiccparser.cpp +++ b/src/plugins/projectexplorer/linuxiccparser.cpp @@ -39,98 +39,96 @@ LinuxIccParser::LinuxIccParser() : setObjectName(QLatin1String("LinuxIccParser")); // main.cpp(53): error #308: function \"AClass::privatefunc\" (declared at line 4 of \"main.h\") is inaccessible - m_firstLine.setPattern(QLatin1String("^([^\\(\\)]+)" // filename (cap 1) - "\\((\\d+)\\):" // line number including : (cap 2) - " ((error|warning)( #\\d+)?: )?" // optional type (cap 4) and optional error number // TODO really optional ? - "(.*)$")); // description (cap 6) - //m_firstLine.setMinimal(true); + m_firstLine.setPattern(QLatin1String("^([^\\(\\)]+?)" // filename (cap 1) + "\\((\\d+?)\\):" // line number including : (cap 2) + " ((error|warning)( #\\d+?)?: )?" // optional type (cap 4) and optional error number // TODO really optional ? + "(.*?)$")); // description (cap 6) QTC_CHECK(m_firstLine.isValid()); // Note pattern also matches caret lines m_continuationLines.setPattern(QLatin1String("^\\s+" // At least one whitespace "(.*)$"));// description - m_continuationLines.setMinimal(true); QTC_CHECK(m_continuationLines.isValid()); - m_caretLine.setPattern(QLatin1String("^\\s*" // Whitespaces + m_caretLine.setPattern(QLatin1String("^\\s*?" // Whitespaces "\\^" // a caret - "\\s*$")); // and again whitespaces - m_caretLine.setMinimal(true); + "\\s*?$")); // and again whitespaces QTC_CHECK(m_caretLine.isValid()); // ".pch/Qt5Core.pchi.cpp": creating precompiled header file ".pch/Qt5Core.pchi" // "animation/qabstractanimation.cpp": using precompiled header file ".pch/Qt5Core.pchi" - m_pchInfoLine.setPattern(QLatin1String("^\".*\": (creating|using) precompiled header file \".*\"\n$")); - m_pchInfoLine.setMinimal(true); + m_pchInfoLine.setPattern(QLatin1String("^\".*?\": (creating|using) precompiled header file \".*?\"\n$")); QTC_CHECK(m_pchInfoLine.isValid()); - - appendOutputParser(new Internal::LldParser); - appendOutputParser(new LdParser); } -void LinuxIccParser::stdError(const QString &line) +OutputLineParser::Result LinuxIccParser::handleLine(const QString &line, OutputFormat type) { - if (m_pchInfoLine.indexIn(line) != -1) { - // totally ignore this line - return; + if (type != Utils::StdErrFormat) + return Status::NotHandled; + + if (line.indexOf(m_pchInfoLine) != -1) + return Status::Done; // totally ignore this line + + if (m_expectFirstLine) { + const QRegularExpressionMatch match = m_firstLine.match(line); + if (match.hasMatch()) { + // Clear out old task + Task::TaskType type = Task::Unknown; + QString category = match.captured(4); + if (category == QLatin1String("error")) + type = Task::Error; + else if (category == QLatin1String("warning")) + type = Task::Warning; + const FilePath filePath = absoluteFilePath(FilePath::fromUserInput(match.captured(1))); + const int lineNo = match.captured(2).toInt(); + LinkSpecs linkSpecs; + addLinkSpecForAbsoluteFilePath(linkSpecs, filePath, lineNo, match, 1); + m_temporary = CompileTask(type, match.captured(6).trimmed(), filePath, lineNo); + + m_lines = 1; + m_expectFirstLine = false; + return Status::InProgress; + } } - - if (m_expectFirstLine && m_firstLine.indexIn(line) != -1) { - // Clear out old task - Task::TaskType type = Task::Unknown; - QString category = m_firstLine.cap(4); - if (category == QLatin1String("error")) - type = Task::Error; - else if (category == QLatin1String("warning")) - type = Task::Warning; - m_temporary = CompileTask(type, - m_firstLine.cap(6).trimmed(), - Utils::FilePath::fromUserInput(m_firstLine.cap(1)), - m_firstLine.cap(2).toInt()); - - m_lines = 1; - m_expectFirstLine = false; - } else if (!m_expectFirstLine && m_caretLine.indexIn(line) != -1) { - // Format the last line as code - QTextLayout::FormatRange fr; - fr.start = m_temporary.description.lastIndexOf(QLatin1Char('\n')) + 1; - fr.length = m_temporary.description.length() - fr.start; - fr.format.setFontItalic(true); - m_temporary.formats.append(fr); - - QTextLayout::FormatRange fr2; - fr2.start = fr.start + line.indexOf(QLatin1Char('^')) - m_indent; - fr2.length = 1; - fr2.format.setFontWeight(QFont::Bold); - m_temporary.formats.append(fr2); - } else if (!m_expectFirstLine && line.trimmed().isEmpty()) { // last Line + if (!m_expectFirstLine && line.indexOf(m_caretLine) != -1) { + // FIXME: m_temporary.details.append(line); + return Status::InProgress; + } + if (!m_expectFirstLine && line.trimmed().isEmpty()) { // last Line m_expectFirstLine = true; - emit addTask(m_temporary, m_lines); + scheduleTask(m_temporary, m_lines); m_temporary = Task(); - } else if (!m_expectFirstLine && m_continuationLines.indexIn(line) != -1) { - m_temporary.description.append(QLatin1Char('\n')); - m_indent = 0; - while (m_indent < line.length() && line.at(m_indent).isSpace()) - m_indent++; - m_temporary.description.append(m_continuationLines.cap(1).trimmed()); + return Status::Done; + } + const QRegularExpressionMatch match = m_continuationLines.match(line); + if (!m_expectFirstLine && match.hasMatch()) { + m_temporary.details.append(match.captured(1).trimmed()); ++m_lines; - } else { - IOutputParser::stdError(line); + return Status::InProgress; } + QTC_CHECK(m_temporary.isNull()); + return Status::NotHandled; } -Core::Id LinuxIccParser::id() +Utils::Id LinuxIccParser::id() { - return Core::Id("ProjectExplorer.OutputParser.Icc"); + return Utils::Id("ProjectExplorer.OutputParser.Icc"); } -void LinuxIccParser::doFlush() +QList<OutputLineParser *> LinuxIccParser::iccParserSuite() +{ + return {new LinuxIccParser, new Internal::LldParser, new LdParser}; +} + +void LinuxIccParser::flush() { if (m_temporary.isNull()) return; + + setDetailsFormat(m_temporary); Task t = m_temporary; m_temporary.clear(); - emit addTask(t, m_lines, 1); + scheduleTask(t, m_lines, 1); } #ifdef WITH_TESTS @@ -227,14 +225,14 @@ void ProjectExplorerPlugin::testLinuxIccOutputParsers_data() << (Tasks() << CompileTask(Task::Unknown, "Note: No relevant classes found. No output generated.", - FilePath::fromUserInput("/home/qtwebkithelpviewer.h"), 0)) + FilePath::fromUserInput("/home/qtwebkithelpviewer.h"), -1)) << QString(); } void ProjectExplorerPlugin::testLinuxIccOutputParsers() { OutputParserTester testbench; - testbench.appendOutputParser(new LinuxIccParser); + testbench.setLineParsers(LinuxIccParser::iccParserSuite()); QFETCH(QString, input); QFETCH(OutputParserTester::Channel, inputChannel); QFETCH(Tasks, tasks); |