2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2018 Sergey Morozov
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2018-07-30 21:42:47 +03:00
|
|
|
|
|
|
|
|
#include "cppcheckdiagnostic.h"
|
|
|
|
|
#include "cppchecktextmark.h"
|
|
|
|
|
#include "cppchecktextmarkmanager.h"
|
|
|
|
|
|
|
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
|
|
|
|
|
namespace Cppcheck {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
CppcheckTextMarkManager::CppcheckTextMarkManager() = default;
|
|
|
|
|
|
|
|
|
|
CppcheckTextMarkManager::~CppcheckTextMarkManager() = default;
|
|
|
|
|
|
|
|
|
|
void CppcheckTextMarkManager::add(const Diagnostic &diagnostic)
|
|
|
|
|
{
|
2018-09-25 21:08:52 +03:00
|
|
|
std::vector<MarkPtr> &fileMarks = m_marks[diagnostic.fileName];
|
|
|
|
|
if (Utils::contains(fileMarks, [diagnostic](const MarkPtr &mark) {return *mark == diagnostic;}))
|
2018-07-30 21:42:47 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
fileMarks.push_back(std::make_unique<CppcheckTextMark>(diagnostic));
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-17 14:07:53 +01:00
|
|
|
void CppcheckTextMarkManager::clearFiles(const Utils::FilePaths &files)
|
2018-07-30 21:42:47 +03:00
|
|
|
{
|
|
|
|
|
if (m_marks.empty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!files.empty()) {
|
2019-05-28 13:49:26 +02:00
|
|
|
for (const Utils::FilePath &file : files)
|
2018-07-30 21:42:47 +03:00
|
|
|
m_marks.erase(file);
|
|
|
|
|
} else {
|
|
|
|
|
m_marks.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Cppcheck
|