OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 | 2 |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 import 'dart:collection' show HashMap, HashSet; | 6 import 'dart:collection' show HashMap, HashSet; |
7 import 'dart:math' show min, max; | 7 import 'dart:math' show min, max; |
8 | 8 |
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 5442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5453 } | 5453 } |
5454 // TODO(vsm): This is not necessarily unique if '__' appears in a file name. | 5454 // TODO(vsm): This is not necessarily unique if '__' appears in a file name. |
5455 var customSeparator = '__'; | 5455 var customSeparator = '__'; |
5456 String qualifiedPath; | 5456 String qualifiedPath; |
5457 if (uri.scheme == 'package') { | 5457 if (uri.scheme == 'package') { |
5458 // Strip the package name. | 5458 // Strip the package name. |
5459 // TODO(vsm): This is not unique if an escaped '/'appears in a filename. | 5459 // TODO(vsm): This is not unique if an escaped '/'appears in a filename. |
5460 // E.g., "foo/bar.dart" and "foo$47bar.dart" would collide. | 5460 // E.g., "foo/bar.dart" and "foo$47bar.dart" would collide. |
5461 qualifiedPath = uri.pathSegments.skip(1).join(customSeparator); | 5461 qualifiedPath = uri.pathSegments.skip(1).join(customSeparator); |
5462 } else if (isWithin(libraryRoot, uri.toFilePath())) { | 5462 } else if (isWithin(libraryRoot, uri.toFilePath())) { |
5463 qualifiedPath = | 5463 qualifiedPath = fromUri(uri) |
5464 fromUri(uri).substring(libraryRoot.length).replaceAll(separator, customS
eparator); | 5464 .substring(libraryRoot.length) |
| 5465 .replaceAll(separator, customSeparator); |
5465 } else { | 5466 } else { |
5466 // We don't have a unique name. | 5467 // We don't have a unique name. |
5467 throw 'Invalid library root. $libraryRoot does not contain ${uri | 5468 throw 'Invalid library root. $libraryRoot does not contain ${uri |
5468 .toFilePath()}'; | 5469 .toFilePath()}'; |
5469 } | 5470 } |
5470 return pathToJSIdentifier(qualifiedPath); | 5471 return pathToJSIdentifier(qualifiedPath); |
5471 } | 5472 } |
5472 | 5473 |
5473 /// Shorthand for identifier-like property names. | 5474 /// Shorthand for identifier-like property names. |
5474 /// For now, we emit them as strings and the printer restores them to | 5475 /// For now, we emit them as strings and the printer restores them to |
(...skipping 21 matching lines...) Expand all Loading... |
5496 } | 5497 } |
5497 | 5498 |
5498 bool isLibraryPrefix(Expression node) => | 5499 bool isLibraryPrefix(Expression node) => |
5499 node is SimpleIdentifier && node.staticElement is PrefixElement; | 5500 node is SimpleIdentifier && node.staticElement is PrefixElement; |
5500 | 5501 |
5501 LibraryElement _getLibrary(AnalysisContext c, String uri) => | 5502 LibraryElement _getLibrary(AnalysisContext c, String uri) => |
5502 c.computeLibraryElement(c.sourceFactory.forUri(uri)); | 5503 c.computeLibraryElement(c.sourceFactory.forUri(uri)); |
5503 | 5504 |
5504 bool _isDartRuntime(LibraryElement l) => | 5505 bool _isDartRuntime(LibraryElement l) => |
5505 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; | 5506 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; |
OLD | NEW |