ClangFormat: Add the logical settings management

Now there are changeable and unchangeable settings,
as it works for usual codestyle settings.
They save parallel with codestyle settings but in another dir.
In general, the behavior became similar to usual codestyle settings.

ToDo: Make indenter use this settings instead standard one and
instead project settings when "override" checkbox is checked.

Change-Id: I639dbda296932bf9b967a11f1cc4fda120415ed9
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Artem Sokolovskii
2022-04-04 14:53:05 +02:00
parent ca7a18568c
commit 7574ec3e21
10 changed files with 67 additions and 29 deletions

View File

@@ -200,6 +200,17 @@ QString currentProjectUniqueId()
.toHex(0));
}
void saveStyleToFile(clang::format::FormatStyle style, Utils::FilePath filePath)
{
std::string styleStr = clang::format::configurationAsText(style);
// workaround: configurationAsText() add comment "# " before BasedOnStyle line
const int pos = styleStr.find("# BasedOnStyle");
if (pos != int(std::string::npos))
styleStr.erase(pos, 2);
filePath.writeFileContents(QByteArray::fromStdString(styleStr));
}
static bool useProjectOverriddenSettings()
{
const Project *project = SessionManager::startupProject();
@@ -371,7 +382,7 @@ void addQtcStatementMacros(clang::format::FormatStyle &style)
}
}
static std::string readFile(const QString &path)
std::string readFile(const QString &path)
{
const std::string defaultStyle = clang::format::configurationAsText(qtcStyle());