OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.parser.element_listener; | 5 library dart2js.parser.element_listener; |
6 | 6 |
7 import 'package:front_end/src/fasta/fasta_codes.dart' show Message; | 7 import 'package:front_end/src/fasta/fasta_codes.dart' show Message; |
8 | 8 |
9 import 'package:front_end/src/fasta/fasta_codes.dart' as codes; | 9 import 'package:front_end/src/fasta/fasta_codes.dart' as codes; |
10 | 10 |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 pushNode(null); | 545 pushNode(null); |
546 } | 546 } |
547 | 547 |
548 Token handleError(Token token, Message message) { | 548 Token handleError(Token token, Message message) { |
549 MessageKind errorCode; | 549 MessageKind errorCode; |
550 Map<String, dynamic> arguments = message.arguments; | 550 Map<String, dynamic> arguments = message.arguments; |
551 | 551 |
552 switch (message.code.dart2jsCode) { | 552 switch (message.code.dart2jsCode) { |
553 case "MISSING_TOKEN_BEFORE_THIS": | 553 case "MISSING_TOKEN_BEFORE_THIS": |
554 String expected = arguments["string"]; | 554 String expected = arguments["string"]; |
| 555 // TODO(danrubel) This functionality is being replaced by |
| 556 // the parser's ensureSemicolon method. |
555 if (identical(";", expected)) { | 557 if (identical(";", expected)) { |
556 // When a semicolon is missing, it often leads to an error on the | 558 // When a semicolon is missing, it often leads to an error on the |
557 // following line. So we try to find the token preceding the semicolon | 559 // following line. So we try to find the token preceding the semicolon |
558 // and report that something is missing *after* it. | 560 // and report that something is missing *after* it. |
559 Token preceding = findPrecedingToken(token); | 561 Token preceding = findPrecedingToken(token); |
560 if (preceding == token) { | 562 if (preceding == token) { |
561 reportErrorFromToken(token, MessageKind.MISSING_TOKEN_BEFORE_THIS, | 563 reportErrorFromToken(token, MessageKind.MISSING_TOKEN_BEFORE_THIS, |
562 {'token': expected}); | 564 {'token': expected}); |
563 } else { | 565 } else { |
564 reportErrorFromToken(preceding, | 566 reportErrorFromToken(preceding, |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 memberErrors = memberErrors.tail.prepend(true); | 953 memberErrors = memberErrors.tail.prepend(true); |
952 } | 954 } |
953 reporter.reportErrorMessage(spannable, errorCode, arguments); | 955 reporter.reportErrorMessage(spannable, errorCode, arguments); |
954 } | 956 } |
955 | 957 |
956 void reportErrorFromToken(Token token, MessageKind errorCode, | 958 void reportErrorFromToken(Token token, MessageKind errorCode, |
957 [Map arguments = const {}]) { | 959 [Map arguments = const {}]) { |
958 reportError(reporter.spanFromToken(token), errorCode, arguments); | 960 reportError(reporter.spanFromToken(token), errorCode, arguments); |
959 } | 961 } |
960 } | 962 } |
OLD | NEW |