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

Side by Side Diff: pkg/front_end/lib/src/fasta/testing/validating_instrumentation.dart

Issue 2872433005: more work aligning fasta.Token with analyzer.Token (Closed)
Patch Set: 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
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 import 'dart:async'; 4 import 'dart:async';
5 import 'dart:convert'; 5 import 'dart:convert';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import 'package:front_end/src/base/instrumentation.dart'; 8 import 'package:front_end/src/base/instrumentation.dart';
9 import 'package:front_end/src/fasta/messages.dart'; 9 import 'package:front_end/src/fasta/messages.dart';
10 import 'package:front_end/src/fasta/scanner.dart'; 10 import 'package:front_end/src/fasta/scanner.dart';
11 import 'package:front_end/src/fasta/scanner/io.dart'; 11 import 'package:front_end/src/fasta/scanner/io.dart';
12 import 'package:front_end/src/scanner/token.dart' as analyzer;
12 13
13 /// Implementation of [Instrumentation] which checks property/value pairs 14 /// Implementation of [Instrumentation] which checks property/value pairs
14 /// against expectations encoded in source files using "/*@...*/" comments. 15 /// against expectations encoded in source files using "/*@...*/" comments.
15 class ValidatingInstrumentation implements Instrumentation { 16 class ValidatingInstrumentation implements Instrumentation {
16 static final _ESCAPE_SEQUENCE = new RegExp(r'\\(.)'); 17 static final _ESCAPE_SEQUENCE = new RegExp(r'\\(.)');
17 18
18 /// Map from feature names to the property names they are short for. 19 /// Map from feature names to the property names they are short for.
19 static const _FEATURES = const { 20 static const _FEATURES = const {
20 'inference': const [ 21 'inference': const [
21 'topType', 22 'topType',
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 93
93 /// Loads expectations from the source file located at [uri]. 94 /// Loads expectations from the source file located at [uri].
94 /// 95 ///
95 /// Should be called before [finish]. 96 /// Should be called before [finish].
96 Future<Null> loadExpectations(Uri uri) async { 97 Future<Null> loadExpectations(Uri uri) async {
97 var bytes = await readBytesFromFile(uri); 98 var bytes = await readBytesFromFile(uri);
98 var expectations = _unsatisfiedExpectations.putIfAbsent(uri, () => {}); 99 var expectations = _unsatisfiedExpectations.putIfAbsent(uri, () => {});
99 var testedFeaturesState = _testedFeaturesState.putIfAbsent(uri, () => {}); 100 var testedFeaturesState = _testedFeaturesState.putIfAbsent(uri, () => {});
100 ScannerResult result = scan(bytes, includeComments: true); 101 ScannerResult result = scan(bytes, includeComments: true);
101 for (Token token = result.tokens; !token.isEof; token = token.next) { 102 for (Token token = result.tokens; !token.isEof; token = token.next) {
102 for (Token commentToken = token.precedingCommentTokens; 103 for (analyzer.Token commentToken = token.precedingComments;
103 commentToken != null; 104 commentToken != null;
104 commentToken = commentToken.next) { 105 commentToken = commentToken.next) {
105 String lexeme = commentToken.lexeme; 106 String lexeme = commentToken.lexeme;
106 if (lexeme.startsWith('/*@') && lexeme.endsWith('*/')) { 107 if (lexeme.startsWith('/*@') && lexeme.endsWith('*/')) {
107 var expectation = lexeme.substring(3, lexeme.length - 2); 108 var expectation = lexeme.substring(3, lexeme.length - 2);
108 var equals = expectation.indexOf('='); 109 var equals = expectation.indexOf('=');
109 String property; 110 String property;
110 String value; 111 String value;
111 if (equals == -1) { 112 if (equals == -1) {
112 property = expectation; 113 property = expectation;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 this.property, this.value, this.commentOffset, this.commentLength); 222 this.property, this.value, this.commentOffset, this.commentLength);
222 } 223 }
223 224
224 class _Fix { 225 class _Fix {
225 final int offset; 226 final int offset;
226 final int length; 227 final int length;
227 final String replacement; 228 final String replacement;
228 229
229 _Fix(this.offset, this.length, this.replacement); 230 _Fix(this.offset, this.length, this.replacement);
230 } 231 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698