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

Side by Side Diff: packages/analyzer/lib/src/generated/source.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
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 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information.
7
8 library engine.source; 5 library engine.source;
9 6
10 import 'dart:collection'; 7 import 'dart:collection';
11 import "dart:math" as math; 8 import "dart:math" as math;
12 9
13 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
14 import 'package:analyzer/file_system/physical_file_system.dart'; 11 import 'package:analyzer/file_system/physical_file_system.dart';
15 import 'package:analyzer/source/package_map_resolver.dart'; 12 import 'package:analyzer/source/package_map_resolver.dart';
16 import 'package:analyzer/src/generated/utilities_dart.dart' as utils; 13 import 'package:analyzer/src/generated/utilities_dart.dart' as utils;
17 import 'package:analyzer/task/model.dart'; 14 import 'package:analyzer/task/model.dart';
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 99 }
103 } 100 }
104 } 101 }
105 102
106 class CustomUriResolver extends UriResolver { 103 class CustomUriResolver extends UriResolver {
107 final Map<String, String> _urlMappings; 104 final Map<String, String> _urlMappings;
108 105
109 CustomUriResolver(this._urlMappings); 106 CustomUriResolver(this._urlMappings);
110 107
111 @override 108 @override
112 Source resolveAbsolute(Uri uri) { 109 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
113 String mapping = _urlMappings[uri.toString()]; 110 String mapping = _urlMappings[uri.toString()];
114 if (mapping == null) return null; 111 if (mapping == null) return null;
115 112
116 Uri fileUri = new Uri.file(mapping); 113 Uri fileUri = new Uri.file(mapping);
117 if (!fileUri.isAbsolute) return null; 114 if (!fileUri.isAbsolute) return null;
118 115
119 JavaFile javaFile = new JavaFile.fromUri(fileUri); 116 JavaFile javaFile = new JavaFile.fromUri(fileUri);
120 return new FileBasedSource(javaFile); 117 return new FileBasedSource(javaFile, actualUri != null ? actualUri : uri);
121 } 118 }
122 } 119 }
123 120
124 /** 121 /**
125 * Instances of the class `DartUriResolver` resolve `dart` URI's. 122 * Instances of the class `DartUriResolver` resolve `dart` URI's.
126 */ 123 */
127 class DartUriResolver extends UriResolver { 124 class DartUriResolver extends UriResolver {
128 /** 125 /**
129 * The name of the `dart` scheme. 126 * The name of the `dart` scheme.
130 */ 127 */
(...skipping 18 matching lines...) Expand all
149 DartUriResolver(this._sdk); 146 DartUriResolver(this._sdk);
150 147
151 /** 148 /**
152 * Return the [DartSdk] against which URIs are to be resolved. 149 * Return the [DartSdk] against which URIs are to be resolved.
153 * 150 *
154 * @return the [DartSdk] against which URIs are to be resolved. 151 * @return the [DartSdk] against which URIs are to be resolved.
155 */ 152 */
156 DartSdk get dartSdk => _sdk; 153 DartSdk get dartSdk => _sdk;
157 154
158 @override 155 @override
159 Source resolveAbsolute(Uri uri) { 156 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
160 if (!isDartUri(uri)) { 157 if (!isDartUri(uri)) {
161 return null; 158 return null;
162 } 159 }
163 return _sdk.mapDartUri(uri.toString()); 160 return _sdk.mapDartUri(uri.toString());
164 } 161 }
165 162
166 /** 163 /**
167 * Return `true` if the given URI is a `dart-ext:` URI. 164 * Return `true` if the given URI is a `dart-ext:` URI.
168 * 165 *
169 * @param uriContent the textual representation of the URI being tested 166 * @param uriContent the textual representation of the URI being tested
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 final int columnNumber; 265 final int columnNumber;
269 266
270 /** 267 /**
271 * Initialize a newly created location to represent the location of the charac ter at the given 268 * Initialize a newly created location to represent the location of the charac ter at the given
272 * line and column position. 269 * line and column position.
273 * 270 *
274 * @param lineNumber the one-based index of the line containing the character 271 * @param lineNumber the one-based index of the line containing the character
275 * @param columnNumber the one-based index of the column containing the charac ter 272 * @param columnNumber the one-based index of the column containing the charac ter
276 */ 273 */
277 LineInfo_Location(this.lineNumber, this.columnNumber); 274 LineInfo_Location(this.lineNumber, this.columnNumber);
275
276 @override
277 String toString() => '$lineNumber:$columnNumber';
278 } 278 }
279 279
280 /** 280 /**
281 * Instances of interface `LocalSourcePredicate` are used to determine if the gi ven 281 * Instances of interface `LocalSourcePredicate` are used to determine if the gi ven
282 * [Source] is "local" in some sense, so can be updated. 282 * [Source] is "local" in some sense, so can be updated.
283 */ 283 */
284 abstract class LocalSourcePredicate { 284 abstract class LocalSourcePredicate {
285 /** 285 /**
286 * Instance of [LocalSourcePredicate] that always returns `false`. 286 * Instance of [LocalSourcePredicate] that always returns `false`.
287 */ 287 */
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 */ 598 */
599 LocalSourcePredicate _localSourcePredicate = LocalSourcePredicate.NOT_SDK; 599 LocalSourcePredicate _localSourcePredicate = LocalSourcePredicate.NOT_SDK;
600 600
601 /** 601 /**
602 * Initialize a newly created source factory with the given absolute URI [reso lvers] and 602 * Initialize a newly created source factory with the given absolute URI [reso lvers] and
603 * optional [packages] resolution helper. 603 * optional [packages] resolution helper.
604 */ 604 */
605 SourceFactory(this._resolvers, 605 SourceFactory(this._resolvers,
606 [this._packages, ResourceProvider resourceProvider]) 606 [this._packages, ResourceProvider resourceProvider])
607 : _resourceProvider = resourceProvider != null 607 : _resourceProvider = resourceProvider != null
608 ? resourceProvider 608 ? resourceProvider
609 : PhysicalResourceProvider.INSTANCE; 609 : PhysicalResourceProvider.INSTANCE;
610 610
611 /** 611 /**
612 * Return the [DartSdk] associated with this [SourceFactory], or `null` if the re 612 * Return the [DartSdk] associated with this [SourceFactory], or `null` if the re
613 * is no such SDK. 613 * is no such SDK.
614 * 614 *
615 * @return the [DartSdk] associated with this [SourceFactory], or `null` if 615 * @return the [DartSdk] associated with this [SourceFactory], or `null` if
616 * there is no such SDK 616 * there is no such SDK
617 */ 617 */
618 DartSdk get dartSdk { 618 DartSdk get dartSdk {
619 for (UriResolver resolver in _resolvers) { 619 for (UriResolver resolver in _resolvers) {
(...skipping 15 matching lines...) Expand all
635 } 635 }
636 636
637 /// A table mapping package names to paths of directories containing 637 /// A table mapping package names to paths of directories containing
638 /// the package (or [null] if there is no registered package URI resolver). 638 /// the package (or [null] if there is no registered package URI resolver).
639 Map<String, List<Folder>> get packageMap { 639 Map<String, List<Folder>> get packageMap {
640 // Start by looking in .packages. 640 // Start by looking in .packages.
641 if (_packages != null) { 641 if (_packages != null) {
642 Map<String, List<Folder>> packageMap = <String, List<Folder>>{}; 642 Map<String, List<Folder>> packageMap = <String, List<Folder>>{};
643 _packages.asMap().forEach((String name, Uri uri) { 643 _packages.asMap().forEach((String name, Uri uri) {
644 if (uri.scheme == 'file' || uri.scheme == '' /* unspecified */) { 644 if (uri.scheme == 'file' || uri.scheme == '' /* unspecified */) {
645 packageMap[name] = 645 packageMap[name] = <Folder>[
646 <Folder>[_resourceProvider.getFolder(uri.toFilePath())]; 646 _resourceProvider.getFolder(uri.toFilePath())
647 ];
647 } 648 }
648 }); 649 });
649 return packageMap; 650 return packageMap;
650 } 651 }
651 652
652 // Default to the PackageMapUriResolver. 653 // Default to the PackageMapUriResolver.
653 PackageMapUriResolver resolver = _resolvers.firstWhere( 654 PackageMapUriResolver resolver = _resolvers
654 (r) => r is PackageMapUriResolver, orElse: () => null); 655 .firstWhere((r) => r is PackageMapUriResolver, orElse: () => null);
655 return resolver != null ? resolver.packageMap : null; 656 return resolver != null ? resolver.packageMap : null;
656 } 657 }
657 658
658 /** 659 /**
659 * Return a source object representing the given absolute URI, or `null` if th e URI is not a 660 * Return a source object representing the given absolute URI, or `null` if th e URI is not a
660 * valid URI or if it is not an absolute URI. 661 * valid URI or if it is not an absolute URI.
661 * 662 *
662 * @param absoluteUri the absolute URI to be resolved 663 * @param absoluteUri the absolute URI to be resolved
663 * @return a source object representing the absolute URI 664 * @return a source object representing the absolute URI
664 */ 665 */
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 * against the source object's URI 808 * against the source object's URI
808 */ 809 */
809 Source _internalResolveUri(Source containingSource, Uri containedUri) { 810 Source _internalResolveUri(Source containingSource, Uri containedUri) {
810 if (!containedUri.isAbsolute) { 811 if (!containedUri.isAbsolute) {
811 if (containingSource == null) { 812 if (containingSource == null) {
812 throw new AnalysisException( 813 throw new AnalysisException(
813 "Cannot resolve a relative URI without a containing source: $contain edUri"); 814 "Cannot resolve a relative URI without a containing source: $contain edUri");
814 } 815 }
815 containedUri = containingSource.resolveRelativeUri(containedUri); 816 containedUri = containingSource.resolveRelativeUri(containedUri);
816 } 817 }
817 // Now check .packages. 818
819 Uri actualUri = containedUri;
820
821 // Check .packages and update target and actual URIs as appropriate.
818 if (_packages != null && containedUri.scheme == 'package') { 822 if (_packages != null && containedUri.scheme == 'package') {
819 Uri packageUri = 823 Uri packageUri =
820 _packages.resolve(containedUri, notFound: (Uri packageUri) => null); 824 _packages.resolve(containedUri, notFound: (Uri packageUri) => null);
821 // Ensure scheme is set. 825
822 if (packageUri != null && packageUri.scheme == '') { 826 if (packageUri != null) {
823 packageUri = packageUri.replace(scheme: 'file'); 827 // Ensure scheme is set.
828 if (packageUri.scheme == '') {
829 packageUri = packageUri.replace(scheme: 'file');
830 }
831 containedUri = packageUri;
824 } 832 }
825 containedUri = packageUri;
826 } 833 }
834
827 for (UriResolver resolver in _resolvers) { 835 for (UriResolver resolver in _resolvers) {
828 Source result = resolver.resolveAbsolute(containedUri); 836 Source result = resolver.resolveAbsolute(containedUri, actualUri);
829 if (result != null) { 837 if (result != null) {
830 return result; 838 return result;
831 } 839 }
832 } 840 }
841
833 return null; 842 return null;
834 } 843 }
835 } 844 }
836 845
837 /** 846 /**
838 * The enumeration `SourceKind` defines the different kinds of sources that are known to the 847 * The enumeration `SourceKind` defines the different kinds of sources that are known to the
839 * analysis engine. 848 * analysis engine.
840 */ 849 */
841 class SourceKind extends Enum<SourceKind> { 850 class SourceKind extends Enum<SourceKind> {
842 /** 851 /**
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of 1064 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of
1056 * absolute URI. 1065 * absolute URI.
1057 */ 1066 */
1058 abstract class UriResolver { 1067 abstract class UriResolver {
1059 /** 1068 /**
1060 * Resolve the given absolute URI. Return a [Source] representing the file to which 1069 * Resolve the given absolute URI. Return a [Source] representing the file to which
1061 * it was resolved, whether or not the resulting source exists, or `null` if i t could not be 1070 * it was resolved, whether or not the resulting source exists, or `null` if i t could not be
1062 * resolved because the URI is invalid. 1071 * resolved because the URI is invalid.
1063 * 1072 *
1064 * @param uri the URI to be resolved 1073 * @param uri the URI to be resolved
1074 * @param actualUri the actual uri for this source -- if `null`, the value of [uri] will be used
1065 * @return a [Source] representing the file to which given URI was resolved 1075 * @return a [Source] representing the file to which given URI was resolved
1066 */ 1076 */
1067 Source resolveAbsolute(Uri uri); 1077 Source resolveAbsolute(Uri uri, [Uri actualUri]);
1068 1078
1069 /** 1079 /**
1070 * Return an absolute URI that represents the given source, or `null` if a val id URI cannot 1080 * Return an absolute URI that represents the given [source], or `null` if a
1071 * be computed. 1081 * valid URI cannot be computed.
1072 * 1082 *
1073 * @param source the source to get URI for 1083 * The computation should be based solely on [source.fullName].
1074 * @return the absolute URI representing the given source
1075 */ 1084 */
1076 Uri restoreAbsolute(Source source) => null; 1085 Uri restoreAbsolute(Source source) => null;
1077 } 1086 }
OLDNEW
« no previous file with comments | « packages/analyzer/lib/src/generated/sdk_io.dart ('k') | packages/analyzer/lib/src/generated/source_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698