ClangCodeModel: Remove ClangFixItOperationsExtractor

Not used anymore.

Change-Id: Ice3dd4c58df73f4075d0c79c011554286b5d9dd7
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Christian Kandeler
2022-05-06 10:53:38 +02:00
parent ccf3e1d5c4
commit 56b5e1f4de
5 changed files with 0 additions and 173 deletions

View File

@@ -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

View File

@@ -47,8 +47,6 @@ QtcPlugin {
"clangeditordocumentprocessor.h",
"clangfixitoperation.cpp",
"clangfixitoperation.h",
"clangfixitoperationsextractor.cpp",
"clangfixitoperationsextractor.h",
"clangmodelmanagersupport.cpp",
"clangmodelmanagersupport.h",
"clangpreprocessorassistproposalitem.cpp",

View File

@@ -28,7 +28,6 @@
#include "clangprojectsettings.h"
#include "clangdiagnostictooltipwidget.h"
#include "clangfixitoperation.h"
#include "clangfixitoperationsextractor.h"
#include "clangmodelmanagersupport.h"
#include "clangutils.h"

View File

@@ -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 <utils/algorithm.h>
#include <utils/link.h>
#include <QDebug>
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<ClangFixIt> &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<ClangDiagnostic> &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<ClangFixIt> &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<ClangFixIt> &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

View File

@@ -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 <texteditor/quickfix.h>
namespace ClangCodeModel {
namespace Internal {
class ClangFixItOperationsExtractor
{
public:
ClangFixItOperationsExtractor(const QList<ClangDiagnostic> &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<ClangFixIt> &fixits);
private:
const QList<ClangDiagnostic> &diagnostics;
TextEditor::QuickFixOperations operations;
};
} // namespace Internal
} // namespace ClangCodeModel