C++ indenter: Enable class, struct, enum, namespace, using in functions.

Fixes incorrect indentation we got previously when they were used in a
statement context.
This commit is contained in:
Christian Kamm
2010-07-08 08:35:12 +02:00
parent 870da8e7e3
commit 6078b36c9c
2 changed files with 34 additions and 21 deletions

View File

@@ -72,16 +72,8 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
switch (m_currentState.top().type) {
case topmost_intro:
if (tryDeclaration())
break;
switch (kind) {
case T_NAMESPACE: enter(namespace_start); break;
case T_STRUCT:
case T_UNION:
case T_CLASS: enter(class_start); break;
case T_ENUM: enter(enum_start); break;
case T_USING: enter(using_start); break;
} break;
tryDeclaration();
break;
case namespace_start:
switch (kind) {
@@ -93,13 +85,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
if (tryDeclaration())
break;
switch (kind) {
case T_NAMESPACE: enter(namespace_start); break;
case T_RBRACE: leave(); continue; // always nested in namespace_start
case T_STRUCT:
case T_UNION:
case T_CLASS: enter(class_start); break;
case T_ENUM: enter(enum_start); break;
case T_USING: enter(using_start); break;
} break;
case class_start:
@@ -113,11 +99,6 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
break;
switch (kind) {
case T_RBRACE: leave(); continue; // always nested in class_start
case T_STRUCT:
case T_UNION:
case T_CLASS: enter(class_start); break;
case T_ENUM: enter(enum_start); break;
case T_USING: enter(using_start); break;
} break;
case enum_start:
@@ -704,6 +685,24 @@ bool CodeFormatter::tryDeclaration()
enter(template_start);
return true;
case T_NAMESPACE:
enter(namespace_start);
return true;
case T_STRUCT:
case T_UNION:
case T_CLASS:
enter(class_start);
return true;
case T_ENUM:
enter(enum_start);
return true;
case T_USING:
enter(using_start);
return true;
default:
return false;
}