Chromium Code Reviews| Index: pkg/front_end/lib/src/fasta/kernel/utils.dart |
| diff --git a/pkg/front_end/lib/src/fasta/kernel/utils.dart b/pkg/front_end/lib/src/fasta/kernel/utils.dart |
| index 6748f99a01758c06ff26ea507cfd5e6bf3308725..34472e17148cfa518a985f26f4e12f2f33bd8f35 100644 |
| --- a/pkg/front_end/lib/src/fasta/kernel/utils.dart |
| +++ b/pkg/front_end/lib/src/fasta/kernel/utils.dart |
| @@ -2,8 +2,13 @@ |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| +import 'dart:async'; |
| +import 'dart:io'; |
| + |
| +import 'package:front_end/src/fasta/ticker.dart'; |
| import 'package:front_end/src/scanner/token.dart' show Token; |
| import 'package:kernel/ast.dart'; |
| +import 'package:kernel/binary/ast_to_binary.dart'; |
| import 'package:kernel/text/ast_to_text.dart'; |
| /// A null-aware alternative to `token.offset`. If [token] is `null`, returns |
| @@ -21,3 +26,21 @@ void printProgramText(Program program) { |
| } |
| print(sb); |
| } |
| + |
| +Future<Program> writeProgramToFileUri(Ticker ticker, Uri uri, Program program, |
|
Siggi Cherem (dart-lang)
2017/05/17 22:01:35
a couple minor suggestions:
- rename to writeProg
scheglov
2017/05/17 22:16:04
Good suggestions.
Done.
|
| + {bool isFullProgram}) async { |
| + File output = new File.fromUri(uri); |
| + IOSink sink = output.openWrite(); |
| + try { |
| + new BinaryPrinter(sink).writeProgramFile(program); |
| + program.unbindCanonicalNames(); |
| + } finally { |
| + await sink.close(); |
| + } |
| + if (isFullProgram) { |
| + ticker.logMs("Wrote program to ${uri.toFilePath()}"); |
| + } else { |
| + ticker.logMs("Wrote outline to ${uri.toFilePath()}"); |
| + } |
| + return null; |
| +} |