| 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 import 'dart:collection' show HashSet; | 5 import 'dart:collection' show HashSet; |
| 6 import 'package:args/args.dart' show ArgParser, ArgResults; | 6 import 'package:args/args.dart' show ArgParser, ArgResults; |
| 7 import 'package:analyzer/analyzer.dart' | 7 import 'package:analyzer/analyzer.dart' |
| 8 show | 8 show |
| 9 AnalysisError, | 9 AnalysisError, |
| 10 CompilationUnit, | 10 CompilationUnit, |
| 11 CompileTimeErrorCode, | 11 CompileTimeErrorCode, |
| 12 ErrorSeverity, | 12 ErrorSeverity, |
| 13 StaticWarningCode; | 13 StaticWarningCode; |
| 14 import 'package:analyzer/file_system/file_system.dart' show ResourceProvider; |
| 14 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; | 15 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
| 15 import 'package:analyzer/src/generated/java_engine.dart' show AnalysisException; | 16 import 'package:analyzer/src/generated/java_engine.dart' show AnalysisException; |
| 16 import 'package:analyzer/src/generated/source_io.dart' show Source, SourceKind; | 17 import 'package:analyzer/src/generated/source.dart' show DartUriResolver; |
| 18 import 'package:analyzer/src/generated/source_io.dart' |
| 19 show Source, SourceKind, UriResolver; |
| 17 import 'package:func/func.dart' show Func1; | 20 import 'package:func/func.dart' show Func1; |
| 18 import 'package:path/path.dart' as path; | 21 import 'package:path/path.dart' as path; |
| 19 | 22 |
| 20 import '../analyzer/context.dart' | 23 import '../analyzer/context.dart' |
| 21 show AnalyzerOptions, createAnalysisContextWithSources; | 24 show AnalyzerOptions, createAnalysisContextWithSources; |
| 22 import 'extension_types.dart' show ExtensionTypeSet; | 25 import 'extension_types.dart' show ExtensionTypeSet; |
| 23 import 'code_generator.dart' show CodeGenerator; | 26 import 'code_generator.dart' show CodeGenerator; |
| 24 import 'error_helpers.dart' show errorSeverity, formatError, sortErrors; | 27 import 'error_helpers.dart' show errorSeverity, formatError, sortErrors; |
| 25 | 28 |
| 26 /// Compiles a set of Dart files into a single JavaScript module. | 29 /// Compiles a set of Dart files into a single JavaScript module. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 : context = context, | 51 : context = context, |
| 49 _extensionTypes = new ExtensionTypeSet(context) { | 52 _extensionTypes = new ExtensionTypeSet(context) { |
| 50 if (!context.analysisOptions.strongMode) { | 53 if (!context.analysisOptions.strongMode) { |
| 51 throw new ArgumentError('AnalysisContext must be strong mode'); | 54 throw new ArgumentError('AnalysisContext must be strong mode'); |
| 52 } | 55 } |
| 53 if (!context.sourceFactory.dartSdk.context.analysisOptions.strongMode) { | 56 if (!context.sourceFactory.dartSdk.context.analysisOptions.strongMode) { |
| 54 throw new ArgumentError('AnalysisContext must have strong mode SDK'); | 57 throw new ArgumentError('AnalysisContext must have strong mode SDK'); |
| 55 } | 58 } |
| 56 } | 59 } |
| 57 | 60 |
| 58 ModuleCompiler(AnalyzerOptions analyzerOptions) | 61 ModuleCompiler(AnalyzerOptions analyzerOptions, |
| 59 : this.withContext(createAnalysisContextWithSources(analyzerOptions)); | 62 {DartUriResolver sdkResolver, |
| 63 ResourceProvider resourceProvider, |
| 64 List<UriResolver> fileResolvers}) |
| 65 : this.withContext(createAnalysisContextWithSources(analyzerOptions, |
| 66 sdkResolver: sdkResolver, |
| 67 fileResolvers: fileResolvers, |
| 68 resourceProvider: resourceProvider)); |
| 60 | 69 |
| 61 /// Compiles a single Dart build unit into a JavaScript module. | 70 /// Compiles a single Dart build unit into a JavaScript module. |
| 62 /// | 71 /// |
| 63 /// *Warning* - this may require resolving the entire world. | 72 /// *Warning* - this may require resolving the entire world. |
| 64 /// If that is not desired, the analysis context must be pre-configured using | 73 /// If that is not desired, the analysis context must be pre-configured using |
| 65 /// summaries before calling this method. | 74 /// summaries before calling this method. |
| 66 JSModuleFile compile(BuildUnit unit, CompilerOptions options) { | 75 JSModuleFile compile(BuildUnit unit, CompilerOptions options) { |
| 67 var trees = <CompilationUnit>[]; | 76 var trees = <CompilationUnit>[]; |
| 68 var errors = <AnalysisError>[]; | 77 var errors = <AnalysisError>[]; |
| 69 | 78 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 351 } |
| 343 } | 352 } |
| 344 | 353 |
| 345 /// (Public for tests) the error code used when a part is missing. | 354 /// (Public for tests) the error code used when a part is missing. |
| 346 final missingPartErrorCode = const CompileTimeErrorCode( | 355 final missingPartErrorCode = const CompileTimeErrorCode( |
| 347 'MISSING_PART', 'The part was not supplied as an input to the compiler.'); | 356 'MISSING_PART', 'The part was not supplied as an input to the compiler.'); |
| 348 | 357 |
| 349 /// (Public for tests) the error code used when a part is unused. | 358 /// (Public for tests) the error code used when a part is unused. |
| 350 final unusedPartWarningCode = const StaticWarningCode( | 359 final unusedPartWarningCode = const StaticWarningCode( |
| 351 'UNUSED_PART', 'The part was not used by any libraries being compiled.'); | 360 'UNUSED_PART', 'The part was not used by any libraries being compiled.'); |
| OLD | NEW |