| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library analyzer.src.generated.utilities_dart; | 5 library analyzer.src.generated.utilities_dart; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart' show AnnotatedNode, Comment; | 7 import 'package:analyzer/dart/ast/ast.dart' show AnnotatedNode, Comment; |
| 8 import 'package:analyzer/dart/ast/token.dart' show Token; | 8 import 'package:analyzer/dart/ast/token.dart' show Token; |
| 9 import 'package:analyzer/exception/exception.dart'; | 9 import 'package:analyzer/exception/exception.dart'; |
| 10 import 'package:analyzer/src/dart/element/element.dart' show ElementImpl; | 10 import 'package:analyzer/src/dart/element/element.dart' show ElementImpl; |
| 11 import 'package:analyzer/src/generated/source.dart'; | 11 import 'package:analyzer/src/generated/source.dart'; |
| 12 import 'package:analyzer/src/util/fast_uri.dart'; | |
| 13 | 12 |
| 14 /** | 13 /** |
| 15 * Resolve the [containedUri] against [baseUri] using Dart rules. | 14 * Resolve the [containedUri] against [baseUri] using Dart rules. |
| 16 * | 15 * |
| 17 * This function behaves similarly to [Uri.resolveUri], except that it properly | 16 * This function behaves similarly to [Uri.resolveUri], except that it properly |
| 18 * handles situations like the following: | 17 * handles situations like the following: |
| 19 * | 18 * |
| 20 * resolveRelativeUri(dart:core, bool.dart) -> dart:core/bool.dart | 19 * resolveRelativeUri(dart:core, bool.dart) -> dart:core/bool.dart |
| 21 * resolveRelativeUri(package:a/b.dart, ../c.dart) -> package:a/c.dart | 20 * resolveRelativeUri(package:a/b.dart, ../c.dart) -> package:a/c.dart |
| 22 */ | 21 */ |
| 23 Uri resolveRelativeUri(Uri baseUri, Uri containedUri) { | 22 Uri resolveRelativeUri(Uri baseUri, Uri containedUri) { |
| 24 if (containedUri.isAbsolute) { | 23 if (containedUri.isAbsolute) { |
| 25 return containedUri; | 24 return containedUri; |
| 26 } | 25 } |
| 27 Uri origBaseUri = baseUri; | 26 Uri origBaseUri = baseUri; |
| 28 try { | 27 try { |
| 29 String scheme = baseUri.scheme; | 28 String scheme = baseUri.scheme; |
| 30 // dart:core => dart:core/core.dart | 29 // dart:core => dart:core/core.dart |
| 31 if (scheme == DartUriResolver.DART_SCHEME) { | 30 if (scheme == DartUriResolver.DART_SCHEME) { |
| 32 String part = baseUri.path; | 31 String part = baseUri.path; |
| 33 if (part.indexOf('/') < 0) { | 32 if (part.indexOf('/') < 0) { |
| 34 baseUri = FastUri.parse('$scheme:$part/$part.dart'); | 33 baseUri = Uri.parse('$scheme:$part/$part.dart'); |
| 35 } | 34 } |
| 36 } | 35 } |
| 37 // foo.dart + ../bar.dart = ../bar.dart | 36 // foo.dart + ../bar.dart = ../bar.dart |
| 38 // TODO(scheglov) Remove this temporary workaround. | 37 // TODO(scheglov) Remove this temporary workaround. |
| 39 // Should be fixed as https://github.com/dart-lang/sdk/issues/27447 | 38 // Should be fixed as https://github.com/dart-lang/sdk/issues/27447 |
| 40 List<String> baseSegments = baseUri.pathSegments; | 39 List<String> baseSegments = baseUri.pathSegments; |
| 41 List<String> containedSegments = containedUri.pathSegments; | 40 List<String> containedSegments = containedUri.pathSegments; |
| 42 if (baseSegments.length == 1 && | 41 if (baseSegments.length == 1 && |
| 43 containedSegments.length > 0 && | 42 containedSegments.length > 0 && |
| 44 containedSegments[0] == '..') { | 43 containedSegments[0] == '..') { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 129 |
| 131 @override | 130 @override |
| 132 int get hashCode => ordinal; | 131 int get hashCode => ordinal; |
| 133 | 132 |
| 134 @override | 133 @override |
| 135 int compareTo(ParameterKind other) => ordinal - other.ordinal; | 134 int compareTo(ParameterKind other) => ordinal - other.ordinal; |
| 136 | 135 |
| 137 @override | 136 @override |
| 138 String toString() => name; | 137 String toString() => name; |
| 139 } | 138 } |
| OLD | NEW |