forked from qt-creator/qt-creator
QmlJS: improve support for enum declarations
Add indentation and little highlighting for enums. It just highlights the 'enum' keyword and the name of the enum, not its values. Task-number: QTCREATORBUG-19226 Change-Id: I36e46a27b0e32c4aecc8e91875c3d22df1814d93 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -177,6 +177,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
|
||||
case Property: enter(property_start); break;
|
||||
case Function: enter(function_start); break;
|
||||
case Signal: enter(signal_start); break;
|
||||
case Enum: enter(enum_start); break;
|
||||
case On:
|
||||
case As:
|
||||
case List:
|
||||
@@ -215,6 +216,11 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
|
||||
default: leave(true); continue;
|
||||
} break;
|
||||
|
||||
case enum_start:
|
||||
switch (kind) {
|
||||
case LeftBrace: enter(objectliteral_open); break;
|
||||
} break;
|
||||
|
||||
case signal_start:
|
||||
switch (kind) {
|
||||
case Colon: enter(binding_assignment); break; // oops, was a binding
|
||||
@@ -931,6 +937,8 @@ CodeFormatter::TokenKind CodeFormatter::extendedTokenKind(const QmlJS::Token &to
|
||||
return On;
|
||||
if (text == QLatin1String("list"))
|
||||
return List;
|
||||
if (text == QLatin1String("enum"))
|
||||
return Enum;
|
||||
} else if (kind == Keyword) {
|
||||
const char char1 = text.at(0).toLatin1();
|
||||
const char char2 = text.at(1).toLatin1();
|
||||
|
||||
@@ -109,6 +109,8 @@ public: // must be public to make Q_GADGET introspection work
|
||||
property_name, // after the type
|
||||
property_maybe_initializer, // after the identifier
|
||||
|
||||
enum_start, // after 'enum'
|
||||
|
||||
signal_start, // after 'signal'
|
||||
signal_maybe_arglist, // after identifier
|
||||
signal_arglist_open, // after '('
|
||||
@@ -197,6 +199,7 @@ protected:
|
||||
Comma,
|
||||
Dot,
|
||||
Delimiter,
|
||||
RegExp,
|
||||
|
||||
EndOfExistingTokenKinds,
|
||||
|
||||
@@ -209,6 +212,7 @@ protected:
|
||||
Delete,
|
||||
Do,
|
||||
Else,
|
||||
Enum,
|
||||
Finally,
|
||||
For,
|
||||
Function,
|
||||
|
||||
Reference in New Issue
Block a user