Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: pkg/compiler/lib/src/parser/element_listener.dart

Issue 3003263002: add support for native methods in class
Patch Set: update listeners Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 message.code != codes.codeUnterminatedComment && 520 message.code != codes.codeUnterminatedComment &&
521 message.code != codes.codeUnterminatedString) { 521 message.code != codes.codeUnterminatedString) {
522 throw new ParserError.fromTokens(token, token, message); 522 throw new ParserError.fromTokens(token, token, message);
523 } else { 523 } else {
524 return next; 524 return next;
525 } 525 }
526 } 526 }
527 527
528 @override 528 @override
529 void handleRecoverableError(Token token, Message message) { 529 void handleRecoverableError(Token token, Message message) {
530 if (message == codes.messageNativeClauseShouldBeAnnotation) return;
530 handleError(token, message); 531 handleError(token, message);
531 } 532 }
532 533
533 @override 534 @override
534 void handleInvalidExpression(Token token) { 535 void handleInvalidExpression(Token token) {
535 pushNode(new ErrorExpression(token)); 536 pushNode(new ErrorExpression(token));
536 } 537 }
537 538
538 @override 539 @override
539 void handleInvalidFunctionBody(Token token) { 540 void handleInvalidFunctionBody(Token token) {
540 lastErrorWasNativeFunctionBody = false; 541 lastErrorWasNativeFunctionBody = false;
541 } 542 }
542 543
543 @override 544 @override
544 void handleInvalidTypeReference(Token token) { 545 void handleInvalidTypeReference(Token token) {
545 pushNode(null); 546 pushNode(null);
546 } 547 }
547 548
548 Token handleError(Token token, Message message) { 549 Token handleError(Token token, Message message) {
549 MessageKind errorCode; 550 MessageKind errorCode;
550 Map<String, dynamic> arguments = message.arguments; 551 Map<String, dynamic> arguments = message.arguments;
551 552
552 switch (message.code.dart2jsCode) { 553 switch (message.code.dart2jsCode) {
553 case "MISSING_TOKEN_BEFORE_THIS": 554 case "MISSING_TOKEN_BEFORE_THIS":
554 String expected = arguments["string"]; 555 String expected = arguments["string"];
555 // TODO(danrubel) This functionality is being replaced by 556 // TODO(danrubel): This functionality is being replaced by
556 // the parser's ensureSemicolon method. 557 // the parser's ensureSemicolon method.
557 if (identical(";", expected)) { 558 if (identical(";", expected)) {
558 // When a semicolon is missing, it often leads to an error on the 559 // When a semicolon is missing, it often leads to an error on the
559 // following line. So we try to find the token preceding the semicolon 560 // following line. So we try to find the token preceding the semicolon
560 // and report that something is missing *after* it. 561 // and report that something is missing *after* it.
561 Token preceding = findPrecedingToken(token); 562 Token preceding = findPrecedingToken(token);
562 if (preceding == token) { 563 if (preceding == token) {
563 reportErrorFromToken(token, MessageKind.MISSING_TOKEN_BEFORE_THIS, 564 reportErrorFromToken(token, MessageKind.MISSING_TOKEN_BEFORE_THIS,
564 {'token': expected}); 565 {'token': expected});
565 } else { 566 } else {
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 memberErrors = memberErrors.tail.prepend(true); 954 memberErrors = memberErrors.tail.prepend(true);
954 } 955 }
955 reporter.reportErrorMessage(spannable, errorCode, arguments); 956 reporter.reportErrorMessage(spannable, errorCode, arguments);
956 } 957 }
957 958
958 void reportErrorFromToken(Token token, MessageKind errorCode, 959 void reportErrorFromToken(Token token, MessageKind errorCode,
959 [Map arguments = const {}]) { 960 [Map arguments = const {}]) {
960 reportError(reporter.spanFromToken(token), errorCode, arguments); 961 reportError(reporter.spanFromToken(token), errorCode, arguments);
961 } 962 }
962 } 963 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698