| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 | 3 |
| 4 library engine.source; | 4 library engine.source; |
| 5 | 5 |
| 6 import 'java_core.dart'; | 6 import 'java_core.dart'; |
| 7 import 'sdk.dart' show DartSdk; | 7 import 'sdk.dart' show DartSdk; |
| 8 import 'engine.dart' show AnalysisContext; | 8 import 'engine.dart' show AnalysisContext; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 */ | 59 */ |
| 60 class SourceFactory { | 60 class SourceFactory { |
| 61 /** | 61 /** |
| 62 * The analysis context that this source factory is associated with. | 62 * The analysis context that this source factory is associated with. |
| 63 */ | 63 */ |
| 64 AnalysisContext context; | 64 AnalysisContext context; |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * A cache of content used to override the default content of a source. | 67 * A cache of content used to override the default content of a source. |
| 68 */ | 68 */ |
| 69 ContentCache contentCache; | 69 ContentCache _contentCache; |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * The resolvers used to resolve absolute URI's. | 72 * The resolvers used to resolve absolute URI's. |
| 73 */ | 73 */ |
| 74 List<UriResolver> _resolvers; | 74 List<UriResolver> _resolvers; |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * The predicate to determine is [Source] is local. | 77 * The predicate to determine is [Source] is local. |
| 78 */ | 78 */ |
| 79 LocalSourcePredicate _localSourcePredicate; | 79 LocalSourcePredicate _localSourcePredicate; |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * Initialize a newly created source factory. | 82 * Initialize a newly created source factory. |
| 83 * | 83 * |
| 84 * @param contentCache the cache holding content used to override the default
content of a source | 84 * @param contentCache the cache holding content used to override the default
content of a source |
| 85 * @param resolvers the resolvers used to resolve absolute URI's | 85 * @param resolvers the resolvers used to resolve absolute URI's |
| 86 */ | 86 */ |
| 87 SourceFactory.con1(ContentCache contentCache, List<UriResolver> resolvers) { | 87 SourceFactory.con1(ContentCache contentCache, List<UriResolver> resolvers) { |
| 88 this.contentCache = contentCache; | 88 this._contentCache = contentCache; |
| 89 this._resolvers = resolvers; | 89 this._resolvers = resolvers; |
| 90 this._localSourcePredicate = LocalSourcePredicate.NOT_SDK; | 90 this._localSourcePredicate = LocalSourcePredicate.NOT_SDK; |
| 91 } | 91 } |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * Initialize a newly created source factory. | 94 * Initialize a newly created source factory. |
| 95 * | 95 * |
| 96 * @param resolvers the resolvers used to resolve absolute URI's | 96 * @param resolvers the resolvers used to resolve absolute URI's |
| 97 */ | 97 */ |
| 98 SourceFactory.con2(List<UriResolver> resolvers) : this.con1(new ContentCache()
, resolvers); | 98 SourceFactory.con2(List<UriResolver> resolvers) : this.con1(new ContentCache()
, resolvers); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 127 if (encoding.length < 2) { | 127 if (encoding.length < 2) { |
| 128 throw new IllegalArgumentException("Invalid encoding length"); | 128 throw new IllegalArgumentException("Invalid encoding length"); |
| 129 } | 129 } |
| 130 UriKind kind = UriKind.fromEncoding(encoding.codeUnitAt(0)); | 130 UriKind kind = UriKind.fromEncoding(encoding.codeUnitAt(0)); |
| 131 if (kind == null) { | 131 if (kind == null) { |
| 132 throw new IllegalArgumentException("Invalid source kind in encoding: ${kin
d}"); | 132 throw new IllegalArgumentException("Invalid source kind in encoding: ${kin
d}"); |
| 133 } | 133 } |
| 134 try { | 134 try { |
| 135 Uri uri = parseUriWithException(encoding.substring(1)); | 135 Uri uri = parseUriWithException(encoding.substring(1)); |
| 136 for (UriResolver resolver in _resolvers) { | 136 for (UriResolver resolver in _resolvers) { |
| 137 Source result = resolver.fromEncoding(contentCache, kind, uri); | 137 Source result = resolver.fromEncoding(_contentCache, kind, uri); |
| 138 if (result != null) { | 138 if (result != null) { |
| 139 return result; | 139 return result; |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 throw new IllegalArgumentException("No resolver for kind: ${kind}"); | 142 throw new IllegalArgumentException("No resolver for kind: ${kind}"); |
| 143 } on JavaException catch (exception) { | 143 } on JavaException catch (exception) { |
| 144 throw new IllegalArgumentException("Invalid URI in encoding"); | 144 throw new IllegalArgumentException("Invalid URI in encoding"); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * Return a cache of content used to override the default content of a source. |
| 150 * |
| 151 * @return a cache of content used to override the default content of a source |
| 152 */ |
| 153 ContentCache get contentCache => _contentCache; |
| 154 |
| 155 /** |
| 149 * Return the [DartSdk] associated with this [SourceFactory], or `null` if the
re | 156 * Return the [DartSdk] associated with this [SourceFactory], or `null` if the
re |
| 150 * is no such SDK. | 157 * is no such SDK. |
| 151 * | 158 * |
| 152 * @return the [DartSdk] associated with this [SourceFactory], or `null` if | 159 * @return the [DartSdk] associated with this [SourceFactory], or `null` if |
| 153 * there is no such SDK | 160 * there is no such SDK |
| 154 */ | 161 */ |
| 155 DartSdk get dartSdk { | 162 DartSdk get dartSdk { |
| 156 for (UriResolver resolver in _resolvers) { | 163 for (UriResolver resolver in _resolvers) { |
| 157 if (resolver is DartUriResolver) { | 164 if (resolver is DartUriResolver) { |
| 158 DartUriResolver dartUriResolver = resolver as DartUriResolver; | 165 DartUriResolver dartUriResolver = resolver as DartUriResolver; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 216 |
| 210 /** | 217 /** |
| 211 * Set the contents of the given source to the given contents. This has the ef
fect of overriding | 218 * Set the contents of the given source to the given contents. This has the ef
fect of overriding |
| 212 * the default contents of the source. If the contents are `null` the override
is removed so | 219 * the default contents of the source. If the contents are `null` the override
is removed so |
| 213 * that the default contents will be returned. | 220 * that the default contents will be returned. |
| 214 * | 221 * |
| 215 * @param source the source whose contents are being overridden | 222 * @param source the source whose contents are being overridden |
| 216 * @param contents the new contents of the source | 223 * @param contents the new contents of the source |
| 217 * @return the original cached contents or `null` if none | 224 * @return the original cached contents or `null` if none |
| 218 */ | 225 */ |
| 219 String setContents(Source source, String contents) => contentCache.setContents
(source, contents); | 226 String setContents(Source source, String contents) => _contentCache.setContent
s(source, contents); |
| 220 | 227 |
| 221 /** | 228 /** |
| 222 * Sets the [LocalSourcePredicate]. | 229 * Sets the [LocalSourcePredicate]. |
| 223 * | 230 * |
| 224 * @param localSourcePredicate the predicate to determine is [Source] is local | 231 * @param localSourcePredicate the predicate to determine is [Source] is local |
| 225 */ | 232 */ |
| 226 void set localSourcePredicate(LocalSourcePredicate localSourcePredicate) { | 233 void set localSourcePredicate(LocalSourcePredicate localSourcePredicate) { |
| 227 this._localSourcePredicate = localSourcePredicate; | 234 this._localSourcePredicate = localSourcePredicate; |
| 228 } | 235 } |
| 229 | 236 |
| 230 /** | 237 /** |
| 231 * Return the contents of the given source, or `null` if this factory does not
override the | 238 * Return the contents of the given source, or `null` if this factory does not
override the |
| 232 * contents of the source. | 239 * contents of the source. |
| 233 * | 240 * |
| 234 * <b>Note:</b> This method is not intended to be used except by | 241 * <b>Note:</b> This method is not intended to be used except by |
| 235 * [FileBasedSource#getContents]. | 242 * [FileBasedSource#getContents]. |
| 236 * | 243 * |
| 237 * @param source the source whose content is to be returned | 244 * @param source the source whose content is to be returned |
| 238 * @return the contents of the given source | 245 * @return the contents of the given source |
| 239 */ | 246 */ |
| 240 String getContents(Source source) => contentCache.getContents(source); | 247 String getContents(Source source) => _contentCache.getContents(source); |
| 241 | 248 |
| 242 /** | 249 /** |
| 243 * Return the modification stamp of the given source, or `null` if this factor
y does not | 250 * Return the modification stamp of the given source, or `null` if this factor
y does not |
| 244 * override the contents of the source. | 251 * override the contents of the source. |
| 245 * | 252 * |
| 246 * <b>Note:</b> This method is not intended to be used except by | 253 * <b>Note:</b> This method is not intended to be used except by |
| 247 * [FileBasedSource#getModificationStamp]. | 254 * [FileBasedSource#getModificationStamp]. |
| 248 * | 255 * |
| 249 * @param source the source whose modification stamp is to be returned | 256 * @param source the source whose modification stamp is to be returned |
| 250 * @return the modification stamp of the given source | 257 * @return the modification stamp of the given source |
| 251 */ | 258 */ |
| 252 int getModificationStamp(Source source) => contentCache.getModificationStamp(s
ource); | 259 int getModificationStamp(Source source) => _contentCache.getModificationStamp(
source); |
| 253 | 260 |
| 254 /** | 261 /** |
| 255 * Return a source object representing the URI that results from resolving the
given (possibly | 262 * Return a source object representing the URI that results from resolving the
given (possibly |
| 256 * relative) contained URI against the URI associated with an existing source
object, or | 263 * relative) contained URI against the URI associated with an existing source
object, or |
| 257 * `null` if either the contained URI is invalid or if it cannot be resolved a
gainst the | 264 * `null` if either the contained URI is invalid or if it cannot be resolved a
gainst the |
| 258 * source object's URI. | 265 * source object's URI. |
| 259 * | 266 * |
| 260 * @param containingSource the source containing the given URI | 267 * @param containingSource the source containing the given URI |
| 261 * @param containedUri the (possibly relative) URI to be resolved against the
containing source | 268 * @param containedUri the (possibly relative) URI to be resolved against the
containing source |
| 262 * @return the source representing the contained URI | 269 * @return the source representing the contained URI |
| 263 */ | 270 */ |
| 264 Source resolveUri2(Source containingSource, Uri containedUri) { | 271 Source resolveUri2(Source containingSource, Uri containedUri) { |
| 265 if (containedUri.isAbsolute) { | 272 if (containedUri.isAbsolute) { |
| 266 for (UriResolver resolver in _resolvers) { | 273 for (UriResolver resolver in _resolvers) { |
| 267 Source result = resolver.resolveAbsolute(contentCache, containedUri); | 274 Source result = resolver.resolveAbsolute(_contentCache, containedUri); |
| 268 if (result != null) { | 275 if (result != null) { |
| 269 return result; | 276 return result; |
| 270 } | 277 } |
| 271 } | 278 } |
| 272 return null; | 279 return null; |
| 273 } else { | 280 } else { |
| 274 return containingSource.resolveRelative(containedUri); | 281 return containingSource.resolveRelative(containedUri); |
| 275 } | 282 } |
| 276 } | 283 } |
| 277 } | 284 } |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 return PACKAGE_URI; | 549 return PACKAGE_URI; |
| 543 } | 550 } |
| 544 break; | 551 break; |
| 545 } | 552 } |
| 546 return null; | 553 return null; |
| 547 } | 554 } |
| 548 | 555 |
| 549 /** | 556 /** |
| 550 * The single character encoding used to identify this kind of URI. | 557 * The single character encoding used to identify this kind of URI. |
| 551 */ | 558 */ |
| 552 int encoding = 0; | 559 final int encoding; |
| 553 | 560 |
| 554 /** | 561 /** |
| 555 * Initialize a newly created URI kind to have the given encoding. | 562 * Initialize a newly created URI kind to have the given encoding. |
| 556 * | 563 * |
| 557 * @param encoding the single character encoding used to identify this kind of
URI. | 564 * @param encoding the single character encoding used to identify this kind of
URI. |
| 558 */ | 565 */ |
| 559 UriKind(String name, int ordinal, int encoding) : super(name, ordinal) { | 566 UriKind(String name, int ordinal, this.encoding) : super(name, ordinal); |
| 560 this.encoding = encoding; | |
| 561 } | |
| 562 } | 567 } |
| 563 | 568 |
| 564 /** | 569 /** |
| 565 * A source range defines an [Element]'s source coordinates relative to its [Sou
rce]. | 570 * A source range defines an [Element]'s source coordinates relative to its [Sou
rce]. |
| 566 * | 571 * |
| 567 * @coverage dart.engine.utilities | 572 * @coverage dart.engine.utilities |
| 568 */ | 573 */ |
| 569 class SourceRange { | 574 class SourceRange { |
| 570 /** | 575 /** |
| 571 * An empty [SourceRange] with offset `0` and length `0`. | 576 * An empty [SourceRange] with offset `0` and length `0`. |
| 572 */ | 577 */ |
| 573 static SourceRange EMPTY = new SourceRange(0, 0); | 578 static SourceRange EMPTY = new SourceRange(0, 0); |
| 574 | 579 |
| 575 /** | 580 /** |
| 576 * The 0-based index of the first character of the source code for this elemen
t, relative to the | 581 * The 0-based index of the first character of the source code for this elemen
t, relative to the |
| 577 * source buffer in which this element is contained. | 582 * source buffer in which this element is contained. |
| 578 */ | 583 */ |
| 579 int offset = 0; | 584 final int offset; |
| 580 | 585 |
| 581 /** | 586 /** |
| 582 * The number of characters of the source code for this element, relative to t
he source buffer in | 587 * The number of characters of the source code for this element, relative to t
he source buffer in |
| 583 * which this element is contained. | 588 * which this element is contained. |
| 584 */ | 589 */ |
| 585 int length = 0; | 590 final int length; |
| 586 | 591 |
| 587 /** | 592 /** |
| 588 * Initialize a newly created source range using the given offset and the give
n length. | 593 * Initialize a newly created source range using the given offset and the give
n length. |
| 589 * | 594 * |
| 590 * @param offset the given offset | 595 * @param offset the given offset |
| 591 * @param length the given length | 596 * @param length the given length |
| 592 */ | 597 */ |
| 593 SourceRange(int offset, int length) { | 598 SourceRange(this.offset, this.length); |
| 594 this.offset = offset; | |
| 595 this.length = length; | |
| 596 } | |
| 597 | 599 |
| 598 /** | 600 /** |
| 599 * @return `true` if <code>x</code> is in [offset, offset + length) interval. | 601 * @return `true` if <code>x</code> is in [offset, offset + length) interval. |
| 600 */ | 602 */ |
| 601 bool contains(int x) => offset <= x && x < offset + length; | 603 bool contains(int x) => offset <= x && x < offset + length; |
| 602 | 604 |
| 603 /** | 605 /** |
| 604 * @return `true` if <code>x</code> is in (offset, offset + length) interval. | 606 * @return `true` if <code>x</code> is in (offset, offset + length) interval. |
| 605 */ | 607 */ |
| 606 bool containsExclusive(int x) => offset < x && x < offset + length; | 608 bool containsExclusive(int x) => offset < x && x < offset + length; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 | 710 |
| 709 /** | 711 /** |
| 710 * Instances of the class `DartUriResolver` resolve `dart` URI's. | 712 * Instances of the class `DartUriResolver` resolve `dart` URI's. |
| 711 * | 713 * |
| 712 * @coverage dart.engine.source | 714 * @coverage dart.engine.source |
| 713 */ | 715 */ |
| 714 class DartUriResolver extends UriResolver { | 716 class DartUriResolver extends UriResolver { |
| 715 /** | 717 /** |
| 716 * The Dart SDK against which URI's are to be resolved. | 718 * The Dart SDK against which URI's are to be resolved. |
| 717 */ | 719 */ |
| 718 DartSdk dartSdk; | 720 DartSdk _sdk; |
| 719 | 721 |
| 720 /** | 722 /** |
| 721 * The name of the `dart` scheme. | 723 * The name of the `dart` scheme. |
| 722 */ | 724 */ |
| 723 static String _DART_SCHEME = "dart"; | 725 static String _DART_SCHEME = "dart"; |
| 724 | 726 |
| 725 /** | 727 /** |
| 726 * Return `true` if the given URI is a `dart:` URI. | 728 * Return `true` if the given URI is a `dart:` URI. |
| 727 * | 729 * |
| 728 * @param uri the URI being tested | 730 * @param uri the URI being tested |
| 729 * @return `true` if the given URI is a `dart:` URI | 731 * @return `true` if the given URI is a `dart:` URI |
| 730 */ | 732 */ |
| 731 static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme; | 733 static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme; |
| 732 | 734 |
| 733 /** | 735 /** |
| 734 * Initialize a newly created resolver to resolve Dart URI's against the given
platform within the | 736 * Initialize a newly created resolver to resolve Dart URI's against the given
platform within the |
| 735 * given Dart SDK. | 737 * given Dart SDK. |
| 736 * | 738 * |
| 737 * @param sdk the Dart SDK against which URI's are to be resolved | 739 * @param sdk the Dart SDK against which URI's are to be resolved |
| 738 */ | 740 */ |
| 739 DartUriResolver(DartSdk sdk) { | 741 DartUriResolver(DartSdk sdk) { |
| 740 this.dartSdk = sdk; | 742 this._sdk = sdk; |
| 741 } | 743 } |
| 742 | 744 |
| 743 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) { | 745 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) { |
| 744 if (identical(kind, UriKind.DART_URI)) { | 746 if (identical(kind, UriKind.DART_URI)) { |
| 745 return dartSdk.fromEncoding(contentCache, kind, uri); | 747 return _sdk.fromEncoding(contentCache, kind, uri); |
| 746 } | 748 } |
| 747 return null; | 749 return null; |
| 748 } | 750 } |
| 749 | 751 |
| 752 /** |
| 753 * Return the [DartSdk] against which URIs are to be resolved. |
| 754 * |
| 755 * @return the [DartSdk] against which URIs are to be resolved. |
| 756 */ |
| 757 DartSdk get dartSdk => _sdk; |
| 758 |
| 750 Source resolveAbsolute(ContentCache contentCache, Uri uri) { | 759 Source resolveAbsolute(ContentCache contentCache, Uri uri) { |
| 751 if (!isDartUri(uri)) { | 760 if (!isDartUri(uri)) { |
| 752 return null; | 761 return null; |
| 753 } | 762 } |
| 754 return dartSdk.mapDartUri(uri.toString()); | 763 return _sdk.mapDartUri(uri.toString()); |
| 755 } | 764 } |
| 756 } | 765 } |
| 757 | 766 |
| 758 /** | 767 /** |
| 759 * Instances of the class `LineInfo` encapsulate information about line and colu
mn information | 768 * Instances of the class `LineInfo` encapsulate information about line and colu
mn information |
| 760 * within a source file. | 769 * within a source file. |
| 761 * | 770 * |
| 762 * @coverage dart.engine.utilities | 771 * @coverage dart.engine.utilities |
| 763 */ | 772 */ |
| 764 class LineInfo { | 773 class LineInfo { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 } | 809 } |
| 801 | 810 |
| 802 /** | 811 /** |
| 803 * Instances of the class `Location` represent the location of a character as a
line and | 812 * Instances of the class `Location` represent the location of a character as a
line and |
| 804 * column pair. | 813 * column pair. |
| 805 */ | 814 */ |
| 806 class LineInfo_Location { | 815 class LineInfo_Location { |
| 807 /** | 816 /** |
| 808 * The one-based index of the line containing the character. | 817 * The one-based index of the line containing the character. |
| 809 */ | 818 */ |
| 810 int lineNumber = 0; | 819 final int lineNumber; |
| 811 | 820 |
| 812 /** | 821 /** |
| 813 * The one-based index of the column containing the character. | 822 * The one-based index of the column containing the character. |
| 814 */ | 823 */ |
| 815 int columnNumber = 0; | 824 final int columnNumber; |
| 816 | 825 |
| 817 /** | 826 /** |
| 818 * Initialize a newly created location to represent the location of the charac
ter at the given | 827 * Initialize a newly created location to represent the location of the charac
ter at the given |
| 819 * line and column position. | 828 * line and column position. |
| 820 * | 829 * |
| 821 * @param lineNumber the one-based index of the line containing the character | 830 * @param lineNumber the one-based index of the line containing the character |
| 822 * @param columnNumber the one-based index of the column containing the charac
ter | 831 * @param columnNumber the one-based index of the column containing the charac
ter |
| 823 */ | 832 */ |
| 824 LineInfo_Location(int lineNumber, int columnNumber) { | 833 LineInfo_Location(this.lineNumber, this.columnNumber); |
| 825 this.lineNumber = lineNumber; | |
| 826 this.columnNumber = columnNumber; | |
| 827 } | |
| 828 } | 834 } |
| 829 | 835 |
| 830 /** | 836 /** |
| 831 * Instances of class `ContentCache` hold content used to override the default c
ontent of a | 837 * Instances of class `ContentCache` hold content used to override the default c
ontent of a |
| 832 * [Source]. | 838 * [Source]. |
| 833 * | 839 * |
| 834 * @coverage dart.engine.source | 840 * @coverage dart.engine.source |
| 835 */ | 841 */ |
| 836 class ContentCache { | 842 class ContentCache { |
| 837 /** | 843 /** |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 * | 883 * |
| 878 * @param source the source whose contents are being overridden | 884 * @param source the source whose contents are being overridden |
| 879 * @param contents the new contents of the source | 885 * @param contents the new contents of the source |
| 880 * @return the original cached contents or `null` if none | 886 * @return the original cached contents or `null` if none |
| 881 */ | 887 */ |
| 882 String setContents(Source source, String contents) { | 888 String setContents(Source source, String contents) { |
| 883 if (contents == null) { | 889 if (contents == null) { |
| 884 _stampMap.remove(source); | 890 _stampMap.remove(source); |
| 885 return _contentMap.remove(source); | 891 return _contentMap.remove(source); |
| 886 } else { | 892 } else { |
| 887 _stampMap[source] = JavaSystem.currentTimeMillis(); | 893 int newStamp = JavaSystem.currentTimeMillis(); |
| 894 int oldStamp = javaMapPut(_stampMap, source, newStamp); |
| 895 if (newStamp == oldStamp) { |
| 896 _stampMap[source] = newStamp + 1; |
| 897 } |
| 888 return javaMapPut(_contentMap, source, contents); | 898 return javaMapPut(_contentMap, source, contents); |
| 889 } | 899 } |
| 890 } | 900 } |
| 891 } | 901 } |
| OLD | NEW |