2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2018 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2018-10-11 14:11:43 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <utils/fileutils.h>
|
2020-06-26 13:59:38 +02:00
|
|
|
#include <utils/id.h>
|
|
|
|
|
|
2018-10-11 14:11:43 +02:00
|
|
|
#include <clang/Format/Format.h>
|
|
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
2022-04-08 15:12:30 +02:00
|
|
|
namespace TextEditor { class ICodeStylePreferences; }
|
2018-10-11 14:11:43 +02:00
|
|
|
namespace ClangFormat {
|
|
|
|
|
|
2018-11-13 11:47:02 +01:00
|
|
|
// Creates the style for the current project or the global style if needed.
|
|
|
|
|
void createStyleFileIfNeeded(bool isGlobal);
|
2018-11-08 10:35:23 +01:00
|
|
|
|
2019-03-05 13:12:44 +01:00
|
|
|
QString currentProjectUniqueId();
|
|
|
|
|
|
2019-04-25 10:40:08 +02:00
|
|
|
std::string currentProjectConfigText();
|
|
|
|
|
std::string currentGlobalConfigText();
|
|
|
|
|
|
2018-11-08 10:35:23 +01:00
|
|
|
clang::format::FormatStyle currentProjectStyle();
|
|
|
|
|
clang::format::FormatStyle currentGlobalStyle();
|
2022-04-04 14:53:05 +02:00
|
|
|
std::string readFile(const QString &path);
|
2018-11-08 10:35:23 +01:00
|
|
|
|
2018-11-13 11:47:02 +01:00
|
|
|
// Is the style from the matching .clang-format file or global one if it's not found.
|
2019-05-28 13:49:26 +02:00
|
|
|
QString configForFile(Utils::FilePath fileName);
|
|
|
|
|
clang::format::FormatStyle styleForFile(Utils::FilePath fileName);
|
2022-04-04 14:53:05 +02:00
|
|
|
void saveStyleToFile(clang::format::FormatStyle style, Utils::FilePath filePath);
|
2018-10-11 14:11:43 +02:00
|
|
|
|
2022-01-11 13:18:29 +01:00
|
|
|
void addQtcStatementMacros(clang::format::FormatStyle &style);
|
|
|
|
|
clang::format::FormatStyle qtcStyle();
|
2022-04-08 15:12:30 +02:00
|
|
|
|
|
|
|
|
Utils::FilePath filePathToCurrentSettings(const TextEditor::ICodeStylePreferences *codeStyle);
|
2018-10-11 14:11:43 +02:00
|
|
|
}
|