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 @JS() | 4 @JS() |
5 library dev_compiler.web.web_command; | 5 library dev_compiler.web.web_command; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html' show HttpRequest; | 8 import 'dart:html' show HttpRequest; |
9 import 'dart:convert' show BASE64; | 9 import 'dart:convert' show BASE64; |
10 | 10 |
11 import 'package:analyzer/file_system/file_system.dart' show ResourceUriResolver; | 11 import 'package:analyzer/file_system/file_system.dart' show ResourceUriResolver; |
12 import 'package:analyzer/file_system/memory_file_system.dart' | 12 import 'package:analyzer/file_system/memory_file_system.dart' |
13 show MemoryResourceProvider; | 13 show MemoryResourceProvider; |
14 import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl; | 14 import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl; |
15 import 'package:analyzer/src/generated/source.dart' show DartUriResolver; | 15 import 'package:analyzer/src/generated/source.dart' show DartUriResolver; |
16 import 'package:analyzer/src/summary/idl.dart' show PackageBundle; | 16 import 'package:analyzer/src/summary/idl.dart' show PackageBundle; |
17 import 'package:analyzer/src/summary/package_bundle_reader.dart' | 17 import 'package:analyzer/src/summary/package_bundle_reader.dart' |
18 show | 18 show |
19 SummaryDataStore, | 19 SummaryDataStore, |
20 InSummaryPackageUriResolver, | 20 InSummaryUriResolver, |
21 InputPackagesResultProvider, | 21 InputPackagesResultProvider, |
22 InSummarySource; | 22 InSummarySource; |
23 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; | 23 import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk; |
24 | 24 |
25 import 'package:args/command_runner.dart'; | 25 import 'package:args/command_runner.dart'; |
26 | 26 |
27 import 'package:dev_compiler/src/analyzer/context.dart' show AnalyzerOptions; | 27 import 'package:dev_compiler/src/analyzer/context.dart' show AnalyzerOptions; |
28 import 'package:dev_compiler/src/compiler/compiler.dart' | 28 import 'package:dev_compiler/src/compiler/compiler.dart' |
29 show BuildUnit, CompilerOptions, JSModuleFile, ModuleCompiler; | 29 show BuildUnit, CompilerOptions, JSModuleFile, ModuleCompiler; |
30 | 30 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 true, packageBundle, resourceProvider); | 85 true, packageBundle, resourceProvider); |
86 var sdkResolver = new DartUriResolver(webDartSdk); | 86 var sdkResolver = new DartUriResolver(webDartSdk); |
87 | 87 |
88 var summaryDataStore = new SummaryDataStore([]); | 88 var summaryDataStore = new SummaryDataStore([]); |
89 for (var i = 0; i < summaryBytes.length; i++) { | 89 for (var i = 0; i < summaryBytes.length; i++) { |
90 var bytes = summaryBytes[i]; | 90 var bytes = summaryBytes[i]; |
91 var url = summaryUrls[i]; | 91 var url = summaryUrls[i]; |
92 var summaryBundle = new PackageBundle.fromBuffer(bytes); | 92 var summaryBundle = new PackageBundle.fromBuffer(bytes); |
93 summaryDataStore.addBundle(url, summaryBundle); | 93 summaryDataStore.addBundle(url, summaryBundle); |
94 } | 94 } |
95 var summaryResolver = new InSummaryPackageUriResolver(summaryDataStore); | 95 var summaryResolver = new InSummaryUriResolver(resourceProvider, summaryData
Store); |
96 | 96 |
97 var fileResolvers = [summaryResolver, resourceUriResolver]; | 97 var fileResolvers = [summaryResolver, resourceUriResolver]; |
98 | 98 |
99 var compiler = new ModuleCompiler( | 99 var compiler = new ModuleCompiler( |
100 new AnalyzerOptions(dartSdkPath: '/dart-sdk'), | 100 new AnalyzerOptions(dartSdkPath: '/dart-sdk'), |
101 sdkResolver: sdkResolver, | 101 sdkResolver: sdkResolver, |
102 fileResolvers: fileResolvers, | 102 fileResolvers: fileResolvers, |
103 resourceProvider: resourceProvider); | 103 resourceProvider: resourceProvider); |
104 | 104 |
105 (compiler.context as AnalysisContextImpl).resultProvider = | 105 (compiler.context as AnalysisContextImpl).resultProvider = |
(...skipping 27 matching lines...) Expand all Loading... |
133 if (source is InSummarySource) { | 133 if (source is InSummarySource) { |
134 return source.summaryPath.substring(1).replaceAll('.api.ds', ''); | 134 return source.summaryPath.substring(1).replaceAll('.api.ds', ''); |
135 } | 135 } |
136 return source.toString().substring(1).replaceAll('.dart', ''); | 136 return source.toString().substring(1).replaceAll('.dart', ''); |
137 } | 137 } |
138 | 138 |
139 /// Thrown when the input source code has errors. | 139 /// Thrown when the input source code has errors. |
140 class CompileErrorException implements Exception { | 140 class CompileErrorException implements Exception { |
141 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; | 141 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; |
142 } | 142 } |
OLD | NEW |