forked from qt-creator/qt-creator
ClangFormat: Refactor indenter to allow ClangFormat unit-tests
We do not build texteditor files in unit-tests so some tricks were required to make ClangFormatIndenter available. First simple unit-test proofs it builds and runs. Change-Id: I81d5ea099bd27fd1c1ed8b5b7877299dcc62a67f Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -31,7 +31,9 @@
|
||||
using namespace Android;
|
||||
using namespace Android::Internal;
|
||||
|
||||
JavaIndenter::JavaIndenter() = default;
|
||||
JavaIndenter::JavaIndenter(QTextDocument *doc)
|
||||
: TextEditor::TextIndenter(doc)
|
||||
{}
|
||||
|
||||
JavaIndenter::~JavaIndenter() = default;
|
||||
|
||||
@@ -44,20 +46,17 @@ bool JavaIndenter::isElectricCharacter(const QChar &ch) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void JavaIndenter::indentBlock(QTextDocument *doc,
|
||||
const QTextBlock &block,
|
||||
void JavaIndenter::indentBlock(const QTextBlock &block,
|
||||
const QChar &typedChar,
|
||||
const TextEditor::TabSettings &tabSettings)
|
||||
{
|
||||
Q_UNUSED(doc);
|
||||
int indent = indentFor(block, tabSettings);
|
||||
if (typedChar == QLatin1Char('}'))
|
||||
indent -= tabSettings.m_indentSize;
|
||||
tabSettings.indentLine(block, qMax(0, indent));
|
||||
}
|
||||
|
||||
int JavaIndenter::indentFor(const QTextBlock &block,
|
||||
const TextEditor::TabSettings &tabSettings)
|
||||
int JavaIndenter::indentFor(const QTextBlock &block, const TextEditor::TabSettings &tabSettings)
|
||||
{
|
||||
QTextBlock previous = block.previous();
|
||||
if (!previous.isValid())
|
||||
|
||||
Reference in New Issue
Block a user