diff --git a/src/plugins/clangformat/clangformatindenter.cpp b/src/plugins/clangformat/clangformatindenter.cpp index cf41925eeed..95d847150f0 100644 --- a/src/plugins/clangformat/clangformatindenter.cpp +++ b/src/plugins/clangformat/clangformatindenter.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -122,7 +123,7 @@ bool ClangFormatIndenter::formatWhileTyping() const ClangFormatForwardingIndenter::ClangFormatForwardingIndenter(QTextDocument *doc) : TextEditor::Indenter(doc) , m_clangFormatIndenter(std::make_unique(doc)) - , m_cppIndenter(CppEditor::CppCodeStylePreferencesFactory().createIndenter(doc)) + , m_cppIndenter(CppEditor::createCppQtStyleIndenter(doc)) {} ClangFormatForwardingIndenter::~ClangFormatForwardingIndenter() = default; diff --git a/src/plugins/cppeditor/cppcodestylepreferencesfactory.cpp b/src/plugins/cppeditor/cppcodestylepreferencesfactory.cpp index 26255bb74e9..f712b9b48cb 100644 --- a/src/plugins/cppeditor/cppcodestylepreferencesfactory.cpp +++ b/src/plugins/cppeditor/cppcodestylepreferencesfactory.cpp @@ -97,7 +97,7 @@ TextEditor::CodeStyleEditorWidget *CppCodeStylePreferencesFactory::createEditor( TextEditor::Indenter *CppCodeStylePreferencesFactory::createIndenter(QTextDocument *doc) const { - return new Internal::CppQtStyleIndenter(doc); + return createCppQtStyleIndenter(doc); } QString CppCodeStylePreferencesFactory::snippetProviderGroupId() const diff --git a/src/plugins/cppeditor/cppcodestylepreferencesfactory.h b/src/plugins/cppeditor/cppcodestylepreferencesfactory.h index 697518e4fac..4120bb8dad2 100644 --- a/src/plugins/cppeditor/cppcodestylepreferencesfactory.h +++ b/src/plugins/cppeditor/cppcodestylepreferencesfactory.h @@ -8,6 +8,7 @@ #include namespace CppEditor { + class CppCodeStyleWidget; class CPPEDITOR_EXPORT CppCodeStylePreferencesFactory : public TextEditor::ICodeStylePreferencesFactory diff --git a/src/plugins/cppeditor/cppqtstyleindenter.cpp b/src/plugins/cppeditor/cppqtstyleindenter.cpp index b7bdfb69b55..e312960b9ee 100644 --- a/src/plugins/cppeditor/cppqtstyleindenter.cpp +++ b/src/plugins/cppeditor/cppqtstyleindenter.cpp @@ -12,7 +12,8 @@ #include #include -namespace CppEditor::Internal { +namespace CppEditor { +namespace Internal { CppQtStyleIndenter::CppQtStyleIndenter(QTextDocument *doc) : TextEditor::TextIndenter(doc) @@ -189,4 +190,11 @@ TextEditor::IndentationForBlock CppQtStyleIndenter::indentationForBlocks( return ret; } -} // namespace CppEditor::Internal +} // namespace Internal + +TextEditor::Indenter *createCppQtStyleIndenter(QTextDocument *doc) +{ + return new Internal::CppQtStyleIndenter(doc); +} + +} // namespace CppEditor diff --git a/src/plugins/cppeditor/cppqtstyleindenter.h b/src/plugins/cppeditor/cppqtstyleindenter.h index df463bce7b1..f30d774cc43 100644 --- a/src/plugins/cppeditor/cppqtstyleindenter.h +++ b/src/plugins/cppeditor/cppqtstyleindenter.h @@ -3,6 +3,8 @@ #pragma once +#include "cppeditor_global.h" + #include namespace TextEditor { class ICodeStylePreferences; } @@ -46,4 +48,7 @@ private: }; } // namespace Internal + +CPPEDITOR_EXPORT TextEditor::Indenter *createCppQtStyleIndenter(QTextDocument *doc); + } // namespace CppEditor diff --git a/src/plugins/cppeditor/cpptoolsreuse.cpp b/src/plugins/cppeditor/cpptoolsreuse.cpp index 3c9f6eeec33..c8ce0effeac 100644 --- a/src/plugins/cppeditor/cpptoolsreuse.cpp +++ b/src/plugins/cppeditor/cpptoolsreuse.cpp @@ -855,8 +855,7 @@ namespace Internal { void decorateCppEditor(TextEditor::TextEditorWidget *editor) { editor->textDocument()->resetSyntaxHighlighter([] { return new CppHighlighter(); }); - editor->textDocument()->setIndenter( - new CppQtStyleIndenter(editor->textDocument()->document())); + editor->textDocument()->setIndenter(createCppQtStyleIndenter(editor->textDocument()->document())); editor->setAutoCompleter(new CppAutoCompleter); }