parseInlineStyleWithImportant method
Implementation
InlineStyleParseResult parseInlineStyleWithImportant() {
final properties = <String, dynamic>{};
final importants = <String, bool>{};
while (!_peekKind(TokenKind.END_OF_FILE)) {
if (TokenKind.isIdentifier(_peekToken.kind)) {
var propertyIdent = camelize(identifier().name);
var resetProperty = false;
var keepGoing = true;
while (keepGoing) {
switch (_peek()) {
case TokenKind.COLON:
_eat(TokenKind.COLON);
keepGoing = false;
break;
case TokenKind.SEMICOLON:
case TokenKind.NEWLINE:
resetProperty = true;
_next();
break;
case TokenKind.IDENTIFIER:
if (resetProperty) {
propertyIdent = camelize(identifier().name);
}
break;
default:
keepGoing = false;
}
}
final expr = processExpr();
var isImportant = false;
if (_peek() == TokenKind.IMPORTANT) {
_next();
isImportant = true;
}
// Allow multiple declarations separated by semicolons.
_maybeEat(TokenKind.SEMICOLON);
properties[propertyIdent] = expr?.trim();
if (isImportant) importants[propertyIdent] = true;
continue;
}
if (_peekToken.kind == TokenKind.VAR_DEFINITION) {
_next();
continue;
}
if (_peekToken.kind == TokenKind.DIRECTIVE_INCLUDE) {
// TODO @include mixinName in the declaration area.
_next();
continue;
}
if (_peekToken.kind == TokenKind.DIRECTIVE_EXTEND) {
_next();
continue;
}
// Skip unknown tokens to avoid infinite loops.
_next();
}
return InlineStyleParseResult(
properties: properties, importants: importants);
}