2016-11-15 15:38:12 +01: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 "refactoringcompilationdatabase.h"
|
|
|
|
|
|
|
|
|
|
#include <clangrefactoringbackend_global.h>
|
|
|
|
|
|
2016-11-30 15:29:36 +01:00
|
|
|
#include <filecontainerv2.h>
|
2019-01-31 10:30:58 +01:00
|
|
|
#include <nativefilepath.h>
|
2016-11-15 15:38:12 +01:00
|
|
|
#include <sourcelocationscontainer.h>
|
|
|
|
|
|
2017-12-13 12:04:35 +01:00
|
|
|
#include <clang/Tooling/Refactoring.h>
|
2016-11-15 15:38:12 +01:00
|
|
|
|
2016-11-30 15:29:36 +01:00
|
|
|
#include <utils/smallstring.h>
|
|
|
|
|
|
2016-11-15 15:38:12 +01:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace ClangBackEnd {
|
|
|
|
|
|
|
|
|
|
struct FileContent
|
|
|
|
|
{
|
2019-01-31 10:30:58 +01:00
|
|
|
FileContent(NativeFilePath &&filePath, const Utils::SmallString &content)
|
|
|
|
|
: filePath(std::move(filePath))
|
|
|
|
|
, content(std::move(content))
|
2016-11-15 15:38:12 +01:00
|
|
|
{}
|
|
|
|
|
|
2019-01-31 10:30:58 +01:00
|
|
|
NativeFilePath filePath;
|
2019-01-30 13:59:30 +01:00
|
|
|
Utils::SmallString content;
|
2016-11-15 15:38:12 +01:00
|
|
|
};
|
|
|
|
|
|
2016-11-30 15:29:36 +01:00
|
|
|
struct UnsavedFileContent
|
|
|
|
|
{
|
2019-01-31 10:30:58 +01:00
|
|
|
UnsavedFileContent(NativeFilePath &&filePath, Utils::SmallString &&content)
|
|
|
|
|
: filePath(std::move(filePath))
|
|
|
|
|
, content(std::move(content))
|
2016-11-30 15:29:36 +01:00
|
|
|
{}
|
|
|
|
|
|
2019-01-31 10:30:58 +01:00
|
|
|
NativeFilePath filePath;
|
2016-11-30 15:29:36 +01:00
|
|
|
Utils::SmallString content;
|
|
|
|
|
};
|
|
|
|
|
|
2016-11-15 15:38:12 +01:00
|
|
|
class ClangTool
|
|
|
|
|
{
|
|
|
|
|
public:
|
2019-01-31 10:30:58 +01:00
|
|
|
void addFile(FilePath &&filePath,
|
|
|
|
|
Utils::SmallString &&content,
|
|
|
|
|
Utils::SmallStringVector &&commandLine);
|
2018-01-22 14:21:01 +01:00
|
|
|
|
2019-01-31 10:30:58 +01:00
|
|
|
void addFiles(const FilePaths &filePaths, const Utils::SmallStringVector &arguments);
|
2016-11-15 15:38:12 +01:00
|
|
|
|
2017-02-01 13:43:28 +01:00
|
|
|
void addUnsavedFiles(const V2::FileContainers &unsavedFiles);
|
2016-11-30 15:29:36 +01:00
|
|
|
|
2016-11-15 15:38:12 +01:00
|
|
|
clang::tooling::ClangTool createTool() const;
|
2018-12-17 12:06:57 +01:00
|
|
|
clang::tooling::ClangTool createOutputTool() const;
|
2016-11-15 15:38:12 +01:00
|
|
|
|
2019-01-22 14:38:39 +01:00
|
|
|
bool isClean() const;
|
|
|
|
|
|
2016-11-15 15:38:12 +01:00
|
|
|
private:
|
2017-07-24 14:55:51 +02:00
|
|
|
RefactoringCompilationDatabase m_compilationDatabase;
|
|
|
|
|
std::vector<FileContent> m_fileContents;
|
|
|
|
|
std::vector<std::string> m_sourceFilePaths;
|
|
|
|
|
std::vector<UnsavedFileContent> m_unsavedFileContents;
|
2016-11-15 15:38:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace ClangBackEnd
|