diff options
Diffstat (limited to 'src/plugins/cppcheck')
-rw-r--r-- | src/plugins/cppcheck/CMakeLists.txt | 14 | ||||
-rw-r--r-- | src/plugins/cppcheck/cppcheckdiagnostic.h | 2 | ||||
-rw-r--r-- | src/plugins/cppcheck/cppcheckrunner.cpp | 22 | ||||
-rw-r--r-- | src/plugins/cppcheck/cppcheckrunner.h | 16 | ||||
-rw-r--r-- | src/plugins/cppcheck/cppchecktextmarkmanager.cpp | 4 | ||||
-rw-r--r-- | src/plugins/cppcheck/cppchecktextmarkmanager.h | 4 | ||||
-rw-r--r-- | src/plugins/cppcheck/cppchecktool.cpp | 18 | ||||
-rw-r--r-- | src/plugins/cppcheck/cppchecktool.h | 10 | ||||
-rw-r--r-- | src/plugins/cppcheck/cppchecktrigger.cpp | 14 | ||||
-rw-r--r-- | src/plugins/cppcheck/cppchecktrigger.h | 10 |
10 files changed, 66 insertions, 48 deletions
diff --git a/src/plugins/cppcheck/CMakeLists.txt b/src/plugins/cppcheck/CMakeLists.txt new file mode 100644 index 0000000000..76c2148c79 --- /dev/null +++ b/src/plugins/cppcheck/CMakeLists.txt @@ -0,0 +1,14 @@ +add_qtc_plugin(Cppcheck + DEPENDS Qt5::Widgets + PLUGIN_DEPENDS Core CppTools ProjectExplorer TextEditor + SOURCES + cppcheckconstants.h + cppcheckdiagnostic.h + cppcheckoptions.cpp cppcheckoptions.h + cppcheckplugin.cpp cppcheckplugin.h + cppcheckrunner.cpp cppcheckrunner.h + cppchecktextmark.cpp cppchecktextmark.h + cppchecktextmarkmanager.cpp cppchecktextmarkmanager.h + cppchecktool.cpp cppchecktool.h + cppchecktrigger.cpp cppchecktrigger.h +) diff --git a/src/plugins/cppcheck/cppcheckdiagnostic.h b/src/plugins/cppcheck/cppcheckdiagnostic.h index 66e0b1dc82..566a60b974 100644 --- a/src/plugins/cppcheck/cppcheckdiagnostic.h +++ b/src/plugins/cppcheck/cppcheckdiagnostic.h @@ -44,7 +44,7 @@ public: QString severityText; QString checkId; QString message; - Utils::FileName fileName; + Utils::FilePath fileName; int lineNumber = 0; }; diff --git a/src/plugins/cppcheck/cppcheckrunner.cpp b/src/plugins/cppcheck/cppcheckrunner.cpp index f67044cb67..9b9872097a 100644 --- a/src/plugins/cppcheck/cppcheckrunner.cpp +++ b/src/plugins/cppcheck/cppcheckrunner.cpp @@ -32,6 +32,8 @@ #include <coreplugin/messagemanager.h> +using namespace Utils; + namespace Cppcheck { namespace Internal { @@ -75,15 +77,15 @@ void CppcheckRunner::reconfigure(const QString &binary, const QString &arguments m_arguments = arguments; } -void CppcheckRunner::addToQueue(const Utils::FileNameList &files, +void CppcheckRunner::addToQueue(const Utils::FilePathList &files, const QString &additionalArguments) { - Utils::FileNameList &existing = m_queue[additionalArguments]; + Utils::FilePathList &existing = m_queue[additionalArguments]; if (existing.isEmpty()) { existing = files; } else { std::copy_if(files.cbegin(), files.cend(), std::back_inserter(existing), - [&existing](const Utils::FileName &file) { return !existing.contains(file); }); + [&existing](const Utils::FilePath &file) { return !existing.contains(file); }); } if (m_isRunning) { @@ -94,7 +96,7 @@ void CppcheckRunner::addToQueue(const Utils::FileNameList &files, m_queueTimer.start(); } -void CppcheckRunner::stop(const Utils::FileNameList &files) +void CppcheckRunner::stop(const Utils::FilePathList &files) { if (!m_isRunning) return; @@ -103,7 +105,7 @@ void CppcheckRunner::stop(const Utils::FileNameList &files) m_process->kill(); } -void CppcheckRunner::removeFromQueue(const Utils::FileNameList &files) +void CppcheckRunner::removeFromQueue(const Utils::FilePathList &files) { if (m_queue.isEmpty()) return; @@ -112,14 +114,14 @@ void CppcheckRunner::removeFromQueue(const Utils::FileNameList &files) m_queue.clear(); } else { for (auto it = m_queue.begin(), end = m_queue.end(); it != end;) { - for (const Utils::FileName &file : files) + for (const Utils::FilePath &file : files) it.value().removeOne(file); it = !it.value().isEmpty() ? ++it : m_queue.erase(it); } } } -const Utils::FileNameList &CppcheckRunner::currentFiles() const +const Utils::FilePathList &CppcheckRunner::currentFiles() const { return m_currentFiles; } @@ -135,12 +137,12 @@ void CppcheckRunner::checkQueued() if (m_queue.isEmpty() || m_binary.isEmpty()) return; - Utils::FileNameList files = m_queue.begin().value(); + Utils::FilePathList files = m_queue.begin().value(); QString arguments = m_arguments + ' ' + m_queue.begin().key(); m_currentFiles.clear(); int argumentsLength = arguments.length(); while (!files.isEmpty()) { - argumentsLength += files.first().length() + 1; // +1 for separator + argumentsLength += files.first().toString().size() + 1; // +1 for separator if (argumentsLength >= m_maxArgumentsLength) break; m_currentFiles.push_back(files.first()); @@ -153,7 +155,7 @@ void CppcheckRunner::checkQueued() else m_queue.begin().value() = files; - m_process->setCommand(m_binary, arguments); + m_process->setCommand(CommandLine(FilePath::fromString(m_binary), arguments)); m_process->start(); } diff --git a/src/plugins/cppcheck/cppcheckrunner.h b/src/plugins/cppcheck/cppcheckrunner.h index 733ef07d6d..522c33af2c 100644 --- a/src/plugins/cppcheck/cppcheckrunner.h +++ b/src/plugins/cppcheck/cppcheckrunner.h @@ -30,8 +30,8 @@ namespace Utils { class QtcProcess; -class FileName; -using FileNameList = QList<FileName>; +class FilePath; +using FilePathList = QList<FilePath>; } namespace Cppcheck { @@ -48,12 +48,12 @@ public: ~CppcheckRunner() override; void reconfigure(const QString &binary, const QString &arguments); - void addToQueue(const Utils::FileNameList &files, + void addToQueue(const Utils::FilePathList &files, const QString &additionalArguments = {}); - void removeFromQueue(const Utils::FileNameList &files); - void stop(const Utils::FileNameList &files = {}); + void removeFromQueue(const Utils::FilePathList &files); + void stop(const Utils::FilePathList &files = {}); - const Utils::FileNameList ¤tFiles() const; + const Utils::FilePathList ¤tFiles() const; QString currentCommand() const; private: @@ -67,8 +67,8 @@ private: Utils::QtcProcess *m_process = nullptr; QString m_binary; QString m_arguments; - QHash<QString, Utils::FileNameList> m_queue; - Utils::FileNameList m_currentFiles; + QHash<QString, Utils::FilePathList> m_queue; + Utils::FilePathList m_currentFiles; QTimer m_queueTimer; int m_maxArgumentsLength = 32767; bool m_isRunning = false; diff --git a/src/plugins/cppcheck/cppchecktextmarkmanager.cpp b/src/plugins/cppcheck/cppchecktextmarkmanager.cpp index 2d19a22151..9c2d50c6aa 100644 --- a/src/plugins/cppcheck/cppchecktextmarkmanager.cpp +++ b/src/plugins/cppcheck/cppchecktextmarkmanager.cpp @@ -45,13 +45,13 @@ void CppcheckTextMarkManager::add(const Diagnostic &diagnostic) fileMarks.push_back(std::make_unique<CppcheckTextMark>(diagnostic)); } -void CppcheckTextMarkManager::clearFiles(const Utils::FileNameList &files) +void CppcheckTextMarkManager::clearFiles(const Utils::FilePathList &files) { if (m_marks.empty()) return; if (!files.empty()) { - for (const Utils::FileName &file : files) + for (const Utils::FilePath &file : files) m_marks.erase(file); } else { m_marks.clear(); diff --git a/src/plugins/cppcheck/cppchecktextmarkmanager.h b/src/plugins/cppcheck/cppchecktextmarkmanager.h index e509fe9985..01be470816 100644 --- a/src/plugins/cppcheck/cppchecktextmarkmanager.h +++ b/src/plugins/cppcheck/cppchecktextmarkmanager.h @@ -42,11 +42,11 @@ public: ~CppcheckTextMarkManager(); void add(const Diagnostic &diagnostic); - void clearFiles(const Utils::FileNameList &files); + void clearFiles(const Utils::FilePathList &files); private: using MarkPtr = std::unique_ptr<CppcheckTextMark>; - std::unordered_map<Utils::FileName, std::vector<MarkPtr>> m_marks; + std::unordered_map<Utils::FilePath, std::vector<MarkPtr>> m_marks; }; } // namespace Internal diff --git a/src/plugins/cppcheck/cppchecktool.cpp b/src/plugins/cppcheck/cppchecktool.cpp index 78d3c9fee0..0c95f30fbd 100644 --- a/src/plugins/cppcheck/cppchecktool.cpp +++ b/src/plugins/cppcheck/cppchecktool.cpp @@ -165,6 +165,8 @@ QStringList CppcheckTool::additionalArguments(const CppTools::ProjectPart &part) case Version::CXX2a: result.push_back("--language=c++"); break; + case Version::None: + break; } using QtVersion = CppTools::ProjectPart::QtVersion; @@ -179,16 +181,16 @@ const CppcheckOptions &CppcheckTool::options() const return m_options; } -void CppcheckTool::check(const Utils::FileNameList &files) +void CppcheckTool::check(const Utils::FilePathList &files) { QTC_ASSERT(m_project, return); - Utils::FileNameList filtered; + Utils::FilePathList filtered; if (m_filters.isEmpty()) { filtered = files; } else { std::copy_if(files.cbegin(), files.cend(), std::back_inserter(filtered), - [this](const Utils::FileName &file) { + [this](const Utils::FilePath &file) { const QString stringed = file.toString(); const auto filter = [stringed](const QRegExp &re) {return re.exactMatch(stringed);}; return !Utils::contains(m_filters, filter); @@ -206,8 +208,8 @@ void CppcheckTool::check(const Utils::FileNameList &files) return; } - std::map<CppTools::ProjectPart::Ptr, Utils::FileNameList> groups; - for (const Utils::FileName &file : qAsConst(filtered)) { + std::map<CppTools::ProjectPart::Ptr, Utils::FilePathList> groups; + for (const Utils::FilePath &file : qAsConst(filtered)) { const QString stringed = file.toString(); for (const CppTools::ProjectPart::Ptr &part : parts) { using CppTools::ProjectFile; @@ -222,7 +224,7 @@ void CppcheckTool::check(const Utils::FileNameList &files) addToQueue(group.second, *group.first); } -void CppcheckTool::addToQueue(const Utils::FileNameList &files, CppTools::ProjectPart &part) +void CppcheckTool::addToQueue(const Utils::FilePathList &files, CppTools::ProjectPart &part) { const QString key = part.id(); if (!m_cachedAdditionalArguments.contains(key)) @@ -230,7 +232,7 @@ void CppcheckTool::addToQueue(const Utils::FileNameList &files, CppTools::Projec m_runner->addToQueue(files, m_cachedAdditionalArguments[key]); } -void CppcheckTool::stop(const Utils::FileNameList &files) +void CppcheckTool::stop(const Utils::FilePathList &files) { m_runner->removeFromQueue(files); m_runner->stop(files); @@ -297,7 +299,7 @@ void CppcheckTool::parseErrorLine(const QString &line) if (!match.hasMatch()) return; - const Utils::FileName fileName = Utils::FileName::fromUserInput(match.captured(File)); + const Utils::FilePath fileName = Utils::FilePath::fromUserInput(match.captured(File)); if (!m_runner->currentFiles().contains(fileName)) return; diff --git a/src/plugins/cppcheck/cppchecktool.h b/src/plugins/cppcheck/cppchecktool.h index b80e3436a7..ff668cf40e 100644 --- a/src/plugins/cppcheck/cppchecktool.h +++ b/src/plugins/cppcheck/cppchecktool.h @@ -34,8 +34,8 @@ #include <memory> namespace Utils { -class FileName; -using FileNameList = QList<FileName>; +class FilePath; +using FilePathList = QList<FilePath>; } namespace CppTools { @@ -64,8 +64,8 @@ public: void updateOptions(const CppcheckOptions &options); void setProject(ProjectExplorer::Project *project); - void check(const Utils::FileNameList &files); - void stop(const Utils::FileNameList &files); + void check(const Utils::FilePathList &files); + void stop(const Utils::FilePathList &files); void startParsing(); void parseOutputLine(const QString &line); @@ -76,7 +76,7 @@ public: private: void updateArguments(); - void addToQueue(const Utils::FileNameList &files, CppTools::ProjectPart &part); + void addToQueue(const Utils::FilePathList &files, CppTools::ProjectPart &part); QStringList additionalArguments(const CppTools::ProjectPart &part) const; CppcheckTextMarkManager &m_marks; diff --git a/src/plugins/cppcheck/cppchecktrigger.cpp b/src/plugins/cppcheck/cppchecktrigger.cpp index cac3772948..a69497f9fa 100644 --- a/src/plugins/cppcheck/cppchecktrigger.cpp +++ b/src/plugins/cppcheck/cppchecktrigger.cpp @@ -83,12 +83,12 @@ void CppcheckTrigger::checkEditors(const QList<Core::IEditor *> &editors) const QList<Core::IEditor *> editorList = !editors.isEmpty() ? editors : Core::DocumentModel::editorsForOpenedDocuments(); - Utils::FileNameList toCheck; + Utils::FilePathList toCheck; for (const Core::IEditor *editor : editorList) { QTC_ASSERT(editor, continue); Core::IDocument *document = editor->document(); QTC_ASSERT(document, continue); - const Utils::FileName &path = document->filePath(); + const Utils::FilePath &path = document->filePath(); if (path.isEmpty()) continue; @@ -128,12 +128,12 @@ void CppcheckTrigger::removeEditors(const QList<Core::IEditor *> &editors) const QList<Core::IEditor *> editorList = !editors.isEmpty() ? editors : Core::DocumentModel::editorsForOpenedDocuments(); - Utils::FileNameList toRemove; + Utils::FilePathList toRemove; for (const Core::IEditor *editor : editorList) { QTC_ASSERT(editor, return); const Core::IDocument *document = editor->document(); QTC_ASSERT(document, return); - const Utils::FileName &path = document->filePath(); + const Utils::FilePath &path = document->filePath(); if (path.isEmpty()) return; @@ -156,7 +156,7 @@ void CppcheckTrigger::checkChangedDocument(Core::IDocument *document) if (!m_currentProject) return; - const Utils::FileName &path = document->filePath(); + const Utils::FilePath &path = document->filePath(); QTC_ASSERT(!path.isEmpty(), return); if (!m_checkedFiles.contains(path)) return; @@ -185,12 +185,12 @@ void CppcheckTrigger::updateProjectFiles(ProjectExplorer::Project *project) checkEditors(Core::DocumentModel::editorsForOpenedDocuments()); } -void CppcheckTrigger::check(const Utils::FileNameList &files) +void CppcheckTrigger::check(const Utils::FilePathList &files) { m_tool.check(files); } -void CppcheckTrigger::remove(const Utils::FileNameList &files) +void CppcheckTrigger::remove(const Utils::FilePathList &files) { m_marks.clearFiles(files); m_tool.stop(files); diff --git a/src/plugins/cppcheck/cppchecktrigger.h b/src/plugins/cppcheck/cppchecktrigger.h index aa44f46fb7..069bfc7b04 100644 --- a/src/plugins/cppcheck/cppchecktrigger.h +++ b/src/plugins/cppcheck/cppchecktrigger.h @@ -29,8 +29,8 @@ #include <QPointer> namespace Utils { -class FileName; -using FileNameList = QList<FileName>; +class FilePath; +using FilePathList = QList<FilePath>; } namespace ProjectExplorer { @@ -68,13 +68,13 @@ private: void checkChangedDocument(Core::IDocument *document); void changeCurrentProject(ProjectExplorer::Project *project); void updateProjectFiles(ProjectExplorer::Project *project); - void check(const Utils::FileNameList &files); - void remove(const Utils::FileNameList &files); + void check(const Utils::FilePathList &files); + void remove(const Utils::FilePathList &files); CppcheckTextMarkManager &m_marks; CppcheckTool &m_tool; QPointer<ProjectExplorer::Project> m_currentProject; - QHash<Utils::FileName, QDateTime> m_checkedFiles; + QHash<Utils::FilePath, QDateTime> m_checkedFiles; }; } // namespace Internal |