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

Side by Side Diff: pkg/compiler/lib/src/native/resolver.dart

Issue 2839403004: change fasta.Token.isIdentifier() from method to getter (Closed)
Patch Set: rebase Created 3 years, 7 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/parser/parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'package:front_end/src/fasta/scanner.dart' 5 import 'package:front_end/src/fasta/scanner.dart'
6 show BeginGroupToken, StringToken, Token; 6 show BeginGroupToken, StringToken, Token;
7 import 'package:front_end/src/fasta/scanner.dart' as Tokens show EOF_TOKEN; 7 import 'package:front_end/src/fasta/scanner.dart' as Tokens show EOF_TOKEN;
8 8
9 import '../common.dart'; 9 import '../common.dart';
10 import '../common_elements.dart' show CommonElements, ElementEnvironment; 10 import '../common_elements.dart' show CommonElements, ElementEnvironment;
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // token = token.next; 521 // token = token.next;
522 // if (token.stringValue == '>') return token.next; 522 // if (token.stringValue == '>') return token.next;
523 // if (token.stringValue == '<') return skipTypeParameters(token); 523 // if (token.stringValue == '<') return skipTypeParameters(token);
524 //} 524 //}
525 } 525 }
526 526
527 String scanForExtendsName(Token token) { 527 String scanForExtendsName(Token token) {
528 if (token.stringValue == 'abstract') token = token.next; 528 if (token.stringValue == 'abstract') token = token.next;
529 if (token.stringValue != 'class') return null; 529 if (token.stringValue != 'class') return null;
530 token = token.next; 530 token = token.next;
531 if (!token.isIdentifier()) return null; 531 if (!token.isIdentifier) return null;
532 token = token.next; 532 token = token.next;
533 // class F<X extends B<X>> extends ... 533 // class F<X extends B<X>> extends ...
534 if (token.stringValue == '<') { 534 if (token.stringValue == '<') {
535 token = skipTypeParameters(token); 535 token = skipTypeParameters(token);
536 } 536 }
537 if (token.stringValue != 'extends') return null; 537 if (token.stringValue != 'extends') return null;
538 token = token.next; 538 token = token.next;
539 Token id = token; 539 Token id = token;
540 while (token.kind != Tokens.EOF_TOKEN) { 540 while (token.kind != Tokens.EOF_TOKEN) {
541 token = token.next; 541 token = token.next;
542 if (token.stringValue != '.') break; 542 if (token.stringValue != '.') break;
543 token = token.next; 543 token = token.next;
544 if (!token.isIdentifier()) return null; 544 if (!token.isIdentifier) return null;
545 id = token; 545 id = token;
546 } 546 }
547 // Should be at '{', 'with', 'implements', '<' or 'native'. 547 // Should be at '{', 'with', 'implements', '<' or 'native'.
548 return id.lexeme; 548 return id.lexeme;
549 } 549 }
550 550
551 return _reporter.withCurrentElement(classElement, () { 551 return _reporter.withCurrentElement(classElement, () {
552 return scanForExtendsName(classElement.position); 552 return scanForExtendsName(classElement.position);
553 }); 553 });
554 } 554 }
555 } 555 }
556 556
557 /// Extracts the name if [value] is a named annotation based on 557 /// Extracts the name if [value] is a named annotation based on
558 /// [annotationClass], otherwise returns `null`. 558 /// [annotationClass], otherwise returns `null`.
559 String readAnnotationName( 559 String readAnnotationName(
560 Spannable spannable, ConstantValue value, ClassEntity annotationClass) { 560 Spannable spannable, ConstantValue value, ClassEntity annotationClass) {
561 if (!value.isConstructedObject) return null; 561 if (!value.isConstructedObject) return null;
562 ConstructedConstantValue constructedObject = value; 562 ConstructedConstantValue constructedObject = value;
563 if (constructedObject.type.element != annotationClass) return null; 563 if (constructedObject.type.element != annotationClass) return null;
564 564
565 Iterable<ConstantValue> fields = constructedObject.fields.values; 565 Iterable<ConstantValue> fields = constructedObject.fields.values;
566 // TODO(sra): Better validation of the constant. 566 // TODO(sra): Better validation of the constant.
567 if (fields.length != 1 || fields.single is! StringConstantValue) { 567 if (fields.length != 1 || fields.single is! StringConstantValue) {
568 throw new SpannableAssertionFailure( 568 throw new SpannableAssertionFailure(
569 spannable, 'Annotations needs one string: ${value.toStructuredText()}'); 569 spannable, 'Annotations needs one string: ${value.toStructuredText()}');
570 } 570 }
571 StringConstantValue specStringConstant = fields.single; 571 StringConstantValue specStringConstant = fields.single;
572 return specStringConstant.toDartString().slowToString(); 572 return specStringConstant.toDartString().slowToString();
573 } 573 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/parser/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698