| 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 library engine.source; | 4 library engine.source; |
| 5 |
| 4 import 'java_core.dart'; | 6 import 'java_core.dart'; |
| 5 import 'sdk.dart' show DartSdk; | 7 import 'sdk.dart' show DartSdk; |
| 6 import 'engine.dart' show AnalysisContext; | 8 import 'engine.dart' show AnalysisContext; |
| 9 |
| 7 /** | 10 /** |
| 8 * Instances of the class `SourceFactory` resolve possibly relative URI's agains
t an existing | 11 * Instances of the class `SourceFactory` resolve possibly relative URI's agains
t an existing |
| 9 * [Source]. | 12 * [Source]. |
| 10 * | 13 * |
| 11 * @coverage dart.engine.source | 14 * @coverage dart.engine.source |
| 12 */ | 15 */ |
| 13 class SourceFactory { | 16 class SourceFactory { |
| 14 | |
| 15 /** | 17 /** |
| 16 * The analysis context that this source factory is associated with. | 18 * The analysis context that this source factory is associated with. |
| 17 */ | 19 */ |
| 18 AnalysisContext context; | 20 AnalysisContext context; |
| 19 | 21 |
| 20 /** | 22 /** |
| 21 * The resolvers used to resolve absolute URI's. | 23 * The resolvers used to resolve absolute URI's. |
| 22 */ | 24 */ |
| 23 List<UriResolver> _resolvers; | 25 List<UriResolver> _resolvers; |
| 24 | 26 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 if (result != null) { | 201 if (result != null) { |
| 200 return result; | 202 return result; |
| 201 } | 203 } |
| 202 } | 204 } |
| 203 return null; | 205 return null; |
| 204 } else { | 206 } else { |
| 205 return containingSource.resolveRelative(containedUri); | 207 return containingSource.resolveRelative(containedUri); |
| 206 } | 208 } |
| 207 } | 209 } |
| 208 } | 210 } |
| 211 |
| 209 /** | 212 /** |
| 210 * The abstract class `UriResolver` defines the behavior of objects that are use
d to resolve | 213 * The abstract class `UriResolver` defines the behavior of objects that are use
d to resolve |
| 211 * URI's for a source factory. Subclasses of this class are expected to resolve
a single scheme of | 214 * URI's for a source factory. Subclasses of this class are expected to resolve
a single scheme of |
| 212 * absolute URI. | 215 * absolute URI. |
| 213 * | 216 * |
| 214 * @coverage dart.engine.source | 217 * @coverage dart.engine.source |
| 215 */ | 218 */ |
| 216 abstract class UriResolver { | 219 abstract class UriResolver { |
| 217 | |
| 218 /** | 220 /** |
| 219 * If this resolver should be used for URI's of the given kind, resolve the gi
ven absolute URI. | 221 * If this resolver should be used for URI's of the given kind, resolve the gi
ven absolute URI. |
| 220 * The URI does not need to have the scheme handled by this resolver if the ki
nd matches. Return a | 222 * The URI does not need to have the scheme handled by this resolver if the ki
nd matches. Return a |
| 221 * [Source] representing the file to which it was resolved, or `null` if it | 223 * [Source] representing the file to which it was resolved, or `null` if it |
| 222 * could not be resolved. | 224 * could not be resolved. |
| 223 * | 225 * |
| 224 * @param contentCache the content cache used to access the contents of the re
turned source | 226 * @param contentCache the content cache used to access the contents of the re
turned source |
| 225 * @param kind the kind of URI that was originally resolved in order to produc
e an encoding with | 227 * @param kind the kind of URI that was originally resolved in order to produc
e an encoding with |
| 226 * the given URI | 228 * the given URI |
| 227 * @param uri the URI to be resolved | 229 * @param uri the URI to be resolved |
| (...skipping 12 matching lines...) Expand all Loading... |
| 240 Source resolveAbsolute(ContentCache contentCache, Uri uri); | 242 Source resolveAbsolute(ContentCache contentCache, Uri uri); |
| 241 | 243 |
| 242 /** | 244 /** |
| 243 * Return an absolute URI that represents the given source. | 245 * Return an absolute URI that represents the given source. |
| 244 * | 246 * |
| 245 * @param source the source to get URI for | 247 * @param source the source to get URI for |
| 246 * @return the absolute URI representing the given source, may be `null` | 248 * @return the absolute URI representing the given source, may be `null` |
| 247 */ | 249 */ |
| 248 Uri restoreAbsolute(Source source) => null; | 250 Uri restoreAbsolute(Source source) => null; |
| 249 } | 251 } |
| 252 |
| 250 /** | 253 /** |
| 251 * The interface `Source` defines the behavior of objects representing source co
de that can be | 254 * The interface `Source` defines the behavior of objects representing source co
de that can be |
| 252 * compiled. | 255 * compiled. |
| 253 * | 256 * |
| 254 * @coverage dart.engine.source | 257 * @coverage dart.engine.source |
| 255 */ | 258 */ |
| 256 abstract class Source { | 259 abstract class Source { |
| 257 | |
| 258 /** | 260 /** |
| 259 * An empty array of sources. | 261 * An empty array of sources. |
| 260 */ | 262 */ |
| 261 static final List<Source> EMPTY_ARRAY = new List<Source>(0); | 263 static final List<Source> EMPTY_ARRAY = new List<Source>(0); |
| 262 | 264 |
| 263 /** | 265 /** |
| 264 * Return `true` if the given object is a source that represents the same sour
ce code as | 266 * Return `true` if the given object is a source that represents the same sour
ce code as |
| 265 * this source. | 267 * this source. |
| 266 * | 268 * |
| 267 * @param object the object to be compared with this object | 269 * @param object the object to be compared with this object |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 * only intended to be invoked by a [SourceFactory]. Source factories will | 362 * only intended to be invoked by a [SourceFactory]. Source factories will |
| 361 * only invoke this method if the URI is relative, so implementations of this
method are not | 363 * only invoke this method if the URI is relative, so implementations of this
method are not |
| 362 * required to, and generally do not, verify the argument. The result of invok
ing this method with | 364 * required to, and generally do not, verify the argument. The result of invok
ing this method with |
| 363 * an absolute URI is intentionally left unspecified. | 365 * an absolute URI is intentionally left unspecified. |
| 364 * | 366 * |
| 365 * @param relativeUri the relative URI to be resolved against the containing s
ource | 367 * @param relativeUri the relative URI to be resolved against the containing s
ource |
| 366 * @return a [Source] representing the URI to which given URI was resolved | 368 * @return a [Source] representing the URI to which given URI was resolved |
| 367 */ | 369 */ |
| 368 Source resolveRelative(Uri relativeUri); | 370 Source resolveRelative(Uri relativeUri); |
| 369 } | 371 } |
| 372 |
| 370 /** | 373 /** |
| 371 * The interface `ContentReceiver` defines the behavior of objects that can rece
ive the | 374 * The interface `ContentReceiver` defines the behavior of objects that can rece
ive the |
| 372 * content of a source. | 375 * content of a source. |
| 373 */ | 376 */ |
| 374 abstract class Source_ContentReceiver { | 377 abstract class Source_ContentReceiver { |
| 375 | |
| 376 /** | 378 /** |
| 377 * Accept the contents of a source represented as a character buffer. | 379 * Accept the contents of a source represented as a character buffer. |
| 378 * | 380 * |
| 379 * @param contents the contents of the source | 381 * @param contents the contents of the source |
| 380 * @param modificationTime the time at which the contents were last set | 382 * @param modificationTime the time at which the contents were last set |
| 381 */ | 383 */ |
| 382 void accept(CharBuffer contents, int modificationTime); | 384 void accept(CharBuffer contents, int modificationTime); |
| 383 | 385 |
| 384 /** | 386 /** |
| 385 * Accept the contents of a source represented as a string. | 387 * Accept the contents of a source represented as a string. |
| 386 * | 388 * |
| 387 * @param contents the contents of the source | 389 * @param contents the contents of the source |
| 388 * @param modificationTime the time at which the contents were last set | 390 * @param modificationTime the time at which the contents were last set |
| 389 */ | 391 */ |
| 390 void accept2(String contents, int modificationTime); | 392 void accept2(String contents, int modificationTime); |
| 391 } | 393 } |
| 394 |
| 392 /** | 395 /** |
| 393 * The enumeration `SourceKind` defines the different kinds of sources that are
known to the | 396 * The enumeration `SourceKind` defines the different kinds of sources that are
known to the |
| 394 * analysis engine. | 397 * analysis engine. |
| 395 * | 398 * |
| 396 * @coverage dart.engine.source | 399 * @coverage dart.engine.source |
| 397 */ | 400 */ |
| 398 class SourceKind extends Enum<SourceKind> { | 401 class SourceKind extends Enum<SourceKind> { |
| 399 | |
| 400 /** | 402 /** |
| 401 * A source containing HTML. The HTML might or might not contain Dart scripts. | 403 * A source containing HTML. The HTML might or might not contain Dart scripts. |
| 402 */ | 404 */ |
| 403 static final SourceKind HTML = new SourceKind('HTML', 0); | 405 static final SourceKind HTML = new SourceKind('HTML', 0); |
| 404 | 406 |
| 405 /** | 407 /** |
| 406 * A Dart compilation unit that is not a part of another library. Libraries mi
ght or might not | 408 * A Dart compilation unit that is not a part of another library. Libraries mi
ght or might not |
| 407 * contain any directives, including a library directive. | 409 * contain any directives, including a library directive. |
| 408 */ | 410 */ |
| 409 static final SourceKind LIBRARY = new SourceKind('LIBRARY', 1); | 411 static final SourceKind LIBRARY = new SourceKind('LIBRARY', 1); |
| 410 | 412 |
| 411 /** | 413 /** |
| 412 * A Dart compilation unit that is part of another library. Parts contain a pa
rt-of directive. | 414 * A Dart compilation unit that is part of another library. Parts contain a pa
rt-of directive. |
| 413 */ | 415 */ |
| 414 static final SourceKind PART = new SourceKind('PART', 2); | 416 static final SourceKind PART = new SourceKind('PART', 2); |
| 415 | 417 |
| 416 /** | 418 /** |
| 417 * An unknown kind of source. Used both when it is not possible to identify th
e kind of a source | 419 * An unknown kind of source. Used both when it is not possible to identify th
e kind of a source |
| 418 * and also when the kind of a source is not known without performing a comput
ation and the client | 420 * and also when the kind of a source is not known without performing a comput
ation and the client |
| 419 * does not want to spend the time to identify the kind. | 421 * does not want to spend the time to identify the kind. |
| 420 */ | 422 */ |
| 421 static final SourceKind UNKNOWN = new SourceKind('UNKNOWN', 3); | 423 static final SourceKind UNKNOWN = new SourceKind('UNKNOWN', 3); |
| 424 |
| 422 static final List<SourceKind> values = [HTML, LIBRARY, PART, UNKNOWN]; | 425 static final List<SourceKind> values = [HTML, LIBRARY, PART, UNKNOWN]; |
| 426 |
| 423 SourceKind(String name, int ordinal) : super(name, ordinal); | 427 SourceKind(String name, int ordinal) : super(name, ordinal); |
| 424 } | 428 } |
| 429 |
| 425 /** | 430 /** |
| 426 * The enumeration `UriKind` defines the different kinds of URI's that are known
to the | 431 * The enumeration `UriKind` defines the different kinds of URI's that are known
to the |
| 427 * analysis engine. These are used to keep track of the kind of URI associated w
ith a given source. | 432 * analysis engine. These are used to keep track of the kind of URI associated w
ith a given source. |
| 428 * | 433 * |
| 429 * @coverage dart.engine.source | 434 * @coverage dart.engine.source |
| 430 */ | 435 */ |
| 431 class UriKind extends Enum<UriKind> { | 436 class UriKind extends Enum<UriKind> { |
| 432 | |
| 433 /** | 437 /** |
| 434 * A 'dart:' URI. | 438 * A 'dart:' URI. |
| 435 */ | 439 */ |
| 436 static final UriKind DART_URI = new UriKind('DART_URI', 0, 0x64); | 440 static final UriKind DART_URI = new UriKind('DART_URI', 0, 0x64); |
| 437 | 441 |
| 438 /** | 442 /** |
| 439 * A 'file:' URI. | 443 * A 'file:' URI. |
| 440 */ | 444 */ |
| 441 static final UriKind FILE_URI = new UriKind('FILE_URI', 1, 0x66); | 445 static final UriKind FILE_URI = new UriKind('FILE_URI', 1, 0x66); |
| 442 | 446 |
| 443 /** | 447 /** |
| 444 * A 'package:' URI referencing source package itself. | 448 * A 'package:' URI referencing source package itself. |
| 445 */ | 449 */ |
| 446 static final UriKind PACKAGE_SELF_URI = new UriKind('PACKAGE_SELF_URI', 2, 0x7
3); | 450 static final UriKind PACKAGE_SELF_URI = new UriKind('PACKAGE_SELF_URI', 2, 0x7
3); |
| 447 | 451 |
| 448 /** | 452 /** |
| 449 * A 'package:' URI. | 453 * A 'package:' URI. |
| 450 */ | 454 */ |
| 451 static final UriKind PACKAGE_URI = new UriKind('PACKAGE_URI', 3, 0x70); | 455 static final UriKind PACKAGE_URI = new UriKind('PACKAGE_URI', 3, 0x70); |
| 456 |
| 452 static final List<UriKind> values = [DART_URI, FILE_URI, PACKAGE_SELF_URI, PAC
KAGE_URI]; | 457 static final List<UriKind> values = [DART_URI, FILE_URI, PACKAGE_SELF_URI, PAC
KAGE_URI]; |
| 453 | 458 |
| 454 /** | 459 /** |
| 455 * Return the URI kind represented by the given encoding, or `null` if there i
s no kind with | 460 * Return the URI kind represented by the given encoding, or `null` if there i
s no kind with |
| 456 * the given encoding. | 461 * the given encoding. |
| 457 * | 462 * |
| 458 * @param encoding the single character encoding used to identify the URI kind
to be returned | 463 * @param encoding the single character encoding used to identify the URI kind
to be returned |
| 459 * @return the URI kind represented by the given encoding | 464 * @return the URI kind represented by the given encoding |
| 460 */ | 465 */ |
| 461 static UriKind fromEncoding(int encoding) { | 466 static UriKind fromEncoding(int encoding) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 481 | 486 |
| 482 /** | 487 /** |
| 483 * Initialize a newly created URI kind to have the given encoding. | 488 * Initialize a newly created URI kind to have the given encoding. |
| 484 * | 489 * |
| 485 * @param encoding the single character encoding used to identify this kind of
URI. | 490 * @param encoding the single character encoding used to identify this kind of
URI. |
| 486 */ | 491 */ |
| 487 UriKind(String name, int ordinal, int encoding) : super(name, ordinal) { | 492 UriKind(String name, int ordinal, int encoding) : super(name, ordinal) { |
| 488 this.encoding = encoding; | 493 this.encoding = encoding; |
| 489 } | 494 } |
| 490 } | 495 } |
| 496 |
| 491 /** | 497 /** |
| 492 * A source range defines an [Element]'s source coordinates relative to its [Sou
rce]. | 498 * A source range defines an [Element]'s source coordinates relative to its [Sou
rce]. |
| 493 * | 499 * |
| 494 * @coverage dart.engine.utilities | 500 * @coverage dart.engine.utilities |
| 495 */ | 501 */ |
| 496 class SourceRange { | 502 class SourceRange { |
| 497 | |
| 498 /** | 503 /** |
| 499 * The 0-based index of the first character of the source code for this elemen
t, relative to the | 504 * The 0-based index of the first character of the source code for this elemen
t, relative to the |
| 500 * source buffer in which this element is contained. | 505 * source buffer in which this element is contained. |
| 501 */ | 506 */ |
| 502 int offset = 0; | 507 int offset = 0; |
| 503 | 508 |
| 504 /** | 509 /** |
| 505 * The number of characters of the source code for this element, relative to t
he source buffer in | 510 * The number of characters of the source code for this element, relative to t
he source buffer in |
| 506 * which this element is contained. | 511 * which this element is contained. |
| 507 */ | 512 */ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 538 */ | 543 */ |
| 539 bool covers(SourceRange otherRange) => offset <= otherRange.offset && otherRan
ge.end <= end; | 544 bool covers(SourceRange otherRange) => offset <= otherRange.offset && otherRan
ge.end <= end; |
| 540 | 545 |
| 541 /** | 546 /** |
| 542 * @return `true` if this [SourceRange] ends in <code>otherRange</code>. | 547 * @return `true` if this [SourceRange] ends in <code>otherRange</code>. |
| 543 */ | 548 */ |
| 544 bool endsIn(SourceRange otherRange) { | 549 bool endsIn(SourceRange otherRange) { |
| 545 int thisEnd = end; | 550 int thisEnd = end; |
| 546 return otherRange.contains(thisEnd); | 551 return otherRange.contains(thisEnd); |
| 547 } | 552 } |
| 553 |
| 548 bool operator ==(Object obj) { | 554 bool operator ==(Object obj) { |
| 549 if (obj is! SourceRange) { | 555 if (obj is! SourceRange) { |
| 550 return false; | 556 return false; |
| 551 } | 557 } |
| 552 SourceRange sourceRange = obj as SourceRange; | 558 SourceRange sourceRange = obj as SourceRange; |
| 553 return sourceRange.offset == offset && sourceRange.length == length; | 559 return sourceRange.offset == offset && sourceRange.length == length; |
| 554 } | 560 } |
| 555 | 561 |
| 556 /** | 562 /** |
| 557 * @return the 0-based index of the after-last character of the source code fo
r this element, | 563 * @return the 0-based index of the after-last character of the source code fo
r this element, |
| 558 * relative to the source buffer in which this element is contained. | 564 * relative to the source buffer in which this element is contained. |
| 559 */ | 565 */ |
| 560 int get end => offset + length; | 566 int get end => offset + length; |
| 561 | 567 |
| 562 /** | 568 /** |
| 563 * @return the expanded instance of [SourceRange], which has the same center. | 569 * @return the expanded instance of [SourceRange], which has the same center. |
| 564 */ | 570 */ |
| 565 SourceRange getExpanded(int delta) => new SourceRange(offset - delta, delta +
length + delta); | 571 SourceRange getExpanded(int delta) => new SourceRange(offset - delta, delta +
length + delta); |
| 566 | 572 |
| 567 /** | 573 /** |
| 568 * @return the instance of [SourceRange] with end moved on "delta". | 574 * @return the instance of [SourceRange] with end moved on "delta". |
| 569 */ | 575 */ |
| 570 SourceRange getMoveEnd(int delta) => new SourceRange(offset, length + delta); | 576 SourceRange getMoveEnd(int delta) => new SourceRange(offset, length + delta); |
| 571 | 577 |
| 572 /** | 578 /** |
| 573 * @return the expanded translated of [SourceRange], with moved start and the
same length. | 579 * @return the expanded translated of [SourceRange], with moved start and the
same length. |
| 574 */ | 580 */ |
| 575 SourceRange getTranslated(int delta) => new SourceRange(offset + delta, length
); | 581 SourceRange getTranslated(int delta) => new SourceRange(offset + delta, length
); |
| 582 |
| 576 int get hashCode => 31 * offset + length; | 583 int get hashCode => 31 * offset + length; |
| 577 | 584 |
| 578 /** | 585 /** |
| 579 * @return `true` if this [SourceRange] intersects with given. | 586 * @return `true` if this [SourceRange] intersects with given. |
| 580 */ | 587 */ |
| 581 bool intersects(SourceRange other) { | 588 bool intersects(SourceRange other) { |
| 582 if (other == null) { | 589 if (other == null) { |
| 583 return false; | 590 return false; |
| 584 } | 591 } |
| 585 if (end <= other.offset) { | 592 if (end <= other.offset) { |
| 586 return false; | 593 return false; |
| 587 } | 594 } |
| 588 if (offset >= other.end) { | 595 if (offset >= other.end) { |
| 589 return false; | 596 return false; |
| 590 } | 597 } |
| 591 return true; | 598 return true; |
| 592 } | 599 } |
| 593 | 600 |
| 594 /** | 601 /** |
| 595 * @return `true` if this [SourceRange] starts in <code>otherRange</code>. | 602 * @return `true` if this [SourceRange] starts in <code>otherRange</code>. |
| 596 */ | 603 */ |
| 597 bool startsIn(SourceRange otherRange) => otherRange.contains(offset); | 604 bool startsIn(SourceRange otherRange) => otherRange.contains(offset); |
| 605 |
| 598 String toString() { | 606 String toString() { |
| 599 JavaStringBuilder builder = new JavaStringBuilder(); | 607 JavaStringBuilder builder = new JavaStringBuilder(); |
| 600 builder.append("[offset="); | 608 builder.append("[offset="); |
| 601 builder.append(offset); | 609 builder.append(offset); |
| 602 builder.append(", length="); | 610 builder.append(", length="); |
| 603 builder.append(length); | 611 builder.append(length); |
| 604 builder.append("]"); | 612 builder.append("]"); |
| 605 return builder.toString(); | 613 return builder.toString(); |
| 606 } | 614 } |
| 607 } | 615 } |
| 616 |
| 608 /** | 617 /** |
| 609 * The interface `SourceContainer` is used by clients to define a collection of
sources | 618 * The interface `SourceContainer` is used by clients to define a collection of
sources |
| 610 * | 619 * |
| 611 * Source containers are not used within analysis engine, but can be used by cli
ents to group | 620 * Source containers are not used within analysis engine, but can be used by cli
ents to group |
| 612 * sources for the purposes of accessing composite dependency information. For e
xample, the Eclipse | 621 * sources for the purposes of accessing composite dependency information. For e
xample, the Eclipse |
| 613 * client uses source containers to represent Eclipse projects, which allows it
to easily compute | 622 * client uses source containers to represent Eclipse projects, which allows it
to easily compute |
| 614 * project-level dependencies. | 623 * project-level dependencies. |
| 615 * | 624 * |
| 616 * @coverage dart.engine.source | 625 * @coverage dart.engine.source |
| 617 */ | 626 */ |
| 618 abstract class SourceContainer { | 627 abstract class SourceContainer { |
| 619 | |
| 620 /** | 628 /** |
| 621 * Determine if the specified source is part of the receiver's collection of s
ources. | 629 * Determine if the specified source is part of the receiver's collection of s
ources. |
| 622 * | 630 * |
| 623 * @param source the source in question | 631 * @param source the source in question |
| 624 * @return `true` if the receiver contains the source, else `false` | 632 * @return `true` if the receiver contains the source, else `false` |
| 625 */ | 633 */ |
| 626 bool contains(Source source); | 634 bool contains(Source source); |
| 627 } | 635 } |
| 636 |
| 628 /** | 637 /** |
| 629 * Instances of the class `DartUriResolver` resolve `dart` URI's. | 638 * Instances of the class `DartUriResolver` resolve `dart` URI's. |
| 630 * | 639 * |
| 631 * @coverage dart.engine.source | 640 * @coverage dart.engine.source |
| 632 */ | 641 */ |
| 633 class DartUriResolver extends UriResolver { | 642 class DartUriResolver extends UriResolver { |
| 634 | |
| 635 /** | 643 /** |
| 636 * The Dart SDK against which URI's are to be resolved. | 644 * The Dart SDK against which URI's are to be resolved. |
| 637 */ | 645 */ |
| 638 DartSdk dartSdk; | 646 DartSdk dartSdk; |
| 639 | 647 |
| 640 /** | 648 /** |
| 641 * The name of the `dart` scheme. | 649 * The name of the `dart` scheme. |
| 642 */ | 650 */ |
| 643 static String _DART_SCHEME = "dart"; | 651 static String _DART_SCHEME = "dart"; |
| 644 | 652 |
| 645 /** | 653 /** |
| 646 * Return `true` if the given URI is a `dart:` URI. | 654 * Return `true` if the given URI is a `dart:` URI. |
| 647 * | 655 * |
| 648 * @param uri the URI being tested | 656 * @param uri the URI being tested |
| 649 * @return `true` if the given URI is a `dart:` URI | 657 * @return `true` if the given URI is a `dart:` URI |
| 650 */ | 658 */ |
| 651 static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme; | 659 static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme; |
| 652 | 660 |
| 653 /** | 661 /** |
| 654 * Initialize a newly created resolver to resolve Dart URI's against the given
platform within the | 662 * Initialize a newly created resolver to resolve Dart URI's against the given
platform within the |
| 655 * given Dart SDK. | 663 * given Dart SDK. |
| 656 * | 664 * |
| 657 * @param sdk the Dart SDK against which URI's are to be resolved | 665 * @param sdk the Dart SDK against which URI's are to be resolved |
| 658 */ | 666 */ |
| 659 DartUriResolver(DartSdk sdk) { | 667 DartUriResolver(DartSdk sdk) { |
| 660 this.dartSdk = sdk; | 668 this.dartSdk = sdk; |
| 661 } | 669 } |
| 670 |
| 662 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) { | 671 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) { |
| 663 if (identical(kind, UriKind.DART_URI)) { | 672 if (identical(kind, UriKind.DART_URI)) { |
| 664 return dartSdk.fromEncoding(contentCache, kind, uri); | 673 return dartSdk.fromEncoding(contentCache, kind, uri); |
| 665 } | 674 } |
| 666 return null; | 675 return null; |
| 667 } | 676 } |
| 677 |
| 668 Source resolveAbsolute(ContentCache contentCache, Uri uri) { | 678 Source resolveAbsolute(ContentCache contentCache, Uri uri) { |
| 669 if (!isDartUri(uri)) { | 679 if (!isDartUri(uri)) { |
| 670 return null; | 680 return null; |
| 671 } | 681 } |
| 672 return dartSdk.mapDartUri(uri.toString()); | 682 return dartSdk.mapDartUri(uri.toString()); |
| 673 } | 683 } |
| 674 } | 684 } |
| 685 |
| 675 /** | 686 /** |
| 676 * Instances of the class `LineInfo` encapsulate information about line and colu
mn information | 687 * Instances of the class `LineInfo` encapsulate information about line and colu
mn information |
| 677 * within a source file. | 688 * within a source file. |
| 678 * | 689 * |
| 679 * @coverage dart.engine.utilities | 690 * @coverage dart.engine.utilities |
| 680 */ | 691 */ |
| 681 class LineInfo { | 692 class LineInfo { |
| 682 | |
| 683 /** | 693 /** |
| 684 * An array containing the offsets of the first character of each line in the
source code. | 694 * An array containing the offsets of the first character of each line in the
source code. |
| 685 */ | 695 */ |
| 686 List<int> _lineStarts; | 696 List<int> _lineStarts; |
| 687 | 697 |
| 688 /** | 698 /** |
| 689 * Initialize a newly created set of line information to represent the data en
coded in the given | 699 * Initialize a newly created set of line information to represent the data en
coded in the given |
| 690 * array. | 700 * array. |
| 691 * | 701 * |
| 692 * @param lineStarts the offsets of the first character of each line in the so
urce code | 702 * @param lineStarts the offsets of the first character of each line in the so
urce code |
| (...skipping 16 matching lines...) Expand all Loading... |
| 709 LineInfo_Location getLocation(int offset) { | 719 LineInfo_Location getLocation(int offset) { |
| 710 int lineCount = _lineStarts.length; | 720 int lineCount = _lineStarts.length; |
| 711 for (int i = 1; i < lineCount; i++) { | 721 for (int i = 1; i < lineCount; i++) { |
| 712 if (offset < _lineStarts[i]) { | 722 if (offset < _lineStarts[i]) { |
| 713 return new LineInfo_Location(i, offset - _lineStarts[i - 1] + 1); | 723 return new LineInfo_Location(i, offset - _lineStarts[i - 1] + 1); |
| 714 } | 724 } |
| 715 } | 725 } |
| 716 return new LineInfo_Location(lineCount, offset - _lineStarts[lineCount - 1]
+ 1); | 726 return new LineInfo_Location(lineCount, offset - _lineStarts[lineCount - 1]
+ 1); |
| 717 } | 727 } |
| 718 } | 728 } |
| 729 |
| 719 /** | 730 /** |
| 720 * Instances of the class `Location` represent the location of a character as a
line and | 731 * Instances of the class `Location` represent the location of a character as a
line and |
| 721 * column pair. | 732 * column pair. |
| 722 */ | 733 */ |
| 723 class LineInfo_Location { | 734 class LineInfo_Location { |
| 724 | |
| 725 /** | 735 /** |
| 726 * The one-based index of the line containing the character. | 736 * The one-based index of the line containing the character. |
| 727 */ | 737 */ |
| 728 int lineNumber = 0; | 738 int lineNumber = 0; |
| 729 | 739 |
| 730 /** | 740 /** |
| 731 * The one-based index of the column containing the character. | 741 * The one-based index of the column containing the character. |
| 732 */ | 742 */ |
| 733 int columnNumber = 0; | 743 int columnNumber = 0; |
| 734 | 744 |
| 735 /** | 745 /** |
| 736 * Initialize a newly created location to represent the location of the charac
ter at the given | 746 * Initialize a newly created location to represent the location of the charac
ter at the given |
| 737 * line and column position. | 747 * line and column position. |
| 738 * | 748 * |
| 739 * @param lineNumber the one-based index of the line containing the character | 749 * @param lineNumber the one-based index of the line containing the character |
| 740 * @param columnNumber the one-based index of the column containing the charac
ter | 750 * @param columnNumber the one-based index of the column containing the charac
ter |
| 741 */ | 751 */ |
| 742 LineInfo_Location(int lineNumber, int columnNumber) { | 752 LineInfo_Location(int lineNumber, int columnNumber) { |
| 743 this.lineNumber = lineNumber; | 753 this.lineNumber = lineNumber; |
| 744 this.columnNumber = columnNumber; | 754 this.columnNumber = columnNumber; |
| 745 } | 755 } |
| 746 } | 756 } |
| 757 |
| 747 /** | 758 /** |
| 748 * Instances of class `ContentCache` hold content used to override the default c
ontent of a | 759 * Instances of class `ContentCache` hold content used to override the default c
ontent of a |
| 749 * [Source]. | 760 * [Source]. |
| 750 * | 761 * |
| 751 * @coverage dart.engine.source | 762 * @coverage dart.engine.source |
| 752 */ | 763 */ |
| 753 class ContentCache { | 764 class ContentCache { |
| 754 | |
| 755 /** | 765 /** |
| 756 * A table mapping sources to the contents of those sources. This is used to o
verride the default | 766 * A table mapping sources to the contents of those sources. This is used to o
verride the default |
| 757 * contents of a source. | 767 * contents of a source. |
| 758 */ | 768 */ |
| 759 Map<Source, String> _contentMap = new Map<Source, String>(); | 769 Map<Source, String> _contentMap = new Map<Source, String>(); |
| 760 | 770 |
| 761 /** | 771 /** |
| 762 * A table mapping sources to the modification stamps of those sources. This i
s used when the | 772 * A table mapping sources to the modification stamps of those sources. This i
s used when the |
| 763 * default contents of a source has been overridden. | 773 * default contents of a source has been overridden. |
| 764 */ | 774 */ |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 String setContents(Source source, String contents) { | 810 String setContents(Source source, String contents) { |
| 801 if (contents == null) { | 811 if (contents == null) { |
| 802 _stampMap.remove(source); | 812 _stampMap.remove(source); |
| 803 return _contentMap.remove(source); | 813 return _contentMap.remove(source); |
| 804 } else { | 814 } else { |
| 805 _stampMap[source] = JavaSystem.currentTimeMillis(); | 815 _stampMap[source] = JavaSystem.currentTimeMillis(); |
| 806 return javaMapPut(_contentMap, source, contents); | 816 return javaMapPut(_contentMap, source, contents); |
| 807 } | 817 } |
| 808 } | 818 } |
| 809 } | 819 } |
| OLD | NEW |