| 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'; |
| 12 import 'package:analyzer/src/generated/source.dart'; |
| 13 |
| 14 /** |
| 15 * Resolve the [containedUri] against [baseUri] using Dart rules. |
| 16 * |
| 17 * This function behaves similarly to [Uri.resolveUri], except that it properly |
| 18 * handles situations like the following: |
| 19 * |
| 20 * resolveRelativeUri(dart:core, bool.dart) -> dart:core/bool.dart |
| 21 * resolveRelativeUri(package:a/b.dart, ../c.dart) -> package:a/c.dart |
| 22 */ |
| 23 Uri resolveRelativeUri(Uri baseUri, Uri containedUri) { |
| 24 Uri origBaseUri = baseUri; |
| 25 try { |
| 26 bool isOpaque = baseUri.isAbsolute && !baseUri.path.startsWith('/'); |
| 27 if (isOpaque) { |
| 28 String scheme = baseUri.scheme; |
| 29 String part = baseUri.path; |
| 30 if (scheme == DartUriResolver.DART_SCHEME && part.indexOf('/') < 0) { |
| 31 part = "$part/$part.dart"; |
| 32 } |
| 33 baseUri = parseUriWithException("$scheme:/$part"); |
| 34 } |
| 35 Uri result = baseUri.resolveUri(containedUri); |
| 36 if (isOpaque) { |
| 37 result = |
| 38 parseUriWithException("${result.scheme}:${result.path.substring(1)}"); |
| 39 } |
| 40 return result; |
| 41 } catch (exception, stackTrace) { |
| 42 throw new AnalysisException( |
| 43 "Could not resolve URI ($containedUri) relative to source ($origBaseUri)
", |
| 44 new CaughtException(exception, stackTrace)); |
| 45 } |
| 46 } |
| 11 | 47 |
| 12 /** | 48 /** |
| 13 * If the given [node] has a documentation comment, remember its content | 49 * If the given [node] has a documentation comment, remember its content |
| 14 * and range into the given [element]. | 50 * and range into the given [element]. |
| 15 */ | 51 */ |
| 16 void setElementDocumentationComment(ElementImpl element, AnnotatedNode node) { | 52 void setElementDocumentationComment(ElementImpl element, AnnotatedNode node) { |
| 17 Comment comment = node.documentationComment; | 53 Comment comment = node.documentationComment; |
| 18 if (comment != null && comment.isDocumentation) { | 54 if (comment != null && comment.isDocumentation) { |
| 19 element.documentationComment = | 55 element.documentationComment = |
| 20 comment.tokens.map((Token t) => t.lexeme).join('\n'); | 56 comment.tokens.map((Token t) => t.lexeme).join('\n'); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 final bool isOptional; | 108 final bool isOptional; |
| 73 | 109 |
| 74 /** | 110 /** |
| 75 * Initialize a newly created kind with the given state. | 111 * Initialize a newly created kind with the given state. |
| 76 * | 112 * |
| 77 * @param isOptional `true` if this is an optional parameter | 113 * @param isOptional `true` if this is an optional parameter |
| 78 */ | 114 */ |
| 79 const ParameterKind(String name, int ordinal, this.isOptional) | 115 const ParameterKind(String name, int ordinal, this.isOptional) |
| 80 : super(name, ordinal); | 116 : super(name, ordinal); |
| 81 } | 117 } |
| OLD | NEW |