From 4dd0537d4bc6150f0c689d6faedffc887afcc9f9 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 11 Nov 2021 17:40:16 +0100 Subject: ProjectExplorer: Point the user to the right source location ... when parsing gcc error messages with a "required from here" part. It's typically buried deep within the output, but points to the actual problem. Change-Id: I06d778655d9e21edb7148f37f3921764e30353ee Reviewed-by: hjk --- src/plugins/projectexplorer/gccparser.cpp | 17 ++++++++++++++--- src/plugins/projectexplorer/gccparser.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/plugins/projectexplorer/gccparser.cpp b/src/plugins/projectexplorer/gccparser.cpp index 30ebe45bf8..346addd3bb 100644 --- a/src/plugins/projectexplorer/gccparser.cpp +++ b/src/plugins/projectexplorer/gccparser.cpp @@ -117,12 +117,22 @@ void GccParser::createOrAmendTask( || (m_currentTask.type == Task::Unknown && type != Task::Unknown)) { m_currentTask.type = type; m_currentTask.summary = description; - if (!file.isEmpty()) { + if (!file.isEmpty() && !m_requiredFromHereFound) { m_currentTask.setFile(file); m_currentTask.line = line; m_currentTask.column = column; } } + + // If a "required from here" line is present, it is almost always the cause of the problem, + // so that's where we should go when the issue is double-clicked. + if (originalLine.endsWith("required from here") && !file.isEmpty() && line > 0) { + m_requiredFromHereFound = true; + m_currentTask.setFile(file); + m_currentTask.line = line; + m_currentTask.column = column; + } + ++m_lines; } @@ -142,6 +152,7 @@ void GccParser::flush() m_linkSpecs.clear(); scheduleTask(t, m_lines, 1); m_lines = 0; + m_requiredFromHereFound = false; } OutputLineParser::Result GccParser::handleLine(const QString &line, OutputFormat type) @@ -1346,8 +1357,8 @@ void ProjectExplorerPlugin::testGccOutputParsers_data() "qmap.h:110:7: error: ‘QMapNode::value’ has incomplete type\n" " 110 | T value;\n" " | ^~~~~", - FilePath::fromUserInput("qmap.h"), - 110, 7, + FilePath::fromUserInput("moc_helpindexfilter.cpp"), + 105, 1, QVector() << formatRange(46, 1458))} << QString(); diff --git a/src/plugins/projectexplorer/gccparser.h b/src/plugins/projectexplorer/gccparser.h index 8628d5d46f..7f32df5aa5 100644 --- a/src/plugins/projectexplorer/gccparser.h +++ b/src/plugins/projectexplorer/gccparser.h @@ -72,6 +72,7 @@ private: Task m_currentTask; LinkSpecs m_linkSpecs; int m_lines = 0; + bool m_requiredFromHereFound = false; }; } // namespace ProjectExplorer -- cgit v1.2.1