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

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

Issue 2919623002: Implement type inference for PropertySet. (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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/testing/validating_instrumentation.dart
diff --git a/pkg/front_end/lib/src/fasta/testing/validating_instrumentation.dart b/pkg/front_end/lib/src/fasta/testing/validating_instrumentation.dart
index c813ab8dd418d250dbaf3cbde916e66b31c3cfce..60311fc27e3c0ffa6c2c10f49c04a50e675e9b8d 100644
--- a/pkg/front_end/lib/src/fasta/testing/validating_instrumentation.dart
+++ b/pkg/front_end/lib/src/fasta/testing/validating_instrumentation.dart
@@ -77,17 +77,25 @@ class ValidatingInstrumentation implements Instrumentation {
/// Updates the source file at [uri] based on the actual property/value
/// pairs that were observed.
- Future<Null> fixSource(Uri uri) async {
+ Future<Null> fixSource(Uri uri, bool offsetsCountCharacters) async {
var fixes = _fixes[uri];
if (fixes == null) return;
File file = new File.fromUri(uri);
var bytes = (await file.readAsBytes()).toList();
+ int convertOffset(int offset) {
+ if (offsetsCountCharacters) {
+ return UTF8.encode(UTF8.decode(bytes).substring(0, offset)).length;
+ } else {
+ return offset;
+ }
+ }
+
// Apply the fixes in reverse order so that offsets don't need to be
// adjusted after each fix.
fixes.sort((a, b) => b.offset.compareTo(a.offset));
for (var fix in fixes) {
- bytes.replaceRange(
- fix.offset, fix.offset + fix.length, UTF8.encode(fix.replacement));
+ bytes.replaceRange(convertOffset(fix.offset),
+ convertOffset(fix.offset + fix.length), UTF8.encode(fix.replacement));
}
await file.writeAsBytes(bytes);
}

Powered by Google App Engine
This is Rietveld 408576698