forked from qt-creator/qt-creator
ClangFormat: Start to use new file management
- Indenter uses .clang-format file from a dir of editing file or from a parent dir. If there is no such file then indenter starts to use file from a dir with the name current CodeStyle settings. - Test fixed ToDo: Add file absentness processing in case of import Change-Id: If09ef0c598899856b948c214e524bcfd5dad76e2 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -30,7 +30,9 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <cppeditor/cppcodestylesettings.h>
|
||||
#include <texteditor/icodestylepreferences.h>
|
||||
#include <texteditor/tabsettings.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -208,6 +210,7 @@ void saveStyleToFile(clang::format::FormatStyle style, Utils::FilePath filePath)
|
||||
const int pos = styleStr.find("# BasedOnStyle");
|
||||
if (pos != int(std::string::npos))
|
||||
styleStr.erase(pos, 2);
|
||||
styleStr.append("\n");
|
||||
filePath.writeFileContents(QByteArray::fromStdString(styleStr));
|
||||
}
|
||||
|
||||
@@ -382,6 +385,13 @@ void addQtcStatementMacros(clang::format::FormatStyle &style)
|
||||
}
|
||||
}
|
||||
|
||||
Utils::FilePath filePathToCurrentSettings(const TextEditor::ICodeStylePreferences *codeStyle)
|
||||
{
|
||||
return Core::ICore::userResourcePath() / "clang-format/"
|
||||
/ Utils::FileUtils::fileSystemFriendlyName(codeStyle->displayName())
|
||||
/ QLatin1String(Constants::SETTINGS_FILE_NAME);
|
||||
}
|
||||
|
||||
std::string readFile(const QString &path)
|
||||
{
|
||||
const std::string defaultStyle = clang::format::configurationAsText(qtcStyle());
|
||||
|
||||
Reference in New Issue
Block a user