OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.src.generated.parser; | 5 library analyzer.src.generated.parser; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import "dart:math" as math; | 8 import "dart:math" as math; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 // We know that we have an identifier, and need to see whether it might be | 535 // We know that we have an identifier, and need to see whether it might be |
536 // a type name. | 536 // a type name. |
537 if (_currentToken.type != TokenType.IDENTIFIER) { | 537 if (_currentToken.type != TokenType.IDENTIFIER) { |
538 allowAdditionalTokens = false; | 538 allowAdditionalTokens = false; |
539 } | 539 } |
540 Token token = skipTypeName(_currentToken); | 540 Token token = skipTypeName(_currentToken); |
541 if (token == null) { | 541 if (token == null) { |
542 // There was no type name, so this can't be a declaration. | 542 // There was no type name, so this can't be a declaration. |
543 return false; | 543 return false; |
544 } | 544 } |
545 if (_tokenMatchesKeyword(token, Keyword.FUNCTION)) { | 545 if (_atGenericFunctionTypeAfterReturnType(token)) { |
546 token = skipGenericFunctionTypeAfterReturnType(token); | 546 token = skipGenericFunctionTypeAfterReturnType(token); |
| 547 if (token == null) { |
| 548 // There was no type name, so this can't be a declaration. |
| 549 return false; |
| 550 } |
547 } | 551 } |
548 if (token.type != TokenType.IDENTIFIER) { | 552 if (token.type != TokenType.IDENTIFIER) { |
549 allowAdditionalTokens = false; | 553 allowAdditionalTokens = false; |
550 } | 554 } |
551 token = skipSimpleIdentifier(token); | 555 token = skipSimpleIdentifier(token); |
552 if (token == null) { | 556 if (token == null) { |
553 return false; | 557 return false; |
554 } | 558 } |
555 TokenType type = token.type; | 559 TokenType type = token.type; |
556 // Usual cases in valid code: | 560 // Usual cases in valid code: |
(...skipping 8001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8558 } | 8562 } |
8559 if (modifiers.finalKeyword != null) { | 8563 if (modifiers.finalKeyword != null) { |
8560 _reportErrorForToken( | 8564 _reportErrorForToken( |
8561 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword); | 8565 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword); |
8562 } | 8566 } |
8563 if (modifiers.varKeyword != null) { | 8567 if (modifiers.varKeyword != null) { |
8564 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword); | 8568 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword); |
8565 } | 8569 } |
8566 } | 8570 } |
8567 } | 8571 } |
OLD | NEW |