forked from qt-creator/qt-creator
indenter.cpp: code cosmetics, re-indent code
This commit is contained in:
@@ -134,7 +134,7 @@ void Indenter::setIndentSize(int size)
|
|||||||
ppContinuationIndentSize = 2 * size;
|
ppContinuationIndentSize = 2 * size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Indenter::setTabSize(int size )
|
void Indenter::setTabSize(int size)
|
||||||
{
|
{
|
||||||
ppHardwareTabSize = size;
|
ppHardwareTabSize = size;
|
||||||
}
|
}
|
||||||
@@ -153,11 +153,11 @@ void Indenter::setDoubleIndentBlocks(bool indent)
|
|||||||
Returns the first non-space character in the string t, or
|
Returns the first non-space character in the string t, or
|
||||||
QChar::null if the string is made only of white space.
|
QChar::null if the string is made only of white space.
|
||||||
*/
|
*/
|
||||||
QChar Indenter::firstNonWhiteSpace( const QString& t )
|
QChar Indenter::firstNonWhiteSpace(const QString &t)
|
||||||
{
|
{
|
||||||
if (const int len = t.length())
|
if (const int len = t.length())
|
||||||
for ( int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
if ( !t[i].isSpace() )
|
if (!t[i].isSpace())
|
||||||
return t[i];
|
return t[i];
|
||||||
return QChar::Null;
|
return QChar::Null;
|
||||||
}
|
}
|
||||||
@@ -166,9 +166,9 @@ QChar Indenter::firstNonWhiteSpace( const QString& t )
|
|||||||
Returns true if string t is made only of white space; otherwise
|
Returns true if string t is made only of white space; otherwise
|
||||||
returns false.
|
returns false.
|
||||||
*/
|
*/
|
||||||
bool Indenter::isOnlyWhiteSpace( const QString& t )
|
bool Indenter::isOnlyWhiteSpace(const QString &t)
|
||||||
{
|
{
|
||||||
return t.isEmpty() || firstNonWhiteSpace( t ).isNull();
|
return t.isEmpty() || firstNonWhiteSpace(t).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -176,17 +176,17 @@ bool Indenter::isOnlyWhiteSpace( const QString& t )
|
|||||||
index. Column numbers and index are identical for strings that don't
|
index. Column numbers and index are identical for strings that don't
|
||||||
contain '\t's.
|
contain '\t's.
|
||||||
*/
|
*/
|
||||||
int Indenter::columnForIndex( const QString& t, int index ) const
|
int Indenter::columnForIndex(const QString &t, int index) const
|
||||||
{
|
{
|
||||||
int col = 0;
|
int col = 0;
|
||||||
if ( index > t.length() )
|
if (index > t.length())
|
||||||
index = t.length();
|
index = t.length();
|
||||||
|
|
||||||
const QChar tab = QLatin1Char('\t');
|
const QChar tab = QLatin1Char('\t');
|
||||||
|
|
||||||
for ( int i = 0; i < index; i++ ) {
|
for (int i = 0; i < index; i++) {
|
||||||
if ( t[i] == tab ) {
|
if (t[i] == tab) {
|
||||||
col = ( (col / ppHardwareTabSize) + 1 ) * ppHardwareTabSize;
|
col = ((col / ppHardwareTabSize) + 1) * ppHardwareTabSize;
|
||||||
} else {
|
} else {
|
||||||
col++;
|
col++;
|
||||||
}
|
}
|
||||||
@@ -197,9 +197,9 @@ int Indenter::columnForIndex( const QString& t, int index ) const
|
|||||||
/*
|
/*
|
||||||
Returns the indentation size of string t.
|
Returns the indentation size of string t.
|
||||||
*/
|
*/
|
||||||
int Indenter::indentOfLine( const QString& t ) const
|
int Indenter::indentOfLine(const QString &t) const
|
||||||
{
|
{
|
||||||
return columnForIndex( t, t.indexOf(firstNonWhiteSpace(t)) );
|
return columnForIndex(t, t.indexOf(firstNonWhiteSpace(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -208,9 +208,9 @@ int Indenter::indentOfLine( const QString& t ) const
|
|||||||
provisions are taken against '\n' or '\r', which shouldn't occur in
|
provisions are taken against '\n' or '\r', which shouldn't occur in
|
||||||
t anyway.
|
t anyway.
|
||||||
*/
|
*/
|
||||||
static inline void eraseChar( QString& t, int k, QChar ch )
|
static inline void eraseChar(QString &t, int k, QChar ch)
|
||||||
{
|
{
|
||||||
if ( t[k] != QLatin1Char('\t') )
|
if (t[k] != QLatin1Char('\t'))
|
||||||
t[k] = ch;
|
t[k] = ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ static inline void eraseChar( QString& t, int k, QChar ch )
|
|||||||
Removes some nefast constructs from a code line and returns the
|
Removes some nefast constructs from a code line and returns the
|
||||||
resulting line.
|
resulting line.
|
||||||
*/
|
*/
|
||||||
QString Indenter::trimmedCodeLine( const QString& t )
|
QString Indenter::trimmedCodeLine(const QString &t)
|
||||||
{
|
{
|
||||||
QString trimmed = t;
|
QString trimmed = t;
|
||||||
int k;
|
int k;
|
||||||
@@ -235,10 +235,10 @@ QString Indenter::trimmedCodeLine( const QString& t )
|
|||||||
continuation lines.
|
continuation lines.
|
||||||
*/
|
*/
|
||||||
k = 0;
|
k = 0;
|
||||||
while ( (k = m_constants.m_literal.indexIn(trimmed), k) != -1 ) {
|
while ((k = m_constants.m_literal.indexIn(trimmed), k) != -1) {
|
||||||
const int matchedLength = m_constants.m_literal.matchedLength();
|
const int matchedLength = m_constants.m_literal.matchedLength();
|
||||||
for ( int i = 0; i < matchedLength ; i++ )
|
for (int i = 0; i < matchedLength ; i++)
|
||||||
eraseChar( trimmed, k + i, capitalX );
|
eraseChar(trimmed, k + i, capitalX);
|
||||||
k += matchedLength;
|
k += matchedLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,10 +247,10 @@ QString Indenter::trimmedCodeLine( const QString& t )
|
|||||||
handled elsewhere.
|
handled elsewhere.
|
||||||
*/
|
*/
|
||||||
k = 0;
|
k = 0;
|
||||||
while ( (k = m_constants.m_inlineCComment.indexIn(trimmed, k)) != -1 ) {
|
while ((k = m_constants.m_inlineCComment.indexIn(trimmed, k)) != -1) {
|
||||||
const int matchedLength = m_constants.m_inlineCComment.matchedLength();
|
const int matchedLength = m_constants.m_inlineCComment.matchedLength();
|
||||||
for ( int i = 0; i < matchedLength; i++ )
|
for (int i = 0; i < matchedLength; i++)
|
||||||
eraseChar( trimmed, k + i, blank );
|
eraseChar(trimmed, k + i, blank);
|
||||||
k += matchedLength;
|
k += matchedLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,21 +261,21 @@ QString Indenter::trimmedCodeLine( const QString& t )
|
|||||||
foo1: bar1;
|
foo1: bar1;
|
||||||
bar2;
|
bar2;
|
||||||
*/
|
*/
|
||||||
while ( trimmed.lastIndexOf(colon ) != -1 && m_constants.m_label.indexIn(trimmed) != -1 ) {
|
while (trimmed.lastIndexOf(colon) != -1 && m_constants.m_label.indexIn(trimmed) != -1) {
|
||||||
const QString cap1 = m_constants.m_label.cap( 1 );
|
const QString cap1 = m_constants.m_label.cap(1);
|
||||||
const int pos1 = m_constants.m_label.pos( 1 );
|
const int pos1 = m_constants.m_label.pos(1);
|
||||||
int stop = cap1.length();
|
int stop = cap1.length();
|
||||||
|
|
||||||
if ( pos1 + stop < trimmed.length() && ppIndentSize < stop )
|
if (pos1 + stop < trimmed.length() && ppIndentSize < stop)
|
||||||
stop = ppIndentSize;
|
stop = ppIndentSize;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while ( i < stop ) {
|
while (i < stop) {
|
||||||
eraseChar( trimmed, pos1 + i, blank );
|
eraseChar(trimmed, pos1 + i, blank );
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
while ( i < cap1.length() ) {
|
while (i < cap1.length()) {
|
||||||
eraseChar( trimmed, pos1 + i,semicolon );
|
eraseChar(trimmed, pos1 + i,semicolon);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,9 +283,9 @@ QString Indenter::trimmedCodeLine( const QString& t )
|
|||||||
/*
|
/*
|
||||||
Remove C++-style comments.
|
Remove C++-style comments.
|
||||||
*/
|
*/
|
||||||
k = trimmed.indexOf(m_constants.m_slashSlash );
|
k = trimmed.indexOf(m_constants.m_slashSlash);
|
||||||
if ( k != -1 )
|
if (k != -1)
|
||||||
trimmed.truncate( k );
|
trimmed.truncate(k);
|
||||||
|
|
||||||
return trimmed;
|
return trimmed;
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ QString Indenter::trimmedCodeLine( const QString& t )
|
|||||||
Returns '(' if the last parenthesis is opening, ')' if it is
|
Returns '(' if the last parenthesis is opening, ')' if it is
|
||||||
closing, and QChar::null if there are no parentheses in t.
|
closing, and QChar::null if there are no parentheses in t.
|
||||||
*/
|
*/
|
||||||
static inline QChar lastParen( const QString& t )
|
static inline QChar lastParen(const QString &t)
|
||||||
{
|
{
|
||||||
|
|
||||||
const QChar opening = QLatin1Char('(');
|
const QChar opening = QLatin1Char('(');
|
||||||
@@ -302,10 +302,10 @@ static inline QChar lastParen( const QString& t )
|
|||||||
|
|
||||||
|
|
||||||
int i = t.length();
|
int i = t.length();
|
||||||
while ( i > 0 ) {
|
while (i > 0) {
|
||||||
i--;
|
i--;
|
||||||
const QChar c = t[i];
|
const QChar c = t[i];
|
||||||
if (c == opening || c == closing )
|
if (c == opening || c == closing)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
return QChar::Null;
|
return QChar::Null;
|
||||||
@@ -315,7 +315,7 @@ static inline QChar lastParen( const QString& t )
|
|||||||
Returns true if typedIn the same as okayCh or is null; otherwise
|
Returns true if typedIn the same as okayCh or is null; otherwise
|
||||||
returns false.
|
returns false.
|
||||||
*/
|
*/
|
||||||
static inline bool okay( QChar typedIn, QChar okayCh )
|
static inline bool okay(QChar typedIn, QChar okayCh)
|
||||||
{
|
{
|
||||||
return typedIn == QChar::Null || typedIn == okayCh;
|
return typedIn == QChar::Null || typedIn == okayCh;
|
||||||
}
|
}
|
||||||
@@ -326,17 +326,17 @@ static inline bool okay( QChar typedIn, QChar okayCh )
|
|||||||
backtracking.
|
backtracking.
|
||||||
*/
|
*/
|
||||||
#define YY_SAVE() \
|
#define YY_SAVE() \
|
||||||
LinizerState savedState = *yyLinizerState
|
LinizerState savedState = *yyLinizerState
|
||||||
#define YY_RESTORE() \
|
#define YY_RESTORE() \
|
||||||
*yyLinizerState = savedState
|
*yyLinizerState = savedState
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Advances to the previous line in yyProgram and update yyLine
|
Advances to the previous line in yyProgram and update yyLine
|
||||||
accordingly. yyLine is cleaned from comments and other damageable
|
accordingly. yyLine is cleaned from comments and other damageable
|
||||||
constructs. Empty lines are skipped.
|
constructs. Empty lines are skipped.
|
||||||
*/
|
*/
|
||||||
bool Indenter::readLine()
|
bool Indenter::readLine()
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
const QChar openingBrace = QLatin1Char('{');
|
const QChar openingBrace = QLatin1Char('{');
|
||||||
@@ -345,10 +345,10 @@ bool Indenter::readLine()
|
|||||||
const QChar hash = QLatin1Char('#');
|
const QChar hash = QLatin1Char('#');
|
||||||
|
|
||||||
yyLinizerState->leftBraceFollows =
|
yyLinizerState->leftBraceFollows =
|
||||||
( firstNonWhiteSpace(yyLinizerState->line) == openingBrace );
|
(firstNonWhiteSpace(yyLinizerState->line) == openingBrace );
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if ( yyLinizerState->iter == yyProgramBegin ) {
|
if (yyLinizerState->iter == yyProgramBegin) {
|
||||||
yyLinizerState->line = QString::null;
|
yyLinizerState->line = QString::null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -356,7 +356,7 @@ bool Indenter::readLine()
|
|||||||
--yyLinizerState->iter;
|
--yyLinizerState->iter;
|
||||||
yyLinizerState->line = *yyLinizerState->iter;
|
yyLinizerState->line = *yyLinizerState->iter;
|
||||||
|
|
||||||
yyLinizerState->line = trimmedCodeLine( yyLinizerState->line );
|
yyLinizerState->line = trimmedCodeLine(yyLinizerState->line);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Remove C-style comments that span multiple lines. If the
|
Remove C-style comments that span multiple lines. If the
|
||||||
@@ -368,22 +368,22 @@ bool Indenter::readLine()
|
|||||||
the first if. The order of the if's is also important.
|
the first if. The order of the if's is also important.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( yyLinizerState->inCComment ) {
|
if (yyLinizerState->inCComment) {
|
||||||
|
|
||||||
k = yyLinizerState->line.indexOf( m_constants.m_slashAster );
|
k = yyLinizerState->line.indexOf(m_constants.m_slashAster);
|
||||||
if ( k == -1 ) {
|
if (k == -1) {
|
||||||
yyLinizerState->line = QString::null;
|
yyLinizerState->line = QString::null;
|
||||||
} else {
|
} else {
|
||||||
yyLinizerState->line.truncate( k );
|
yyLinizerState->line.truncate(k);
|
||||||
yyLinizerState->inCComment = false;
|
yyLinizerState->inCComment = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !yyLinizerState->inCComment ) {
|
if (!yyLinizerState->inCComment) {
|
||||||
k = yyLinizerState->line.indexOf( m_constants.m_asterSlash );
|
k = yyLinizerState->line.indexOf(m_constants.m_asterSlash);
|
||||||
if ( k != -1 ) {
|
if (k != -1) {
|
||||||
for ( int i = 0; i < k + 2; i++ )
|
for (int i = 0; i < k + 2; i++)
|
||||||
eraseChar( yyLinizerState->line, i, blank );
|
eraseChar(yyLinizerState->line, i, blank);
|
||||||
yyLinizerState->inCComment = true;
|
yyLinizerState->inCComment = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -392,11 +392,11 @@ bool Indenter::readLine()
|
|||||||
Remove preprocessor directives.
|
Remove preprocessor directives.
|
||||||
*/
|
*/
|
||||||
k = 0;
|
k = 0;
|
||||||
while ( k < yyLinizerState->line.length() ) {
|
while (k < yyLinizerState->line.length()) {
|
||||||
QChar ch = yyLinizerState->line[k];
|
QChar ch = yyLinizerState->line[k];
|
||||||
if ( ch == hash ) {
|
if (ch == hash) {
|
||||||
yyLinizerState->line = QString::null;
|
yyLinizerState->line = QString::null;
|
||||||
} else if ( !ch.isSpace() ) {
|
} else if (!ch.isSpace()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
k++;
|
k++;
|
||||||
@@ -406,16 +406,16 @@ bool Indenter::readLine()
|
|||||||
Remove trailing spaces.
|
Remove trailing spaces.
|
||||||
*/
|
*/
|
||||||
k = yyLinizerState->line.length();
|
k = yyLinizerState->line.length();
|
||||||
while ( k > 0 && yyLinizerState->line[k - 1].isSpace() )
|
while (k > 0 && yyLinizerState->line[k - 1].isSpace())
|
||||||
k--;
|
k--;
|
||||||
yyLinizerState->line.truncate( k );
|
yyLinizerState->line.truncate(k);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
'}' increment the brace depth and '{' decrements it and not
|
'}' increment the brace depth and '{' decrements it and not
|
||||||
the other way around, as we are parsing backwards.
|
the other way around, as we are parsing backwards.
|
||||||
*/
|
*/
|
||||||
yyLinizerState->braceDepth +=
|
yyLinizerState->braceDepth +=
|
||||||
yyLinizerState->line.count( closingBrace ) - yyLinizerState->line.count( openingBrace );
|
yyLinizerState->line.count(closingBrace ) - yyLinizerState->line.count(openingBrace );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We use a dirty trick for
|
We use a dirty trick for
|
||||||
@@ -428,13 +428,13 @@ bool Indenter::readLine()
|
|||||||
}
|
}
|
||||||
else ...
|
else ...
|
||||||
*/
|
*/
|
||||||
if ( yyLinizerState->pendingRightBrace )
|
if (yyLinizerState->pendingRightBrace)
|
||||||
yyLinizerState->braceDepth++;
|
yyLinizerState->braceDepth++;
|
||||||
yyLinizerState->pendingRightBrace =
|
yyLinizerState->pendingRightBrace =
|
||||||
( m_constants.m_braceX.indexIn(yyLinizerState->line) == 0 );
|
(m_constants.m_braceX.indexIn(yyLinizerState->line) == 0);
|
||||||
if ( yyLinizerState->pendingRightBrace )
|
if (yyLinizerState->pendingRightBrace)
|
||||||
yyLinizerState->braceDepth--;
|
yyLinizerState->braceDepth--;
|
||||||
} while ( yyLinizerState->line.isEmpty() );
|
} while (yyLinizerState->line.isEmpty());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -473,17 +473,17 @@ bool Indenter::bottomLineStartsInCComment()
|
|||||||
Iterator p = yyProgramEnd;
|
Iterator p = yyProgramEnd;
|
||||||
--p; // skip bottom line
|
--p; // skip bottom line
|
||||||
|
|
||||||
for ( int i = 0; i < BigRoof; i++ ) {
|
for (int i = 0; i < BigRoof; i++) {
|
||||||
if ( p == yyProgramBegin )
|
if (p == yyProgramBegin)
|
||||||
return false;
|
return false;
|
||||||
--p;
|
--p;
|
||||||
|
|
||||||
if ( (*p).contains(m_constants.m_slashAster) || (*p).contains(m_constants.m_asterSlash) ) {
|
if ((*p).contains(m_constants.m_slashAster) || (*p).contains(m_constants.m_asterSlash)) {
|
||||||
QString trimmed = trimmedCodeLine( *p );
|
QString trimmed = trimmedCodeLine(*p);
|
||||||
|
|
||||||
if ( trimmed.contains(m_constants.m_slashAster) ) {
|
if (trimmed.contains(m_constants.m_slashAster)) {
|
||||||
return true;
|
return true;
|
||||||
} else if ( trimmed.contains(m_constants.m_asterSlash) ) {
|
} else if (trimmed.contains(m_constants.m_asterSlash)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -501,24 +501,24 @@ bool Indenter::bottomLineStartsInCComment()
|
|||||||
*/
|
*/
|
||||||
int Indenter::indentWhenBottomLineStartsInCComment() const
|
int Indenter::indentWhenBottomLineStartsInCComment() const
|
||||||
{
|
{
|
||||||
int k = yyLine->lastIndexOf(m_constants.m_slashAster );
|
int k = yyLine->lastIndexOf(m_constants.m_slashAster);
|
||||||
if ( k == -1 ) {
|
if (k == -1) {
|
||||||
/*
|
/*
|
||||||
We found a normal text line in a comment. Align the
|
We found a normal text line in a comment. Align the
|
||||||
bottom line with the text on this line.
|
bottom line with the text on this line.
|
||||||
*/
|
*/
|
||||||
return indentOfLine( *yyLine );
|
return indentOfLine(*yyLine);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
The C-style comment starts on this line. If there is
|
The C-style comment starts on this line. If there is
|
||||||
text on the same line, align with it. Otherwise, align
|
text on the same line, align with it. Otherwise, align
|
||||||
with the slash-aster plus a given offset.
|
with the slash-aster plus a given offset.
|
||||||
*/
|
*/
|
||||||
const int indent = columnForIndex( *yyLine, k );
|
const int indent = columnForIndex(*yyLine, k);
|
||||||
k += 2;
|
k += 2;
|
||||||
while ( k < yyLine->length() ) {
|
while (k < yyLine->length()) {
|
||||||
if ( !(*yyLine)[k].isSpace() )
|
if (!(*yyLine)[k].isSpace())
|
||||||
return columnForIndex( *yyLine, k );
|
return columnForIndex(*yyLine, k);
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
return indent + ppCommentOffset;
|
return indent + ppCommentOffset;
|
||||||
@@ -540,7 +540,7 @@ int Indenter::indentWhenBottomLineStartsInCComment() const
|
|||||||
The first line of the following example is a "braceless control
|
The first line of the following example is a "braceless control
|
||||||
statement":
|
statement":
|
||||||
|
|
||||||
if ( x )
|
if (x)
|
||||||
y;
|
y;
|
||||||
*/
|
*/
|
||||||
bool Indenter::matchBracelessControlStatement()
|
bool Indenter::matchBracelessControlStatement()
|
||||||
@@ -550,49 +550,49 @@ bool Indenter::matchBracelessControlStatement()
|
|||||||
const QChar semicolon = QLatin1Char(';');
|
const QChar semicolon = QLatin1Char(';');
|
||||||
|
|
||||||
|
|
||||||
if ( yyLine->endsWith(m_constants.m_else))
|
if (yyLine->endsWith(m_constants.m_else))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( !yyLine->endsWith(QLatin1Char(')')))
|
if (!yyLine->endsWith(QLatin1Char(')')))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for ( int i = 0; i < SmallRoof; i++ ) {
|
for (int i = 0; i < SmallRoof; i++) {
|
||||||
int j = yyLine->length();
|
int j = yyLine->length();
|
||||||
while ( j > 0 ) {
|
while (j > 0) {
|
||||||
j--;
|
j--;
|
||||||
QChar ch = (*yyLine)[j];
|
QChar ch = (*yyLine)[j];
|
||||||
|
|
||||||
switch ( ch.unicode() ) {
|
switch (ch.unicode()) {
|
||||||
case ')':
|
case ')':
|
||||||
delimDepth++;
|
delimDepth++;
|
||||||
break;
|
break;
|
||||||
case '(':
|
case '(':
|
||||||
delimDepth--;
|
delimDepth--;
|
||||||
if ( delimDepth == 0 ) {
|
if (delimDepth == 0) {
|
||||||
if ( yyLine->contains(m_constants.m_iflikeKeyword) ) {
|
if (yyLine->contains(m_constants.m_iflikeKeyword)) {
|
||||||
/*
|
/*
|
||||||
We have
|
We have
|
||||||
|
|
||||||
if ( x )
|
if (x)
|
||||||
y
|
y
|
||||||
|
|
||||||
"if ( x )" is not part of the statement
|
"if (x)" is not part of the statement
|
||||||
"y".
|
"y".
|
||||||
*/
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( delimDepth == -1 ) {
|
if (delimDepth == -1) {
|
||||||
/*
|
/*
|
||||||
We have
|
We have
|
||||||
|
|
||||||
if ( (1 +
|
if ((1 +
|
||||||
2)
|
2)
|
||||||
|
|
||||||
and not
|
and not
|
||||||
|
|
||||||
if ( 1 +
|
if (1 +
|
||||||
2 )
|
2)
|
||||||
*/
|
*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -606,12 +606,12 @@ bool Indenter::matchBracelessControlStatement()
|
|||||||
continuation line. Be careful with ';' in for,
|
continuation line. Be careful with ';' in for,
|
||||||
though.
|
though.
|
||||||
*/
|
*/
|
||||||
if ( ch != semicolon || delimDepth == 0 )
|
if (ch != semicolon || delimDepth == 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !readLine() )
|
if (!readLine())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -640,32 +640,32 @@ bool Indenter::isUnfinishedLine()
|
|||||||
const QChar openingParenthesis = QLatin1Char('(');
|
const QChar openingParenthesis = QLatin1Char('(');
|
||||||
const QChar semicolon = QLatin1Char(';');
|
const QChar semicolon = QLatin1Char(';');
|
||||||
|
|
||||||
if ( yyLine->isEmpty() )
|
if (yyLine->isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QChar lastCh = (*yyLine)[ yyLine->length() - 1];
|
const QChar lastCh = (*yyLine)[ yyLine->length() - 1];
|
||||||
if ( ! m_constants.m_bracesSemicolon.contains(lastCh) && !yyLine->endsWith(m_constants.m_3dots) ) {
|
if (! m_constants.m_bracesSemicolon.contains(lastCh) && !yyLine->endsWith(m_constants.m_3dots)) {
|
||||||
/*
|
/*
|
||||||
It doesn't end with ';' or similar. If it's neither
|
It doesn't end with ';' or similar. If it's neither
|
||||||
"Q_OBJECT" nor "if ( x )" nor is a template function, it must be an unfinished line.
|
"Q_OBJECT" nor "if (x)" nor is a template function, it must be an unfinished line.
|
||||||
*/
|
*/
|
||||||
unf = ( !yyLine->contains(m_constants.m_qobject) &&
|
unf = (!yyLine->contains(m_constants.m_qobject) &&
|
||||||
!matchBracelessControlStatement() &&
|
!matchBracelessControlStatement() &&
|
||||||
!yyLine->contains(m_constants.m_templateFunc) );
|
!yyLine->contains(m_constants.m_templateFunc));
|
||||||
} else if ( lastCh == semicolon ) {
|
} else if (lastCh == semicolon) {
|
||||||
if ( lastParen(*yyLine) == openingParenthesis ) {
|
if (lastParen(*yyLine) == openingParenthesis) {
|
||||||
/*
|
/*
|
||||||
Exception:
|
Exception:
|
||||||
|
|
||||||
for ( int i = 1; i < 10;
|
for (int i = 1; i < 10;
|
||||||
*/
|
*/
|
||||||
unf = true;
|
unf = true;
|
||||||
} else if ( readLine() && yyLine->endsWith(semicolon) &&
|
} else if (readLine() && yyLine->endsWith(semicolon) &&
|
||||||
lastParen(*yyLine) == openingParenthesis ) {
|
lastParen(*yyLine) == openingParenthesis) {
|
||||||
/*
|
/*
|
||||||
Exception:
|
Exception:
|
||||||
|
|
||||||
for ( int i = 1;
|
for (int i = 1;
|
||||||
i < 10;
|
i < 10;
|
||||||
*/
|
*/
|
||||||
unf = true;
|
unf = true;
|
||||||
@@ -708,15 +708,15 @@ int Indenter::indentForContinuationLine()
|
|||||||
const QChar openingParenthesis = QLatin1Char('(');
|
const QChar openingParenthesis = QLatin1Char('(');
|
||||||
const QChar closingParenthesis = QLatin1Char(')');
|
const QChar closingParenthesis = QLatin1Char(')');
|
||||||
|
|
||||||
for ( int i = 0; i < SmallRoof; i++ ) {
|
for (int i = 0; i < SmallRoof; i++) {
|
||||||
int hook = -1;
|
int hook = -1;
|
||||||
|
|
||||||
int j = yyLine->length();
|
int j = yyLine->length();
|
||||||
while ( j > 0 && hook < 0 ) {
|
while (j > 0 && hook < 0) {
|
||||||
j--;
|
j--;
|
||||||
QChar ch = (*yyLine)[j];
|
QChar ch = (*yyLine)[j];
|
||||||
|
|
||||||
switch ( ch.unicode() ) {
|
switch (ch.unicode()) {
|
||||||
case ')':
|
case ')':
|
||||||
case ']':
|
case ']':
|
||||||
delimDepth++;
|
delimDepth++;
|
||||||
@@ -731,7 +731,7 @@ int Indenter::indentForContinuationLine()
|
|||||||
An unclosed delimiter is a good place to align at,
|
An unclosed delimiter is a good place to align at,
|
||||||
at least for some styles (including Trolltech's).
|
at least for some styles (including Trolltech's).
|
||||||
*/
|
*/
|
||||||
if ( delimDepth == -1 )
|
if (delimDepth == -1)
|
||||||
hook = j;
|
hook = j;
|
||||||
break;
|
break;
|
||||||
case '{':
|
case '{':
|
||||||
@@ -742,8 +742,8 @@ int Indenter::indentForContinuationLine()
|
|||||||
Such a brace must be treated just like the other
|
Such a brace must be treated just like the other
|
||||||
delimiters.
|
delimiters.
|
||||||
*/
|
*/
|
||||||
if ( braceDepth == -1 ) {
|
if (braceDepth == -1) {
|
||||||
if ( j < yyLine->length() - 1 ) {
|
if (j < yyLine->length() - 1) {
|
||||||
hook = j;
|
hook = j;
|
||||||
} else {
|
} else {
|
||||||
return 0; // shouldn't happen
|
return 0; // shouldn't happen
|
||||||
@@ -764,62 +764,62 @@ int Indenter::indentForContinuationLine()
|
|||||||
default arguments and explicit enum constant
|
default arguments and explicit enum constant
|
||||||
values:
|
values:
|
||||||
|
|
||||||
void foo( int x = 0,
|
void foo(int x = 0,
|
||||||
int y = 0 );
|
int y = 0);
|
||||||
|
|
||||||
And not
|
And not
|
||||||
|
|
||||||
void foo( int x = 0,
|
void foo(int x = 0,
|
||||||
int y = 0 );
|
int y = 0);
|
||||||
|
|
||||||
These constructs are caracterized by a ',' at the
|
These constructs are caracterized by a ',' at the
|
||||||
end of the unfinished lines or by unbalanced
|
end of the unfinished lines or by unbalanced
|
||||||
parentheses.
|
parentheses.
|
||||||
*/
|
*/
|
||||||
if ( j > 0 && j < yyLine->length() - 1
|
if (j > 0 && j < yyLine->length() - 1
|
||||||
&& !m_constants.m_operators.contains((*yyLine)[j - 1])
|
&& !m_constants.m_operators.contains((*yyLine)[j - 1])
|
||||||
&& (*yyLine)[j + 1] != equals ) {
|
&& (*yyLine)[j + 1] != equals) {
|
||||||
if ( braceDepth == 0 && delimDepth == 0 &&
|
if (braceDepth == 0 && delimDepth == 0 &&
|
||||||
!yyLine->endsWith(comma) &&
|
!yyLine->endsWith(comma) &&
|
||||||
(yyLine->contains(openingParenthesis) == yyLine->contains(closingParenthesis)) )
|
(yyLine->contains(openingParenthesis) == yyLine->contains(closingParenthesis)))
|
||||||
hook = j;
|
hook = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( hook >= 0 ) {
|
if (hook >= 0) {
|
||||||
/*
|
/*
|
||||||
Yes, we have a delimiter or an operator to align
|
Yes, we have a delimiter or an operator to align
|
||||||
against! We don't really align against it, but rather
|
against! We don't really align against it, but rather
|
||||||
against the following token, if any. In this example,
|
against the following token, if any. In this example,
|
||||||
the following token is "11":
|
the following token is "11":
|
||||||
|
|
||||||
int x = ( 11 +
|
int x = (11 +
|
||||||
2 );
|
2);
|
||||||
|
|
||||||
If there is no such token, we use a continuation indent:
|
If there is no such token, we use a continuation indent:
|
||||||
|
|
||||||
static QRegExp foo( QString(
|
static QRegExp foo(QString(
|
||||||
"foo foo foo foo foo foo foo foo foo") );
|
"foo foo foo foo foo foo foo foo foo"));
|
||||||
*/
|
*/
|
||||||
hook++;
|
hook++;
|
||||||
while ( hook < yyLine->length() ) {
|
while (hook < yyLine->length()) {
|
||||||
if ( !(*yyLine)[hook].isSpace() )
|
if (!(*yyLine)[hook].isSpace())
|
||||||
return columnForIndex( *yyLine, hook );
|
return columnForIndex(*yyLine, hook);
|
||||||
hook++;
|
hook++;
|
||||||
}
|
}
|
||||||
return indentOfLine( *yyLine ) + ppContinuationIndentSize;
|
return indentOfLine(*yyLine) + ppContinuationIndentSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( braceDepth != 0 )
|
if (braceDepth != 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The line's delimiters are balanced. It looks like a
|
The line's delimiters are balanced. It looks like a
|
||||||
continuation line or something.
|
continuation line or something.
|
||||||
*/
|
*/
|
||||||
if ( delimDepth == 0 ) {
|
if (delimDepth == 0) {
|
||||||
if ( leftBraceFollowed ) {
|
if (leftBraceFollowed) {
|
||||||
/*
|
/*
|
||||||
We have
|
We have
|
||||||
|
|
||||||
@@ -829,14 +829,14 @@ int Indenter::indentForContinuationLine()
|
|||||||
or
|
or
|
||||||
|
|
||||||
Bar::Bar()
|
Bar::Bar()
|
||||||
: Foo( x )
|
: Foo(x)
|
||||||
{
|
{
|
||||||
|
|
||||||
The "{" should be flush left.
|
The "{" should be flush left.
|
||||||
*/
|
*/
|
||||||
if ( !isContinuationLine() )
|
if (!isContinuationLine())
|
||||||
return indentOfLine( *yyLine );
|
return indentOfLine(*yyLine);
|
||||||
} else if ( isContinuationLine() || yyLine->endsWith(comma)) {
|
} else if (isContinuationLine() || yyLine->endsWith(comma)) {
|
||||||
/*
|
/*
|
||||||
We have
|
We have
|
||||||
|
|
||||||
@@ -853,7 +853,7 @@ int Indenter::indentForContinuationLine()
|
|||||||
The "c;" should fall right under the "b +", and the
|
The "c;" should fall right under the "b +", and the
|
||||||
"4, 5, 6" right under the "1, 2, 3,".
|
"4, 5, 6" right under the "1, 2, 3,".
|
||||||
*/
|
*/
|
||||||
return indentOfLine( *yyLine );
|
return indentOfLine(*yyLine);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
We have
|
We have
|
||||||
@@ -871,11 +871,11 @@ int Indenter::indentForContinuationLine()
|
|||||||
We do have a special trick above for the assignment
|
We do have a special trick above for the assignment
|
||||||
operator above, though.
|
operator above, though.
|
||||||
*/
|
*/
|
||||||
return indentOfLine( *yyLine ) + ppContinuationIndentSize;
|
return indentOfLine(*yyLine) + ppContinuationIndentSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !readLine() )
|
if (!readLine())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -904,26 +904,26 @@ int Indenter::indentForContinuationLine()
|
|||||||
|
|
||||||
Example 2:
|
Example 2:
|
||||||
|
|
||||||
if ( x ) {
|
if (x) {
|
||||||
y;
|
y;
|
||||||
|
|
||||||
The hook line is "if ( x ) {". No matter what precedes it, "y;" has
|
The hook line is "if (x) {". No matter what precedes it, "y;" has
|
||||||
to be indented one level deeper than the hook line, since we met one
|
to be indented one level deeper than the hook line, since we met one
|
||||||
opening brace along the way.
|
opening brace along the way.
|
||||||
|
|
||||||
Example 3:
|
Example 3:
|
||||||
|
|
||||||
if ( a )
|
if (a)
|
||||||
while ( b ) {
|
while (b) {
|
||||||
c;
|
c;
|
||||||
}
|
}
|
||||||
d;
|
d;
|
||||||
|
|
||||||
To indent "d;" correctly, we have to go as far as the "if ( a )".
|
To indent "d;" correctly, we have to go as far as the "if (a)".
|
||||||
Compare with
|
Compare with
|
||||||
|
|
||||||
if ( a ) {
|
if (a) {
|
||||||
while ( b ) {
|
while (b) {
|
||||||
c;
|
c;
|
||||||
}
|
}
|
||||||
d;
|
d;
|
||||||
@@ -937,81 +937,81 @@ int Indenter::indentForStandaloneLine()
|
|||||||
const QChar semicolon = QLatin1Char(';');
|
const QChar semicolon = QLatin1Char(';');
|
||||||
const QChar openingBrace = QLatin1Char('{');
|
const QChar openingBrace = QLatin1Char('{');
|
||||||
|
|
||||||
for ( int i = 0; i < SmallRoof; i++ ) {
|
for (int i = 0; i < SmallRoof; i++) {
|
||||||
if ( !*yyLeftBraceFollows ) {
|
if (!*yyLeftBraceFollows) {
|
||||||
YY_SAVE();
|
YY_SAVE();
|
||||||
|
|
||||||
if ( matchBracelessControlStatement() ) {
|
if (matchBracelessControlStatement()) {
|
||||||
/*
|
/*
|
||||||
The situation is this, and we want to indent "z;":
|
The situation is this, and we want to indent "z;":
|
||||||
|
|
||||||
if ( x &&
|
if (x &&
|
||||||
y )
|
y)
|
||||||
z;
|
z;
|
||||||
|
|
||||||
yyLine is "if ( x &&".
|
yyLine is "if (x &&".
|
||||||
*/
|
*/
|
||||||
return indentOfLine( *yyLine ) + ppIndentSize;
|
return indentOfLine(*yyLine) + ppIndentSize;
|
||||||
}
|
}
|
||||||
YY_RESTORE();
|
YY_RESTORE();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( yyLine->endsWith(semicolon) || yyLine->count(openingBrace) > 0 ) {
|
if (yyLine->endsWith(semicolon) || yyLine->count(openingBrace) > 0) {
|
||||||
/*
|
/*
|
||||||
The situation is possibly this, and we want to indent
|
The situation is possibly this, and we want to indent
|
||||||
"z;":
|
"z;":
|
||||||
|
|
||||||
while ( x )
|
while (x)
|
||||||
y;
|
y;
|
||||||
z;
|
z;
|
||||||
|
|
||||||
We return the indent of "while ( x )". In place of "y;",
|
We return the indent of "while (x)". In place of "y;",
|
||||||
any arbitrarily complex compound statement can appear.
|
any arbitrarily complex compound statement can appear.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( *yyBraceDepth > 0 ) {
|
if (*yyBraceDepth > 0) {
|
||||||
do {
|
do {
|
||||||
if ( !readLine() )
|
if (!readLine())
|
||||||
break;
|
break;
|
||||||
} while ( *yyBraceDepth > 0 );
|
} while (*yyBraceDepth > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinizerState hookState;
|
LinizerState hookState;
|
||||||
|
|
||||||
while ( isContinuationLine() )
|
while (isContinuationLine())
|
||||||
readLine();
|
readLine();
|
||||||
hookState = *yyLinizerState;
|
hookState = *yyLinizerState;
|
||||||
|
|
||||||
readLine();
|
readLine();
|
||||||
if ( *yyBraceDepth <= 0 ) {
|
if (*yyBraceDepth <= 0) {
|
||||||
do {
|
do {
|
||||||
if ( !matchBracelessControlStatement() )
|
if (!matchBracelessControlStatement())
|
||||||
break;
|
break;
|
||||||
hookState = *yyLinizerState;
|
hookState = *yyLinizerState;
|
||||||
} while ( readLine() );
|
} while (readLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
*yyLinizerState = hookState;
|
*yyLinizerState = hookState;
|
||||||
|
|
||||||
while ( isContinuationLine() )
|
while (isContinuationLine())
|
||||||
readLine();
|
readLine();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Never trust lines containing only '{' or '}', as some
|
Never trust lines containing only '{' or '}', as some
|
||||||
people (Richard M. Stallman) format them weirdly.
|
people (Richard M. Stallman) format them weirdly.
|
||||||
*/
|
*/
|
||||||
if ( yyLine->trimmed().length() > 1 ) {
|
if (yyLine->trimmed().length() > 1) {
|
||||||
if (!ppDoubleIndentBlocks)
|
if (!ppDoubleIndentBlocks)
|
||||||
return indentOfLine( *yyLine ) - *yyBraceDepth * ppIndentSize;
|
return indentOfLine(*yyLine) - *yyBraceDepth * ppIndentSize;
|
||||||
else {
|
else {
|
||||||
if (*yyBraceDepth == -1 && indentOfLine( *yyLine ) == 0)
|
if (*yyBraceDepth == -1 && indentOfLine(*yyLine) == 0)
|
||||||
return ppIndentSize; // don't do double indent for upper level blocks
|
return ppIndentSize; // don't do double indent for upper level blocks
|
||||||
return indentOfLine( *yyLine ) - *yyBraceDepth * ppIndentSize * 2;
|
return indentOfLine(*yyLine) - *yyBraceDepth * ppIndentSize * 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !readLine() )
|
if (!readLine())
|
||||||
return -*yyBraceDepth * ppIndentSize;
|
return -*yyBraceDepth * ppIndentSize;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1030,9 +1030,9 @@ int Indenter::indentForStandaloneLine()
|
|||||||
int Indenter::indentForBottomLine(const Iterator ¤t,
|
int Indenter::indentForBottomLine(const Iterator ¤t,
|
||||||
const Iterator &programBegin,
|
const Iterator &programBegin,
|
||||||
const Iterator &programEnd,
|
const Iterator &programEnd,
|
||||||
QChar typedIn )
|
QChar typedIn)
|
||||||
{
|
{
|
||||||
if ( programBegin == programEnd )
|
if (programBegin == programEnd)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
yyProgramBegin = programBegin;
|
yyProgramBegin = programBegin;
|
||||||
@@ -1043,7 +1043,7 @@ int Indenter::indentForBottomLine(const Iterator ¤t,
|
|||||||
Iterator lastIt = current;
|
Iterator lastIt = current;
|
||||||
|
|
||||||
QString bottomLine = *lastIt;
|
QString bottomLine = *lastIt;
|
||||||
QChar firstCh = firstNonWhiteSpace( bottomLine );
|
QChar firstCh = firstNonWhiteSpace(bottomLine);
|
||||||
int indent;
|
int indent;
|
||||||
|
|
||||||
const QChar hash = QLatin1Char('#');
|
const QChar hash = QLatin1Char('#');
|
||||||
@@ -1051,32 +1051,32 @@ int Indenter::indentForBottomLine(const Iterator ¤t,
|
|||||||
const QChar closingBrace = QLatin1Char('}');
|
const QChar closingBrace = QLatin1Char('}');
|
||||||
const QChar colon = QLatin1Char(':');
|
const QChar colon = QLatin1Char(':');
|
||||||
|
|
||||||
if ( bottomLineStartsInCComment() ) {
|
if (bottomLineStartsInCComment()) {
|
||||||
/*
|
/*
|
||||||
The bottom line starts in a C-style comment. Indent it
|
The bottom line starts in a C-style comment. Indent it
|
||||||
smartly, unless the user has already played around with it,
|
smartly, unless the user has already played around with it,
|
||||||
in which case it's better to leave her stuff alone.
|
in which case it's better to leave her stuff alone.
|
||||||
*/
|
*/
|
||||||
if ( isOnlyWhiteSpace(bottomLine) ) {
|
if (isOnlyWhiteSpace(bottomLine)) {
|
||||||
indent = indentWhenBottomLineStartsInCComment();
|
indent = indentWhenBottomLineStartsInCComment();
|
||||||
} else {
|
} else {
|
||||||
indent = indentOfLine( bottomLine );
|
indent = indentOfLine(bottomLine);
|
||||||
}
|
}
|
||||||
} else if ( okay(typedIn, hash) && firstCh == hash ) {
|
} else if (okay(typedIn, hash) && firstCh == hash) {
|
||||||
/*
|
/*
|
||||||
Preprocessor directives go flush left.
|
Preprocessor directives go flush left.
|
||||||
*/
|
*/
|
||||||
indent = 0;
|
indent = 0;
|
||||||
} else {
|
} else {
|
||||||
if ( isUnfinishedLine() ) {
|
if (isUnfinishedLine()) {
|
||||||
indent = indentForContinuationLine();
|
indent = indentForContinuationLine();
|
||||||
} else {
|
} else {
|
||||||
indent = indentForStandaloneLine();
|
indent = indentForStandaloneLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ppIndentBraces && firstCh == openingBrace ) {
|
if (ppIndentBraces && firstCh == openingBrace) {
|
||||||
indent += ppIndentSize;
|
indent += ppIndentSize;
|
||||||
} else if ( firstCh == closingBrace ) {
|
} else if (firstCh == closingBrace) {
|
||||||
/*
|
/*
|
||||||
A closing brace is one level more to the left than the
|
A closing brace is one level more to the left than the
|
||||||
code it follows.
|
code it follows.
|
||||||
@@ -1093,8 +1093,8 @@ int Indenter::indentForBottomLine(const Iterator ¤t,
|
|||||||
if (ppDoubleIndentBlocks)
|
if (ppDoubleIndentBlocks)
|
||||||
indent -= ppIndentSize;
|
indent -= ppIndentSize;
|
||||||
|
|
||||||
} else if ( okay(typedIn, colon) ) {
|
} else if (okay(typedIn, colon)) {
|
||||||
if ( m_constants.m_caseLabel.indexIn(bottomLine) != -1 ) {
|
if (m_constants.m_caseLabel.indexIn(bottomLine) != -1) {
|
||||||
/*
|
/*
|
||||||
Move a case label (or the ':' in front of a
|
Move a case label (or the ':' in front of a
|
||||||
constructor initialization list) one level to the
|
constructor initialization list) one level to the
|
||||||
@@ -1108,18 +1108,18 @@ int Indenter::indentForBottomLine(const Iterator ¤t,
|
|||||||
user is probably the middle of "foo::bar". (Who
|
user is probably the middle of "foo::bar". (Who
|
||||||
uses goto, anyway?)
|
uses goto, anyway?)
|
||||||
*/
|
*/
|
||||||
if ( indentOfLine(bottomLine) <= indent )
|
if (indentOfLine(bottomLine) <= indent)
|
||||||
indent -= ppIndentSize;
|
indent -= ppIndentSize;
|
||||||
else
|
else
|
||||||
indent = indentOfLine( bottomLine );
|
indent = indentOfLine(bottomLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ppIndentBraces && indent == ppIndentSize &&
|
if (ppIndentBraces && indent == ppIndentSize &&
|
||||||
(firstCh == openingBrace || firstCh == closingBrace ) ) {
|
(firstCh == openingBrace || firstCh == closingBrace) ) {
|
||||||
indent = 0;
|
indent = 0;
|
||||||
}
|
}
|
||||||
return qMax( 0, indent );
|
return qMax(0, indent);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace SharedTools
|
} // namespace SharedTools
|
||||||
|
|||||||
Reference in New Issue
Block a user