ClangFormat: Add parseConfigurationFile utility function

Change-Id: I7824e6bb77e9976aa212cdef478c4d40c4d8c56c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Artem Sokolovskii
2024-01-08 16:00:54 +01:00
parent 910126867d
commit 2d96d1a39f
5 changed files with 23 additions and 27 deletions

View File

@@ -792,13 +792,8 @@ clang::format::FormatStyle ClangFormatBaseIndenter::customSettingsStyle(
return currentQtStyle(preferences);
clang::format::FormatStyle currentSettingsStyle;
currentSettingsStyle.Language = clang::format::FormatStyle::LK_Cpp;
const std::error_code error = clang::format::parseConfiguration(filePath.fileContents()
.value_or(QByteArray())
.toStdString(),
&currentSettingsStyle);
QTC_ASSERT(error.value() == static_cast<int>(clang::format::ParseError::Success),
return currentQtStyle(preferences));
bool success = parseConfigurationFile(filePath, currentSettingsStyle);
QTC_ASSERT(success, return currentQtStyle(preferences));
return currentSettingsStyle;
}