Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [cmake] incomplete path of cmake error #1065

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/plugins/cxx/cmake/builder/parser/cmakeparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,29 @@

#include "cmakeparser.h"

#include "common/util/fileutils.h"

Check warning on line 7 in src/plugins/cxx/cmake/builder/parser/cmakeparser.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "common/util/fileutils.h" not found.

Check warning on line 7 in src/plugins/cxx/cmake/builder/parser/cmakeparser.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "common/util/fileutils.h" not found.
#include "common/util/qtcassert.h"

Check warning on line 8 in src/plugins/cxx/cmake/builder/parser/cmakeparser.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "common/util/qtcassert.h" not found.

Check warning on line 8 in src/plugins/cxx/cmake/builder/parser/cmakeparser.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "common/util/qtcassert.h" not found.

#include "services/project/projectservice.h"

Check warning on line 9 in src/plugins/cxx/cmake/builder/parser/cmakeparser.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "services/project/projectservice.h" not found.

Check warning on line 9 in src/plugins/cxx/cmake/builder/parser/cmakeparser.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "services/project/projectservice.h" not found.

const char COMMON_ERROR_PATTERN[] = "^CMake Error at (.*):([0-9]*)( \\((.*)\\))?:";
const char NEXT_SUBERROR_PATTERN[] = "^CMake Error in (.*):";
const char LOCATION_LINE_PATTERN[] = ":(\\d+):(?:(\\d+))?$";

const char TASK_CATEGORY_BUILDSYSTEM[] = "Task.Category.Buildsystem";

QString assembleCmakePath(const QString &relativePath)
{
auto prjService = dpfGetService(dpfservice::ProjectService);
QString workSpace = prjService->getActiveProjectInfo().workspaceFolder();
return workSpace + QDir::separator() + relativePath;
}

CMakeParser::CMakeParser()
{
commonError.setPattern(QLatin1String(COMMON_ERROR_PATTERN));
commonError.setMinimal(true);
QTC_CHECK(commonError.isValid());

nextSubError.setPattern(QLatin1String(NEXT_SUBERROR_PATTERN));
nextSubError.setMinimal(true);
QTC_CHECK(nextSubError.isValid());

locationLine.setPattern(QLatin1String(LOCATION_LINE_PATTERN));
Expand All @@ -38,6 +43,8 @@
{
QString trimmedLine = rightTrimmed(line);

auto commonErrorMatch = commonError.match(trimmedLine);
auto nextSubErrorMatch = nextSubError.match(trimmedLine);
switch (expectTripleLineErrorData) {
case NONE:
if (trimmedLine.isEmpty() && !lastTask.isNull()) {
Expand All @@ -47,12 +54,11 @@
skippedFirstEmptyLine = true;
return;
}
if (skippedFirstEmptyLine)
skippedFirstEmptyLine = false;
skippedFirstEmptyLine = false;

if (commonError.indexIn(trimmedLine) != -1) {
lastTask = Task(Task::Error, QString(), Utils::FileName::fromUserInput(commonError.cap(1)),
commonError.cap(2).toInt(), TASK_CATEGORY_BUILDSYSTEM);
if (commonErrorMatch.hasMatch()) {
lastTask = Task(Task::Error, QString(), Utils::FileName::fromUserInput(assembleCmakePath(commonErrorMatch.captured(1))),
commonErrorMatch.captured(2).toInt(), TASK_CATEGORY_BUILDSYSTEM);
lines = 1;
return;
} else if (trimmedLine.startsWith(QLatin1String(" ")) && !lastTask.isNull()) {
Expand All @@ -72,8 +78,8 @@
Utils::FileName(), -1, TASK_CATEGORY_BUILDSYSTEM);
lines = 1;
return;
} else if (nextSubError.indexIn(trimmedLine) != -1) {
lastTask = Task(Task::Error, QString(), Utils::FileName::fromUserInput(nextSubError.cap(1)), -1,
} else if (nextSubErrorMatch.hasMatch()) {
lastTask = Task(Task::Error, QString(), Utils::FileName::fromUserInput(assembleCmakePath(nextSubErrorMatch.captured(1))), -1,
TASK_CATEGORY_BUILDSYSTEM);
lines = 1;
return;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/cxx/cmake/builder/parser/cmakeparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class CMakeParser : public AbstractOutputParser
TripleLineError expectTripleLineErrorData = NONE;

Task lastTask;
QRegExp commonError;
QRegExp nextSubError;
QRegularExpression commonError;
QRegularExpression nextSubError;
QRegularExpression locationLine;
bool skippedFirstEmptyLine = false;
int lines = 0;
Expand Down
Loading