Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: lib/src/compiler/compiler.dart

Issue 1886393003: add command test, fix relative paths (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/command/hello.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 /// Compiles a single Dart build unit into a JavaScript module. 46 /// Compiles a single Dart build unit into a JavaScript module.
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 var sourceUri = Uri.parse(sourcePath);
57 if (path.isAbsolute(sourcePath)) { 57 if (sourceUri.scheme == '') {
58 sourceUri = path.toUri(sourcePath).toString(); 58 sourceUri = path.toUri(path.absolute(sourcePath));
59 } 59 }
60 Source source = context.sourceFactory.forUri(sourceUri); 60 Source source = context.sourceFactory.forUri(sourceUri.toString());
61 if (source == null) { 61 if (source == null) {
62 throw new AnalysisException('could not create a source for $sourcePath.' 62 throw new AnalysisException('could not create a source for $sourcePath.'
63 ' 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.');
64 } 64 }
65 65
66 // 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.
67 if (context.getKindOf(source) == SourceKind.PART) { 67 if (context.getKindOf(source) == SourceKind.PART) {
68 continue; 68 continue;
69 } 69 }
70 70
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 var map = new Map.from(this.sourceMap); 260 var map = new Map.from(this.sourceMap);
261 List list = new List.from(map['sources']); 261 List list = new List.from(map['sources']);
262 map['sources'] = list; 262 map['sources'] = list;
263 for (int i = 0; i < list.length; i++) { 263 for (int i = 0; i < list.length; i++) {
264 list[i] = path.relative(list[i], from: dir); 264 list[i] = path.relative(list[i], from: dir);
265 } 265 }
266 return map; 266 return map;
267 } 267 }
268 } 268 }
OLDNEW
« no previous file with comments | « no previous file | test/command/hello.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698