2016-08-04 15:26:53 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** 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 "refactoringengine.h"
|
|
|
|
|
|
2016-11-23 13:13:38 +01:00
|
|
|
#include <searchhandle.h>
|
2016-11-15 15:38:12 +01:00
|
|
|
|
2016-08-04 15:26:53 +02:00
|
|
|
#include <refactoringclientinterface.h>
|
|
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
2016-11-15 15:38:12 +01:00
|
|
|
namespace ClangBackEnd {
|
|
|
|
|
class FilePath;
|
|
|
|
|
class SourceRangesContainer;
|
|
|
|
|
class SourceRangeWithTextContainer;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-04 15:26:53 +02:00
|
|
|
namespace ClangRefactoring {
|
|
|
|
|
|
2016-11-15 15:38:12 +01:00
|
|
|
class RefactoringClient final : public ClangBackEnd::RefactoringClientInterface
|
2016-08-04 15:26:53 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2016-08-16 11:48:41 +02:00
|
|
|
void alive() final;
|
2016-11-15 15:38:12 +01:00
|
|
|
void sourceLocationsForRenamingMessage(
|
|
|
|
|
ClangBackEnd::SourceLocationsForRenamingMessage &&message) final;
|
|
|
|
|
void sourceRangesAndDiagnosticsForQueryMessage(
|
|
|
|
|
ClangBackEnd::SourceRangesAndDiagnosticsForQueryMessage &&message) final;
|
2016-08-04 15:26:53 +02:00
|
|
|
|
2016-11-15 15:38:12 +01:00
|
|
|
void setLocalRenamingCallback(
|
|
|
|
|
CppTools::RefactoringEngineInterface::RenameCallback &&localRenamingCallback) final;
|
2016-08-04 15:26:53 +02:00
|
|
|
void setRefactoringEngine(ClangRefactoring::RefactoringEngine *refactoringEngine);
|
2016-11-23 13:13:38 +01:00
|
|
|
void setSearchHandle(ClangRefactoring::SearchHandle *searchHandleInterface);
|
|
|
|
|
ClangRefactoring::SearchHandle *searchHandle() const;
|
2016-08-04 15:26:53 +02:00
|
|
|
|
|
|
|
|
bool hasValidLocalRenamingCallback() const;
|
|
|
|
|
|
2016-11-15 15:38:12 +01:00
|
|
|
static std::unordered_map<uint, QString> convertFilePaths(
|
|
|
|
|
const std::unordered_map<uint, ClangBackEnd::FilePath> &filePaths);
|
|
|
|
|
|
2016-11-23 13:13:38 +01:00
|
|
|
void setExpectedResultCount(uint count);
|
|
|
|
|
uint expectedResultCount() const;
|
|
|
|
|
uint resultCounter() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UNIT_TEST_PUBLIC:
|
2016-11-15 15:38:12 +01:00
|
|
|
void addSearchResult(const ClangBackEnd::SourceRangeWithTextContainer &sourceRange,
|
|
|
|
|
std::unordered_map<uint, QString> &filePaths);
|
2016-11-23 13:13:38 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void addSearchResults(const ClangBackEnd::SourceRangesContainer &sourceRanges);
|
|
|
|
|
|
|
|
|
|
void setResultCounterAndSendSearchIsFinishedIfFinished();
|
2016-11-15 15:38:12 +01:00
|
|
|
void sendSearchIsFinished();
|
2016-11-23 13:13:38 +01:00
|
|
|
|
2016-08-04 15:26:53 +02:00
|
|
|
private:
|
|
|
|
|
CppTools::RefactoringEngineInterface::RenameCallback localRenamingCallback;
|
2016-11-23 13:13:38 +01:00
|
|
|
ClangRefactoring::SearchHandle *searchHandle_ = nullptr;
|
2016-08-04 15:26:53 +02:00
|
|
|
ClangRefactoring::RefactoringEngine *refactoringEngine = nullptr;
|
2016-11-23 13:13:38 +01:00
|
|
|
uint expectedResultCount_ = 0;
|
|
|
|
|
uint resultCounter_ = 0;
|
2016-08-04 15:26:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace ClangRefactoring
|