OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.src.dart.ast.ast; | 5 library analyzer.src.dart.ast.ast; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 2576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2587 * | 2587 * |
2588 * test ::= | 2588 * test ::= |
2589 * dottedName ('==' stringLiteral)? | 2589 * dottedName ('==' stringLiteral)? |
2590 * | 2590 * |
2591 * dottedName ::= | 2591 * dottedName ::= |
2592 * identifier ('.' identifier)* | 2592 * identifier ('.' identifier)* |
2593 */ | 2593 */ |
2594 class ConfigurationImpl extends AstNodeImpl implements Configuration { | 2594 class ConfigurationImpl extends AstNodeImpl implements Configuration { |
2595 @override | 2595 @override |
2596 Token ifKeyword; | 2596 Token ifKeyword; |
| 2597 |
2597 @override | 2598 @override |
2598 Token leftParenthesis; | 2599 Token leftParenthesis; |
| 2600 |
2599 DottedName _name; | 2601 DottedName _name; |
| 2602 |
2600 @override | 2603 @override |
2601 Token equalToken; | 2604 Token equalToken; |
| 2605 |
2602 StringLiteral _value; | 2606 StringLiteral _value; |
| 2607 |
2603 @override | 2608 @override |
2604 Token rightParenthesis; | 2609 Token rightParenthesis; |
| 2610 |
2605 StringLiteral _libraryUri; | 2611 StringLiteral _libraryUri; |
2606 | 2612 |
| 2613 @override |
| 2614 Source uriSource; |
| 2615 |
2607 ConfigurationImpl( | 2616 ConfigurationImpl( |
2608 this.ifKeyword, | 2617 this.ifKeyword, |
2609 this.leftParenthesis, | 2618 this.leftParenthesis, |
2610 DottedNameImpl name, | 2619 DottedNameImpl name, |
2611 this.equalToken, | 2620 this.equalToken, |
2612 StringLiteralImpl value, | 2621 StringLiteralImpl value, |
2613 this.rightParenthesis, | 2622 this.rightParenthesis, |
2614 StringLiteralImpl libraryUri) { | 2623 StringLiteralImpl libraryUri) { |
2615 _name = _becomeParentOf(name); | 2624 _name = _becomeParentOf(name); |
2616 _value = _becomeParentOf(value); | 2625 _value = _becomeParentOf(value); |
(...skipping 4830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7447 * The combinators used to control which names are imported or exported. | 7456 * The combinators used to control which names are imported or exported. |
7448 */ | 7457 */ |
7449 NodeList<Combinator> _combinators; | 7458 NodeList<Combinator> _combinators; |
7450 | 7459 |
7451 /** | 7460 /** |
7452 * The semicolon terminating the directive. | 7461 * The semicolon terminating the directive. |
7453 */ | 7462 */ |
7454 @override | 7463 @override |
7455 Token semicolon; | 7464 Token semicolon; |
7456 | 7465 |
| 7466 @override |
| 7467 Source selectedSource; |
| 7468 |
7457 /** | 7469 /** |
7458 * Initialize a newly created namespace directive. Either or both of the | 7470 * Initialize a newly created namespace directive. Either or both of the |
7459 * [comment] and [metadata] can be `null` if the directive does not have the | 7471 * [comment] and [metadata] can be `null` if the directive does not have the |
7460 * corresponding attribute. The list of [combinators] can be `null` if there | 7472 * corresponding attribute. The list of [combinators] can be `null` if there |
7461 * are no combinators. | 7473 * are no combinators. |
7462 */ | 7474 */ |
7463 NamespaceDirectiveImpl( | 7475 NamespaceDirectiveImpl( |
7464 Comment comment, | 7476 Comment comment, |
7465 List<Annotation> metadata, | 7477 List<Annotation> metadata, |
7466 this.keyword, | 7478 this.keyword, |
(...skipping 11 matching lines...) Expand all Loading... |
7478 | 7490 |
7479 @override | 7491 @override |
7480 NodeList<Configuration> get configurations => _configurations; | 7492 NodeList<Configuration> get configurations => _configurations; |
7481 | 7493 |
7482 @override | 7494 @override |
7483 Token get endToken => semicolon; | 7495 Token get endToken => semicolon; |
7484 | 7496 |
7485 @override | 7497 @override |
7486 Token get firstTokenAfterCommentAndMetadata => keyword; | 7498 Token get firstTokenAfterCommentAndMetadata => keyword; |
7487 | 7499 |
| 7500 @deprecated |
| 7501 @override |
| 7502 Source get source => selectedSource; |
| 7503 |
| 7504 @deprecated |
| 7505 @override |
| 7506 void set source(Source source) { |
| 7507 selectedSource = source; |
| 7508 } |
| 7509 |
7488 @override | 7510 @override |
7489 LibraryElement get uriElement; | 7511 LibraryElement get uriElement; |
7490 } | 7512 } |
7491 | 7513 |
7492 /** | 7514 /** |
7493 * The "native" clause in an class declaration. | 7515 * The "native" clause in an class declaration. |
7494 * | 7516 * |
7495 * nativeClause ::= | 7517 * nativeClause ::= |
7496 * 'native' [StringLiteral] | 7518 * 'native' [StringLiteral] |
7497 */ | 7519 */ |
(...skipping 2990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10488 * The prefix of a URI using the `dart-ext` scheme to reference a native code | 10510 * The prefix of a URI using the `dart-ext` scheme to reference a native code |
10489 * library. | 10511 * library. |
10490 */ | 10512 */ |
10491 static String _DART_EXT_SCHEME = "dart-ext:"; | 10513 static String _DART_EXT_SCHEME = "dart-ext:"; |
10492 | 10514 |
10493 /** | 10515 /** |
10494 * The URI referenced by this directive. | 10516 * The URI referenced by this directive. |
10495 */ | 10517 */ |
10496 StringLiteral _uri; | 10518 StringLiteral _uri; |
10497 | 10519 |
10498 /** | 10520 @override |
10499 * The content of the URI. | |
10500 */ | |
10501 String uriContent; | 10521 String uriContent; |
10502 | 10522 |
10503 /** | 10523 @override |
10504 * The source to which the URI was resolved. | 10524 Source uriSource; |
10505 */ | |
10506 Source source; | |
10507 | 10525 |
10508 /** | 10526 /** |
10509 * Initialize a newly create URI-based directive. Either or both of the | 10527 * Initialize a newly create URI-based directive. Either or both of the |
10510 * [comment] and [metadata] can be `null` if the directive does not have the | 10528 * [comment] and [metadata] can be `null` if the directive does not have the |
10511 * corresponding attribute. | 10529 * corresponding attribute. |
10512 */ | 10530 */ |
10513 UriBasedDirectiveImpl( | 10531 UriBasedDirectiveImpl( |
10514 CommentImpl comment, List<Annotation> metadata, StringLiteralImpl uri) | 10532 CommentImpl comment, List<Annotation> metadata, StringLiteralImpl uri) |
10515 : super(comment, metadata) { | 10533 : super(comment, metadata) { |
10516 _uri = _becomeParentOf(uri); | 10534 _uri = _becomeParentOf(uri); |
10517 } | 10535 } |
10518 | 10536 |
| 10537 @deprecated |
| 10538 @override |
| 10539 Source get source => uriSource; |
| 10540 |
| 10541 @deprecated |
| 10542 @override |
| 10543 void set source(Source source) { |
| 10544 uriSource = source; |
| 10545 } |
| 10546 |
10519 @override | 10547 @override |
10520 StringLiteral get uri => _uri; | 10548 StringLiteral get uri => _uri; |
10521 | 10549 |
10522 @override | 10550 @override |
10523 void set uri(StringLiteral uri) { | 10551 void set uri(StringLiteral uri) { |
10524 _uri = _becomeParentOf(uri as AstNodeImpl); | 10552 _uri = _becomeParentOf(uri as AstNodeImpl); |
10525 } | 10553 } |
10526 | 10554 |
10527 @override | 10555 @override |
10528 UriValidationCode validate() { | 10556 UriValidationCode validate() { |
10529 StringLiteral uriLiteral = this.uri; | 10557 return validateUri(this is ImportDirective, uri, uriContent); |
| 10558 } |
| 10559 |
| 10560 @override |
| 10561 void visitChildren(AstVisitor visitor) { |
| 10562 super.visitChildren(visitor); |
| 10563 _uri?.accept(visitor); |
| 10564 } |
| 10565 |
| 10566 /** |
| 10567 * Validate this directive, but do not check for existence. Return a code |
| 10568 * indicating the problem if there is one, or `null` no problem. |
| 10569 */ |
| 10570 static UriValidationCode validateUri( |
| 10571 bool isImport, StringLiteral uriLiteral, String uriContent) { |
10530 if (uriLiteral is StringInterpolation) { | 10572 if (uriLiteral is StringInterpolation) { |
10531 return UriValidationCode.URI_WITH_INTERPOLATION; | 10573 return UriValidationCode.URI_WITH_INTERPOLATION; |
10532 } | 10574 } |
10533 String uriContent = this.uriContent; | |
10534 if (uriContent == null) { | 10575 if (uriContent == null) { |
10535 return UriValidationCode.INVALID_URI; | 10576 return UriValidationCode.INVALID_URI; |
10536 } | 10577 } |
10537 if (this is ImportDirective && uriContent.startsWith(_DART_EXT_SCHEME)) { | 10578 if (isImport && uriContent.startsWith(_DART_EXT_SCHEME)) { |
10538 return UriValidationCode.URI_WITH_DART_EXT_SCHEME; | 10579 return UriValidationCode.URI_WITH_DART_EXT_SCHEME; |
10539 } | 10580 } |
10540 Uri uri; | 10581 Uri uri; |
10541 try { | 10582 try { |
10542 uri = Uri.parse(Uri.encodeFull(uriContent)); | 10583 uri = Uri.parse(Uri.encodeFull(uriContent)); |
10543 } on FormatException { | 10584 } on FormatException { |
10544 return UriValidationCode.INVALID_URI; | 10585 return UriValidationCode.INVALID_URI; |
10545 } | 10586 } |
10546 if (uri.path.isEmpty) { | 10587 if (uri.path.isEmpty) { |
10547 return UriValidationCode.INVALID_URI; | 10588 return UriValidationCode.INVALID_URI; |
10548 } | 10589 } |
10549 return null; | 10590 return null; |
10550 } | 10591 } |
10551 | |
10552 @override | |
10553 void visitChildren(AstVisitor visitor) { | |
10554 super.visitChildren(visitor); | |
10555 _uri?.accept(visitor); | |
10556 } | |
10557 } | 10592 } |
10558 | 10593 |
10559 /** | 10594 /** |
10560 * Validation codes returned by [UriBasedDirective.validate]. | 10595 * Validation codes returned by [UriBasedDirective.validate]. |
10561 */ | 10596 */ |
10562 class UriValidationCodeImpl implements UriValidationCode { | 10597 class UriValidationCodeImpl implements UriValidationCode { |
10563 static const UriValidationCode INVALID_URI = | 10598 static const UriValidationCode INVALID_URI = |
10564 const UriValidationCodeImpl('INVALID_URI'); | 10599 const UriValidationCodeImpl('INVALID_URI'); |
10565 | 10600 |
10566 static const UriValidationCode URI_WITH_INTERPOLATION = | 10601 static const UriValidationCode URI_WITH_INTERPOLATION = |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11047 | 11082 |
11048 @override | 11083 @override |
11049 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => | 11084 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => |
11050 visitor.visitYieldStatement(this); | 11085 visitor.visitYieldStatement(this); |
11051 | 11086 |
11052 @override | 11087 @override |
11053 void visitChildren(AstVisitor visitor) { | 11088 void visitChildren(AstVisitor visitor) { |
11054 _expression?.accept(visitor); | 11089 _expression?.accept(visitor); |
11055 } | 11090 } |
11056 } | 11091 } |
OLD | NEW |