Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: pkg/analyzer/lib/src/generated/utilities_dart.dart

Issue 2668553002: Move resolveRelativeUri into front_end. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/front_end/lib/src/base/resolve_relative_uri.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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';
10 import 'package:analyzer/src/dart/element/element.dart' show ElementImpl; 9 import 'package:analyzer/src/dart/element/element.dart' show ElementImpl;
11 import 'package:analyzer/src/generated/source.dart';
12 10
13 /** 11 export 'package:front_end/src/base/resolve_relative_uri.dart'
14 * Resolve the [containedUri] against [baseUri] using Dart rules. 12 show resolveRelativeUri;
15 *
16 * This function behaves similarly to [Uri.resolveUri], except that it properly
17 * handles situations like the following:
18 *
19 * resolveRelativeUri(dart:core, bool.dart) -> dart:core/bool.dart
20 * resolveRelativeUri(package:a/b.dart, ../c.dart) -> package:a/c.dart
21 */
22 Uri resolveRelativeUri(Uri baseUri, Uri containedUri) {
23 if (containedUri.isAbsolute) {
24 return containedUri;
25 }
26 Uri origBaseUri = baseUri;
27 try {
28 String scheme = baseUri.scheme;
29 // dart:core => dart:core/core.dart
30 if (scheme == DartUriResolver.DART_SCHEME) {
31 String part = baseUri.path;
32 if (part.indexOf('/') < 0) {
33 baseUri = Uri.parse('$scheme:$part/$part.dart');
34 }
35 }
36 return baseUri.resolveUri(containedUri);
37 } catch (exception, stackTrace) {
38 throw new AnalysisException(
39 "Could not resolve URI ($containedUri) relative to source ($origBaseUri) ",
40 new CaughtException(exception, stackTrace));
41 }
42 }
43 13
44 /** 14 /**
45 * If the given [node] has a documentation comment, remember its content 15 * If the given [node] has a documentation comment, remember its content
46 * and range into the given [element]. 16 * and range into the given [element].
47 */ 17 */
48 void setElementDocumentationComment(ElementImpl element, AnnotatedNode node) { 18 void setElementDocumentationComment(ElementImpl element, AnnotatedNode node) {
49 Comment comment = node.documentationComment; 19 Comment comment = node.documentationComment;
50 if (comment != null && comment.isDocumentation) { 20 if (comment != null && comment.isDocumentation) {
51 element.documentationComment = 21 element.documentationComment =
52 comment.tokens.map((Token t) => t.lexeme).join('\n'); 22 comment.tokens.map((Token t) => t.lexeme).join('\n');
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 89
120 @override 90 @override
121 int get hashCode => ordinal; 91 int get hashCode => ordinal;
122 92
123 @override 93 @override
124 int compareTo(ParameterKind other) => ordinal - other.ordinal; 94 int compareTo(ParameterKind other) => ordinal - other.ordinal;
125 95
126 @override 96 @override
127 String toString() => name; 97 String toString() => name;
128 } 98 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/base/resolve_relative_uri.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698