CppTools: Simplify the currentProjectCodeStyle code

Use alias to shorten the repeating default return value.

Change-Id: I673fc1d293c1612c945c80d554c6667a756108de
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Ivan Donchevskii
2018-11-12 09:58:35 +01:00
parent cf816448ce
commit 36f4ed54df

View File

@@ -203,20 +203,21 @@ bool CppCodeStyleSettings::equals(const CppCodeStyleSettings &rhs) const
Utils::optional<CppCodeStyleSettings> CppCodeStyleSettings::currentProjectCodeStyle() Utils::optional<CppCodeStyleSettings> CppCodeStyleSettings::currentProjectCodeStyle()
{ {
ProjectExplorer::Project *project = ProjectExplorer::ProjectTree::currentProject(); ProjectExplorer::Project *project = ProjectExplorer::ProjectTree::currentProject();
using OptSettings = Utils::optional<CppCodeStyleSettings>;
if (!project) if (!project)
return Utils::optional<CppCodeStyleSettings>(); return OptSettings();
ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration(); ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration();
QTC_ASSERT(editorConfiguration, return Utils::optional<CppCodeStyleSettings>()); QTC_ASSERT(editorConfiguration, return OptSettings());
TextEditor::ICodeStylePreferences *codeStylePreferences TextEditor::ICodeStylePreferences *codeStylePreferences
= editorConfiguration->codeStyle(Constants::CPP_SETTINGS_ID); = editorConfiguration->codeStyle(Constants::CPP_SETTINGS_ID);
QTC_ASSERT(codeStylePreferences, return Utils::optional<CppCodeStyleSettings>()); QTC_ASSERT(codeStylePreferences, return OptSettings());
CppCodeStylePreferences *cppCodeStylePreferences CppCodeStylePreferences *cppCodeStylePreferences
= dynamic_cast<CppCodeStylePreferences *>(codeStylePreferences); = dynamic_cast<CppCodeStylePreferences *>(codeStylePreferences);
if (!cppCodeStylePreferences) if (!cppCodeStylePreferences)
return Utils::optional<CppCodeStyleSettings>(); return OptSettings();
return cppCodeStylePreferences->currentCodeStyleSettings(); return cppCodeStylePreferences->currentCodeStyleSettings();
} }