OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library dart2js.test.memory_compiler; | 5 library dart2js.test.memory_compiler; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:compiler/compiler.dart' show | 9 import 'package:compiler/compiler.dart' show |
10 DiagnosticHandler; | 10 DiagnosticHandler; |
11 import 'package:compiler/compiler_new.dart' show | 11 import 'package:compiler/compiler_new.dart' show |
12 CompilationResult, | 12 CompilationResult, |
13 CompilerDiagnostics, | 13 CompilerDiagnostics, |
14 CompilerOutput, | 14 CompilerOutput, |
15 Diagnostic, | 15 Diagnostic, |
16 PackagesDiscoveryProvider; | 16 PackagesDiscoveryProvider; |
17 import 'package:compiler/src/diagnostics/messages.dart' show | 17 import 'package:compiler/src/diagnostics/messages.dart' show |
18 Message; | 18 Message; |
19 import 'package:compiler/src/mirrors/source_mirrors.dart'; | |
20 import 'package:compiler/src/mirrors/analyze.dart'; | |
21 import 'package:compiler/src/null_compiler_output.dart' show | 19 import 'package:compiler/src/null_compiler_output.dart' show |
22 NullCompilerOutput; | 20 NullCompilerOutput; |
23 import 'package:compiler/src/library_loader.dart' show | 21 import 'package:compiler/src/library_loader.dart' show |
24 LoadedLibraries; | 22 LoadedLibraries; |
25 import 'package:compiler/src/options.dart' show | 23 import 'package:compiler/src/options.dart' show |
26 CompilerOptions; | 24 CompilerOptions; |
27 | 25 |
28 import 'memory_source_file_helper.dart'; | 26 import 'memory_source_file_helper.dart'; |
29 | 27 |
30 export 'output_collector.dart'; | 28 export 'output_collector.dart'; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) { | 250 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) { |
253 diagnosticHandler(uri, begin, end, message, kind); | 251 diagnosticHandler(uri, begin, end, message, kind); |
254 formattingHandler(uri, begin, end, message, kind); | 252 formattingHandler(uri, begin, end, message, kind); |
255 }; | 253 }; |
256 } | 254 } |
257 } else if (diagnosticHandler == null) { | 255 } else if (diagnosticHandler == null) { |
258 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {}; | 256 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {}; |
259 } | 257 } |
260 return handler; | 258 return handler; |
261 } | 259 } |
262 | |
263 Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles, | |
264 {DiagnosticHandler diagnosticHandler, | |
265 List<String> options: const [], | |
266 bool showDiagnostics: true}) { | |
267 Uri libraryRoot = Uri.base.resolve('sdk/'); | |
268 Uri packageRoot = Uri.base.resolve(Platform.packageRoot); | |
269 | |
270 var provider = new MemorySourceFileProvider(memorySourceFiles); | |
271 var handler = | |
272 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); | |
273 | |
274 List<Uri> libraries = <Uri>[]; | |
275 memorySourceFiles.forEach((String path, _) { | |
276 libraries.add(new Uri(scheme: 'memory', path: path)); | |
277 }); | |
278 | |
279 return analyze(libraries, libraryRoot, packageRoot, | |
280 provider, handler, options); | |
281 } | |
OLD | NEW |