diff --git a/src/plugins/android/javaeditor.cpp b/src/plugins/android/javaeditor.cpp index b0b844c1563..27ced1b025a 100644 --- a/src/plugins/android/javaeditor.cpp +++ b/src/plugins/android/javaeditor.cpp @@ -24,7 +24,7 @@ static TextEditor::TextDocument *createJavaDocument() auto doc = new TextEditor::TextDocument; doc->setId(Constants::JAVA_EDITOR_ID); doc->setMimeType(Utils::Constants::JAVA_MIMETYPE); - doc->setIndenter(new JavaIndenter(doc->document())); + doc->setIndenter(createJavaIndenter(doc->document())); return doc; } diff --git a/src/plugins/android/javaindenter.cpp b/src/plugins/android/javaindenter.cpp index 036834f8e5c..ca131f584a3 100644 --- a/src/plugins/android/javaindenter.cpp +++ b/src/plugins/android/javaindenter.cpp @@ -2,27 +2,34 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "javaindenter.h" + #include #include -using namespace Android; -using namespace Android::Internal; +namespace Android::Internal { -JavaIndenter::JavaIndenter(QTextDocument *doc) - : TextEditor::TextIndenter(doc) -{} - -JavaIndenter::~JavaIndenter() = default; - -bool JavaIndenter::isElectricCharacter(const QChar &ch) const +class JavaIndenter final : public TextEditor::TextIndenter { - if (ch == QLatin1Char('{') - || ch == QLatin1Char('}')) { - return true; +public: + explicit JavaIndenter(QTextDocument *doc) + : TextEditor::TextIndenter(doc) + {} + + bool isElectricCharacter(const QChar &ch) const final + { + return ch == QLatin1Char('{') || ch == QLatin1Char('}'); } - return false; -} + + void indentBlock(const QTextBlock &block, + const QChar &typedChar, + const TextEditor::TabSettings &tabSettings, + int cursorPositionInEditor = -1) final; + + int indentFor(const QTextBlock &block, + const TextEditor::TabSettings &tabSettings, + int cursorPositionInEditor = -1) final; +}; void JavaIndenter::indentBlock(const QTextBlock &block, const QChar &typedChar, @@ -58,3 +65,10 @@ int JavaIndenter::indentFor(const QTextBlock &block, return qMax(0, indent + adjust); } + +TextEditor::TextIndenter *createJavaIndenter(QTextDocument *doc) +{ + return new JavaIndenter(doc); +} + +} // Android::Internal diff --git a/src/plugins/android/javaindenter.h b/src/plugins/android/javaindenter.h index 46aaf882373..f57da987e9c 100644 --- a/src/plugins/android/javaindenter.h +++ b/src/plugins/android/javaindenter.h @@ -5,24 +5,8 @@ #include -namespace Android { -namespace Internal { -class JavaIndenter : public TextEditor::TextIndenter -{ -public: - explicit JavaIndenter(QTextDocument *doc); - ~JavaIndenter() override; +namespace Android::Internal { - bool isElectricCharacter(const QChar &ch) const override; +TextEditor::TextIndenter *createJavaIndenter(QTextDocument *doc); - void indentBlock(const QTextBlock &block, - const QChar &typedChar, - const TextEditor::TabSettings &tabSettings, - int cursorPositionInEditor = -1) override; - - int indentFor(const QTextBlock &block, - const TextEditor::TabSettings &tabSettings, - int cursorPositionInEditor = -1) override; -}; -} // namespace Internal -} // namespace Android +} // Android::Internal