| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * This library serializes the Dart2Js AST into a compact and easy to use | 6 * This library serializes the Dart2Js AST into a compact and easy to use |
| 7 * [Element] tree useful for code exploration tools such as DartDoc. | 7 * [Element] tree useful for code exploration tools such as DartDoc. |
| 8 */ | 8 */ |
| 9 library universe_serializer; | 9 library universe_serializer; |
| 10 | 10 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 206 |
| 207 // Find either pkg/ or packages/ | 207 // Find either pkg/ or packages/ |
| 208 var pkgDir = parts.lastIndexOf('pkg'); | 208 var pkgDir = parts.lastIndexOf('pkg'); |
| 209 var packageDir = parts.lastIndexOf('packages'); | 209 var packageDir = parts.lastIndexOf('packages'); |
| 210 | 210 |
| 211 if (pkgDir >= 0) { | 211 if (pkgDir >= 0) { |
| 212 packageDir = pkgDir; | 212 packageDir = pkgDir; |
| 213 } | 213 } |
| 214 | 214 |
| 215 var libDir = parts.lastIndexOf('lib'); | 215 var libDir = parts.lastIndexOf('lib'); |
| 216 var rest = parts.getRange(libDir + 1, parts.length - libDir - 1); | 216 var rest = parts.sublist(libDir + 1); |
| 217 | 217 |
| 218 // If there's no lib, we can't find the package. | 218 // If there's no lib, we can't find the package. |
| 219 if (libDir < 0 || libDir < packageDir) { | 219 if (libDir < 0 || libDir < packageDir) { |
| 220 // TODO(jacobr): this is a lousy fallback. | 220 // TODO(jacobr): this is a lousy fallback. |
| 221 print("Unable to determine package for $uriPath."); | 221 print("Unable to determine package for $uriPath."); |
| 222 return mirror.uri.toString(); | 222 return mirror.uri.toString(); |
| 223 } else if (packageDir >= 0 && rest.length >= 1) { | 223 } else if (packageDir >= 0 && rest.length >= 1) { |
| 224 // For URI: foo/bar/packages/widget/lib/sprocket.dart will return: | 224 // For URI: foo/bar/packages/widget/lib/sprocket.dart will return: |
| 225 // 'package:widget/sprocket.dart' | 225 // 'package:widget/sprocket.dart' |
| 226 return 'package:${parts[packageDir + 1]}/${rest.join('/')}'; | 226 return 'package:${parts[packageDir + 1]}/${rest.join('/')}'; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 Reference.fromElement(LibraryElement e) : name = e.name, refId = e.id; | 523 Reference.fromElement(LibraryElement e) : name = e.name, refId = e.id; |
| 524 | 524 |
| 525 static String getId(Mirror mirror) { | 525 static String getId(Mirror mirror) { |
| 526 String id = _escapeId(mirror.simpleName); | 526 String id = _escapeId(mirror.simpleName); |
| 527 if (mirror.owner != null) { | 527 if (mirror.owner != null) { |
| 528 id = '${getId(mirror.owner)}/$id'; | 528 id = '${getId(mirror.owner)}/$id'; |
| 529 } | 529 } |
| 530 return id; | 530 return id; |
| 531 } | 531 } |
| 532 } | 532 } |
| OLD | NEW |