diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2021-11-11 17:40:16 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2021-11-12 08:45:40 +0000 |
commit | 4dd0537d4bc6150f0c689d6faedffc887afcc9f9 (patch) | |
tree | d9909e8e8328d54617a02ae285dc18a9dd57e53c | |
parent | e88d0494026fbefd27a9306a14acfafeedd37738 (diff) |
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 <hjk@qt.io>
-rw-r--r-- | src/plugins/projectexplorer/gccparser.cpp | 17 | ||||
-rw-r--r-- | 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<Key, T>::value’ has incomplete type\n" " 110 | T value;\n" " | ^~~~~", - FilePath::fromUserInput("qmap.h"), - 110, 7, + FilePath::fromUserInput("moc_helpindexfilter.cpp"), + 105, 1, QVector<QTextLayout::FormatRange>() << 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 |