From 56b5e1f4de94dbae9d0173665d9d7415e468336c Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 6 May 2022 10:53:38 +0200 Subject: [PATCH] ClangCodeModel: Remove ClangFixItOperationsExtractor Not used anymore. Change-Id: Ice3dd4c58df73f4075d0c79c011554286b5d9dd7 Reviewed-by: David Schulz Reviewed-by: Qt CI Bot Reviewed-by: --- src/plugins/clangcodemodel/CMakeLists.txt | 1 - src/plugins/clangcodemodel/clangcodemodel.qbs | 2 - .../clangeditordocumentprocessor.cpp | 1 - .../clangfixitoperationsextractor.cpp | 114 ------------------ .../clangfixitoperationsextractor.h | 55 --------- 5 files changed, 173 deletions(-) delete mode 100644 src/plugins/clangcodemodel/clangfixitoperationsextractor.cpp delete mode 100644 src/plugins/clangcodemodel/clangfixitoperationsextractor.h diff --git a/src/plugins/clangcodemodel/CMakeLists.txt b/src/plugins/clangcodemodel/CMakeLists.txt index af26ec89640..4f47be868a6 100644 --- a/src/plugins/clangcodemodel/CMakeLists.txt +++ b/src/plugins/clangcodemodel/CMakeLists.txt @@ -26,7 +26,6 @@ add_qtc_plugin(ClangCodeModel clangdqpropertyhighlighter.cpp clangdqpropertyhighlighter.h clangeditordocumentprocessor.cpp clangeditordocumentprocessor.h clangfixitoperation.cpp clangfixitoperation.h - clangfixitoperationsextractor.cpp clangfixitoperationsextractor.h clangdlocatorfilters.cpp clangdlocatorfilters.h clangmodelmanagersupport.cpp clangmodelmanagersupport.h clangpreprocessorassistproposalitem.cpp clangpreprocessorassistproposalitem.h diff --git a/src/plugins/clangcodemodel/clangcodemodel.qbs b/src/plugins/clangcodemodel/clangcodemodel.qbs index 9afe54780d5..e36a4635d04 100644 --- a/src/plugins/clangcodemodel/clangcodemodel.qbs +++ b/src/plugins/clangcodemodel/clangcodemodel.qbs @@ -47,8 +47,6 @@ QtcPlugin { "clangeditordocumentprocessor.h", "clangfixitoperation.cpp", "clangfixitoperation.h", - "clangfixitoperationsextractor.cpp", - "clangfixitoperationsextractor.h", "clangmodelmanagersupport.cpp", "clangmodelmanagersupport.h", "clangpreprocessorassistproposalitem.cpp", diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp index 69c260b8cc6..2d3eba9e62d 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp @@ -28,7 +28,6 @@ #include "clangprojectsettings.h" #include "clangdiagnostictooltipwidget.h" #include "clangfixitoperation.h" -#include "clangfixitoperationsextractor.h" #include "clangmodelmanagersupport.h" #include "clangutils.h" diff --git a/src/plugins/clangcodemodel/clangfixitoperationsextractor.cpp b/src/plugins/clangcodemodel/clangfixitoperationsextractor.cpp deleted file mode 100644 index d1bc8273984..00000000000 --- a/src/plugins/clangcodemodel/clangfixitoperationsextractor.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "clangfixitoperationsextractor.h" - -#include "clangfixitoperation.h" -#include "clangutils.h" - -#include -#include - -#include - -namespace ClangCodeModel { -namespace Internal { - -namespace { - -void capitalizeText(QString &text) -{ - text[0] = text[0].toUpper(); -} - -QString tweakedDiagnosticText(const QString &diagnosticText) -{ - // Examples: - // "note: use '==' to turn this assignment into an equality comparison" - // "error: expected ';' at end of declaration" - - QString tweakedText = diagnosticText; - - if (!tweakedText.isEmpty()) { - tweakedText = diagnosticCategoryPrefixRemoved(tweakedText); - capitalizeText(tweakedText); - } - - return tweakedText; -} - -bool hasFixItAt(const QList &fixits, const QString &filePath, int line) -{ - const auto isFixitForLocation = [filePath, line] (const ClangFixIt &fixit) { - const Utils::Link &location = fixit.range.start; - return location.targetFilePath.toString() == filePath && location.targetLine == line; - }; - return Utils::anyOf(fixits, isFixitForLocation); -} - -} // anonymous namespace - -ClangFixItOperationsExtractor::ClangFixItOperationsExtractor( - const QList &diagnosticContainers) - : diagnostics(diagnosticContainers) -{ -} - -TextEditor::QuickFixOperations -ClangFixItOperationsExtractor::extract(const QString &filePath, int line) -{ - foreach (const ClangDiagnostic &diagnostic, diagnostics) - extractFromDiagnostic(diagnostic, filePath, line); - - return operations; -} - -void ClangFixItOperationsExtractor::appendFixitOperation( - const QString &diagnosticText, - const QList &fixits) -{ - if (!fixits.isEmpty()) { - const QString diagnosticTextTweaked = tweakedDiagnosticText(diagnosticText); - TextEditor::QuickFixOperation::Ptr operation( - new ClangFixItOperation(diagnosticTextTweaked, fixits)); - operations.append(operation); - } -} - -void ClangFixItOperationsExtractor::extractFromDiagnostic( - const ClangDiagnostic &diagnostic, - const QString &filePath, - int line) -{ - const QList &fixIts = diagnostic.fixIts; - if (hasFixItAt(fixIts, filePath, line)) { - appendFixitOperation(diagnostic.text, fixIts); - for (const auto &child : diagnostic.children) - extractFromDiagnostic(child, filePath, line); - } -} - -} // namespace Internal -} // namespace ClangCodeModel diff --git a/src/plugins/clangcodemodel/clangfixitoperationsextractor.h b/src/plugins/clangcodemodel/clangfixitoperationsextractor.h deleted file mode 100644 index 8c0b0a0395b..00000000000 --- a/src/plugins/clangcodemodel/clangfixitoperationsextractor.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "clangutils.h" - -#include - -namespace ClangCodeModel { -namespace Internal { - -class ClangFixItOperationsExtractor -{ -public: - ClangFixItOperationsExtractor(const QList &diagnosticContainers); - - TextEditor::QuickFixOperations extract(const QString &filePath, int line); - -private: - void extractFromDiagnostic(const ClangDiagnostic &diagnostic, - const QString &filePath, - int line); - void appendFixitOperation(const QString &diagnosticText, - const QList &fixits); - -private: - const QList &diagnostics; - TextEditor::QuickFixOperations operations; -}; - -} // namespace Internal -} // namespace ClangCodeModel