| 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/src/dart/element/element.dart' show ElementImpl; | 9 import 'package:analyzer/src/dart/element/element.dart' show ElementImpl; |
| 10 import 'package:analyzer/src/generated/java_core.dart'; | 10 import 'package:analyzer/src/generated/java_core.dart'; |
| 11 import 'package:analyzer/src/generated/java_engine.dart'; | 11 import 'package:analyzer/src/generated/java_engine.dart'; |
| 12 import 'package:analyzer/src/generated/source.dart'; | 12 import 'package:analyzer/src/generated/source.dart'; |
| 13 import 'package:analyzer/src/util/fast_uri.dart'; |
| 13 | 14 |
| 14 /** | 15 /** |
| 15 * Resolve the [containedUri] against [baseUri] using Dart rules. | 16 * Resolve the [containedUri] against [baseUri] using Dart rules. |
| 16 * | 17 * |
| 17 * This function behaves similarly to [Uri.resolveUri], except that it properly | 18 * This function behaves similarly to [Uri.resolveUri], except that it properly |
| 18 * handles situations like the following: | 19 * handles situations like the following: |
| 19 * | 20 * |
| 20 * resolveRelativeUri(dart:core, bool.dart) -> dart:core/bool.dart | 21 * resolveRelativeUri(dart:core, bool.dart) -> dart:core/bool.dart |
| 21 * resolveRelativeUri(package:a/b.dart, ../c.dart) -> package:a/c.dart | 22 * resolveRelativeUri(package:a/b.dart, ../c.dart) -> package:a/c.dart |
| 22 */ | 23 */ |
| 23 Uri resolveRelativeUri(Uri baseUri, Uri containedUri) { | 24 Uri resolveRelativeUri(Uri baseUri, Uri containedUri) { |
| 24 if (containedUri.isAbsolute) { | 25 if (containedUri.isAbsolute) { |
| 25 return containedUri; | 26 return containedUri; |
| 26 } | 27 } |
| 27 Uri origBaseUri = baseUri; | 28 Uri origBaseUri = baseUri; |
| 28 try { | 29 try { |
| 29 bool isOpaque = baseUri.isAbsolute && !baseUri.path.startsWith('/'); | 30 bool isOpaque = baseUri.isAbsolute && !baseUri.path.startsWith('/'); |
| 30 if (isOpaque) { | 31 if (isOpaque) { |
| 31 String scheme = baseUri.scheme; | 32 String scheme = baseUri.scheme; |
| 32 String part = baseUri.path; | 33 String part = baseUri.path; |
| 33 if (scheme == DartUriResolver.DART_SCHEME && part.indexOf('/') < 0) { | 34 if (scheme == DartUriResolver.DART_SCHEME && part.indexOf('/') < 0) { |
| 34 part = "$part/$part.dart"; | 35 part = "$part/$part.dart"; |
| 35 } | 36 } |
| 36 baseUri = parseUriWithException("$scheme:/$part"); | 37 baseUri = FastUri.parse("$scheme:/$part"); |
| 37 } | 38 } |
| 38 Uri result = baseUri.resolveUri(containedUri); | 39 Uri result = baseUri.resolveUri(containedUri); |
| 39 if (isOpaque) { | 40 if (isOpaque) { |
| 40 result = | 41 result = |
| 41 parseUriWithException("${result.scheme}:${result.path.substring(1)}"); | 42 FastUri.parse("${result.scheme}:${result.path.substring(1)}"); |
| 42 } | 43 } |
| 43 return result; | 44 return result; |
| 44 } catch (exception, stackTrace) { | 45 } catch (exception, stackTrace) { |
| 45 throw new AnalysisException( | 46 throw new AnalysisException( |
| 46 "Could not resolve URI ($containedUri) relative to source ($origBaseUri)
", | 47 "Could not resolve URI ($containedUri) relative to source ($origBaseUri)
", |
| 47 new CaughtException(exception, stackTrace)); | 48 new CaughtException(exception, stackTrace)); |
| 48 } | 49 } |
| 49 } | 50 } |
| 50 | 51 |
| 51 /** | 52 /** |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 final bool isOptional; | 112 final bool isOptional; |
| 112 | 113 |
| 113 /** | 114 /** |
| 114 * Initialize a newly created kind with the given state. | 115 * Initialize a newly created kind with the given state. |
| 115 * | 116 * |
| 116 * @param isOptional `true` if this is an optional parameter | 117 * @param isOptional `true` if this is an optional parameter |
| 117 */ | 118 */ |
| 118 const ParameterKind(String name, int ordinal, this.isOptional) | 119 const ParameterKind(String name, int ordinal, this.isOptional) |
| 119 : super(name, ordinal); | 120 : super(name, ordinal); |
| 120 } | 121 } |
| OLD | NEW |