Clang: Improve interfaces

The interfaces should never used to handle ownership. So it is now using
protected destructors. Copy operations are forbidden too.

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c35-a-base-class-destructor-should-be-either-public-and-virtual-or-protected-and-nonvirtual

Change-Id: Ib0b60a73a7ec130973b5cb0095cc5b2f10fa0758
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-03-12 14:08:18 +01:00
parent f1e02c0826
commit 9c4bfbe20a
52 changed files with 186 additions and 316 deletions

View File

@@ -39,7 +39,5 @@ SOURCES += \
$$PWD/refactoringconnectionclient.cpp \
$$PWD/refactoringengine.cpp \
$$PWD/refactoringprojectupdater.cpp \
$$PWD/searchinterface.cpp \
$$PWD/searchhandle.cpp \
$$PWD/symbolsfindfilter.cpp \
$$PWD/projectpartproviderinterface.cpp
$$PWD/symbolsfindfilter.cpp

View File

@@ -1,32 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2017 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 "projectpartproviderinterface.h"
namespace ClangRefactoring {
ProjectPartProviderInterface::~ProjectPartProviderInterface() = default;
} // namespace ClangRefactoring

View File

@@ -39,7 +39,6 @@ class ProjectPartProviderInterface
{
public:
ProjectPartProviderInterface() = default;
virtual ~ProjectPartProviderInterface();
ProjectPartProviderInterface(const ProjectPartProviderInterface&) = delete;
ProjectPartProviderInterface& operator=(const ProjectPartProviderInterface&) = delete;
@@ -49,6 +48,9 @@ public:
virtual CppTools::ProjectPart *projectPart(const QString &projectPartId) const = 0;
virtual ClangBackEnd::V2::FileContainers generatedFiles() const = 0;
protected:
~ProjectPartProviderInterface() = default;
};
} // namespace ClangRefactoring

View File

@@ -34,6 +34,10 @@ namespace ClangRefactoring {
class SearchHandle
{
public:
SearchHandle() = default;
SearchHandle(const SearchHandle &) = delete;
SearchHandle &operator=(const SearchHandle &) = delete;
virtual ~SearchHandle();
virtual void addResult(const QString &fileName,

View File

@@ -36,9 +36,15 @@ namespace ClangRefactoring {
class SearchInterface
{
public:
virtual ~SearchInterface();
SearchInterface() = default;
SearchInterface(const SearchInterface &) = delete;
SearchInterface &operator=(const SearchInterface &) = delete;
virtual std::unique_ptr<SearchHandle> startNewSearch(const QString &searchLabel,
const QString &searchTerm) = 0;
const QString &searchTerm) = 0;
protected:
~SearchInterface() = default;
};
} // namespace ClangRefactoring

View File

@@ -47,7 +47,10 @@ enum class SymbolType
class SymbolQueryInterface
{
public:
virtual ~SymbolQueryInterface() {}
SymbolQueryInterface() = default;
SymbolQueryInterface(const SymbolQueryInterface &) = delete;
SymbolQueryInterface &operator=(const SymbolQueryInterface &) = delete;
virtual SourceLocations locationsAt(ClangBackEnd::FilePathId filePathId,
int line,
int utf8Column) const = 0;
@@ -57,6 +60,9 @@ public:
virtual Symbols symbolsContaining(SymbolType symbolType,
Utils::SmallStringView regularExpression) const = 0;
virtual Functions functionsContaining(Utils::SmallStringView regularExpression) const = 0;
protected:
~SymbolQueryInterface() = default;
};
} // namespace ClangRefactoring