| 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/comment_type.dart'; |
| 10 import 'package:analyzer/dart/ast/syntactic_entity.dart'; | 11 import 'package:analyzer/dart/ast/syntactic_entity.dart'; |
| 11 import 'package:analyzer/dart/ast/token.dart'; | 12 import 'package:analyzer/dart/ast/token.dart'; |
| 12 import 'package:analyzer/dart/element/element.dart'; | 13 import 'package:analyzer/dart/element/element.dart'; |
| 13 import 'package:analyzer/dart/element/type.dart'; | 14 import 'package:analyzer/dart/element/type.dart'; |
| 14 import 'package:analyzer/exception/exception.dart'; | 15 import 'package:analyzer/exception/exception.dart'; |
| 15 import 'package:analyzer/src/dart/ast/token.dart'; | 16 import 'package:analyzer/src/dart/ast/token.dart'; |
| 16 import 'package:analyzer/src/dart/ast/utilities.dart'; | 17 import 'package:analyzer/src/dart/ast/utilities.dart'; |
| 17 import 'package:analyzer/src/dart/element/element.dart'; | 18 import 'package:analyzer/src/dart/element/element.dart'; |
| 18 import 'package:analyzer/src/dart/element/type.dart'; | 19 import 'package:analyzer/src/dart/element/type.dart'; |
| 19 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine; | 20 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine; |
| 20 import 'package:analyzer/src/generated/java_engine.dart'; | 21 import 'package:analyzer/src/generated/java_engine.dart'; |
| 21 import 'package:analyzer/src/generated/parser.dart'; | 22 import 'package:analyzer/src/generated/parser.dart'; |
| 22 import 'package:analyzer/src/generated/source.dart' show LineInfo, Source; | 23 import 'package:analyzer/src/generated/source.dart' show LineInfo, Source; |
| 23 import 'package:analyzer/src/generated/utilities_dart.dart'; | 24 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 24 | 25 |
| 26 export 'package:analyzer/dart/ast/comment_type.dart' show CommentType; |
| 27 export 'package:analyzer/src/dart/ast/uri_validation_code.dart' show UriValidati
onCodeImpl; |
| 28 |
| 25 /** | 29 /** |
| 26 * Two or more string literals that are implicitly concatenated because of being | 30 * Two or more string literals that are implicitly concatenated because of being |
| 27 * adjacent (separated only by whitespace). | 31 * adjacent (separated only by whitespace). |
| 28 * | 32 * |
| 29 * While the grammar only allows adjacent strings when all of the strings are of | 33 * While the grammar only allows adjacent strings when all of the strings are of |
| 30 * the same kind (single line or multi-line), this class doesn't enforce that | 34 * the same kind (single line or multi-line), this class doesn't enforce that |
| 31 * restriction. | 35 * restriction. |
| 32 * | 36 * |
| 33 * adjacentStrings ::= | 37 * adjacentStrings ::= |
| 34 * [StringLiteral] [StringLiteral]+ | 38 * [StringLiteral] [StringLiteral]+ |
| (...skipping 2294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => | 2333 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => |
| 2330 visitor.visitCommentReference(this); | 2334 visitor.visitCommentReference(this); |
| 2331 | 2335 |
| 2332 @override | 2336 @override |
| 2333 void visitChildren(AstVisitor visitor) { | 2337 void visitChildren(AstVisitor visitor) { |
| 2334 _identifier?.accept(visitor); | 2338 _identifier?.accept(visitor); |
| 2335 } | 2339 } |
| 2336 } | 2340 } |
| 2337 | 2341 |
| 2338 /** | 2342 /** |
| 2339 * The possible types of comments that are recognized by the parser. | |
| 2340 */ | |
| 2341 class CommentType { | |
| 2342 /** | |
| 2343 * A block comment. | |
| 2344 */ | |
| 2345 static const CommentType BLOCK = const CommentType('BLOCK'); | |
| 2346 | |
| 2347 /** | |
| 2348 * A documentation comment. | |
| 2349 */ | |
| 2350 static const CommentType DOCUMENTATION = const CommentType('DOCUMENTATION'); | |
| 2351 | |
| 2352 /** | |
| 2353 * An end-of-line comment. | |
| 2354 */ | |
| 2355 static const CommentType END_OF_LINE = const CommentType('END_OF_LINE'); | |
| 2356 | |
| 2357 /** | |
| 2358 * The name of the comment type. | |
| 2359 */ | |
| 2360 final String name; | |
| 2361 | |
| 2362 /** | |
| 2363 * Initialize a newly created comment type to have the given [name]. | |
| 2364 */ | |
| 2365 const CommentType(this.name); | |
| 2366 | |
| 2367 @override | |
| 2368 String toString() => name; | |
| 2369 } | |
| 2370 | |
| 2371 /** | |
| 2372 * A compilation unit. | 2343 * A compilation unit. |
| 2373 * | 2344 * |
| 2374 * While the grammar restricts the order of the directives and declarations | 2345 * While the grammar restricts the order of the directives and declarations |
| 2375 * within a compilation unit, this class does not enforce those restrictions. | 2346 * within a compilation unit, this class does not enforce those restrictions. |
| 2376 * In particular, the children of a compilation unit will be visited in lexical | 2347 * In particular, the children of a compilation unit will be visited in lexical |
| 2377 * order even if lexical order does not conform to the restrictions of the | 2348 * order even if lexical order does not conform to the restrictions of the |
| 2378 * grammar. | 2349 * grammar. |
| 2379 * | 2350 * |
| 2380 * compilationUnit ::= | 2351 * compilationUnit ::= |
| 2381 * directives declarations | 2352 * directives declarations |
| (...skipping 8319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10701 return UriValidationCode.INVALID_URI; | 10672 return UriValidationCode.INVALID_URI; |
| 10702 } | 10673 } |
| 10703 if (uri.path.isEmpty) { | 10674 if (uri.path.isEmpty) { |
| 10704 return UriValidationCode.INVALID_URI; | 10675 return UriValidationCode.INVALID_URI; |
| 10705 } | 10676 } |
| 10706 return null; | 10677 return null; |
| 10707 } | 10678 } |
| 10708 } | 10679 } |
| 10709 | 10680 |
| 10710 /** | 10681 /** |
| 10711 * Validation codes returned by [UriBasedDirective.validate]. | |
| 10712 */ | |
| 10713 class UriValidationCodeImpl implements UriValidationCode { | |
| 10714 static const UriValidationCode INVALID_URI = | |
| 10715 const UriValidationCodeImpl('INVALID_URI'); | |
| 10716 | |
| 10717 static const UriValidationCode URI_WITH_INTERPOLATION = | |
| 10718 const UriValidationCodeImpl('URI_WITH_INTERPOLATION'); | |
| 10719 | |
| 10720 static const UriValidationCode URI_WITH_DART_EXT_SCHEME = | |
| 10721 const UriValidationCodeImpl('URI_WITH_DART_EXT_SCHEME'); | |
| 10722 | |
| 10723 /** | |
| 10724 * The name of the validation code. | |
| 10725 */ | |
| 10726 final String name; | |
| 10727 | |
| 10728 /** | |
| 10729 * Initialize a newly created validation code to have the given [name]. | |
| 10730 */ | |
| 10731 const UriValidationCodeImpl(this.name); | |
| 10732 | |
| 10733 @override | |
| 10734 String toString() => name; | |
| 10735 } | |
| 10736 | |
| 10737 /** | |
| 10738 * An identifier that has an initial value associated with it. Instances of this | 10682 * An identifier that has an initial value associated with it. Instances of this |
| 10739 * class are always children of the class [VariableDeclarationList]. | 10683 * class are always children of the class [VariableDeclarationList]. |
| 10740 * | 10684 * |
| 10741 * variableDeclaration ::= | 10685 * variableDeclaration ::= |
| 10742 * [SimpleIdentifier] ('=' [Expression])? | 10686 * [SimpleIdentifier] ('=' [Expression])? |
| 10743 * | 10687 * |
| 10744 * TODO(paulberry): the grammar does not allow metadata to be associated with | 10688 * TODO(paulberry): the grammar does not allow metadata to be associated with |
| 10745 * a VariableDeclaration, and currently we don't record comments for it either. | 10689 * a VariableDeclaration, and currently we don't record comments for it either. |
| 10746 * Consider changing the class hierarchy so that [VariableDeclaration] does not | 10690 * Consider changing the class hierarchy so that [VariableDeclaration] does not |
| 10747 * extend [Declaration]. | 10691 * extend [Declaration]. |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11198 | 11142 |
| 11199 @override | 11143 @override |
| 11200 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => | 11144 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => |
| 11201 visitor.visitYieldStatement(this); | 11145 visitor.visitYieldStatement(this); |
| 11202 | 11146 |
| 11203 @override | 11147 @override |
| 11204 void visitChildren(AstVisitor visitor) { | 11148 void visitChildren(AstVisitor visitor) { |
| 11205 _expression?.accept(visitor); | 11149 _expression?.accept(visitor); |
| 11206 } | 11150 } |
| 11207 } | 11151 } |
| OLD | NEW |