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

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

Issue 221483002: Fix for translation of \!= to \!identical(), but use == and \!= for Enum. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
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 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. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.source; 8 library engine.source;
9 9
10 import 'java_core.dart'; 10 import 'java_core.dart';
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 */ 62 */
63 class SourceFactory { 63 class SourceFactory {
64 /** 64 /**
65 * The analysis context that this source factory is associated with. 65 * The analysis context that this source factory is associated with.
66 */ 66 */
67 AnalysisContext context; 67 AnalysisContext context;
68 68
69 /** 69 /**
70 * The resolvers used to resolve absolute URI's. 70 * The resolvers used to resolve absolute URI's.
71 */ 71 */
72 List<UriResolver> _resolvers; 72 final List<UriResolver> _resolvers;
73 73
74 /** 74 /**
75 * The predicate to determine is [Source] is local. 75 * The predicate to determine is [Source] is local.
76 */ 76 */
77 LocalSourcePredicate _localSourcePredicate = LocalSourcePredicate.NOT_SDK; 77 LocalSourcePredicate _localSourcePredicate = LocalSourcePredicate.NOT_SDK;
78 78
79 /** 79 /**
80 * Initialize a newly created source factory. 80 * Initialize a newly created source factory.
81 * 81 *
82 * @param resolvers the resolvers used to resolve absolute URI's 82 * @param resolvers the resolvers used to resolve absolute URI's
83 */ 83 */
84 SourceFactory(List<UriResolver> resolvers) { 84 SourceFactory(this._resolvers);
85 this._resolvers = resolvers;
86 }
87 85
88 /** 86 /**
89 * Return a source object representing the given absolute URI, or `null` if th e URI is not a 87 * Return a source object representing the given absolute URI, or `null` if th e URI is not a
90 * valid URI or if it is not an absolute URI. 88 * valid URI or if it is not an absolute URI.
91 * 89 *
92 * @param absoluteUri the absolute URI to be resolved 90 * @param absoluteUri the absolute URI to be resolved
93 * @return a source object representing the absolute URI 91 * @return a source object representing the absolute URI
94 */ 92 */
95 Source forUri(String absoluteUri) { 93 Source forUri(String absoluteUri) {
96 try { 94 try {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 /** 151 /**
154 * Determines if the given [Source] is local. 152 * Determines if the given [Source] is local.
155 * 153 *
156 * @param source the [Source] to analyze 154 * @param source the [Source] to analyze
157 * @return `true` if the given [Source] is local 155 * @return `true` if the given [Source] is local
158 */ 156 */
159 bool isLocalSource(Source source) => _localSourcePredicate.isLocal(source); 157 bool isLocalSource(Source source) => _localSourcePredicate.isLocal(source);
160 158
161 /** 159 /**
162 * Return a source object representing the URI that results from resolving the given (possibly 160 * Return a source object representing the URI that results from resolving the given (possibly
163 * relative) contained URI against the URI associated with an existing source object, or 161 * relative) contained URI against the URI associated with an existing source object, whether or
164 * `null` if either the contained URI is invalid or if it cannot be resolved a gainst the 162 * not the resulting source exists, or `null` if either the contained URI is i nvalid or if
165 * source object's URI. 163 * it cannot be resolved against the source object's URI.
166 * 164 *
167 * @param containingSource the source containing the given URI 165 * @param containingSource the source containing the given URI
168 * @param containedUri the (possibly relative) URI to be resolved against the containing source 166 * @param containedUri the (possibly relative) URI to be resolved against the containing source
169 * @return the source representing the contained URI 167 * @return the source representing the contained URI
170 */ 168 */
171 Source resolveUri(Source containingSource, String containedUri) { 169 Source resolveUri(Source containingSource, String containedUri) {
172 if (containedUri == null || containedUri.isEmpty) { 170 if (containedUri == null || containedUri.isEmpty) {
173 return null; 171 return null;
174 } 172 }
175 try { 173 try {
176 // Force the creation of an escaped URI to deal with spaces, etc. 174 // Force the creation of an escaped URI to deal with spaces, etc.
177 return _internalResolveUri(containingSource, parseUriWithException(contain edUri)); 175 return _internalResolveUri(containingSource, parseUriWithException(contain edUri));
178 } on URISyntaxException catch (exception) { 176 } on URISyntaxException catch (exception) {
179 return null; 177 return null;
180 } 178 }
181 } 179 }
182 180
183 /** 181 /**
184 * Return an absolute URI that represents the given source. 182 * Return an absolute URI that represents the given source, or `null` if a val id URI cannot
183 * be computed.
185 * 184 *
186 * @param source the source to get URI for 185 * @param source the source to get URI for
187 * @return the absolute URI representing the given source, may be `null` 186 * @return the absolute URI representing the given source
188 */ 187 */
189 Uri restoreUri(Source source) { 188 Uri restoreUri(Source source) {
190 for (UriResolver resolver in _resolvers) { 189 for (UriResolver resolver in _resolvers) {
191 Uri uri = resolver.restoreAbsolute(source); 190 Uri uri = resolver.restoreAbsolute(source);
192 if (uri != null) { 191 if (uri != null) {
193 return uri; 192 return uri;
194 } 193 }
195 } 194 }
196 return null; 195 return null;
197 } 196 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 231
233 /** 232 /**
234 * The abstract class `UriResolver` defines the behavior of objects that are use d to resolve 233 * The abstract class `UriResolver` defines the behavior of objects that are use d to resolve
235 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of 234 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of
236 * absolute URI. 235 * absolute URI.
237 */ 236 */
238 abstract class UriResolver { 237 abstract class UriResolver {
239 /** 238 /**
240 * If this resolver should be used for URI's of the given kind, resolve the gi ven absolute URI. 239 * If this resolver should be used for URI's of the given kind, resolve the gi ven absolute URI.
241 * The URI does not need to have the scheme handled by this resolver if the ki nd matches. Return a 240 * The URI does not need to have the scheme handled by this resolver if the ki nd matches. Return a
242 * [Source] representing the file to which it was resolved, or `null` if it 241 * [Source] representing the file to which it was resolved, whether or not the
243 * could not be resolved. 242 * resulting source exists, or `null` if it could not be resolved because the URI is
243 * invalid.
244 * 244 *
245 * @param kind the kind of URI that was originally resolved in order to produc e an encoding with 245 * @param kind the kind of URI that was originally resolved in order to produc e an encoding with
246 * the given URI 246 * the given URI
247 * @param uri the URI to be resolved 247 * @param uri the URI to be resolved
248 * @return a [Source] representing the file to which given URI was resolved 248 * @return a [Source] representing the file to which given URI was resolved
249 */ 249 */
250 Source fromEncoding(UriKind kind, Uri uri); 250 Source fromEncoding(UriKind kind, Uri uri);
251 251
252 /** 252 /**
253 * Resolve the given absolute URI. Return a [Source] representing the file to which 253 * Resolve the given absolute URI. Return a [Source] representing the file to which
254 * it was resolved, or `null` if it could not be resolved. 254 * it was resolved, whether or not the resulting source exists, or `null` if i t could not be
255 * resolved because the URI is invalid.
255 * 256 *
256 * @param uri the URI to be resolved 257 * @param uri the URI to be resolved
257 * @return a [Source] representing the file to which given URI was resolved 258 * @return a [Source] representing the file to which given URI was resolved
258 */ 259 */
259 Source resolveAbsolute(Uri uri); 260 Source resolveAbsolute(Uri uri);
260 261
261 /** 262 /**
262 * Return an absolute URI that represents the given source. 263 * Return an absolute URI that represents the given source, or `null` if a val id URI cannot
264 * be computed.
263 * 265 *
264 * @param source the source to get URI for 266 * @param source the source to get URI for
265 * @return the absolute URI representing the given source, may be `null` 267 * @return the absolute URI representing the given source
266 */ 268 */
267 Uri restoreAbsolute(Source source) => null; 269 Uri restoreAbsolute(Source source) => null;
268 } 270 }
269 271
270 /** 272 /**
271 * The interface `Source` defines the behavior of objects representing source co de that can be 273 * The interface `Source` defines the behavior of objects representing source co de that can be
272 * compiled. 274 * analyzed by the analysis engine.
275 *
276 * Implementations of this interface need to be aware of some assumptions made b y the analysis
277 * engine concerning sources:
278 * * Sources are not required to be unique. That is, there can be multiple insta nces representing
279 * the same source.
280 * * Sources are long lived. That is, the engine is allowed to hold on to a sour ce for an extended
281 * period of time and that source must continue to report accurate and up-to-dat e information.
282 * Because of these assumptions, most implementations will not maintain any stat e but will delegate
283 * to an authoritative system of record in order to implement this API. For exam ple, a source that
284 * represents files on disk would typically query the file system to determine t he state of the
285 * file.
286 *
287 * If the instances that implement this API are the system of record, then they will typically be
288 * unique. In that case, sources that are created that represent non-existent fi les must also be
289 * retained so that if those files are created at a later date the long-lived so urces representing
290 * those files will know that they now exist.
273 */ 291 */
274 abstract class Source { 292 abstract class Source {
275 /** 293 /**
276 * An empty array of sources. 294 * An empty array of sources.
277 */ 295 */
278 static final List<Source> EMPTY_ARRAY = new List<Source>(0); 296 static final List<Source> EMPTY_ARRAY = new List<Source>(0);
279 297
280 /** 298 /**
281 * Return `true` if the given object is a source that represents the same sour ce code as 299 * Return `true` if the given object is a source that represents the same sour ce code as
282 * this source. 300 * this source.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 429 }
412 430
413 /** 431 /**
414 * The enumeration `SourceKind` defines the different kinds of sources that are known to the 432 * The enumeration `SourceKind` defines the different kinds of sources that are known to the
415 * analysis engine. 433 * analysis engine.
416 */ 434 */
417 class SourceKind extends Enum<SourceKind> { 435 class SourceKind extends Enum<SourceKind> {
418 /** 436 /**
419 * A source containing HTML. The HTML might or might not contain Dart scripts. 437 * A source containing HTML. The HTML might or might not contain Dart scripts.
420 */ 438 */
421 static final SourceKind HTML = new SourceKind('HTML', 0); 439 static const SourceKind HTML = const SourceKind('HTML', 0);
422 440
423 /** 441 /**
424 * A Dart compilation unit that is not a part of another library. Libraries mi ght or might not 442 * A Dart compilation unit that is not a part of another library. Libraries mi ght or might not
425 * contain any directives, including a library directive. 443 * contain any directives, including a library directive.
426 */ 444 */
427 static final SourceKind LIBRARY = new SourceKind('LIBRARY', 1); 445 static const SourceKind LIBRARY = const SourceKind('LIBRARY', 1);
428 446
429 /** 447 /**
430 * A Dart compilation unit that is part of another library. Parts contain a pa rt-of directive. 448 * A Dart compilation unit that is part of another library. Parts contain a pa rt-of directive.
431 */ 449 */
432 static final SourceKind PART = new SourceKind('PART', 2); 450 static const SourceKind PART = const SourceKind('PART', 2);
433 451
434 /** 452 /**
435 * An unknown kind of source. Used both when it is not possible to identify th e kind of a source 453 * An unknown kind of source. Used both when it is not possible to identify th e kind of a source
436 * and also when the kind of a source is not known without performing a comput ation and the client 454 * and also when the kind of a source is not known without performing a comput ation and the client
437 * does not want to spend the time to identify the kind. 455 * does not want to spend the time to identify the kind.
438 */ 456 */
439 static final SourceKind UNKNOWN = new SourceKind('UNKNOWN', 3); 457 static const SourceKind UNKNOWN = const SourceKind('UNKNOWN', 3);
440 458
441 static final List<SourceKind> values = [HTML, LIBRARY, PART, UNKNOWN]; 459 static const List<SourceKind> values = const [HTML, LIBRARY, PART, UNKNOWN];
442 460
443 SourceKind(String name, int ordinal) : super(name, ordinal); 461 const SourceKind(String name, int ordinal) : super(name, ordinal);
444 } 462 }
445 463
446 /** 464 /**
447 * The enumeration `UriKind` defines the different kinds of URI's that are known to the 465 * The enumeration `UriKind` defines the different kinds of URI's that are known to the
448 * analysis engine. These are used to keep track of the kind of URI associated w ith a given source. 466 * analysis engine. These are used to keep track of the kind of URI associated w ith a given source.
449 */ 467 */
450 class UriKind extends Enum<UriKind> { 468 class UriKind extends Enum<UriKind> {
451 /** 469 /**
452 * A 'dart:' URI. 470 * A 'dart:' URI.
453 */ 471 */
454 static final UriKind DART_URI = new UriKind('DART_URI', 0, 0x64); 472 static const UriKind DART_URI = const UriKind('DART_URI', 0, 0x64);
455 473
456 /** 474 /**
457 * A 'file:' URI. 475 * A 'file:' URI.
458 */ 476 */
459 static final UriKind FILE_URI = new UriKind('FILE_URI', 1, 0x66); 477 static const UriKind FILE_URI = const UriKind('FILE_URI', 1, 0x66);
460 478
461 /** 479 /**
462 * A 'package:' URI referencing source package itself. 480 * A 'package:' URI referencing source package itself.
463 */ 481 */
464 static final UriKind PACKAGE_SELF_URI = new UriKind('PACKAGE_SELF_URI', 2, 0x7 3); 482 static const UriKind PACKAGE_SELF_URI = const UriKind('PACKAGE_SELF_URI', 2, 0 x73);
465 483
466 /** 484 /**
467 * A 'package:' URI. 485 * A 'package:' URI.
468 */ 486 */
469 static final UriKind PACKAGE_URI = new UriKind('PACKAGE_URI', 3, 0x70); 487 static const UriKind PACKAGE_URI = const UriKind('PACKAGE_URI', 3, 0x70);
470 488
471 static final List<UriKind> values = [DART_URI, FILE_URI, PACKAGE_SELF_URI, PAC KAGE_URI]; 489 static const List<UriKind> values = const [DART_URI, FILE_URI, PACKAGE_SELF_UR I, PACKAGE_URI];
472 490
473 /** 491 /**
474 * Return the URI kind represented by the given encoding, or `null` if there i s no kind with 492 * Return the URI kind represented by the given encoding, or `null` if there i s no kind with
475 * the given encoding. 493 * the given encoding.
476 * 494 *
477 * @param encoding the single character encoding used to identify the URI kind to be returned 495 * @param encoding the single character encoding used to identify the URI kind to be returned
478 * @return the URI kind represented by the given encoding 496 * @return the URI kind represented by the given encoding
479 */ 497 */
480 static UriKind fromEncoding(int encoding) { 498 static UriKind fromEncoding(int encoding) {
481 while (true) { 499 while (true) {
482 if (encoding == 0x64) { 500 if (encoding == 0x64) {
483 return DART_URI; 501 return DART_URI;
484 } else if (encoding == 0x66) { 502 } else if (encoding == 0x66) {
485 return FILE_URI; 503 return FILE_URI;
486 } else if (encoding == 0x73) { 504 } else if (encoding == 0x73) {
487 return PACKAGE_SELF_URI; 505 return PACKAGE_SELF_URI;
488 } else if (encoding == 0x70) { 506 } else if (encoding == 0x70) {
489 return PACKAGE_URI; 507 return PACKAGE_URI;
490 } 508 }
491 break; 509 break;
492 } 510 }
493 return null; 511 return null;
494 } 512 }
495 513
496 /** 514 /**
497 * The single character encoding used to identify this kind of URI. 515 * The single character encoding used to identify this kind of URI.
498 */ 516 */
499 int encoding = 0; 517 final int encoding;
500 518
501 /** 519 /**
502 * Initialize a newly created URI kind to have the given encoding. 520 * Initialize a newly created URI kind to have the given encoding.
503 * 521 *
504 * @param encoding the single character encoding used to identify this kind of URI. 522 * @param encoding the single character encoding used to identify this kind of URI.
505 */ 523 */
506 UriKind(String name, int ordinal, int encoding) : super(name, ordinal) { 524 const UriKind(String name, int ordinal, this.encoding) : super(name, ordinal);
507 this.encoding = encoding;
508 }
509 } 525 }
510 526
511 /** 527 /**
512 * A source range defines an [Element]'s source coordinates relative to its [Sou rce]. 528 * A source range defines an [Element]'s source coordinates relative to its [Sou rce].
513 */ 529 */
514 class SourceRange { 530 class SourceRange {
515 /** 531 /**
516 * An empty [SourceRange] with offset `0` and length `0`. 532 * An empty [SourceRange] with offset `0` and length `0`.
517 */ 533 */
518 static SourceRange EMPTY = new SourceRange(0, 0); 534 static SourceRange EMPTY = new SourceRange(0, 0);
519 535
520 /** 536 /**
521 * The 0-based index of the first character of the source code for this elemen t, relative to the 537 * The 0-based index of the first character of the source code for this elemen t, relative to the
522 * source buffer in which this element is contained. 538 * source buffer in which this element is contained.
523 */ 539 */
524 int offset = 0; 540 final int offset;
525 541
526 /** 542 /**
527 * The number of characters of the source code for this element, relative to t he source buffer in 543 * The number of characters of the source code for this element, relative to t he source buffer in
528 * which this element is contained. 544 * which this element is contained.
529 */ 545 */
530 int length = 0; 546 final int length;
531 547
532 /** 548 /**
533 * Initialize a newly created source range using the given offset and the give n length. 549 * Initialize a newly created source range using the given offset and the give n length.
534 * 550 *
535 * @param offset the given offset 551 * @param offset the given offset
536 * @param length the given length 552 * @param length the given length
537 */ 553 */
538 SourceRange(int offset, int length) { 554 SourceRange(this.offset, this.length);
539 this.offset = offset;
540 this.length = length;
541 }
542 555
543 /** 556 /**
544 * @return `true` if <code>x</code> is in [offset, offset + length) interval. 557 * @return `true` if <code>x</code> is in [offset, offset + length) interval.
545 */ 558 */
546 bool contains(int x) => offset <= x && x < offset + length; 559 bool contains(int x) => offset <= x && x < offset + length;
547 560
548 /** 561 /**
549 * @return `true` if <code>x</code> is in (offset, offset + length) interval. 562 * @return `true` if <code>x</code> is in (offset, offset + length) interval.
550 */ 563 */
551 bool containsExclusive(int x) => offset < x && x < offset + length; 564 bool containsExclusive(int x) => offset < x && x < offset + length;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 * @return `true` if the receiver contains the source, else `false` 663 * @return `true` if the receiver contains the source, else `false`
651 */ 664 */
652 bool contains(Source source); 665 bool contains(Source source);
653 } 666 }
654 667
655 /** 668 /**
656 * Instances of the class `DartUriResolver` resolve `dart` URI's. 669 * Instances of the class `DartUriResolver` resolve `dart` URI's.
657 */ 670 */
658 class DartUriResolver extends UriResolver { 671 class DartUriResolver extends UriResolver {
659 /** 672 /**
673 * Return `true` if the given URI is a `dart-ext:` URI.
674 *
675 * @param uriContent the textual representation of the URI being tested
676 * @return `true` if the given URI is a `dart-ext:` URI
677 */
678 static bool isDartExtUri(String uriContent) => uriContent != null && uriConten t.startsWith(_DART_EXT_SCHEME);
679
680 /**
660 * The Dart SDK against which URI's are to be resolved. 681 * The Dart SDK against which URI's are to be resolved.
661 */ 682 */
662 DartSdk _sdk; 683 final DartSdk _sdk;
663 684
664 /** 685 /**
665 * The name of the `dart` scheme. 686 * The name of the `dart` scheme.
666 */ 687 */
667 static String _DART_SCHEME = "dart"; 688 static String _DART_SCHEME = "dart";
668 689
669 /** 690 /**
691 * The prefix of a URI using the dart-ext scheme to reference a native code li brary.
692 */
693 static String _DART_EXT_SCHEME = "dart-ext:";
694
695 /**
670 * Return `true` if the given URI is a `dart:` URI. 696 * Return `true` if the given URI is a `dart:` URI.
671 * 697 *
672 * @param uri the URI being tested 698 * @param uri the URI being tested
673 * @return `true` if the given URI is a `dart:` URI 699 * @return `true` if the given URI is a `dart:` URI
674 */ 700 */
675 static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme; 701 static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme;
676 702
677 /** 703 /**
678 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the 704 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the
679 * given Dart SDK. 705 * given Dart SDK.
680 * 706 *
681 * @param sdk the Dart SDK against which URI's are to be resolved 707 * @param sdk the Dart SDK against which URI's are to be resolved
682 */ 708 */
683 DartUriResolver(DartSdk sdk) { 709 DartUriResolver(this._sdk);
684 this._sdk = sdk;
685 }
686 710
687 @override 711 @override
688 Source fromEncoding(UriKind kind, Uri uri) { 712 Source fromEncoding(UriKind kind, Uri uri) {
689 if (identical(kind, UriKind.DART_URI)) { 713 if (kind == UriKind.DART_URI) {
690 return _sdk.fromEncoding(kind, uri); 714 return _sdk.fromEncoding(kind, uri);
691 } 715 }
692 return null; 716 return null;
693 } 717 }
694 718
695 /** 719 /**
696 * Return the [DartSdk] against which URIs are to be resolved. 720 * Return the [DartSdk] against which URIs are to be resolved.
697 * 721 *
698 * @return the [DartSdk] against which URIs are to be resolved. 722 * @return the [DartSdk] against which URIs are to be resolved.
699 */ 723 */
700 DartSdk get dartSdk => _sdk; 724 DartSdk get dartSdk => _sdk;
701 725
702 @override 726 @override
703 Source resolveAbsolute(Uri uri) { 727 Source resolveAbsolute(Uri uri) {
704 if (!isDartUri(uri)) { 728 if (!isDartUri(uri)) {
705 return null; 729 return null;
706 } 730 }
707 return _sdk.mapDartUri(uri.toString()); 731 return _sdk.mapDartUri(uri.toString());
708 } 732 }
709 } 733 }
710 734
711 /** 735 /**
712 * Instances of the class `LineInfo` encapsulate information about line and colu mn information 736 * Instances of the class `LineInfo` encapsulate information about line and colu mn information
713 * within a source file. 737 * within a source file.
714 */ 738 */
715 class LineInfo { 739 class LineInfo {
716 /** 740 /**
717 * An array containing the offsets of the first character of each line in the source code. 741 * An array containing the offsets of the first character of each line in the source code.
718 */ 742 */
719 List<int> _lineStarts; 743 final List<int> _lineStarts;
720 744
721 /** 745 /**
722 * Initialize a newly created set of line information to represent the data en coded in the given 746 * Initialize a newly created set of line information to represent the data en coded in the given
723 * array. 747 * array.
724 * 748 *
725 * @param lineStarts the offsets of the first character of each line in the so urce code 749 * @param lineStarts the offsets of the first character of each line in the so urce code
726 */ 750 */
727 LineInfo(List<int> lineStarts) { 751 LineInfo(this._lineStarts) {
728 if (lineStarts == null) { 752 if (_lineStarts == null) {
729 throw new IllegalArgumentException("lineStarts must be non-null"); 753 throw new IllegalArgumentException("lineStarts must be non-null");
730 } else if (lineStarts.length < 1) { 754 } else if (_lineStarts.length < 1) {
731 throw new IllegalArgumentException("lineStarts must be non-empty"); 755 throw new IllegalArgumentException("lineStarts must be non-empty");
732 } 756 }
733 this._lineStarts = lineStarts;
734 } 757 }
735 758
736 /** 759 /**
737 * Return the location information for the character at the given offset. 760 * Return the location information for the character at the given offset.
738 * 761 *
739 * @param offset the offset of the character for which location information is to be returned 762 * @param offset the offset of the character for which location information is to be returned
740 * @return the location information for the character at the given offset 763 * @return the location information for the character at the given offset
741 */ 764 */
742 LineInfo_Location getLocation(int offset) { 765 LineInfo_Location getLocation(int offset) {
743 int lineCount = _lineStarts.length; 766 int lineCount = _lineStarts.length;
744 for (int i = 1; i < lineCount; i++) { 767 for (int i = 1; i < lineCount; i++) {
745 if (offset < _lineStarts[i]) { 768 if (offset < _lineStarts[i]) {
746 return new LineInfo_Location(i, offset - _lineStarts[i - 1] + 1); 769 return new LineInfo_Location(i, offset - _lineStarts[i - 1] + 1);
747 } 770 }
748 } 771 }
749 return new LineInfo_Location(lineCount, offset - _lineStarts[lineCount - 1] + 1); 772 return new LineInfo_Location(lineCount, offset - _lineStarts[lineCount - 1] + 1);
750 } 773 }
751 } 774 }
752 775
753 /** 776 /**
754 * Instances of the class `Location` represent the location of a character as a line and 777 * Instances of the class `Location` represent the location of a character as a line and
755 * column pair. 778 * column pair.
756 */ 779 */
757 class LineInfo_Location { 780 class LineInfo_Location {
758 /** 781 /**
759 * The one-based index of the line containing the character. 782 * The one-based index of the line containing the character.
760 */ 783 */
761 int lineNumber = 0; 784 final int lineNumber;
762 785
763 /** 786 /**
764 * The one-based index of the column containing the character. 787 * The one-based index of the column containing the character.
765 */ 788 */
766 int columnNumber = 0; 789 final int columnNumber;
767 790
768 /** 791 /**
769 * Initialize a newly created location to represent the location of the charac ter at the given 792 * Initialize a newly created location to represent the location of the charac ter at the given
770 * line and column position. 793 * line and column position.
771 * 794 *
772 * @param lineNumber the one-based index of the line containing the character 795 * @param lineNumber the one-based index of the line containing the character
773 * @param columnNumber the one-based index of the column containing the charac ter 796 * @param columnNumber the one-based index of the column containing the charac ter
774 */ 797 */
775 LineInfo_Location(int lineNumber, int columnNumber) { 798 LineInfo_Location(this.lineNumber, this.columnNumber);
776 this.lineNumber = lineNumber;
777 this.columnNumber = columnNumber;
778 }
779 } 799 }
780 800
781 /** 801 /**
782 * Instances of class `ContentCache` hold content used to override the default c ontent of a 802 * Instances of class `ContentCache` hold content used to override the default c ontent of a
783 * [Source]. 803 * [Source].
784 */ 804 */
785 class ContentCache { 805 class ContentCache {
786 /** 806 /**
787 * A table mapping sources to the contents of those sources. This is used to o verride the default 807 * A table mapping sources to the contents of those sources. This is used to o verride the default
788 * contents of a source. 808 * contents of a source.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 int oldStamp = javaMapPut(_stampMap, source, newStamp); 857 int oldStamp = javaMapPut(_stampMap, source, newStamp);
838 // Occasionally, if this method is called in rapid succession, the timesta mps are equal. 858 // Occasionally, if this method is called in rapid succession, the timesta mps are equal.
839 // Guard against this by artificially incrementing the new timestamp 859 // Guard against this by artificially incrementing the new timestamp
840 if (newStamp == oldStamp) { 860 if (newStamp == oldStamp) {
841 _stampMap[source] = newStamp + 1; 861 _stampMap[source] = newStamp + 1;
842 } 862 }
843 return javaMapPut(_contentMap, source, contents); 863 return javaMapPut(_contentMap, source, contents);
844 } 864 }
845 } 865 }
846 } 866 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | pkg/analyzer/lib/src/generated/source_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698