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

Side by Side Diff: dart/pkg/compiler/samples/jsonify/jsonify.dart

Issue 838773002: Throw ArgumentError if packageRoot is null. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « dart/pkg/compiler/lib/src/warnings.dart ('k') | dart/tests/compiler/dart2js/mirrors_test.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) 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 import 'dart:io'; 5 import 'dart:io';
6 import 'dart:convert'; 6 import 'dart:convert';
7 7
8 import 'dart:mirrors'; 8 import 'dart:mirrors';
9 9
10 import 'package:_internal/libraries.dart' 10 import 'package:_internal/libraries.dart'
(...skipping 28 matching lines...) Expand all
39 handler = new FormattingDiagnosticHandler() 39 handler = new FormattingDiagnosticHandler()
40 ..throwOnError = true; 40 ..throwOnError = true;
41 41
42 outputUri = 42 outputUri =
43 handler.provider.cwd.resolve(nativeToUriPath(arguments.first)); 43 handler.provider.cwd.resolve(nativeToUriPath(arguments.first));
44 output = new File(arguments.first).openSync(mode: FileMode.WRITE); 44 output = new File(arguments.first).openSync(mode: FileMode.WRITE);
45 45
46 Uri myLocation = 46 Uri myLocation =
47 handler.provider.cwd.resolveUri(Platform.script); 47 handler.provider.cwd.resolveUri(Platform.script);
48 48
49 sdkRoot = myLocation.resolve(SDK_ROOT).resolve('../'); 49 Uri packageRoot =
50 handler.provider.cwd.resolve(Platform.packageRoot);
Johnni Winther 2015/01/08 08:16:15 You need to ensure that the URI path ends with a /
ahe 2015/01/08 08:34:43 This isn't a super user friendly tool. For example
Johnni Winther 2015/01/08 09:40:42 The problem is really with Platform.packageRoot wh
51
52 Uri libraryRoot = myLocation.resolve(SDK_ROOT);
53
54 sdkRoot = libraryRoot.resolve('../');
50 55
51 // Get the names of public dart2js libraries. 56 // Get the names of public dart2js libraries.
52 Iterable<String> names = LIBRARIES.keys.where(isPublicDart2jsLibrary); 57 Iterable<String> names = LIBRARIES.keys.where(isPublicDart2jsLibrary);
53 58
54 // Turn the names into uris by prepending dart: to them. 59 // Turn the names into uris by prepending dart: to them.
55 List<Uri> uris = names.map((String name) => Uri.parse('dart:$name')).toList(); 60 List<Uri> uris = names.map((String name) => Uri.parse('dart:$name')).toList();
56 61
57 analyze(uris, myLocation.resolve(SDK_ROOT), null, handler.provider, handler) 62 analyze(uris, libraryRoot, packageRoot, handler.provider, handler)
58 .then(jsonify); 63 .then(jsonify);
59 } 64 }
60 65
61 jsonify(MirrorSystem mirrors) { 66 jsonify(MirrorSystem mirrors) {
62 var map = <String, String>{}; 67 var map = <String, String>{};
63 68
64 mirrors.libraries.forEach((_, LibraryMirror library) { 69 mirrors.libraries.forEach((_, LibraryMirror library) {
65 BackDoor.compilationUnitsOf(library).forEach((compilationUnit) { 70 BackDoor.compilationUnitsOf(library).forEach((compilationUnit) {
66 Uri uri = compilationUnit.uri; 71 Uri uri = compilationUnit.uri;
67 String filename = relativize(sdkRoot, uri, false); 72 String filename = relativize(sdkRoot, uri, false);
(...skipping 24 matching lines...) Expand all
92 // This file is generated by jsonify.dart. 97 // This file is generated by jsonify.dart.
93 98
94 library dart.sdk_sources; 99 library dart.sdk_sources;
95 100
96 const Map<String, String> SDK_SOURCES = const <String, String>'''); 101 const Map<String, String> SDK_SOURCES = const <String, String>''');
97 output.writeStringSync(JSON.encode(map).replaceAll(r'$', r'\$')); 102 output.writeStringSync(JSON.encode(map).replaceAll(r'$', r'\$'));
98 output.writeStringSync(';\n'); 103 output.writeStringSync(';\n');
99 } 104 }
100 output.closeSync(); 105 output.closeSync();
101 } 106 }
OLDNEW
« no previous file with comments | « dart/pkg/compiler/lib/src/warnings.dart ('k') | dart/tests/compiler/dart2js/mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698