| 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 'package:args/args.dart' show ArgParser, ArgResults; | 5 import 'package:args/args.dart' show ArgParser, ArgResults; |
| 6 import 'package:analyzer/analyzer.dart' | 6 import 'package:analyzer/analyzer.dart' |
| 7 show AnalysisError, CompilationUnit, ErrorSeverity; | 7 show AnalysisError, CompilationUnit, ErrorSeverity; |
| 8 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; | 8 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
| 9 import 'package:analyzer/src/generated/java_engine.dart' show AnalysisException; | 9 import 'package:analyzer/src/generated/java_engine.dart' show AnalysisException; |
| 10 import 'package:analyzer/src/generated/source_io.dart' show Source, SourceKind; | 10 import 'package:analyzer/src/generated/source_io.dart' show Source, SourceKind; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 /// | 47 /// |
| 48 /// *Warning* - this may require resolving the entire world. | 48 /// *Warning* - this may require resolving the entire world. |
| 49 /// If that is not desired, the analysis context must be pre-configured using | 49 /// If that is not desired, the analysis context must be pre-configured using |
| 50 /// summaries before calling this method. | 50 /// summaries before calling this method. |
| 51 JSModuleFile compile(BuildUnit unit, CompilerOptions options) { | 51 JSModuleFile compile(BuildUnit unit, CompilerOptions options) { |
| 52 var trees = <CompilationUnit>[]; | 52 var trees = <CompilationUnit>[]; |
| 53 var errors = <AnalysisError>[]; | 53 var errors = <AnalysisError>[]; |
| 54 | 54 |
| 55 for (var sourcePath in unit.sources) { | 55 for (var sourcePath in unit.sources) { |
| 56 String sourceUri = sourcePath; | 56 String sourceUri = sourcePath; |
| 57 if (path.isRelative(sourcePath)) { | 57 if (path.isAbsolute(sourcePath)) { |
| 58 sourceUri = path.absolute(sourceUri); | 58 sourceUri = path.toUri(sourcePath).toString(); |
| 59 } | 59 } |
| 60 sourceUri = path.toUri(sourceUri).toString(); | |
| 61 Source source = context.sourceFactory.forUri(sourceUri); | 60 Source source = context.sourceFactory.forUri(sourceUri); |
| 62 if (source == null) { | 61 if (source == null) { |
| 63 throw new AnalysisException('could not create a source for $sourcePath.' | 62 throw new AnalysisException('could not create a source for $sourcePath.' |
| 64 ' The file name is in the wrong format or was not found.'); | 63 ' The file name is in the wrong format or was not found.'); |
| 65 } | 64 } |
| 66 | 65 |
| 67 // Ignore parts. They need to be handled in the context of their library. | 66 // Ignore parts. They need to be handled in the context of their library. |
| 68 if (context.getKindOf(source) == SourceKind.PART) { | 67 if (context.getKindOf(source) == SourceKind.PART) { |
| 69 continue; | 68 continue; |
| 70 } | 69 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 259 |
| 261 var map = new Map.from(this.sourceMap); | 260 var map = new Map.from(this.sourceMap); |
| 262 List list = new List.from(map['sources']); | 261 List list = new List.from(map['sources']); |
| 263 map['sources'] = list; | 262 map['sources'] = list; |
| 264 for (int i = 0; i < list.length; i++) { | 263 for (int i = 0; i < list.length; i++) { |
| 265 list[i] = path.relative(list[i], from: dir); | 264 list[i] = path.relative(list[i], from: dir); |
| 266 } | 265 } |
| 267 return map; | 266 return map; |
| 268 } | 267 } |
| 269 } | 268 } |
| OLD | NEW |