ClangTools: Fix stringification of check names

The BaseChecksTreeModel class abuses a FilePath-based base class for non-
FilePath-based contents, so we cannot apply the usual logic there.
This partially reverts 218a8b7787.

Fixes: QTCREATORBUG-32147
Change-Id: Ic3176a78ec5915a9d420f742324407be1881338e
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Andrii Semkiv <andrii.semkiv@qt.io>
This commit is contained in:
Christian Kandeler
2024-12-19 11:14:31 +01:00
parent 11df2309fc
commit c760836796

View File

@@ -401,7 +401,8 @@ static void buildTree(ProjectExplorer::Tree *parent,
current->name = node.name; current->name = node.name;
current->isDir = node.children.size(); current->isDir = node.children.size();
if (parent) { if (parent) {
current->fullPath = parent->fullPath.pathAppended(current->name); current->fullPath = Utils::FilePath::fromString(parent->fullPath.toString()
+ current->name);
parent->childDirectories.push_back(current); parent->childDirectories.push_back(current);
} else { } else {
current->fullPath = Utils::FilePath::fromString(current->name); current->fullPath = Utils::FilePath::fromString(current->name);
@@ -412,9 +413,9 @@ static void buildTree(ProjectExplorer::Tree *parent,
} }
static bool needsLink(ProjectExplorer::Tree *node) { static bool needsLink(ProjectExplorer::Tree *node) {
if (node->fullPath.path() == "clang-analyzer-") if (node->fullPath.toString() == "clang-analyzer-")
return true; return true;
return !node->isDir && !node->fullPath.startsWith("clang-analyzer-"); return !node->isDir && !node->fullPath.toString().startsWith("clang-analyzer-");
} }
class BaseChecksTreeModel : public ProjectExplorer::SelectableFilesModel // FIXME: This isn't about files. class BaseChecksTreeModel : public ProjectExplorer::SelectableFilesModel // FIXME: This isn't about files.
@@ -590,7 +591,7 @@ public:
// 'clang-analyzer-' group // 'clang-analyzer-' group
if (node->isDir) if (node->isDir)
return CppEditor::Constants::CLANG_STATIC_ANALYZER_DOCUMENTATION_URL; return CppEditor::Constants::CLANG_STATIC_ANALYZER_DOCUMENTATION_URL;
return clangTidyDocUrl(node->fullPath.path()); return clangTidyDocUrl(node->fullPath.toString());
} }
return BaseChecksTreeModel::data(fullIndex, role); return BaseChecksTreeModel::data(fullIndex, role);
@@ -628,7 +629,7 @@ private:
return false; return false;
auto *node = static_cast<Tree *>(index.internalPointer()); auto *node = static_cast<Tree *>(index.internalPointer());
const QString nodeName = node->fullPath.path(); const QString nodeName = node->fullPath.toString();
if ((check.endsWith("*") && nodeName.startsWith(check.left(check.length() - 1))) if ((check.endsWith("*") && nodeName.startsWith(check.left(check.length() - 1)))
|| (!node->isDir && nodeName == check)) { || (!node->isDir && nodeName == check)) {
result = index; result = index;
@@ -645,7 +646,7 @@ private:
if (root->checked == Qt::Unchecked) if (root->checked == Qt::Unchecked)
return; return;
if (root->checked == Qt::Checked) { if (root->checked == Qt::Checked) {
checks += "," + root->fullPath.path(); checks += "," + root->fullPath.toString();
if (root->isDir) if (root->isDir)
checks += "*"; checks += "*";
return; return;