| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 analyzer_impl; | 5 library analyzer_impl; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| 11 import 'package:analyzer/file_system/physical_file_system.dart'; | 11 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 12 import 'package:analyzer/source/package_map_provider.dart'; | 12 import 'package:analyzer/source/package_map_provider.dart'; |
| 13 import 'package:analyzer/source/package_map_resolver.dart'; | 13 import 'package:analyzer/source/package_map_resolver.dart'; |
| 14 import 'package:analyzer/source/pub_package_map_provider.dart'; | 14 import 'package:analyzer/source/pub_package_map_provider.dart'; |
| 15 import 'package:analyzer/src/error_formatter.dart'; | 15 import 'package:analyzer/src/error_formatter.dart'; |
| 16 import 'package:analyzer/src/generated/java_core.dart' show JavaSystem; | 16 import 'package:analyzer/src/generated/java_core.dart' show JavaSystem; |
| 17 import 'package:analyzer/src/generated/java_engine.dart'; | 17 import 'package:analyzer/src/generated/java_engine.dart'; |
| 18 | 18 |
| 19 import '../options.dart'; | 19 import '../options.dart'; |
| 20 import 'generated/constant.dart'; | 20 import 'generated/constant.dart'; |
| 21 import 'generated/element.dart'; | 21 import 'generated/element.dart'; |
| 22 import 'generated/engine.dart'; | 22 import 'generated/engine.dart'; |
| 23 import 'generated/error.dart'; | 23 import 'generated/error.dart'; |
| 24 import 'generated/java_io.dart'; | 24 import 'generated/java_io.dart'; |
| 25 import 'generated/sdk_io.dart'; | 25 import 'generated/sdk_io.dart'; |
| 26 import 'generated/source_io.dart'; | 26 import 'generated/source_io.dart'; |
| 27 import 'package:analyzer/file_system/file_system.dart'; |
| 27 | 28 |
| 28 DirectoryBasedDartSdk sdk; | 29 DirectoryBasedDartSdk sdk; |
| 29 | 30 |
| 30 /** | 31 /** |
| 31 * The maximum number of sources for which AST structures should be kept in the
cache. | 32 * The maximum number of sources for which AST structures should be kept in the
cache. |
| 32 */ | 33 */ |
| 33 const int _MAX_CACHE_SIZE = 512; | 34 const int _MAX_CACHE_SIZE = 512; |
| 34 | 35 |
| 35 /// Analyzes single library [File]. | 36 /// Analyzes single library [File]. |
| 36 class AnalyzerImpl { | 37 class AnalyzerImpl { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 { | 145 { |
| 145 JavaFile packageDirectory; | 146 JavaFile packageDirectory; |
| 146 if (options.packageRootPath != null) { | 147 if (options.packageRootPath != null) { |
| 147 packageDirectory = new JavaFile(options.packageRootPath); | 148 packageDirectory = new JavaFile(options.packageRootPath); |
| 148 resolvers.add(new PackageUriResolver([packageDirectory])); | 149 resolvers.add(new PackageUriResolver([packageDirectory])); |
| 149 } else { | 150 } else { |
| 150 PubPackageMapProvider pubPackageMapProvider = | 151 PubPackageMapProvider pubPackageMapProvider = |
| 151 new PubPackageMapProvider(PhysicalResourceProvider.INSTANCE, sdk); | 152 new PubPackageMapProvider(PhysicalResourceProvider.INSTANCE, sdk); |
| 152 PackageMapInfo packageMapInfo = pubPackageMapProvider.computePackageMap( | 153 PackageMapInfo packageMapInfo = pubPackageMapProvider.computePackageMap( |
| 153 PhysicalResourceProvider.INSTANCE.getResource('.')); | 154 PhysicalResourceProvider.INSTANCE.getResource('.')); |
| 154 resolvers.add( | 155 Map<String, List<Folder>> packageMap = packageMapInfo.packageMap; |
| 155 new PackageMapUriResolver( | 156 if (packageMap != null) { |
| 156 PhysicalResourceProvider.INSTANCE, | 157 resolvers.add( |
| 157 packageMapInfo.packageMap)); | 158 new PackageMapUriResolver( |
| 159 PhysicalResourceProvider.INSTANCE, |
| 160 packageMap)); |
| 161 } |
| 158 } | 162 } |
| 159 } | 163 } |
| 160 sourceFactory = new SourceFactory(resolvers); | 164 sourceFactory = new SourceFactory(resolvers); |
| 161 context = AnalysisEngine.instance.createAnalysisContext(); | 165 context = AnalysisEngine.instance.createAnalysisContext(); |
| 162 context.sourceFactory = sourceFactory; | 166 context.sourceFactory = sourceFactory; |
| 163 Map<String, String> definedVariables = options.definedVariables; | 167 Map<String, String> definedVariables = options.definedVariables; |
| 164 if (!definedVariables.isEmpty) { | 168 if (!definedVariables.isEmpty) { |
| 165 DeclaredVariables declaredVariables = context.declaredVariables; | 169 DeclaredVariables declaredVariables = context.declaredVariables; |
| 166 definedVariables.forEach((String variableName, String value) { | 170 definedVariables.forEach((String variableName, String value) { |
| 167 declaredVariables.define(variableName, value); | 171 declaredVariables.define(variableName, value); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 } | 447 } |
| 444 } | 448 } |
| 445 | 449 |
| 446 @override | 450 @override |
| 447 void logInformation2(String message, Object exception) { | 451 void logInformation2(String message, Object exception) { |
| 448 if (log) { | 452 if (log) { |
| 449 stdout.writeln(message); | 453 stdout.writeln(message); |
| 450 } | 454 } |
| 451 } | 455 } |
| 452 } | 456 } |
| OLD | NEW |