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-11-08 10:35:23 +01:00
|
|
|
|
|
|
|
|
#include "clangformatutils.h"
|
|
|
|
|
|
2018-11-13 09:29:09 +01:00
|
|
|
#include "clangformatconstants.h"
|
|
|
|
|
|
2018-11-08 10:35:23 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2023-01-16 12:33:43 +01:00
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
#include <cppeditor/cppcodestylesettings.h>
|
2023-01-16 12:33:43 +01:00
|
|
|
|
2022-04-08 15:12:30 +02:00
|
|
|
#include <texteditor/icodestylepreferences.h>
|
2018-11-08 10:35:23 +01:00
|
|
|
#include <texteditor/tabsettings.h>
|
2022-04-08 15:12:30 +02:00
|
|
|
#include <texteditor/texteditorsettings.h>
|
2023-01-16 12:33:43 +01:00
|
|
|
|
|
|
|
|
#include <projectexplorer/editorconfiguration.h>
|
2018-11-08 10:35:23 +01:00
|
|
|
#include <projectexplorer/project.h>
|
2023-02-14 15:47:22 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
2023-01-16 12:33:43 +01:00
|
|
|
|
2022-01-11 13:18:29 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2018-11-08 10:35:23 +01:00
|
|
|
|
2019-03-05 13:12:44 +01:00
|
|
|
#include <QCryptographicHash>
|
|
|
|
|
|
2018-11-08 10:35:23 +01:00
|
|
|
using namespace clang;
|
|
|
|
|
using namespace format;
|
|
|
|
|
using namespace llvm;
|
2021-08-30 10:58:08 +02:00
|
|
|
using namespace CppEditor;
|
2018-11-08 10:35:23 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace TextEditor;
|
2021-08-17 18:16:43 +02:00
|
|
|
using namespace Utils;
|
2018-11-08 10:35:23 +01:00
|
|
|
|
|
|
|
|
namespace ClangFormat {
|
|
|
|
|
|
2022-01-11 13:18:29 +01:00
|
|
|
clang::format::FormatStyle qtcStyle()
|
2019-03-07 13:45:22 +01:00
|
|
|
{
|
|
|
|
|
clang::format::FormatStyle style = getLLVMStyle();
|
|
|
|
|
style.Language = FormatStyle::LK_Cpp;
|
|
|
|
|
style.AccessModifierOffset = -4;
|
|
|
|
|
style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
|
2022-03-22 18:06:07 +01:00
|
|
|
#if LLVM_VERSION_MAJOR >= 15
|
2022-10-12 10:39:03 +02:00
|
|
|
style.AlignConsecutiveAssignments = {false, false, false, false, false};
|
|
|
|
|
style.AlignConsecutiveDeclarations = {false, false, false, false, false};
|
2022-03-22 18:06:07 +01:00
|
|
|
#elif LLVM_VERSION_MAJOR >= 12
|
2021-01-29 18:01:37 +01:00
|
|
|
style.AlignConsecutiveAssignments = FormatStyle::ACS_None;
|
|
|
|
|
style.AlignConsecutiveDeclarations = FormatStyle::ACS_None;
|
|
|
|
|
#else
|
2019-03-07 13:45:22 +01:00
|
|
|
style.AlignConsecutiveAssignments = false;
|
|
|
|
|
style.AlignConsecutiveDeclarations = false;
|
2021-01-29 18:01:37 +01:00
|
|
|
#endif
|
2019-03-07 13:45:22 +01:00
|
|
|
style.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign;
|
2020-06-03 11:11:16 +02:00
|
|
|
#if LLVM_VERSION_MAJOR >= 11
|
|
|
|
|
style.AlignOperands = FormatStyle::OAS_Align;
|
|
|
|
|
#else
|
2019-03-07 13:45:22 +01:00
|
|
|
style.AlignOperands = true;
|
2020-06-03 11:11:16 +02:00
|
|
|
#endif
|
2022-11-04 07:18:50 +01:00
|
|
|
#if LLVM_VERSION_MAJOR >= 16
|
|
|
|
|
style.AlignTrailingComments = {FormatStyle::TCAS_Always, 0};
|
|
|
|
|
#else
|
2019-03-07 13:45:22 +01:00
|
|
|
style.AlignTrailingComments = true;
|
2022-11-04 07:18:50 +01:00
|
|
|
#endif
|
2019-03-07 13:45:22 +01:00
|
|
|
style.AllowAllParametersOfDeclarationOnNextLine = true;
|
2020-02-17 23:21:17 +02:00
|
|
|
#if LLVM_VERSION_MAJOR >= 10
|
|
|
|
|
style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
|
|
|
|
|
#else
|
2019-03-07 13:45:22 +01:00
|
|
|
style.AllowShortBlocksOnASingleLine = false;
|
2020-02-17 23:21:17 +02:00
|
|
|
#endif
|
2019-03-07 13:45:22 +01:00
|
|
|
style.AllowShortCaseLabelsOnASingleLine = false;
|
|
|
|
|
style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
|
2019-10-02 09:28:43 +02:00
|
|
|
#if LLVM_VERSION_MAJOR >= 9
|
|
|
|
|
style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
|
|
|
|
|
#else
|
2019-03-07 13:45:22 +01:00
|
|
|
style.AllowShortIfStatementsOnASingleLine = false;
|
2019-10-02 09:28:43 +02:00
|
|
|
#endif
|
2019-03-07 13:45:22 +01:00
|
|
|
style.AllowShortLoopsOnASingleLine = false;
|
|
|
|
|
style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
|
|
|
|
|
style.AlwaysBreakBeforeMultilineStrings = false;
|
|
|
|
|
style.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
|
|
|
|
|
style.BinPackArguments = false;
|
|
|
|
|
style.BinPackParameters = false;
|
|
|
|
|
style.BraceWrapping.AfterClass = true;
|
2020-02-17 23:21:17 +02:00
|
|
|
#if LLVM_VERSION_MAJOR >= 10
|
|
|
|
|
style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
|
|
|
|
|
#else
|
2019-03-07 13:45:22 +01:00
|
|
|
style.BraceWrapping.AfterControlStatement = false;
|
2020-02-17 23:21:17 +02:00
|
|
|
#endif
|
2019-03-07 13:45:22 +01:00
|
|
|
style.BraceWrapping.AfterEnum = false;
|
|
|
|
|
style.BraceWrapping.AfterFunction = true;
|
|
|
|
|
style.BraceWrapping.AfterNamespace = false;
|
|
|
|
|
style.BraceWrapping.AfterObjCDeclaration = false;
|
|
|
|
|
style.BraceWrapping.AfterStruct = true;
|
|
|
|
|
style.BraceWrapping.AfterUnion = false;
|
|
|
|
|
style.BraceWrapping.BeforeCatch = false;
|
|
|
|
|
style.BraceWrapping.BeforeElse = false;
|
|
|
|
|
style.BraceWrapping.IndentBraces = false;
|
|
|
|
|
style.BraceWrapping.SplitEmptyFunction = false;
|
|
|
|
|
style.BraceWrapping.SplitEmptyRecord = false;
|
|
|
|
|
style.BraceWrapping.SplitEmptyNamespace = false;
|
|
|
|
|
style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
|
|
|
|
|
style.BreakBeforeBraces = FormatStyle::BS_Custom;
|
|
|
|
|
style.BreakBeforeTernaryOperators = true;
|
|
|
|
|
style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
|
|
|
|
|
style.BreakAfterJavaFieldAnnotations = false;
|
|
|
|
|
style.BreakStringLiterals = true;
|
|
|
|
|
style.ColumnLimit = 100;
|
|
|
|
|
style.CommentPragmas = "^ IWYU pragma:";
|
|
|
|
|
style.CompactNamespaces = false;
|
2022-07-27 13:46:27 +02:00
|
|
|
#if LLVM_VERSION_MAJOR >= 15
|
|
|
|
|
style.PackConstructorInitializers = FormatStyle::PCIS_BinPack;
|
|
|
|
|
#else
|
2019-03-07 13:45:22 +01:00
|
|
|
style.ConstructorInitializerAllOnOneLineOrOnePerLine = false;
|
2022-08-16 21:04:39 +02:00
|
|
|
#endif
|
2019-03-07 13:45:22 +01:00
|
|
|
style.ConstructorInitializerIndentWidth = 4;
|
|
|
|
|
style.ContinuationIndentWidth = 4;
|
|
|
|
|
style.Cpp11BracedListStyle = true;
|
|
|
|
|
style.DerivePointerAlignment = false;
|
|
|
|
|
style.DisableFormat = false;
|
|
|
|
|
style.ExperimentalAutoDetectBinPacking = false;
|
|
|
|
|
style.FixNamespaceComments = true;
|
|
|
|
|
style.ForEachMacros = {"forever", "foreach", "Q_FOREACH", "BOOST_FOREACH"};
|
2021-07-12 12:03:26 +02:00
|
|
|
#if LLVM_VERSION_MAJOR >= 12
|
|
|
|
|
style.IncludeStyle.IncludeCategories = {{"^<Q.*", 200, 200, true}};
|
|
|
|
|
#else
|
2020-11-13 09:36:58 +01:00
|
|
|
style.IncludeStyle.IncludeCategories = {{"^<Q.*", 200, 200}};
|
2021-07-12 12:03:26 +02:00
|
|
|
#endif
|
2019-03-07 13:45:22 +01:00
|
|
|
style.IncludeStyle.IncludeIsMainRegex = "(Test)?$";
|
|
|
|
|
style.IndentCaseLabels = false;
|
|
|
|
|
style.IndentWidth = 4;
|
|
|
|
|
style.IndentWrappedFunctionNames = false;
|
|
|
|
|
style.JavaScriptQuotes = FormatStyle::JSQS_Leave;
|
|
|
|
|
style.JavaScriptWrapImports = true;
|
|
|
|
|
style.KeepEmptyLinesAtTheStartOfBlocks = false;
|
|
|
|
|
// Do not add QT_BEGIN_NAMESPACE/QT_END_NAMESPACE as this will indent lines in between.
|
|
|
|
|
style.MacroBlockBegin = "";
|
|
|
|
|
style.MacroBlockEnd = "";
|
|
|
|
|
style.MaxEmptyLinesToKeep = 1;
|
|
|
|
|
style.NamespaceIndentation = FormatStyle::NI_None;
|
|
|
|
|
style.ObjCBlockIndentWidth = 4;
|
|
|
|
|
style.ObjCSpaceAfterProperty = false;
|
|
|
|
|
style.ObjCSpaceBeforeProtocolList = true;
|
|
|
|
|
style.PenaltyBreakAssignment = 150;
|
|
|
|
|
style.PenaltyBreakBeforeFirstCallParameter = 300;
|
|
|
|
|
style.PenaltyBreakComment = 500;
|
|
|
|
|
style.PenaltyBreakFirstLessLess = 400;
|
|
|
|
|
style.PenaltyBreakString = 600;
|
|
|
|
|
style.PenaltyExcessCharacter = 50;
|
|
|
|
|
style.PenaltyReturnTypeOnItsOwnLine = 300;
|
|
|
|
|
style.PointerAlignment = FormatStyle::PAS_Right;
|
|
|
|
|
style.ReflowComments = false;
|
2021-03-11 13:08:16 +01:00
|
|
|
#if LLVM_VERSION_MAJOR >= 13
|
2021-03-08 21:56:06 +01:00
|
|
|
style.SortIncludes = FormatStyle::SI_CaseSensitive;
|
|
|
|
|
#else
|
2019-03-07 13:45:22 +01:00
|
|
|
style.SortIncludes = true;
|
2021-03-08 21:56:06 +01:00
|
|
|
#endif
|
2023-01-31 08:11:29 +01:00
|
|
|
#if LLVM_VERSION_MAJOR >= 16
|
|
|
|
|
style.SortUsingDeclarations = FormatStyle::SUD_Lexicographic;
|
|
|
|
|
#else
|
2019-03-07 13:45:22 +01:00
|
|
|
style.SortUsingDeclarations = true;
|
2023-01-31 08:11:29 +01:00
|
|
|
#endif
|
2019-03-07 13:45:22 +01:00
|
|
|
style.SpaceAfterCStyleCast = true;
|
|
|
|
|
style.SpaceAfterTemplateKeyword = false;
|
|
|
|
|
style.SpaceBeforeAssignmentOperators = true;
|
|
|
|
|
style.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
|
|
|
|
|
style.SpaceInEmptyParentheses = false;
|
|
|
|
|
style.SpacesBeforeTrailingComments = 1;
|
2021-06-16 20:59:29 +02:00
|
|
|
#if LLVM_VERSION_MAJOR >= 13
|
|
|
|
|
style.SpacesInAngles = FormatStyle::SIAS_Never;
|
|
|
|
|
#else
|
2019-03-07 13:45:22 +01:00
|
|
|
style.SpacesInAngles = false;
|
2021-06-16 20:59:29 +02:00
|
|
|
#endif
|
2019-03-07 13:45:22 +01:00
|
|
|
style.SpacesInContainerLiterals = false;
|
|
|
|
|
style.SpacesInCStyleCastParentheses = false;
|
|
|
|
|
style.SpacesInParentheses = false;
|
|
|
|
|
style.SpacesInSquareBrackets = false;
|
2023-04-25 16:04:30 +02:00
|
|
|
addQtcStatementMacros(style);
|
2019-03-07 13:45:22 +01:00
|
|
|
style.Standard = FormatStyle::LS_Cpp11;
|
|
|
|
|
style.TabWidth = 4;
|
|
|
|
|
style.UseTab = FormatStyle::UT_Never;
|
2023-04-17 15:08:00 +02:00
|
|
|
style.Standard = FormatStyle::LS_Auto;
|
2019-03-07 13:45:22 +01:00
|
|
|
return style;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-16 12:33:43 +01:00
|
|
|
QString projectUniqueId(ProjectExplorer::Project *project)
|
|
|
|
|
{
|
2019-03-05 13:12:44 +01:00
|
|
|
if (!project)
|
|
|
|
|
return QString();
|
2018-11-08 10:35:23 +01:00
|
|
|
|
2019-03-05 13:12:44 +01:00
|
|
|
return QString::fromUtf8(QCryptographicHash::hash(project->projectFilePath().toString().toUtf8(),
|
|
|
|
|
QCryptographicHash::Md5)
|
|
|
|
|
.toHex(0));
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-10 14:29:49 +01:00
|
|
|
bool getProjectUseGlobalSettings(const ProjectExplorer::Project *project)
|
|
|
|
|
{
|
|
|
|
|
const QVariant projectUseGlobalSettings = project ? project->namedSettings(
|
|
|
|
|
Constants::USE_GLOBAL_SETTINGS)
|
|
|
|
|
: QVariant();
|
|
|
|
|
|
|
|
|
|
return projectUseGlobalSettings.isValid() ? projectUseGlobalSettings.toBool() : true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool getProjectOverriddenSettings(const ProjectExplorer::Project *project)
|
|
|
|
|
{
|
|
|
|
|
const QVariant projectOverride = project ? project->namedSettings(Constants::OVERRIDE_FILE_ID)
|
|
|
|
|
: QVariant();
|
|
|
|
|
|
|
|
|
|
return projectOverride.isValid()
|
|
|
|
|
? projectOverride.toBool()
|
|
|
|
|
: ClangFormatSettings::instance().overrideDefaultFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool getCurrentOverriddenSettings(const Utils::FilePath &filePath)
|
|
|
|
|
{
|
2023-02-14 15:47:22 +01:00
|
|
|
const ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::projectForFile(
|
2023-01-10 14:29:49 +01:00
|
|
|
filePath);
|
|
|
|
|
|
2023-05-08 11:00:04 +02:00
|
|
|
return getProjectUseGlobalSettings(project)
|
|
|
|
|
? !TextEditor::TextEditorSettings::codeStyle("Cpp")
|
|
|
|
|
->currentPreferences()
|
|
|
|
|
->isTemporarilyReadOnly()
|
|
|
|
|
&& !TextEditor::TextEditorSettings::codeStyle("Cpp")
|
|
|
|
|
->currentPreferences()
|
|
|
|
|
->isAdditionalTabDisabled()
|
|
|
|
|
: getProjectOverriddenSettings(project);
|
2023-01-10 14:29:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClangFormatSettings::Mode getProjectIndentationOrFormattingSettings(
|
|
|
|
|
const ProjectExplorer::Project *project)
|
|
|
|
|
{
|
|
|
|
|
const QVariant projectIndentationOrFormatting = project
|
|
|
|
|
? project->namedSettings(Constants::MODE_ID)
|
|
|
|
|
: QVariant();
|
|
|
|
|
|
|
|
|
|
return projectIndentationOrFormatting.isValid()
|
|
|
|
|
? static_cast<ClangFormatSettings::Mode>(projectIndentationOrFormatting.toInt())
|
|
|
|
|
: ClangFormatSettings::instance().mode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClangFormatSettings::Mode getCurrentIndentationOrFormattingSettings(const Utils::FilePath &filePath)
|
|
|
|
|
{
|
2023-02-14 15:47:22 +01:00
|
|
|
const ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::projectForFile(
|
2023-01-10 14:29:49 +01:00
|
|
|
filePath);
|
|
|
|
|
|
|
|
|
|
return getProjectUseGlobalSettings(project)
|
|
|
|
|
? ClangFormatSettings::instance().mode()
|
|
|
|
|
: getProjectIndentationOrFormattingSettings(project);
|
2018-11-08 10:35:23 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-16 12:40:41 +01:00
|
|
|
Utils::FilePath findConfig(const Utils::FilePath &fileName)
|
2018-11-08 10:35:23 +01:00
|
|
|
{
|
2023-01-16 12:40:41 +01:00
|
|
|
Utils::FilePath parentDirectory = fileName.parentDir();
|
|
|
|
|
while (parentDirectory.exists()) {
|
|
|
|
|
Utils::FilePath settingsFilePath = parentDirectory / Constants::SETTINGS_FILE_NAME;
|
|
|
|
|
if (settingsFilePath.exists())
|
|
|
|
|
return settingsFilePath;
|
2018-11-08 10:35:23 +01:00
|
|
|
|
2023-01-16 12:40:41 +01:00
|
|
|
Utils::FilePath settingsAltFilePath = parentDirectory / Constants::SETTINGS_FILE_ALT_NAME;
|
|
|
|
|
if (settingsAltFilePath.exists())
|
|
|
|
|
return settingsAltFilePath;
|
2019-02-21 13:45:18 +01:00
|
|
|
|
2023-01-16 12:40:41 +01:00
|
|
|
parentDirectory = parentDirectory.parentDir();
|
2019-03-05 17:14:42 +01:00
|
|
|
}
|
2023-01-16 12:40:41 +01:00
|
|
|
return Utils::FilePath();
|
2019-03-05 17:14:42 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-16 12:40:41 +01:00
|
|
|
Utils::FilePath configForFile(const Utils::FilePath &fileName)
|
2019-03-05 13:12:44 +01:00
|
|
|
{
|
2023-01-16 12:40:41 +01:00
|
|
|
if (!getCurrentOverriddenSettings(fileName))
|
|
|
|
|
return findConfig(fileName);
|
2019-03-05 13:12:44 +01:00
|
|
|
|
2023-01-16 12:40:41 +01:00
|
|
|
const ProjectExplorer::Project *projectForFile
|
2023-02-14 15:47:22 +01:00
|
|
|
= ProjectExplorer::ProjectManager::projectForFile(fileName);
|
2019-03-05 13:12:44 +01:00
|
|
|
|
2023-01-16 12:40:41 +01:00
|
|
|
const TextEditor::ICodeStylePreferences *preferences
|
|
|
|
|
= projectForFile
|
|
|
|
|
? projectForFile->editorConfiguration()->codeStyle("Cpp")->currentPreferences()
|
|
|
|
|
: TextEditor::TextEditorSettings::codeStyle("Cpp")->currentPreferences();
|
2018-11-08 10:35:23 +01:00
|
|
|
|
2023-01-16 12:40:41 +01:00
|
|
|
return filePathToCurrentSettings(preferences);
|
2019-03-07 11:35:57 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-11 13:18:29 +01:00
|
|
|
void addQtcStatementMacros(clang::format::FormatStyle &style)
|
|
|
|
|
{
|
2023-04-25 16:04:30 +02:00
|
|
|
static const std::vector<std::string> macros = {"Q_CLASSINFO",
|
|
|
|
|
"Q_ENUM",
|
|
|
|
|
"Q_ENUM_NS",
|
|
|
|
|
"Q_FLAG",
|
|
|
|
|
"Q_FLAG_NS",
|
|
|
|
|
"Q_GADGET",
|
|
|
|
|
"Q_GADGET_EXPORT",
|
|
|
|
|
"Q_INTERFACES",
|
|
|
|
|
"Q_MOC_INCLUDE",
|
|
|
|
|
"Q_NAMESPACE",
|
|
|
|
|
"Q_NAMESPACE_EXPORT",
|
|
|
|
|
"Q_OBJECT",
|
|
|
|
|
"Q_PROPERTY",
|
|
|
|
|
"Q_REVISION",
|
|
|
|
|
"Q_DISABLE_COPY",
|
|
|
|
|
"Q_SET_OBJECT_NAME",
|
2022-01-11 13:18:29 +01:00
|
|
|
"QT_BEGIN_NAMESPACE",
|
2023-04-25 16:04:30 +02:00
|
|
|
"QT_END_NAMESPACE",
|
|
|
|
|
|
|
|
|
|
"QML_ADDED_IN_MINOR_VERSION",
|
|
|
|
|
"QML_ANONYMOUS",
|
|
|
|
|
"QML_ATTACHED",
|
|
|
|
|
"QML_DECLARE_TYPE",
|
|
|
|
|
"QML_DECLARE_TYPEINFO",
|
|
|
|
|
"QML_ELEMENT",
|
|
|
|
|
"QML_EXTENDED",
|
|
|
|
|
"QML_EXTENDED_NAMESPACE",
|
|
|
|
|
"QML_EXTRA_VERSION",
|
|
|
|
|
"QML_FOREIGN",
|
|
|
|
|
"QML_FOREIGN_NAMESPACE",
|
|
|
|
|
"QML_IMPLEMENTS_INTERFACES",
|
|
|
|
|
"QML_INTERFACE",
|
|
|
|
|
"QML_NAMED_ELEMENT",
|
|
|
|
|
"QML_REMOVED_IN_MINOR_VERSION",
|
|
|
|
|
"QML_SINGLETON",
|
|
|
|
|
"QML_UNAVAILABLE",
|
|
|
|
|
"QML_UNCREATABLE",
|
|
|
|
|
"QML_VALUE_TYPE"};
|
2022-01-11 13:18:29 +01:00
|
|
|
for (const std::string ¯o : macros) {
|
|
|
|
|
if (std::find(style.StatementMacros.begin(), style.StatementMacros.end(), macro)
|
|
|
|
|
== style.StatementMacros.end())
|
|
|
|
|
style.StatementMacros.emplace_back(macro);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-08 15:12:30 +02:00
|
|
|
Utils::FilePath filePathToCurrentSettings(const TextEditor::ICodeStylePreferences *codeStyle)
|
|
|
|
|
{
|
|
|
|
|
return Core::ICore::userResourcePath() / "clang-format/"
|
|
|
|
|
/ Utils::FileUtils::fileSystemFriendlyName(codeStyle->displayName())
|
|
|
|
|
/ QLatin1String(Constants::SETTINGS_FILE_NAME);
|
|
|
|
|
}
|
2019-03-07 13:45:22 +01:00
|
|
|
} // namespace ClangFormat
|