forked from qt-creator/qt-creator
Android: Move JavaIndenter class definition to .cpp
Change-Id: I0634062c22abfe592afb1be62616eaf05882519d Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -24,7 +24,7 @@ static TextEditor::TextDocument *createJavaDocument()
|
|||||||
auto doc = new TextEditor::TextDocument;
|
auto doc = new TextEditor::TextDocument;
|
||||||
doc->setId(Constants::JAVA_EDITOR_ID);
|
doc->setId(Constants::JAVA_EDITOR_ID);
|
||||||
doc->setMimeType(Utils::Constants::JAVA_MIMETYPE);
|
doc->setMimeType(Utils::Constants::JAVA_MIMETYPE);
|
||||||
doc->setIndenter(new JavaIndenter(doc->document()));
|
doc->setIndenter(createJavaIndenter(doc->document()));
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,27 +2,34 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "javaindenter.h"
|
#include "javaindenter.h"
|
||||||
|
|
||||||
#include <texteditor/tabsettings.h>
|
#include <texteditor/tabsettings.h>
|
||||||
|
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
|
|
||||||
using namespace Android;
|
namespace Android::Internal {
|
||||||
using namespace Android::Internal;
|
|
||||||
|
|
||||||
JavaIndenter::JavaIndenter(QTextDocument *doc)
|
class JavaIndenter final : public TextEditor::TextIndenter
|
||||||
: TextEditor::TextIndenter(doc)
|
|
||||||
{}
|
|
||||||
|
|
||||||
JavaIndenter::~JavaIndenter() = default;
|
|
||||||
|
|
||||||
bool JavaIndenter::isElectricCharacter(const QChar &ch) const
|
|
||||||
{
|
{
|
||||||
if (ch == QLatin1Char('{')
|
public:
|
||||||
|| ch == QLatin1Char('}')) {
|
explicit JavaIndenter(QTextDocument *doc)
|
||||||
return true;
|
: 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,
|
void JavaIndenter::indentBlock(const QTextBlock &block,
|
||||||
const QChar &typedChar,
|
const QChar &typedChar,
|
||||||
@@ -58,3 +65,10 @@ int JavaIndenter::indentFor(const QTextBlock &block,
|
|||||||
|
|
||||||
return qMax(0, indent + adjust);
|
return qMax(0, indent + adjust);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextEditor::TextIndenter *createJavaIndenter(QTextDocument *doc)
|
||||||
|
{
|
||||||
|
return new JavaIndenter(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Android::Internal
|
||||||
|
@@ -5,24 +5,8 @@
|
|||||||
|
|
||||||
#include <texteditor/textindenter.h>
|
#include <texteditor/textindenter.h>
|
||||||
|
|
||||||
namespace Android {
|
namespace Android::Internal {
|
||||||
namespace Internal {
|
|
||||||
class JavaIndenter : public TextEditor::TextIndenter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit JavaIndenter(QTextDocument *doc);
|
|
||||||
~JavaIndenter() override;
|
|
||||||
|
|
||||||
bool isElectricCharacter(const QChar &ch) const override;
|
TextEditor::TextIndenter *createJavaIndenter(QTextDocument *doc);
|
||||||
|
|
||||||
void indentBlock(const QTextBlock &block,
|
} // Android::Internal
|
||||||
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
|
|
||||||
|
Reference in New Issue
Block a user