@@ -507,8 +507,12 @@ class Parser {
507507 token = parseMetadataStar (token);
508508 Token next = token.next! ;
509509 if (next.isTopLevelKeyword) {
510- return parseTopLevelKeywordDeclaration (/* start = */ token,
511- /* keyword = */ next, /* macroToken = */ null , directiveState);
510+ return parseTopLevelKeywordDeclaration (
511+ /* start = */ token,
512+ /* keyword = */ next,
513+ /* macroToken = */ null ,
514+ /* viewToken = */ null ,
515+ directiveState);
512516 }
513517 Token start = token;
514518 // Skip modifiers to find a top level keyword or identifier
@@ -528,15 +532,25 @@ class Parser {
528532 }
529533 next = token.next! ;
530534 Token ? macroToken;
535+ Token ? viewToken;
531536 if (next.isIdentifier &&
537+ next.lexeme == 'view' &&
538+ optional ('class' , next.next! )) {
539+ viewToken = next;
540+ next = next.next! ;
541+ } else if (next.isIdentifier &&
532542 next.lexeme == 'macro' &&
533543 optional ('class' , next.next! )) {
534544 macroToken = next;
535545 next = next.next! ;
536546 }
537547 if (next.isTopLevelKeyword) {
538- return parseTopLevelKeywordDeclaration (/* start = */ start,
539- /* keyword = */ next, /* macroToken = */ macroToken, directiveState);
548+ return parseTopLevelKeywordDeclaration (
549+ /* start = */ start,
550+ /* keyword = */ next,
551+ /* macroToken = */ macroToken,
552+ /* viewToken = */ viewToken,
553+ directiveState);
540554 } else if (next.isKeywordOrIdentifier) {
541555 // TODO(danrubel): improve parseTopLevelMember
542556 // so that we don't parse modifiers twice.
@@ -569,7 +583,7 @@ class Parser {
569583 /// Parse any top-level declaration that begins with a keyword.
570584 /// [start] is the token before any modifiers preceding [keyword] .
571585 Token parseTopLevelKeywordDeclaration (Token start, Token keyword,
572- Token ? macroToken, DirectiveContext ? directiveState) {
586+ Token ? macroToken, Token ? viewToken, DirectiveContext ? directiveState) {
573587 assert (keyword.isTopLevelKeyword);
574588 final String ? value = keyword.stringValue;
575589 if (identical (value, 'class' )) {
@@ -579,7 +593,7 @@ class Parser {
579593 Token ? abstractToken = context.abstractToken;
580594 Token ? augmentToken = context.augmentToken;
581595 return parseClassOrNamedMixinApplication (
582- abstractToken, macroToken, augmentToken, keyword);
596+ abstractToken, macroToken, viewToken, augmentToken, keyword);
583597 } else if (identical (value, 'enum' )) {
584598 directiveState? .checkDeclaration ();
585599 ModifierContext context = new ModifierContext (this );
@@ -2415,8 +2429,12 @@ class Parser {
24152429 return token;
24162430 }
24172431
2418- Token parseClassOrNamedMixinApplication (Token ? abstractToken,
2419- Token ? macroToken, Token ? augmentToken, Token classKeyword) {
2432+ Token parseClassOrNamedMixinApplication (
2433+ Token ? abstractToken,
2434+ Token ? macroToken,
2435+ Token ? viewToken,
2436+ Token ? augmentToken,
2437+ Token classKeyword) {
24202438 assert (optional ('class' , classKeyword));
24212439 Token begin = abstractToken ?? classKeyword;
24222440 listener.beginClassOrMixinOrNamedMixinApplicationPrelude (begin);
@@ -2427,11 +2445,11 @@ class Parser {
24272445 .parseVariables (name, this );
24282446 if (optional ('=' , token.next! )) {
24292447 listener.beginNamedMixinApplication (
2430- begin, abstractToken, macroToken, augmentToken, name);
2448+ begin, abstractToken, macroToken, viewToken, augmentToken, name);
24312449 return parseNamedMixinApplication (token, begin, classKeyword);
24322450 } else {
24332451 listener.beginClassDeclaration (
2434- begin, abstractToken, macroToken, augmentToken, name);
2452+ begin, abstractToken, macroToken, viewToken, augmentToken, name);
24352453 return parseClass (token, begin, classKeyword, name.lexeme);
24362454 }
24372455 }
0 commit comments