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

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

Issue 2977013002: Report messages instead of just printing. (Closed)
Patch Set: Update expectations. Created 3 years, 5 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/compiler_context.dart' show CompilerContext;
9 import 'package:front_end/src/fasta/messages.dart'; 10 import 'package:front_end/src/fasta/messages.dart';
10 import 'package:front_end/src/fasta/scanner.dart'; 11 import 'package:front_end/src/fasta/scanner.dart';
11 import 'package:front_end/src/fasta/scanner/io.dart'; 12 import 'package:front_end/src/fasta/scanner/io.dart';
13 import 'package:front_end/src/fasta/severity.dart' show Severity;
12 import 'package:front_end/src/scanner/token.dart' as analyzer; 14 import 'package:front_end/src/scanner/token.dart' as analyzer;
13 15
14 /// Implementation of [Instrumentation] which checks property/value pairs 16 /// Implementation of [Instrumentation] which checks property/value pairs
15 /// against expectations encoded in source files using "/*@...*/" comments. 17 /// against expectations encoded in source files using "/*@...*/" comments.
16 class ValidatingInstrumentation implements Instrumentation { 18 class ValidatingInstrumentation implements Instrumentation {
17 static final _ESCAPE_SEQUENCE = new RegExp(r'\\(.)'); 19 static final _ESCAPE_SEQUENCE = new RegExp(r'\\(.)');
18 20
19 /// Map from feature names to the property names they are short for. 21 /// Map from feature names to the property names they are short for.
20 static const _FEATURES = const { 22 static const _FEATURES = const {
21 'inference': const [ 23 'inference': const [
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 String _escape(String s) { 195 String _escape(String s) {
194 s = s.replaceAll(r'\', r'\\'); 196 s = s.replaceAll(r'\', r'\\');
195 if (s.endsWith('/')) { 197 if (s.endsWith('/')) {
196 s = '$s '; 198 s = '$s ';
197 } 199 }
198 return s.replaceAll('/*', r'/\*').replaceAll('*/', r'*\/'); 200 return s.replaceAll('/*', r'/\*').replaceAll('*/', r'*\/');
199 } 201 }
200 202
201 String _formatProblem( 203 String _formatProblem(
202 Uri uri, int offset, String desc, StackTrace stackTrace) { 204 Uri uri, int offset, String desc, StackTrace stackTrace) {
203 return deprecated_format( 205 return CompilerContext.current.format(
204 uri, offset, '$desc${stackTrace == null ? '' : '\n$stackTrace'}'); 206 templateUnspecified
207 .withArguments('$desc${stackTrace == null ? '' : '\n$stackTrace'}')
208 .withLocation(uri, offset),
209 Severity.internalProblem);
205 } 210 }
206 211
207 String _makeExpectationComment(String property, InstrumentationValue value) { 212 String _makeExpectationComment(String property, InstrumentationValue value) {
208 return '/*@$property=${_escape(value.toString())}*/'; 213 return '/*@$property=${_escape(value.toString())}*/';
209 } 214 }
210 215
211 void _problem(Uri uri, int offset, String desc, _Fix fix) { 216 void _problem(Uri uri, int offset, String desc, _Fix fix) {
212 _problems.add(_formatProblem(uri, offset, desc, null)); 217 _problems.add(_formatProblem(uri, offset, desc, null));
213 _fixes.putIfAbsent(uri, () => []).add(fix); 218 _fixes.putIfAbsent(uri, () => []).add(fix);
214 } 219 }
(...skipping 26 matching lines...) Expand all
241 this.property, this.value, this.commentOffset, this.commentLength); 246 this.property, this.value, this.commentOffset, this.commentLength);
242 } 247 }
243 248
244 class _Fix { 249 class _Fix {
245 final int offset; 250 final int offset;
246 final int length; 251 final int length;
247 final String replacement; 252 final String replacement;
248 253
249 _Fix(this.offset, this.length, this.replacement); 254 _Fix(this.offset, this.length, this.replacement);
250 } 255 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698