ClangFormat: Move the functions from clangformatutils

- Moved the functions from clangformatutils to the places where
it is belong

Change-Id: Ia4108c5b096610170e0f9d16d15d40d5538ffbdc
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Artem Sokolovskii
2023-01-16 12:33:43 +01:00
parent 32d71c6da7
commit 42c3e88f95
6 changed files with 118 additions and 98 deletions

View File

@@ -118,6 +118,18 @@ void ClangFormatFile::saveNewFormat(QByteArray style)
m_filePath.writeFileContents(style);
}
void ClangFormatFile::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);
styleStr.append("\n");
filePath.writeFileContents(QByteArray::fromStdString(styleStr));
}
CppEditor::CppCodeStyleSettings ClangFormatFile::toCppCodeStyleSettings(
ProjectExplorer::Project *project) const
{