forked from qt-creator/qt-creator
CppTools: Allow to check whether project code style exists
The calling code can anyways fallback to the global style without extra help if no project style exists. It is useful when you want to get the project style if it exists and understand at the same time that it is not a global one. Change-Id: I265de3f436f90623385427fc8a1abad09c8c3577 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -118,7 +118,8 @@ static clang::format::FormatStyle constructStyle(bool isGlobal)
|
||||
FormatStyle style = getLLVMStyle();
|
||||
const CppCodeStyleSettings codeStyleSettings = isGlobal
|
||||
? CppCodeStyleSettings::currentGlobalCodeStyle()
|
||||
: CppCodeStyleSettings::currentProjectCodeStyle();
|
||||
: CppCodeStyleSettings::currentProjectCodeStyle()
|
||||
.value_or(CppCodeStyleSettings::currentGlobalCodeStyle());
|
||||
const TabSettings tabSettings = isGlobal
|
||||
? CppCodeStyleSettings::currentGlobalTabSettings()
|
||||
: CppCodeStyleSettings::currentProjectTabSettings();
|
||||
@@ -171,8 +172,7 @@ clang::format::FormatStyle currentGlobalStyle()
|
||||
|
||||
clang::format::FormatStyle currentStyle()
|
||||
{
|
||||
const bool isGlobal = (CppCodeStyleSettings::currentProjectCodeStyle()
|
||||
== CppCodeStyleSettings::currentGlobalCodeStyle());
|
||||
const bool isGlobal = !CppCodeStyleSettings::currentProjectCodeStyle().has_value();
|
||||
return currentStyle(isGlobal);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user