| // This code was auto-generated, is not intended to be edited, and is subject to |
| // significant change. Please see the README file for more information. |
| library engine.ast; |
| import 'dart:collection'; |
| import 'java_core.dart'; |
| import 'java_engine.dart'; |
| import 'error.dart'; |
| import 'source.dart' show LineInfo; |
| import 'scanner.dart'; |
| import 'engine.dart' show AnalysisEngine; |
| import 'utilities_dart.dart'; |
| import 'element.dart'; |
| /** |
| * The abstract class `ASTNode` defines the behavior common to all nodes in the AST structure |
| * for a Dart program. |
| * |
| * @coverage dart.engine.ast |
| */ |
| abstract class ASTNode { |
| |
| /** |
| * An empty array of ast nodes. |
| */ |
| static List<ASTNode> EMPTY_ARRAY = new List<ASTNode>(0); |
| |
| /** |
| * The parent of the node, or `null` if the node is the root of an AST structure. |
| */ |
| ASTNode _parent; |
| |
| /** |
| * A table mapping the names of properties to their values, or `null` if this node does not |
| * have any properties associated with it. |
| */ |
| Map<String, Object> _propertyMap; |
| |
| /** |
| * A comparator that can be used to sort AST nodes in lexical order. In other words, |
| * `compare` will return a negative value if the offset of the first node is less than the |
| * offset of the second node, zero (0) if the nodes have the same offset, and a positive value if |
| * if the offset of the first node is greater than the offset of the second node. |
| */ |
| static Comparator<ASTNode> LEXICAL_ORDER = (ASTNode first, ASTNode second) => second.offset - first.offset; |
| |
| /** |
| * Use the given visitor to visit this node. |
| * |
| * @param visitor the visitor that will visit this node |
| * @return the value returned by the visitor as a result of visiting this node |
| */ |
| accept(ASTVisitor visitor); |
| |
| /** |
| * Return the node of the given class that most immediately encloses this node, or `null` if |
| * there is no enclosing node of the given class. |
| * |
| * @param nodeClass the class of the node to be returned |
| * @return the node of the given type that encloses this node |
| */ |
| ASTNode getAncestor(Type enclosingClass) { |
| ASTNode node = this; |
| while (node != null && !isInstanceOf(node, enclosingClass)) { |
| node = node.parent; |
| } |
| ; |
| return node as ASTNode; |
| } |
| |
| /** |
| * Return the first token included in this node's source range. |
| * |
| * @return the first token included in this node's source range |
| */ |
| Token get beginToken; |
| |
| /** |
| * Return the offset of the character immediately following the last character of this node's |
| * source range. This is equivalent to `node.getOffset() + node.getLength()`. For a |
| * compilation unit this will be equal to the length of the unit's source. For synthetic nodes |
| * this will be equivalent to the node's offset (because the length is zero (0) by definition). |
| * |
| * @return the offset of the character just past the node's source range |
| */ |
| int get end => offset + length; |
| |
| /** |
| * Return the last token included in this node's source range. |
| * |
| * @return the last token included in this node's source range |
| */ |
| Token get endToken; |
| |
| /** |
| * Return the number of characters in the node's source range. |
| * |
| * @return the number of characters in the node's source range |
| */ |
| int get length { |
| Token beginToken = this.beginToken; |
| Token endToken = this.endToken; |
| if (beginToken == null || endToken == null) { |
| return -1; |
| } |
| return endToken.offset + endToken.length - beginToken.offset; |
| } |
| |
| /** |
| * Return the offset from the beginning of the file to the first character in the node's source |
| * range. |
| * |
| * @return the offset from the beginning of the file to the first character in the node's source |
| * range |
| */ |
| int get offset { |
| Token beginToken = this.beginToken; |
| if (beginToken == null) { |
| return -1; |
| } |
| return this.beginToken.offset; |
| } |
| |
| /** |
| * Return this node's parent node, or `null` if this node is the root of an AST structure. |
| * |
| * Note that the relationship between an AST node and its parent node may change over the lifetime |
| * of a node. |
| * |
| * @return the parent of this node, or `null` if none |
| */ |
| ASTNode get parent => _parent; |
| |
| /** |
| * Return the value of the property with the given name, or `null` if this node does not |
| * have a property with the given name. |
| * |
| * @return the value of the property with the given name |
| */ |
| Object getProperty(String propertyName) { |
| if (_propertyMap == null) { |
| return null; |
| } |
| return _propertyMap[propertyName]; |
| } |
| |
| /** |
| * Return the node at the root of this node's AST structure. Note that this method's performance |
| * is linear with respect to the depth of the node in the AST structure (O(depth)). |
| * |
| * @return the node at the root of this node's AST structure |
| */ |
| ASTNode get root { |
| ASTNode root = this; |
| ASTNode parent = this.parent; |
| while (parent != null) { |
| root = parent; |
| parent = root.parent; |
| } |
| return root; |
| } |
| |
| /** |
| * Return `true` if this node is a synthetic node. A synthetic node is a node that was |
| * introduced by the parser in order to recover from an error in the code. Synthetic nodes always |
| * have a length of zero (`0`). |
| * |
| * @return `true` if this node is a synthetic node |
| */ |
| bool get isSynthetic => false; |
| |
| /** |
| * Set the value of the property with the given name to the given value. If the value is |
| * `null`, the property will effectively be removed. |
| * |
| * @param propertyName the name of the property whose value is to be set |
| * @param propertyValue the new value of the property |
| */ |
| void setProperty(String propertyName, Object propertyValue) { |
| if (propertyValue == null) { |
| if (_propertyMap != null) { |
| _propertyMap.remove(propertyName); |
| if (_propertyMap.isEmpty) { |
| _propertyMap = null; |
| } |
| } |
| } else { |
| if (_propertyMap == null) { |
| _propertyMap = new Map<String, Object>(); |
| } |
| _propertyMap[propertyName] = propertyValue; |
| } |
| } |
| |
| /** |
| * Return a textual description of this node in a form approximating valid source. The returned |
| * string will not be valid source primarily in the case where the node itself is not well-formed. |
| * |
| * @return the source code equivalent of this node |
| */ |
| String toSource() { |
| PrintStringWriter writer = new PrintStringWriter(); |
| accept(new ToSourceVisitor(writer)); |
| return writer.toString(); |
| } |
| String toString() => toSource(); |
| |
| /** |
| * Use the given visitor to visit all of the children of this node. The children will be visited |
| * in source order. |
| * |
| * @param visitor the visitor that will be used to visit the children of this node |
| */ |
| void visitChildren(ASTVisitor visitor); |
| |
| /** |
| * Make this node the parent of the given child node. |
| * |
| * @param child the node that will become a child of this node |
| * @return the node that was made a child of this node |
| */ |
| ASTNode becomeParentOf(ASTNode child) { |
| if (child != null) { |
| ASTNode node = child; |
| node.parent = this; |
| } |
| return child; |
| } |
| |
| /** |
| * If the given child is not `null`, use the given visitor to visit it. |
| * |
| * @param child the child to be visited |
| * @param visitor the visitor that will be used to visit the child |
| */ |
| void safelyVisitChild(ASTNode child, ASTVisitor visitor) { |
| if (child != null) { |
| child.accept(visitor); |
| } |
| } |
| |
| /** |
| * Set the parent of this node to the given node. |
| * |
| * @param newParent the node that is to be made the parent of this node |
| */ |
| void set parent(ASTNode newParent) { |
| _parent = newParent; |
| } |
| static int _hashCodeGenerator = 0; |
| final int hashCode = ++_hashCodeGenerator; |
| } |
| /** |
| * The interface `ASTVisitor` defines the behavior of objects that can be used to visit an AST |
| * structure. |
| * |
| * @coverage dart.engine.ast |
| */ |
| abstract class ASTVisitor<R> { |
| R visitAdjacentStrings(AdjacentStrings node); |
| R visitAnnotation(Annotation node); |
| R visitArgumentDefinitionTest(ArgumentDefinitionTest node); |
| R visitArgumentList(ArgumentList node); |
| R visitAsExpression(AsExpression node); |
| R visitAssertStatement(AssertStatement assertStatement); |
| R visitAssignmentExpression(AssignmentExpression node); |
| R visitBinaryExpression(BinaryExpression node); |
| R visitBlock(Block node); |
| R visitBlockFunctionBody(BlockFunctionBody node); |
| R visitBooleanLiteral(BooleanLiteral node); |
| R visitBreakStatement(BreakStatement node); |
| R visitCascadeExpression(CascadeExpression node); |
| R visitCatchClause(CatchClause node); |
| R visitClassDeclaration(ClassDeclaration node); |
| R visitClassTypeAlias(ClassTypeAlias node); |
| R visitComment(Comment node); |
| R visitCommentReference(CommentReference node); |
| R visitCompilationUnit(CompilationUnit node); |
| R visitConditionalExpression(ConditionalExpression node); |
| R visitConstructorDeclaration(ConstructorDeclaration node); |
| R visitConstructorFieldInitializer(ConstructorFieldInitializer node); |
| R visitConstructorName(ConstructorName node); |
| R visitContinueStatement(ContinueStatement node); |
| R visitDeclaredIdentifier(DeclaredIdentifier node); |
| R visitDefaultFormalParameter(DefaultFormalParameter node); |
| R visitDoStatement(DoStatement node); |
| R visitDoubleLiteral(DoubleLiteral node); |
| R visitEmptyFunctionBody(EmptyFunctionBody node); |
| R visitEmptyStatement(EmptyStatement node); |
| R visitExportDirective(ExportDirective node); |
| R visitExpressionFunctionBody(ExpressionFunctionBody node); |
| R visitExpressionStatement(ExpressionStatement node); |
| R visitExtendsClause(ExtendsClause node); |
| R visitFieldDeclaration(FieldDeclaration node); |
| R visitFieldFormalParameter(FieldFormalParameter node); |
| R visitForEachStatement(ForEachStatement node); |
| R visitFormalParameterList(FormalParameterList node); |
| R visitForStatement(ForStatement node); |
| R visitFunctionDeclaration(FunctionDeclaration node); |
| R visitFunctionDeclarationStatement(FunctionDeclarationStatement node); |
| R visitFunctionExpression(FunctionExpression node); |
| R visitFunctionExpressionInvocation(FunctionExpressionInvocation node); |
| R visitFunctionTypeAlias(FunctionTypeAlias functionTypeAlias); |
| R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node); |
| R visitHideCombinator(HideCombinator node); |
| R visitIfStatement(IfStatement node); |
| R visitImplementsClause(ImplementsClause node); |
| R visitImportDirective(ImportDirective node); |
| R visitIndexExpression(IndexExpression node); |
| R visitInstanceCreationExpression(InstanceCreationExpression node); |
| R visitIntegerLiteral(IntegerLiteral node); |
| R visitInterpolationExpression(InterpolationExpression node); |
| R visitInterpolationString(InterpolationString node); |
| R visitIsExpression(IsExpression node); |
| R visitLabel(Label node); |
| R visitLabeledStatement(LabeledStatement node); |
| R visitLibraryDirective(LibraryDirective node); |
| R visitLibraryIdentifier(LibraryIdentifier node); |
| R visitListLiteral(ListLiteral node); |
| R visitMapLiteral(MapLiteral node); |
| R visitMapLiteralEntry(MapLiteralEntry node); |
| R visitMethodDeclaration(MethodDeclaration node); |
| R visitMethodInvocation(MethodInvocation node); |
| R visitNamedExpression(NamedExpression node); |
| R visitNativeClause(NativeClause node); |
| R visitNativeFunctionBody(NativeFunctionBody node); |
| R visitNullLiteral(NullLiteral node); |
| R visitParenthesizedExpression(ParenthesizedExpression node); |
| R visitPartDirective(PartDirective node); |
| R visitPartOfDirective(PartOfDirective node); |
| R visitPostfixExpression(PostfixExpression node); |
| R visitPrefixedIdentifier(PrefixedIdentifier node); |
| R visitPrefixExpression(PrefixExpression node); |
| R visitPropertyAccess(PropertyAccess node); |
| R visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node); |
| R visitRethrowExpression(RethrowExpression node); |
| R visitReturnStatement(ReturnStatement node); |
| R visitScriptTag(ScriptTag node); |
| R visitShowCombinator(ShowCombinator node); |
| R visitSimpleFormalParameter(SimpleFormalParameter node); |
| R visitSimpleIdentifier(SimpleIdentifier node); |
| R visitSimpleStringLiteral(SimpleStringLiteral node); |
| R visitStringInterpolation(StringInterpolation node); |
| R visitSuperConstructorInvocation(SuperConstructorInvocation node); |
| R visitSuperExpression(SuperExpression node); |
| R visitSwitchCase(SwitchCase node); |
| R visitSwitchDefault(SwitchDefault node); |
| R visitSwitchStatement(SwitchStatement node); |
| R visitSymbolLiteral(SymbolLiteral node); |
| R visitThisExpression(ThisExpression node); |
| R visitThrowExpression(ThrowExpression node); |
| R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node); |
| R visitTryStatement(TryStatement node); |
| R visitTypeArgumentList(TypeArgumentList node); |
| R visitTypeName(TypeName node); |
| R visitTypeParameter(TypeParameter node); |
| R visitTypeParameterList(TypeParameterList node); |
| R visitVariableDeclaration(VariableDeclaration node); |
| R visitVariableDeclarationList(VariableDeclarationList node); |
| R visitVariableDeclarationStatement(VariableDeclarationStatement node); |
| R visitWhileStatement(WhileStatement node); |
| R visitWithClause(WithClause node); |
| } |
| /** |
| * Instances of the class `AdjacentStrings` represents two or more string literals that are |
| * implicitly concatenated because of being adjacent (separated only by whitespace). |
| * |
| * While the grammar only allows adjacent strings when all of the strings are of the same kind |
| * (single line or multi-line), this class doesn't enforce that restriction. |
| * |
| * <pre> |
| * adjacentStrings ::= |
| * [StringLiteral] [StringLiteral]+ |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class AdjacentStrings extends StringLiteral { |
| |
| /** |
| * The strings that are implicitly concatenated. |
| */ |
| NodeList<StringLiteral> strings; |
| |
| /** |
| * Initialize a newly created list of adjacent strings. |
| * |
| * @param strings the strings that are implicitly concatenated |
| */ |
| AdjacentStrings.full(List<StringLiteral> strings) { |
| this.strings = new NodeList<StringLiteral>(this); |
| this.strings.addAll(strings); |
| } |
| |
| /** |
| * Initialize a newly created list of adjacent strings. |
| * |
| * @param strings the strings that are implicitly concatenated |
| */ |
| AdjacentStrings({List<StringLiteral> strings}) : this.full(strings); |
| accept(ASTVisitor visitor) => visitor.visitAdjacentStrings(this); |
| Token get beginToken => strings.beginToken; |
| Token get endToken => strings.endToken; |
| void visitChildren(ASTVisitor visitor) { |
| strings.accept(visitor); |
| } |
| void appendStringValue(JavaStringBuilder builder) { |
| for (StringLiteral stringLiteral in strings) { |
| stringLiteral.appendStringValue(builder); |
| } |
| } |
| } |
| /** |
| * The abstract class `AnnotatedNode` defines the behavior of nodes that can be annotated with |
| * both a comment and metadata. |
| * |
| * @coverage dart.engine.ast |
| */ |
| abstract class AnnotatedNode extends ASTNode { |
| |
| /** |
| * The documentation comment associated with this node, or `null` if this node does not have |
| * a documentation comment associated with it. |
| */ |
| Comment _comment; |
| |
| /** |
| * The annotations associated with this node. |
| */ |
| NodeList<Annotation> _metadata; |
| |
| /** |
| * Initialize a newly created node. |
| * |
| * @param comment the documentation comment associated with this node |
| * @param metadata the annotations associated with this node |
| */ |
| AnnotatedNode.full(Comment comment, List<Annotation> metadata) { |
| this._metadata = new NodeList<Annotation>(this); |
| this._comment = becomeParentOf(comment); |
| this._metadata.addAll(metadata); |
| } |
| |
| /** |
| * Initialize a newly created node. |
| * |
| * @param comment the documentation comment associated with this node |
| * @param metadata the annotations associated with this node |
| */ |
| AnnotatedNode({Comment comment, List<Annotation> metadata}) : this.full(comment, metadata); |
| Token get beginToken { |
| if (_comment == null) { |
| if (_metadata.isEmpty) { |
| return firstTokenAfterCommentAndMetadata; |
| } else { |
| return _metadata.beginToken; |
| } |
| } else if (_metadata.isEmpty) { |
| return _comment.beginToken; |
| } |
| Token commentToken = _comment.beginToken; |
| Token metadataToken = _metadata.beginToken; |
| if (commentToken.offset < metadataToken.offset) { |
| return commentToken; |
| } |
| return metadataToken; |
| } |
| |
| /** |
| * Return the documentation comment associated with this node, or `null` if this node does |
| * not have a documentation comment associated with it. |
| * |
| * @return the documentation comment associated with this node |
| */ |
| Comment get documentationComment => _comment; |
| |
| /** |
| * Return the annotations associated with this node. |
| * |
| * @return the annotations associated with this node |
| */ |
| NodeList<Annotation> get metadata => _metadata; |
| |
| /** |
| * Set the documentation comment associated with this node to the given comment. |
| * |
| * @param comment the documentation comment to be associated with this node |
| */ |
| void set documentationComment(Comment comment) { |
| this._comment = becomeParentOf(comment); |
| } |
| |
| /** |
| * Set the metadata associated with this node to the given metadata. |
| * |
| * @param metadata the metadata to be associated with this node |
| */ |
| void set metadata(List<Annotation> metadata) { |
| this._metadata.clear(); |
| this._metadata.addAll(metadata); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| if (commentIsBeforeAnnotations()) { |
| safelyVisitChild(_comment, visitor); |
| _metadata.accept(visitor); |
| } else { |
| for (ASTNode child in sortedCommentAndAnnotations) { |
| child.accept(visitor); |
| } |
| } |
| } |
| |
| /** |
| * Return the first token following the comment and metadata. |
| * |
| * @return the first token following the comment and metadata |
| */ |
| Token get firstTokenAfterCommentAndMetadata; |
| |
| /** |
| * Return `true` if the comment is lexically before any annotations. |
| * |
| * @return `true` if the comment is lexically before any annotations |
| */ |
| bool commentIsBeforeAnnotations() { |
| if (_comment == null || _metadata.isEmpty) { |
| return true; |
| } |
| Annotation firstAnnotation = _metadata[0]; |
| return _comment.offset < firstAnnotation.offset; |
| } |
| |
| /** |
| * Return an array containing the comment and annotations associated with this node, sorted in |
| * lexical order. |
| * |
| * @return the comment and annotations associated with this node in the order in which they |
| * appeared in the original source |
| */ |
| List<ASTNode> get sortedCommentAndAnnotations { |
| List<ASTNode> childList = new List<ASTNode>(); |
| childList.add(_comment); |
| childList.addAll(_metadata); |
| List<ASTNode> children = new List.from(childList); |
| children.sort(ASTNode.LEXICAL_ORDER); |
| return children; |
| } |
| } |
| /** |
| * Instances of the class `Annotation` represent an annotation that can be associated with an |
| * AST node. |
| * |
| * <pre> |
| * metadata ::= |
| * annotation* |
| * |
| * annotation ::= |
| * '@' [Identifier] ('.' [SimpleIdentifier])? [ArgumentList]? |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class Annotation extends ASTNode { |
| |
| /** |
| * The at sign that introduced the annotation. |
| */ |
| Token atSign; |
| |
| /** |
| * The name of the class defining the constructor that is being invoked or the name of the field |
| * that is being referenced. |
| */ |
| Identifier _name; |
| |
| /** |
| * The period before the constructor name, or `null` if this annotation is not the |
| * invocation of a named constructor. |
| */ |
| Token period; |
| |
| /** |
| * The name of the constructor being invoked, or `null` if this annotation is not the |
| * invocation of a named constructor. |
| */ |
| SimpleIdentifier _constructorName; |
| |
| /** |
| * The arguments to the constructor being invoked, or `null` if this annotation is not the |
| * invocation of a constructor. |
| */ |
| ArgumentList _arguments; |
| |
| /** |
| * The element associated with this annotation, or `null` if the AST structure has not been |
| * resolved or if this annotation could not be resolved. |
| */ |
| Element _element; |
| |
| /** |
| * Initialize a newly created annotation. |
| * |
| * @param atSign the at sign that introduced the annotation |
| * @param name the name of the class defining the constructor that is being invoked or the name of |
| * the field that is being referenced |
| * @param period the period before the constructor name, or `null` if this annotation is not |
| * the invocation of a named constructor |
| * @param constructorName the name of the constructor being invoked, or `null` if this |
| * annotation is not the invocation of a named constructor |
| * @param arguments the arguments to the constructor being invoked, or `null` if this |
| * annotation is not the invocation of a constructor |
| */ |
| Annotation.full(Token atSign, Identifier name, Token period, SimpleIdentifier constructorName, ArgumentList arguments) { |
| this.atSign = atSign; |
| this._name = becomeParentOf(name); |
| this.period = period; |
| this._constructorName = becomeParentOf(constructorName); |
| this._arguments = becomeParentOf(arguments); |
| } |
| |
| /** |
| * Initialize a newly created annotation. |
| * |
| * @param atSign the at sign that introduced the annotation |
| * @param name the name of the class defining the constructor that is being invoked or the name of |
| * the field that is being referenced |
| * @param period the period before the constructor name, or `null` if this annotation is not |
| * the invocation of a named constructor |
| * @param constructorName the name of the constructor being invoked, or `null` if this |
| * annotation is not the invocation of a named constructor |
| * @param arguments the arguments to the constructor being invoked, or `null` if this |
| * annotation is not the invocation of a constructor |
| */ |
| Annotation({Token atSign, Identifier name, Token period, SimpleIdentifier constructorName, ArgumentList arguments}) : this.full(atSign, name, period, constructorName, arguments); |
| accept(ASTVisitor visitor) => visitor.visitAnnotation(this); |
| |
| /** |
| * Return the arguments to the constructor being invoked, or `null` if this annotation is |
| * not the invocation of a constructor. |
| * |
| * @return the arguments to the constructor being invoked |
| */ |
| ArgumentList get arguments => _arguments; |
| Token get beginToken => atSign; |
| |
| /** |
| * Return the name of the constructor being invoked, or `null` if this annotation is not the |
| * invocation of a named constructor. |
| * |
| * @return the name of the constructor being invoked |
| */ |
| SimpleIdentifier get constructorName => _constructorName; |
| |
| /** |
| * Return the element associated with this annotation, or `null` if the AST structure has |
| * not been resolved or if this annotation could not be resolved. |
| * |
| * @return the element associated with this annotation |
| */ |
| Element get element { |
| if (_element != null) { |
| return _element; |
| } |
| if (_name != null) { |
| return _name.staticElement; |
| } |
| return null; |
| } |
| Token get endToken { |
| if (_arguments != null) { |
| return _arguments.endToken; |
| } else if (_constructorName != null) { |
| return _constructorName.endToken; |
| } |
| return _name.endToken; |
| } |
| |
| /** |
| * Return the name of the class defining the constructor that is being invoked or the name of the |
| * field that is being referenced. |
| * |
| * @return the name of the constructor being invoked or the name of the field being referenced |
| */ |
| Identifier get name => _name; |
| |
| /** |
| * Set the arguments to the constructor being invoked to the given arguments. |
| * |
| * @param arguments the arguments to the constructor being invoked |
| */ |
| void set arguments(ArgumentList arguments) { |
| this._arguments = becomeParentOf(arguments); |
| } |
| |
| /** |
| * Set the name of the constructor being invoked to the given name. |
| * |
| * @param constructorName the name of the constructor being invoked |
| */ |
| void set constructorName(SimpleIdentifier constructorName) { |
| this._constructorName = becomeParentOf(constructorName); |
| } |
| |
| /** |
| * Set the element associated with this annotation based. |
| * |
| * @param element the element to be associated with this identifier |
| */ |
| void set element(Element element) { |
| this._element = element; |
| } |
| |
| /** |
| * Set the name of the class defining the constructor that is being invoked or the name of the |
| * field that is being referenced to the given name. |
| * |
| * @param name the name of the constructor being invoked or the name of the field being referenced |
| */ |
| void set name(Identifier name) { |
| this._name = becomeParentOf(name); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_name, visitor); |
| safelyVisitChild(_constructorName, visitor); |
| safelyVisitChild(_arguments, visitor); |
| } |
| } |
| /** |
| * Instances of the class `ArgumentDefinitionTest` represent an argument definition test. |
| * |
| * <pre> |
| * argumentDefinitionTest ::= |
| * '?' [SimpleIdentifier] |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class ArgumentDefinitionTest extends Expression { |
| |
| /** |
| * The token representing the question mark. |
| */ |
| Token question; |
| |
| /** |
| * The identifier representing the argument being tested. |
| */ |
| SimpleIdentifier _identifier; |
| |
| /** |
| * Initialize a newly created argument definition test. |
| * |
| * @param question the token representing the question mark |
| * @param identifier the identifier representing the argument being tested |
| */ |
| ArgumentDefinitionTest.full(Token question, SimpleIdentifier identifier) { |
| this.question = question; |
| this._identifier = becomeParentOf(identifier); |
| } |
| |
| /** |
| * Initialize a newly created argument definition test. |
| * |
| * @param question the token representing the question mark |
| * @param identifier the identifier representing the argument being tested |
| */ |
| ArgumentDefinitionTest({Token question, SimpleIdentifier identifier}) : this.full(question, identifier); |
| accept(ASTVisitor visitor) => visitor.visitArgumentDefinitionTest(this); |
| Token get beginToken => question; |
| Token get endToken => _identifier.endToken; |
| |
| /** |
| * Return the identifier representing the argument being tested. |
| * |
| * @return the identifier representing the argument being tested |
| */ |
| SimpleIdentifier get identifier => _identifier; |
| |
| /** |
| * Set the identifier representing the argument being tested to the given identifier. |
| * |
| * @param identifier the identifier representing the argument being tested |
| */ |
| void set identifier(SimpleIdentifier identifier) { |
| this._identifier = becomeParentOf(identifier); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_identifier, visitor); |
| } |
| } |
| /** |
| * Instances of the class `ArgumentList` represent a list of arguments in the invocation of a |
| * executable element: a function, method, or constructor. |
| * |
| * <pre> |
| * argumentList ::= |
| * '(' arguments? ')' |
| * |
| * arguments ::= |
| * [NamedExpression] (',' [NamedExpression])* |
| * | [Expression] (',' [NamedExpression])* |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class ArgumentList extends ASTNode { |
| |
| /** |
| * The left parenthesis. |
| */ |
| Token _leftParenthesis; |
| |
| /** |
| * The expressions producing the values of the arguments. |
| */ |
| NodeList<Expression> arguments; |
| |
| /** |
| * The right parenthesis. |
| */ |
| Token _rightParenthesis; |
| |
| /** |
| * An array containing the elements representing the parameters corresponding to each of the |
| * arguments in this list, or `null` if the AST has not been resolved or if the function or |
| * method being invoked could not be determined based on static type information. The array must |
| * be the same length as the number of arguments, but can contain `null` entries if a given |
| * argument does not correspond to a formal parameter. |
| */ |
| List<ParameterElement> _correspondingStaticParameters; |
| |
| /** |
| * An array containing the elements representing the parameters corresponding to each of the |
| * arguments in this list, or `null` if the AST has not been resolved or if the function or |
| * method being invoked could not be determined based on propagated type information. The array |
| * must be the same length as the number of arguments, but can contain `null` entries if a |
| * given argument does not correspond to a formal parameter. |
| */ |
| List<ParameterElement> _correspondingPropagatedParameters; |
| |
| /** |
| * Initialize a newly created list of arguments. |
| * |
| * @param leftParenthesis the left parenthesis |
| * @param arguments the expressions producing the values of the arguments |
| * @param rightParenthesis the right parenthesis |
| */ |
| ArgumentList.full(Token leftParenthesis, List<Expression> arguments, Token rightParenthesis) { |
| this.arguments = new NodeList<Expression>(this); |
| this._leftParenthesis = leftParenthesis; |
| this.arguments.addAll(arguments); |
| this._rightParenthesis = rightParenthesis; |
| } |
| |
| /** |
| * Initialize a newly created list of arguments. |
| * |
| * @param leftParenthesis the left parenthesis |
| * @param arguments the expressions producing the values of the arguments |
| * @param rightParenthesis the right parenthesis |
| */ |
| ArgumentList({Token leftParenthesis, List<Expression> arguments, Token rightParenthesis}) : this.full(leftParenthesis, arguments, rightParenthesis); |
| accept(ASTVisitor visitor) => visitor.visitArgumentList(this); |
| Token get beginToken => _leftParenthesis; |
| Token get endToken => _rightParenthesis; |
| |
| /** |
| * Return the left parenthesis. |
| * |
| * @return the left parenthesis |
| */ |
| Token get leftParenthesis => _leftParenthesis; |
| |
| /** |
| * Return the right parenthesis. |
| * |
| * @return the right parenthesis |
| */ |
| Token get rightParenthesis => _rightParenthesis; |
| |
| /** |
| * Set the parameter elements corresponding to each of the arguments in this list to the given |
| * array of parameters. The array of parameters must be the same length as the number of |
| * arguments, but can contain `null` entries if a given argument does not correspond to a |
| * formal parameter. |
| * |
| * @param parameters the parameter elements corresponding to the arguments |
| */ |
| void set correspondingPropagatedParameters(List<ParameterElement> parameters) { |
| if (parameters.length != arguments.length) { |
| throw new IllegalArgumentException("Expected ${arguments.length} parameters, not ${parameters.length}"); |
| } |
| _correspondingPropagatedParameters = parameters; |
| } |
| |
| /** |
| * Set the parameter elements corresponding to each of the arguments in this list to the given |
| * array of parameters. The array of parameters must be the same length as the number of |
| * arguments, but can contain `null` entries if a given argument does not correspond to a |
| * formal parameter. |
| * |
| * @param parameters the parameter elements corresponding to the arguments |
| */ |
| void set correspondingStaticParameters(List<ParameterElement> parameters) { |
| if (parameters.length != arguments.length) { |
| throw new IllegalArgumentException("Expected ${arguments.length} parameters, not ${parameters.length}"); |
| } |
| _correspondingStaticParameters = parameters; |
| } |
| |
| /** |
| * Set the left parenthesis to the given token. |
| * |
| * @param parenthesis the left parenthesis |
| */ |
| void set leftParenthesis(Token parenthesis) { |
| _leftParenthesis = parenthesis; |
| } |
| |
| /** |
| * Set the right parenthesis to the given token. |
| * |
| * @param parenthesis the right parenthesis |
| */ |
| void set rightParenthesis(Token parenthesis) { |
| _rightParenthesis = parenthesis; |
| } |
| void visitChildren(ASTVisitor visitor) { |
| arguments.accept(visitor); |
| } |
| |
| /** |
| * If the given expression is a child of this list, and the AST structure has been resolved, and |
| * the function being invoked is known based on propagated type information, and the expression |
| * corresponds to one of the parameters of the function being invoked, then return the parameter |
| * element representing the parameter to which the value of the given expression will be bound. |
| * Otherwise, return `null`. |
| * |
| * This method is only intended to be used by [Expression#getPropagatedParameterElement]. |
| * |
| * @param expression the expression corresponding to the parameter to be returned |
| * @return the parameter element representing the parameter to which the value of the expression |
| * will be bound |
| */ |
| ParameterElement getPropagatedParameterElementFor(Expression expression) { |
| if (_correspondingPropagatedParameters == null) { |
| return null; |
| } |
| int index = arguments.indexOf(expression); |
| if (index < 0) { |
| return null; |
| } |
| return _correspondingPropagatedParameters[index]; |
| } |
| |
| /** |
| * If the given expression is a child of this list, and the AST structure has been resolved, and |
| * the function being invoked is known based on static type information, and the expression |
| * corresponds to one of the parameters of the function being invoked, then return the parameter |
| * element representing the parameter to which the value of the given expression will be bound. |
| * Otherwise, return `null`. |
| * |
| * This method is only intended to be used by [Expression#getStaticParameterElement]. |
| * |
| * @param expression the expression corresponding to the parameter to be returned |
| * @return the parameter element representing the parameter to which the value of the expression |
| * will be bound |
| */ |
| ParameterElement getStaticParameterElementFor(Expression expression) { |
| if (_correspondingStaticParameters == null) { |
| return null; |
| } |
| int index = arguments.indexOf(expression); |
| if (index < 0) { |
| return null; |
| } |
| return _correspondingStaticParameters[index]; |
| } |
| } |
| /** |
| * Instances of the class `AsExpression` represent an 'as' expression. |
| * |
| * <pre> |
| * asExpression ::= |
| * [Expression] 'as' [TypeName] |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class AsExpression extends Expression { |
| |
| /** |
| * The expression used to compute the value being cast. |
| */ |
| Expression _expression; |
| |
| /** |
| * The as operator. |
| */ |
| Token asOperator; |
| |
| /** |
| * The name of the type being cast to. |
| */ |
| TypeName _type; |
| |
| /** |
| * Initialize a newly created as expression. |
| * |
| * @param expression the expression used to compute the value being cast |
| * @param isOperator the is operator |
| * @param type the name of the type being cast to |
| */ |
| AsExpression.full(Expression expression, Token isOperator, TypeName type) { |
| this._expression = becomeParentOf(expression); |
| this.asOperator = isOperator; |
| this._type = becomeParentOf(type); |
| } |
| |
| /** |
| * Initialize a newly created as expression. |
| * |
| * @param expression the expression used to compute the value being cast |
| * @param isOperator the is operator |
| * @param type the name of the type being cast to |
| */ |
| AsExpression({Expression expression, Token isOperator, TypeName type}) : this.full(expression, isOperator, type); |
| accept(ASTVisitor visitor) => visitor.visitAsExpression(this); |
| Token get beginToken => _expression.beginToken; |
| Token get endToken => _type.endToken; |
| |
| /** |
| * Return the expression used to compute the value being cast. |
| * |
| * @return the expression used to compute the value being cast |
| */ |
| Expression get expression => _expression; |
| |
| /** |
| * Return the name of the type being cast to. |
| * |
| * @return the name of the type being cast to |
| */ |
| TypeName get type => _type; |
| |
| /** |
| * Set the expression used to compute the value being cast to the given expression. |
| * |
| * @param expression the expression used to compute the value being cast |
| */ |
| void set expression(Expression expression) { |
| this._expression = becomeParentOf(expression); |
| } |
| |
| /** |
| * Set the name of the type being cast to to the given name. |
| * |
| * @param name the name of the type being cast to |
| */ |
| void set type(TypeName name) { |
| this._type = becomeParentOf(name); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_expression, visitor); |
| safelyVisitChild(_type, visitor); |
| } |
| } |
| /** |
| * Instances of the class `AssertStatement` represent an assert statement. |
| * |
| * <pre> |
| * assertStatement ::= |
| * 'assert' '(' [Expression] ')' ';' |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class AssertStatement extends Statement { |
| |
| /** |
| * The token representing the 'assert' keyword. |
| */ |
| Token keyword; |
| |
| /** |
| * The left parenthesis. |
| */ |
| Token leftParenthesis; |
| |
| /** |
| * The condition that is being asserted to be `true`. |
| */ |
| Expression _condition; |
| |
| /** |
| * The right parenthesis. |
| */ |
| Token rightParenthesis; |
| |
| /** |
| * The semicolon terminating the statement. |
| */ |
| Token semicolon; |
| |
| /** |
| * Initialize a newly created assert statement. |
| * |
| * @param keyword the token representing the 'assert' keyword |
| * @param leftParenthesis the left parenthesis |
| * @param condition the condition that is being asserted to be `true` |
| * @param rightParenthesis the right parenthesis |
| * @param semicolon the semicolon terminating the statement |
| */ |
| AssertStatement.full(Token keyword, Token leftParenthesis, Expression condition, Token rightParenthesis, Token semicolon) { |
| this.keyword = keyword; |
| this.leftParenthesis = leftParenthesis; |
| this._condition = becomeParentOf(condition); |
| this.rightParenthesis = rightParenthesis; |
| this.semicolon = semicolon; |
| } |
| |
| /** |
| * Initialize a newly created assert statement. |
| * |
| * @param keyword the token representing the 'assert' keyword |
| * @param leftParenthesis the left parenthesis |
| * @param condition the condition that is being asserted to be `true` |
| * @param rightParenthesis the right parenthesis |
| * @param semicolon the semicolon terminating the statement |
| */ |
| AssertStatement({Token keyword, Token leftParenthesis, Expression condition, Token rightParenthesis, Token semicolon}) : this.full(keyword, leftParenthesis, condition, rightParenthesis, semicolon); |
| accept(ASTVisitor visitor) => visitor.visitAssertStatement(this); |
| Token get beginToken => keyword; |
| |
| /** |
| * Return the condition that is being asserted to be `true`. |
| * |
| * @return the condition that is being asserted to be `true` |
| */ |
| Expression get condition => _condition; |
| Token get endToken => semicolon; |
| |
| /** |
| * Set the condition that is being asserted to be `true` to the given expression. |
| * |
| * @param the condition that is being asserted to be `true` |
| */ |
| void set condition(Expression condition) { |
| this._condition = becomeParentOf(condition); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_condition, visitor); |
| } |
| } |
| /** |
| * Instances of the class `AssignmentExpression` represent an assignment expression. |
| * |
| * <pre> |
| * assignmentExpression ::= |
| * [Expression] [Token] [Expression] |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class AssignmentExpression extends Expression { |
| |
| /** |
| * The expression used to compute the left hand side. |
| */ |
| Expression _leftHandSide; |
| |
| /** |
| * The assignment operator being applied. |
| */ |
| Token operator; |
| |
| /** |
| * The expression used to compute the right hand side. |
| */ |
| Expression _rightHandSide; |
| |
| /** |
| * The element associated with the operator based on the static type of the left-hand-side, or |
| * `null` if the AST structure has not been resolved, if the operator is not a compound |
| * operator, or if the operator could not be resolved. |
| */ |
| MethodElement _staticElement; |
| |
| /** |
| * The element associated with the operator based on the propagated type of the left-hand-side, or |
| * `null` if the AST structure has not been resolved, if the operator is not a compound |
| * operator, or if the operator could not be resolved. |
| */ |
| MethodElement _propagatedElement; |
| |
| /** |
| * Initialize a newly created assignment expression. |
| * |
| * @param leftHandSide the expression used to compute the left hand side |
| * @param operator the assignment operator being applied |
| * @param rightHandSide the expression used to compute the right hand side |
| */ |
| AssignmentExpression.full(Expression leftHandSide, Token operator, Expression rightHandSide) { |
| this._leftHandSide = becomeParentOf(leftHandSide); |
| this.operator = operator; |
| this._rightHandSide = becomeParentOf(rightHandSide); |
| } |
| |
| /** |
| * Initialize a newly created assignment expression. |
| * |
| * @param leftHandSide the expression used to compute the left hand side |
| * @param operator the assignment operator being applied |
| * @param rightHandSide the expression used to compute the right hand side |
| */ |
| AssignmentExpression({Expression leftHandSide, Token operator, Expression rightHandSide}) : this.full(leftHandSide, operator, rightHandSide); |
| accept(ASTVisitor visitor) => visitor.visitAssignmentExpression(this); |
| Token get beginToken => _leftHandSide.beginToken; |
| |
| /** |
| * Return the best element available for this operator. If resolution was able to find a better |
| * element based on type propagation, that element will be returned. Otherwise, the element found |
| * using the result of static analysis will be returned. If resolution has not been performed, |
| * then `null` will be returned. |
| * |
| * @return the best element available for this operator |
| */ |
| MethodElement get bestElement { |
| MethodElement element = propagatedElement; |
| if (element == null) { |
| element = staticElement; |
| } |
| return element; |
| } |
| Token get endToken => _rightHandSide.endToken; |
| |
| /** |
| * Set the expression used to compute the left hand side to the given expression. |
| * |
| * @return the expression used to compute the left hand side |
| */ |
| Expression get leftHandSide => _leftHandSide; |
| |
| /** |
| * Return the element associated with the operator based on the propagated type of the |
| * left-hand-side, or `null` if the AST structure has not been resolved, if the operator is |
| * not a compound operator, or if the operator could not be resolved. One example of the latter |
| * case is an operator that is not defined for the type of the left-hand operand. |
| * |
| * @return the element associated with the operator |
| */ |
| MethodElement get propagatedElement => _propagatedElement; |
| |
| /** |
| * Return the expression used to compute the right hand side. |
| * |
| * @return the expression used to compute the right hand side |
| */ |
| Expression get rightHandSide => _rightHandSide; |
| |
| /** |
| * Return the element associated with the operator based on the static type of the left-hand-side, |
| * or `null` if the AST structure has not been resolved, if the operator is not a compound |
| * operator, or if the operator could not be resolved. One example of the latter case is an |
| * operator that is not defined for the type of the left-hand operand. |
| * |
| * @return the element associated with the operator |
| */ |
| MethodElement get staticElement => _staticElement; |
| |
| /** |
| * Return the expression used to compute the left hand side. |
| * |
| * @param expression the expression used to compute the left hand side |
| */ |
| void set leftHandSide(Expression expression) { |
| _leftHandSide = becomeParentOf(expression); |
| } |
| |
| /** |
| * Set the element associated with the operator based on the propagated type of the left-hand-side |
| * to the given element. |
| * |
| * @param element the element to be associated with the operator |
| */ |
| void set propagatedElement(MethodElement element) { |
| _propagatedElement = element; |
| } |
| |
| /** |
| * Set the expression used to compute the left hand side to the given expression. |
| * |
| * @param expression the expression used to compute the left hand side |
| */ |
| void set rightHandSide(Expression expression) { |
| _rightHandSide = becomeParentOf(expression); |
| } |
| |
| /** |
| * Set the element associated with the operator based on the static type of the left-hand-side to |
| * the given element. |
| * |
| * @param element the static element to be associated with the operator |
| */ |
| void set staticElement(MethodElement element) { |
| _staticElement = element; |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_leftHandSide, visitor); |
| safelyVisitChild(_rightHandSide, visitor); |
| } |
| |
| /** |
| * If the AST structure has been resolved, and the function being invoked is known based on |
| * propagated type information, then return the parameter element representing the parameter to |
| * which the value of the right operand will be bound. Otherwise, return `null`. |
| * |
| * This method is only intended to be used by [Expression#getPropagatedParameterElement]. |
| * |
| * @return the parameter element representing the parameter to which the value of the right |
| * operand will be bound |
| */ |
| ParameterElement get propagatedParameterElementForRightHandSide { |
| if (_propagatedElement == null) { |
| return null; |
| } |
| List<ParameterElement> parameters = _propagatedElement.parameters; |
| if (parameters.length < 1) { |
| return null; |
| } |
| return parameters[0]; |
| } |
| |
| /** |
| * If the AST structure has been resolved, and the function being invoked is known based on static |
| * type information, then return the parameter element representing the parameter to which the |
| * value of the right operand will be bound. Otherwise, return `null`. |
| * |
| * This method is only intended to be used by [Expression#getStaticParameterElement]. |
| * |
| * @return the parameter element representing the parameter to which the value of the right |
| * operand will be bound |
| */ |
| ParameterElement get staticParameterElementForRightHandSide { |
| if (_staticElement == null) { |
| return null; |
| } |
| List<ParameterElement> parameters = _staticElement.parameters; |
| if (parameters.length < 1) { |
| return null; |
| } |
| return parameters[0]; |
| } |
| } |
| /** |
| * Instances of the class `BinaryExpression` represent a binary (infix) expression. |
| * |
| * <pre> |
| * binaryExpression ::= |
| * [Expression] [Token] [Expression] |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class BinaryExpression extends Expression { |
| |
| /** |
| * The expression used to compute the left operand. |
| */ |
| Expression _leftOperand; |
| |
| /** |
| * The binary operator being applied. |
| */ |
| Token operator; |
| |
| /** |
| * The expression used to compute the right operand. |
| */ |
| Expression _rightOperand; |
| |
| /** |
| * The element associated with the operator based on the static type of the left operand, or |
| * `null` if the AST structure has not been resolved, if the operator is not user definable, |
| * or if the operator could not be resolved. |
| */ |
| MethodElement _staticElement; |
| |
| /** |
| * The element associated with the operator based on the propagated type of the left operand, or |
| * `null` if the AST structure has not been resolved, if the operator is not user definable, |
| * or if the operator could not be resolved. |
| */ |
| MethodElement _propagatedElement; |
| |
| /** |
| * Initialize a newly created binary expression. |
| * |
| * @param leftOperand the expression used to compute the left operand |
| * @param operator the binary operator being applied |
| * @param rightOperand the expression used to compute the right operand |
| */ |
| BinaryExpression.full(Expression leftOperand, Token operator, Expression rightOperand) { |
| this._leftOperand = becomeParentOf(leftOperand); |
| this.operator = operator; |
| this._rightOperand = becomeParentOf(rightOperand); |
| } |
| |
| /** |
| * Initialize a newly created binary expression. |
| * |
| * @param leftOperand the expression used to compute the left operand |
| * @param operator the binary operator being applied |
| * @param rightOperand the expression used to compute the right operand |
| */ |
| BinaryExpression({Expression leftOperand, Token operator, Expression rightOperand}) : this.full(leftOperand, operator, rightOperand); |
| accept(ASTVisitor visitor) => visitor.visitBinaryExpression(this); |
| Token get beginToken => _leftOperand.beginToken; |
| |
| /** |
| * Return the best element available for this operator. If resolution was able to find a better |
| * element based on type propagation, that element will be returned. Otherwise, the element found |
| * using the result of static analysis will be returned. If resolution has not been performed, |
| * then `null` will be returned. |
| * |
| * @return the best element available for this operator |
| */ |
| MethodElement get bestElement { |
| MethodElement element = propagatedElement; |
| if (element == null) { |
| element = staticElement; |
| } |
| return element; |
| } |
| Token get endToken => _rightOperand.endToken; |
| |
| /** |
| * Return the expression used to compute the left operand. |
| * |
| * @return the expression used to compute the left operand |
| */ |
| Expression get leftOperand => _leftOperand; |
| |
| /** |
| * Return the element associated with the operator based on the propagated type of the left |
| * operand, or `null` if the AST structure has not been resolved, if the operator is not |
| * user definable, or if the operator could not be resolved. One example of the latter case is an |
| * operator that is not defined for the type of the left-hand operand. |
| * |
| * @return the element associated with the operator |
| */ |
| MethodElement get propagatedElement => _propagatedElement; |
| |
| /** |
| * Return the expression used to compute the right operand. |
| * |
| * @return the expression used to compute the right operand |
| */ |
| Expression get rightOperand => _rightOperand; |
| |
| /** |
| * Return the element associated with the operator based on the static type of the left operand, |
| * or `null` if the AST structure has not been resolved, if the operator is not user |
| * definable, or if the operator could not be resolved. One example of the latter case is an |
| * operator that is not defined for the type of the left operand. |
| * |
| * @return the element associated with the operator |
| */ |
| MethodElement get staticElement => _staticElement; |
| |
| /** |
| * Set the expression used to compute the left operand to the given expression. |
| * |
| * @param expression the expression used to compute the left operand |
| */ |
| void set leftOperand(Expression expression) { |
| _leftOperand = becomeParentOf(expression); |
| } |
| |
| /** |
| * Set the element associated with the operator based on the propagated type of the left operand |
| * to the given element. |
| * |
| * @param element the element to be associated with the operator |
| */ |
| void set propagatedElement(MethodElement element) { |
| _propagatedElement = element; |
| } |
| |
| /** |
| * Set the expression used to compute the right operand to the given expression. |
| * |
| * @param expression the expression used to compute the right operand |
| */ |
| void set rightOperand(Expression expression) { |
| _rightOperand = becomeParentOf(expression); |
| } |
| |
| /** |
| * Set the element associated with the operator based on the static type of the left operand to |
| * the given element. |
| * |
| * @param element the static element to be associated with the operator |
| */ |
| void set staticElement(MethodElement element) { |
| _staticElement = element; |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_leftOperand, visitor); |
| safelyVisitChild(_rightOperand, visitor); |
| } |
| |
| /** |
| * If the AST structure has been resolved, and the function being invoked is known based on |
| * propagated type information, then return the parameter element representing the parameter to |
| * which the value of the right operand will be bound. Otherwise, return `null`. |
| * |
| * This method is only intended to be used by [Expression#getPropagatedParameterElement]. |
| * |
| * @return the parameter element representing the parameter to which the value of the right |
| * operand will be bound |
| */ |
| ParameterElement get propagatedParameterElementForRightOperand { |
| if (_propagatedElement == null) { |
| return null; |
| } |
| List<ParameterElement> parameters = _propagatedElement.parameters; |
| if (parameters.length < 1) { |
| return null; |
| } |
| return parameters[0]; |
| } |
| |
| /** |
| * If the AST structure has been resolved, and the function being invoked is known based on static |
| * type information, then return the parameter element representing the parameter to which the |
| * value of the right operand will be bound. Otherwise, return `null`. |
| * |
| * This method is only intended to be used by [Expression#getStaticParameterElement]. |
| * |
| * @return the parameter element representing the parameter to which the value of the right |
| * operand will be bound |
| */ |
| ParameterElement get staticParameterElementForRightOperand { |
| if (_staticElement == null) { |
| return null; |
| } |
| List<ParameterElement> parameters = _staticElement.parameters; |
| if (parameters.length < 1) { |
| return null; |
| } |
| return parameters[0]; |
| } |
| } |
| /** |
| * Instances of the class `Block` represent a sequence of statements. |
| * |
| * <pre> |
| * block ::= |
| * '{' statement* '}' |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class Block extends Statement { |
| |
| /** |
| * The left curly bracket. |
| */ |
| Token leftBracket; |
| |
| /** |
| * The statements contained in the block. |
| */ |
| NodeList<Statement> statements; |
| |
| /** |
| * The right curly bracket. |
| */ |
| Token rightBracket; |
| |
| /** |
| * Initialize a newly created block of code. |
| * |
| * @param leftBracket the left curly bracket |
| * @param statements the statements contained in the block |
| * @param rightBracket the right curly bracket |
| */ |
| Block.full(Token leftBracket, List<Statement> statements, Token rightBracket) { |
| this.statements = new NodeList<Statement>(this); |
| this.leftBracket = leftBracket; |
| this.statements.addAll(statements); |
| this.rightBracket = rightBracket; |
| } |
| |
| /** |
| * Initialize a newly created block of code. |
| * |
| * @param leftBracket the left curly bracket |
| * @param statements the statements contained in the block |
| * @param rightBracket the right curly bracket |
| */ |
| Block({Token leftBracket, List<Statement> statements, Token rightBracket}) : this.full(leftBracket, statements, rightBracket); |
| accept(ASTVisitor visitor) => visitor.visitBlock(this); |
| Token get beginToken => leftBracket; |
| Token get endToken => rightBracket; |
| void visitChildren(ASTVisitor visitor) { |
| statements.accept(visitor); |
| } |
| } |
| /** |
| * Instances of the class `BlockFunctionBody` represent a function body that consists of a |
| * block of statements. |
| * |
| * <pre> |
| * blockFunctionBody ::= |
| * [Block] |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class BlockFunctionBody extends FunctionBody { |
| |
| /** |
| * The block representing the body of the function. |
| */ |
| Block _block; |
| |
| /** |
| * Initialize a newly created function body consisting of a block of statements. |
| * |
| * @param block the block representing the body of the function |
| */ |
| BlockFunctionBody.full(Block block) { |
| this._block = becomeParentOf(block); |
| } |
| |
| /** |
| * Initialize a newly created function body consisting of a block of statements. |
| * |
| * @param block the block representing the body of the function |
| */ |
| BlockFunctionBody({Block block}) : this.full(block); |
| accept(ASTVisitor visitor) => visitor.visitBlockFunctionBody(this); |
| Token get beginToken => _block.beginToken; |
| |
| /** |
| * Return the block representing the body of the function. |
| * |
| * @return the block representing the body of the function |
| */ |
| Block get block => _block; |
| Token get endToken => _block.endToken; |
| |
| /** |
| * Set the block representing the body of the function to the given block. |
| * |
| * @param block the block representing the body of the function |
| */ |
| void set block(Block block) { |
| this._block = becomeParentOf(block); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_block, visitor); |
| } |
| } |
| /** |
| * Instances of the class `BooleanLiteral` represent a boolean literal expression. |
| * |
| * <pre> |
| * booleanLiteral ::= |
| * 'false' | 'true' |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class BooleanLiteral extends Literal { |
| |
| /** |
| * The token representing the literal. |
| */ |
| Token literal; |
| |
| /** |
| * The value of the literal. |
| */ |
| bool value = false; |
| |
| /** |
| * Initialize a newly created boolean literal. |
| * |
| * @param literal the token representing the literal |
| * @param value the value of the literal |
| */ |
| BooleanLiteral.full(Token literal, bool value) { |
| this.literal = literal; |
| this.value = value; |
| } |
| |
| /** |
| * Initialize a newly created boolean literal. |
| * |
| * @param literal the token representing the literal |
| * @param value the value of the literal |
| */ |
| BooleanLiteral({Token literal, bool value}) : this.full(literal, value); |
| accept(ASTVisitor visitor) => visitor.visitBooleanLiteral(this); |
| Token get beginToken => literal; |
| Token get endToken => literal; |
| bool get isSynthetic => literal.isSynthetic; |
| void visitChildren(ASTVisitor visitor) { |
| } |
| } |
| /** |
| * Instances of the class `BreakStatement` represent a break statement. |
| * |
| * <pre> |
| * breakStatement ::= |
| * 'break' [SimpleIdentifier]? ';' |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class BreakStatement extends Statement { |
| |
| /** |
| * The token representing the 'break' keyword. |
| */ |
| Token keyword; |
| |
| /** |
| * The label associated with the statement, or `null` if there is no label. |
| */ |
| SimpleIdentifier _label; |
| |
| /** |
| * The semicolon terminating the statement. |
| */ |
| Token semicolon; |
| |
| /** |
| * Initialize a newly created break statement. |
| * |
| * @param keyword the token representing the 'break' keyword |
| * @param label the label associated with the statement |
| * @param semicolon the semicolon terminating the statement |
| */ |
| BreakStatement.full(Token keyword, SimpleIdentifier label, Token semicolon) { |
| this.keyword = keyword; |
| this._label = becomeParentOf(label); |
| this.semicolon = semicolon; |
| } |
| |
| /** |
| * Initialize a newly created break statement. |
| * |
| * @param keyword the token representing the 'break' keyword |
| * @param label the label associated with the statement |
| * @param semicolon the semicolon terminating the statement |
| */ |
| BreakStatement({Token keyword, SimpleIdentifier label, Token semicolon}) : this.full(keyword, label, semicolon); |
| accept(ASTVisitor visitor) => visitor.visitBreakStatement(this); |
| Token get beginToken => keyword; |
| Token get endToken => semicolon; |
| |
| /** |
| * Return the label associated with the statement, or `null` if there is no label. |
| * |
| * @return the label associated with the statement |
| */ |
| SimpleIdentifier get label => _label; |
| |
| /** |
| * Set the label associated with the statement to the given identifier. |
| * |
| * @param identifier the label associated with the statement |
| */ |
| void set label(SimpleIdentifier identifier) { |
| _label = becomeParentOf(identifier); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_label, visitor); |
| } |
| } |
| /** |
| * Instances of the class `CascadeExpression` represent a sequence of cascaded expressions: |
| * expressions that share a common target. There are three kinds of expressions that can be used in |
| * a cascade expression: [IndexExpression], [MethodInvocation] and |
| * [PropertyAccess]. |
| * |
| * <pre> |
| * cascadeExpression ::= |
| * [Expression] cascadeSection* |
| * |
| * cascadeSection ::= |
| * '..' (cascadeSelector arguments*) (assignableSelector arguments*)* (assignmentOperator expressionWithoutCascade)? |
| * |
| * cascadeSelector ::= |
| * '[ ' expression '] ' |
| * | identifier |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class CascadeExpression extends Expression { |
| |
| /** |
| * The target of the cascade sections. |
| */ |
| Expression _target; |
| |
| /** |
| * The cascade sections sharing the common target. |
| */ |
| NodeList<Expression> cascadeSections; |
| |
| /** |
| * Initialize a newly created cascade expression. |
| * |
| * @param target the target of the cascade sections |
| * @param cascadeSections the cascade sections sharing the common target |
| */ |
| CascadeExpression.full(Expression target, List<Expression> cascadeSections) { |
| this.cascadeSections = new NodeList<Expression>(this); |
| this._target = becomeParentOf(target); |
| this.cascadeSections.addAll(cascadeSections); |
| } |
| |
| /** |
| * Initialize a newly created cascade expression. |
| * |
| * @param target the target of the cascade sections |
| * @param cascadeSections the cascade sections sharing the common target |
| */ |
| CascadeExpression({Expression target, List<Expression> cascadeSections}) : this.full(target, cascadeSections); |
| accept(ASTVisitor visitor) => visitor.visitCascadeExpression(this); |
| Token get beginToken => _target.beginToken; |
| Token get endToken => cascadeSections.endToken; |
| |
| /** |
| * Return the target of the cascade sections. |
| * |
| * @return the target of the cascade sections |
| */ |
| Expression get target => _target; |
| |
| /** |
| * Set the target of the cascade sections to the given expression. |
| * |
| * @param target the target of the cascade sections |
| */ |
| void set target(Expression target) { |
| this._target = becomeParentOf(target); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_target, visitor); |
| cascadeSections.accept(visitor); |
| } |
| } |
| /** |
| * Instances of the class `CatchClause` represent a catch clause within a try statement. |
| * |
| * <pre> |
| * onPart ::= |
| * catchPart [Block] |
| * | 'on' type catchPart? [Block] |
| * |
| * catchPart ::= |
| * 'catch' '(' [SimpleIdentifier] (',' [SimpleIdentifier])? ')' |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class CatchClause extends ASTNode { |
| |
| /** |
| * The token representing the 'on' keyword, or `null` if there is no 'on' keyword. |
| */ |
| Token onKeyword; |
| |
| /** |
| * The type of exceptions caught by this catch clause, or `null` if this catch clause |
| * catches every type of exception. |
| */ |
| TypeName exceptionType; |
| |
| /** |
| * The token representing the 'catch' keyword, or `null` if there is no 'catch' keyword. |
| */ |
| Token catchKeyword; |
| |
| /** |
| * The left parenthesis. |
| */ |
| Token _leftParenthesis; |
| |
| /** |
| * The parameter whose value will be the exception that was thrown. |
| */ |
| SimpleIdentifier _exceptionParameter; |
| |
| /** |
| * The comma separating the exception parameter from the stack trace parameter, or `null` if |
| * there is no stack trace parameter. |
| */ |
| Token comma; |
| |
| /** |
| * The parameter whose value will be the stack trace associated with the exception, or |
| * `null` if there is no stack trace parameter. |
| */ |
| SimpleIdentifier _stackTraceParameter; |
| |
| /** |
| * The right parenthesis. |
| */ |
| Token _rightParenthesis; |
| |
| /** |
| * The body of the catch block. |
| */ |
| Block _body; |
| |
| /** |
| * Initialize a newly created catch clause. |
| * |
| * @param onKeyword the token representing the 'on' keyword |
| * @param exceptionType the type of exceptions caught by this catch clause |
| * @param leftParenthesis the left parenthesis |
| * @param exceptionParameter the parameter whose value will be the exception that was thrown |
| * @param comma the comma separating the exception parameter from the stack trace parameter |
| * @param stackTraceParameter the parameter whose value will be the stack trace associated with |
| * the exception |
| * @param rightParenthesis the right parenthesis |
| * @param body the body of the catch block |
| */ |
| CatchClause.full(Token onKeyword, TypeName exceptionType, Token catchKeyword, Token leftParenthesis, SimpleIdentifier exceptionParameter, Token comma, SimpleIdentifier stackTraceParameter, Token rightParenthesis, Block body) { |
| this.onKeyword = onKeyword; |
| this.exceptionType = becomeParentOf(exceptionType); |
| this.catchKeyword = catchKeyword; |
| this._leftParenthesis = leftParenthesis; |
| this._exceptionParameter = becomeParentOf(exceptionParameter); |
| this.comma = comma; |
| this._stackTraceParameter = becomeParentOf(stackTraceParameter); |
| this._rightParenthesis = rightParenthesis; |
| this._body = becomeParentOf(body); |
| } |
| |
| /** |
| * Initialize a newly created catch clause. |
| * |
| * @param onKeyword the token representing the 'on' keyword |
| * @param exceptionType the type of exceptions caught by this catch clause |
| * @param leftParenthesis the left parenthesis |
| * @param exceptionParameter the parameter whose value will be the exception that was thrown |
| * @param comma the comma separating the exception parameter from the stack trace parameter |
| * @param stackTraceParameter the parameter whose value will be the stack trace associated with |
| * the exception |
| * @param rightParenthesis the right parenthesis |
| * @param body the body of the catch block |
| */ |
| CatchClause({Token onKeyword, TypeName exceptionType, Token catchKeyword, Token leftParenthesis, SimpleIdentifier exceptionParameter, Token comma, SimpleIdentifier stackTraceParameter, Token rightParenthesis, Block body}) : this.full(onKeyword, exceptionType, catchKeyword, leftParenthesis, exceptionParameter, comma, stackTraceParameter, rightParenthesis, body); |
| accept(ASTVisitor visitor) => visitor.visitCatchClause(this); |
| Token get beginToken { |
| if (onKeyword != null) { |
| return onKeyword; |
| } |
| return catchKeyword; |
| } |
| |
| /** |
| * Return the body of the catch block. |
| * |
| * @return the body of the catch block |
| */ |
| Block get body => _body; |
| Token get endToken => _body.endToken; |
| |
| /** |
| * Return the parameter whose value will be the exception that was thrown. |
| * |
| * @return the parameter whose value will be the exception that was thrown |
| */ |
| SimpleIdentifier get exceptionParameter => _exceptionParameter; |
| |
| /** |
| * Return the left parenthesis. |
| * |
| * @return the left parenthesis |
| */ |
| Token get leftParenthesis => _leftParenthesis; |
| |
| /** |
| * Return the right parenthesis. |
| * |
| * @return the right parenthesis |
| */ |
| Token get rightParenthesis => _rightParenthesis; |
| |
| /** |
| * Return the parameter whose value will be the stack trace associated with the exception, or |
| * `null` if there is no stack trace parameter. |
| * |
| * @return the parameter whose value will be the stack trace associated with the exception |
| */ |
| SimpleIdentifier get stackTraceParameter => _stackTraceParameter; |
| |
| /** |
| * Set the body of the catch block to the given block. |
| * |
| * @param block the body of the catch block |
| */ |
| void set body(Block block) { |
| _body = becomeParentOf(block); |
| } |
| |
| /** |
| * Set the parameter whose value will be the exception that was thrown to the given parameter. |
| * |
| * @param parameter the parameter whose value will be the exception that was thrown |
| */ |
| void set exceptionParameter(SimpleIdentifier parameter) { |
| _exceptionParameter = becomeParentOf(parameter); |
| } |
| |
| /** |
| * Set the left parenthesis to the given token. |
| * |
| * @param parenthesis the left parenthesis |
| */ |
| void set leftParenthesis(Token parenthesis) { |
| _leftParenthesis = parenthesis; |
| } |
| |
| /** |
| * Set the right parenthesis to the given token. |
| * |
| * @param parenthesis the right parenthesis |
| */ |
| void set rightParenthesis(Token parenthesis) { |
| _rightParenthesis = parenthesis; |
| } |
| |
| /** |
| * Set the parameter whose value will be the stack trace associated with the exception to the |
| * given parameter. |
| * |
| * @param parameter the parameter whose value will be the stack trace associated with the |
| * exception |
| */ |
| void set stackTraceParameter(SimpleIdentifier parameter) { |
| _stackTraceParameter = becomeParentOf(parameter); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(exceptionType, visitor); |
| safelyVisitChild(_exceptionParameter, visitor); |
| safelyVisitChild(_stackTraceParameter, visitor); |
| safelyVisitChild(_body, visitor); |
| } |
| } |
| /** |
| * Instances of the class `ClassDeclaration` represent the declaration of a class. |
| * |
| * <pre> |
| * classDeclaration ::= |
| * 'abstract'? 'class' [SimpleIdentifier] [TypeParameterList]? |
| * ([ExtendsClause] [WithClause]?)? |
| * [ImplementsClause]? |
| * '{' [ClassMember]* '}' |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class ClassDeclaration extends CompilationUnitMember { |
| |
| /** |
| * The 'abstract' keyword, or `null` if the keyword was absent. |
| */ |
| Token abstractKeyword; |
| |
| /** |
| * The token representing the 'class' keyword. |
| */ |
| Token classKeyword; |
| |
| /** |
| * The name of the class being declared. |
| */ |
| SimpleIdentifier _name; |
| |
| /** |
| * The type parameters for the class, or `null` if the class does not have any type |
| * parameters. |
| */ |
| TypeParameterList typeParameters; |
| |
| /** |
| * The extends clause for the class, or `null` if the class does not extend any other class. |
| */ |
| ExtendsClause _extendsClause; |
| |
| /** |
| * The with clause for the class, or `null` if the class does not have a with clause. |
| */ |
| WithClause _withClause; |
| |
| /** |
| * The implements clause for the class, or `null` if the class does not implement any |
| * interfaces. |
| */ |
| ImplementsClause _implementsClause; |
| |
| /** |
| * The native clause for the class, or `null` if the class does not have a native clause. |
| */ |
| NativeClause nativeClause; |
| |
| /** |
| * The left curly bracket. |
| */ |
| Token leftBracket; |
| |
| /** |
| * The members defined by the class. |
| */ |
| NodeList<ClassMember> members; |
| |
| /** |
| * The right curly bracket. |
| */ |
| Token rightBracket; |
| |
| /** |
| * Initialize a newly created class declaration. |
| * |
| * @param comment the documentation comment associated with this class |
| * @param metadata the annotations associated with this class |
| * @param abstractKeyword the 'abstract' keyword, or `null` if the keyword was absent |
| * @param classKeyword the token representing the 'class' keyword |
| * @param name the name of the class being declared |
| * @param typeParameters the type parameters for the class |
| * @param extendsClause the extends clause for the class |
| * @param withClause the with clause for the class |
| * @param implementsClause the implements clause for the class |
| * @param leftBracket the left curly bracket |
| * @param members the members defined by the class |
| * @param rightBracket the right curly bracket |
| */ |
| ClassDeclaration.full(Comment comment, List<Annotation> metadata, Token abstractKeyword, Token classKeyword, SimpleIdentifier name, TypeParameterList typeParameters, ExtendsClause extendsClause, WithClause withClause, ImplementsClause implementsClause, Token leftBracket, List<ClassMember> members, Token rightBracket) : super.full(comment, metadata) { |
| this.members = new NodeList<ClassMember>(this); |
| this.abstractKeyword = abstractKeyword; |
| this.classKeyword = classKeyword; |
| this._name = becomeParentOf(name); |
| this.typeParameters = becomeParentOf(typeParameters); |
| this._extendsClause = becomeParentOf(extendsClause); |
| this._withClause = becomeParentOf(withClause); |
| this._implementsClause = becomeParentOf(implementsClause); |
| this.leftBracket = leftBracket; |
| this.members.addAll(members); |
| this.rightBracket = rightBracket; |
| } |
| |
| /** |
| * Initialize a newly created class declaration. |
| * |
| * @param comment the documentation comment associated with this class |
| * @param metadata the annotations associated with this class |
| * @param abstractKeyword the 'abstract' keyword, or `null` if the keyword was absent |
| * @param classKeyword the token representing the 'class' keyword |
| * @param name the name of the class being declared |
| * @param typeParameters the type parameters for the class |
| * @param extendsClause the extends clause for the class |
| * @param withClause the with clause for the class |
| * @param implementsClause the implements clause for the class |
| * @param leftBracket the left curly bracket |
| * @param members the members defined by the class |
| * @param rightBracket the right curly bracket |
| */ |
| ClassDeclaration({Comment comment, List<Annotation> metadata, Token abstractKeyword, Token classKeyword, SimpleIdentifier name, TypeParameterList typeParameters, ExtendsClause extendsClause, WithClause withClause, ImplementsClause implementsClause, Token leftBracket, List<ClassMember> members, Token rightBracket}) : this.full(comment, metadata, abstractKeyword, classKeyword, name, typeParameters, extendsClause, withClause, implementsClause, leftBracket, members, rightBracket); |
| accept(ASTVisitor visitor) => visitor.visitClassDeclaration(this); |
| ClassElement get element => _name != null ? (_name.staticElement as ClassElement) : null; |
| Token get endToken => rightBracket; |
| |
| /** |
| * Return the extends clause for this class, or `null` if the class does not extend any |
| * other class. |
| * |
| * @return the extends clause for this class |
| */ |
| ExtendsClause get extendsClause => _extendsClause; |
| |
| /** |
| * Return the implements clause for the class, or `null` if the class does not implement any |
| * interfaces. |
| * |
| * @return the implements clause for the class |
| */ |
| ImplementsClause get implementsClause => _implementsClause; |
| |
| /** |
| * Return the name of the class being declared. |
| * |
| * @return the name of the class being declared |
| */ |
| SimpleIdentifier get name => _name; |
| |
| /** |
| * Return the with clause for the class, or `null` if the class does not have a with clause. |
| * |
| * @return the with clause for the class |
| */ |
| WithClause get withClause => _withClause; |
| |
| /** |
| * Set the extends clause for this class to the given clause. |
| * |
| * @param extendsClause the extends clause for this class |
| */ |
| void set extendsClause(ExtendsClause extendsClause) { |
| this._extendsClause = becomeParentOf(extendsClause); |
| } |
| |
| /** |
| * Set the implements clause for the class to the given clause. |
| * |
| * @param implementsClause the implements clause for the class |
| */ |
| void set implementsClause(ImplementsClause implementsClause) { |
| this._implementsClause = becomeParentOf(implementsClause); |
| } |
| |
| /** |
| * Set the name of the class being declared to the given identifier. |
| * |
| * @param identifier the name of the class being declared |
| */ |
| void set name(SimpleIdentifier identifier) { |
| _name = becomeParentOf(identifier); |
| } |
| |
| /** |
| * Set the with clause for the class to the given clause. |
| * |
| * @param withClause the with clause for the class |
| */ |
| void set withClause(WithClause withClause) { |
| this._withClause = becomeParentOf(withClause); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| super.visitChildren(visitor); |
| safelyVisitChild(_name, visitor); |
| safelyVisitChild(typeParameters, visitor); |
| safelyVisitChild(_extendsClause, visitor); |
| safelyVisitChild(_withClause, visitor); |
| safelyVisitChild(_implementsClause, visitor); |
| safelyVisitChild(nativeClause, visitor); |
| members.accept(visitor); |
| } |
| Token get firstTokenAfterCommentAndMetadata { |
| if (abstractKeyword != null) { |
| return abstractKeyword; |
| } |
| return classKeyword; |
| } |
| } |
| /** |
| * The abstract class `ClassMember` defines the behavior common to nodes that declare a name |
| * within the scope of a class. |
| * |
| * @coverage dart.engine.ast |
| */ |
| abstract class ClassMember extends Declaration { |
| |
| /** |
| * Initialize a newly created member of a class. |
| * |
| * @param comment the documentation comment associated with this member |
| * @param metadata the annotations associated with this member |
| */ |
| ClassMember.full(Comment comment, List<Annotation> metadata) : super.full(comment, metadata); |
| |
| /** |
| * Initialize a newly created member of a class. |
| * |
| * @param comment the documentation comment associated with this member |
| * @param metadata the annotations associated with this member |
| */ |
| ClassMember({Comment comment, List<Annotation> metadata}) : this.full(comment, metadata); |
| } |
| /** |
| * Instances of the class `ClassTypeAlias` represent a class type alias. |
| * |
| * <pre> |
| * classTypeAlias ::= |
| * [SimpleIdentifier] [TypeParameterList]? '=' 'abstract'? mixinApplication |
| * |
| * mixinApplication ::= |
| * [TypeName] [WithClause] [ImplementsClause]? ';' |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class ClassTypeAlias extends TypeAlias { |
| |
| /** |
| * The name of the class being declared. |
| */ |
| SimpleIdentifier _name; |
| |
| /** |
| * The type parameters for the class, or `null` if the class does not have any type |
| * parameters. |
| */ |
| TypeParameterList _typeParameters; |
| |
| /** |
| * The token for the '=' separating the name from the definition. |
| */ |
| Token equals; |
| |
| /** |
| * The token for the 'abstract' keyword, or `null` if this is not defining an abstract |
| * class. |
| */ |
| Token abstractKeyword; |
| |
| /** |
| * The name of the superclass of the class being declared. |
| */ |
| TypeName _superclass; |
| |
| /** |
| * The with clause for this class. |
| */ |
| WithClause _withClause; |
| |
| /** |
| * The implements clause for this class, or `null` if there is no implements clause. |
| */ |
| ImplementsClause _implementsClause; |
| |
| /** |
| * Initialize a newly created class type alias. |
| * |
| * @param comment the documentation comment associated with this type alias |
| * @param metadata the annotations associated with this type alias |
| * @param keyword the token representing the 'typedef' keyword |
| * @param name the name of the class being declared |
| * @param typeParameters the type parameters for the class |
| * @param equals the token for the '=' separating the name from the definition |
| * @param abstractKeyword the token for the 'abstract' keyword |
| * @param superclass the name of the superclass of the class being declared |
| * @param withClause the with clause for this class |
| * @param implementsClause the implements clause for this class |
| * @param semicolon the semicolon terminating the declaration |
| */ |
| ClassTypeAlias.full(Comment comment, List<Annotation> metadata, Token keyword, SimpleIdentifier name, TypeParameterList typeParameters, Token equals, Token abstractKeyword, TypeName superclass, WithClause withClause, ImplementsClause implementsClause, Token semicolon) : super.full(comment, metadata, keyword, semicolon) { |
| this._name = becomeParentOf(name); |
| this._typeParameters = becomeParentOf(typeParameters); |
| this.equals = equals; |
| this.abstractKeyword = abstractKeyword; |
| this._superclass = becomeParentOf(superclass); |
| this._withClause = becomeParentOf(withClause); |
| this._implementsClause = becomeParentOf(implementsClause); |
| } |
| |
| /** |
| * Initialize a newly created class type alias. |
| * |
| * @param comment the documentation comment associated with this type alias |
| * @param metadata the annotations associated with this type alias |
| * @param keyword the token representing the 'typedef' keyword |
| * @param name the name of the class being declared |
| * @param typeParameters the type parameters for the class |
| * @param equals the token for the '=' separating the name from the definition |
| * @param abstractKeyword the token for the 'abstract' keyword |
| * @param superclass the name of the superclass of the class being declared |
| * @param withClause the with clause for this class |
| * @param implementsClause the implements clause for this class |
| * @param semicolon the semicolon terminating the declaration |
| */ |
| ClassTypeAlias({Comment comment, List<Annotation> metadata, Token keyword, SimpleIdentifier name, TypeParameterList typeParameters, Token equals, Token abstractKeyword, TypeName superclass, WithClause withClause, ImplementsClause implementsClause, Token semicolon}) : this.full(comment, metadata, keyword, name, typeParameters, equals, abstractKeyword, superclass, withClause, implementsClause, semicolon); |
| accept(ASTVisitor visitor) => visitor.visitClassTypeAlias(this); |
| ClassElement get element => _name != null ? (_name.staticElement as ClassElement) : null; |
| |
| /** |
| * Return the implements clause for this class, or `null` if there is no implements clause. |
| * |
| * @return the implements clause for this class |
| */ |
| ImplementsClause get implementsClause => _implementsClause; |
| |
| /** |
| * Return the name of the class being declared. |
| * |
| * @return the name of the class being declared |
| */ |
| SimpleIdentifier get name => _name; |
| |
| /** |
| * Return the name of the superclass of the class being declared. |
| * |
| * @return the name of the superclass of the class being declared |
| */ |
| TypeName get superclass => _superclass; |
| |
| /** |
| * Return the type parameters for the class, or `null` if the class does not have any type |
| * parameters. |
| * |
| * @return the type parameters for the class |
| */ |
| TypeParameterList get typeParameters => _typeParameters; |
| |
| /** |
| * Return the with clause for this class. |
| * |
| * @return the with clause for this class |
| */ |
| WithClause get withClause => _withClause; |
| |
| /** |
| * Set the implements clause for this class to the given implements clause. |
| * |
| * @param implementsClause the implements clause for this class |
| */ |
| void set implementsClause(ImplementsClause implementsClause) { |
| this._implementsClause = becomeParentOf(implementsClause); |
| } |
| |
| /** |
| * Set the name of the class being declared to the given identifier. |
| * |
| * @param name the name of the class being declared |
| */ |
| void set name(SimpleIdentifier name) { |
| this._name = becomeParentOf(name); |
| } |
| |
| /** |
| * Set the name of the superclass of the class being declared to the given name. |
| * |
| * @param superclass the name of the superclass of the class being declared |
| */ |
| void set superclass(TypeName superclass) { |
| this._superclass = becomeParentOf(superclass); |
| } |
| |
| /** |
| * Set the type parameters for the class to the given list of parameters. |
| * |
| * @param typeParameters the type parameters for the class |
| */ |
| void set typeParameters(TypeParameterList typeParameters) { |
| this._typeParameters = becomeParentOf(typeParameters); |
| } |
| |
| /** |
| * Set the with clause for this class to the given with clause. |
| * |
| * @param withClause the with clause for this class |
| */ |
| void set withClause(WithClause withClause) { |
| this._withClause = becomeParentOf(withClause); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| super.visitChildren(visitor); |
| safelyVisitChild(_name, visitor); |
| safelyVisitChild(_typeParameters, visitor); |
| safelyVisitChild(_superclass, visitor); |
| safelyVisitChild(_withClause, visitor); |
| safelyVisitChild(_implementsClause, visitor); |
| } |
| } |
| /** |
| * Instances of the class `Combinator` represent the combinator associated with an import |
| * directive. |
| * |
| * <pre> |
| * combinator ::= |
| * [HideCombinator] |
| * | [ShowCombinator] |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| abstract class Combinator extends ASTNode { |
| |
| /** |
| * The keyword specifying what kind of processing is to be done on the imported names. |
| */ |
| Token keyword; |
| |
| /** |
| * Initialize a newly created import combinator. |
| * |
| * @param keyword the keyword specifying what kind of processing is to be done on the imported |
| * names |
| */ |
| Combinator.full(Token keyword) { |
| this.keyword = keyword; |
| } |
| |
| /** |
| * Initialize a newly created import combinator. |
| * |
| * @param keyword the keyword specifying what kind of processing is to be done on the imported |
| * names |
| */ |
| Combinator({Token keyword}) : this.full(keyword); |
| Token get beginToken => keyword; |
| } |
| /** |
| * Instances of the class `Comment` represent a comment within the source code. |
| * |
| * <pre> |
| * comment ::= |
| * endOfLineComment |
| * | blockComment |
| * | documentationComment |
| * |
| * endOfLineComment ::= |
| * '//' (CHARACTER - EOL)* EOL |
| * |
| * blockComment ::= |
| * '/ *' CHARACTER* '*/' |
| * |
| * documentationComment ::= |
| * '/ **' (CHARACTER | [CommentReference])* '*/' |
| * | ('///' (CHARACTER - EOL)* EOL)+ |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class Comment extends ASTNode { |
| |
| /** |
| * Create a block comment. |
| * |
| * @param tokens the tokens representing the comment |
| * @return the block comment that was created |
| */ |
| static Comment createBlockComment(List<Token> tokens) => new Comment.full(tokens, CommentType.BLOCK, null); |
| |
| /** |
| * Create a documentation comment. |
| * |
| * @param tokens the tokens representing the comment |
| * @return the documentation comment that was created |
| */ |
| static Comment createDocumentationComment(List<Token> tokens) => new Comment.full(tokens, CommentType.DOCUMENTATION, new List<CommentReference>()); |
| |
| /** |
| * Create a documentation comment. |
| * |
| * @param tokens the tokens representing the comment |
| * @param references the references embedded within the documentation comment |
| * @return the documentation comment that was created |
| */ |
| static Comment createDocumentationComment2(List<Token> tokens, List<CommentReference> references) => new Comment.full(tokens, CommentType.DOCUMENTATION, references); |
| |
| /** |
| * Create an end-of-line comment. |
| * |
| * @param tokens the tokens representing the comment |
| * @return the end-of-line comment that was created |
| */ |
| static Comment createEndOfLineComment(List<Token> tokens) => new Comment.full(tokens, CommentType.END_OF_LINE, null); |
| |
| /** |
| * The tokens representing the comment. |
| */ |
| List<Token> tokens; |
| |
| /** |
| * The type of the comment. |
| */ |
| CommentType _type; |
| |
| /** |
| * The references embedded within the documentation comment. This list will be empty unless this |
| * is a documentation comment that has references embedded within it. |
| */ |
| NodeList<CommentReference> references; |
| |
| /** |
| * Initialize a newly created comment. |
| * |
| * @param tokens the tokens representing the comment |
| * @param type the type of the comment |
| * @param references the references embedded within the documentation comment |
| */ |
| Comment.full(List<Token> tokens, CommentType type, List<CommentReference> references) { |
| this.references = new NodeList<CommentReference>(this); |
| this.tokens = tokens; |
| this._type = type; |
| this.references.addAll(references); |
| } |
| |
| /** |
| * Initialize a newly created comment. |
| * |
| * @param tokens the tokens representing the comment |
| * @param type the type of the comment |
| * @param references the references embedded within the documentation comment |
| */ |
| Comment({List<Token> tokens, CommentType type, List<CommentReference> references}) : this.full(tokens, type, references); |
| accept(ASTVisitor visitor) => visitor.visitComment(this); |
| Token get beginToken => tokens[0]; |
| Token get endToken => tokens[tokens.length - 1]; |
| |
| /** |
| * Return `true` if this is a block comment. |
| * |
| * @return `true` if this is a block comment |
| */ |
| bool get isBlock => identical(_type, CommentType.BLOCK); |
| |
| /** |
| * Return `true` if this is a documentation comment. |
| * |
| * @return `true` if this is a documentation comment |
| */ |
| bool get isDocumentation => identical(_type, CommentType.DOCUMENTATION); |
| |
| /** |
| * Return `true` if this is an end-of-line comment. |
| * |
| * @return `true` if this is an end-of-line comment |
| */ |
| bool get isEndOfLine => identical(_type, CommentType.END_OF_LINE); |
| void visitChildren(ASTVisitor visitor) { |
| references.accept(visitor); |
| } |
| } |
| /** |
| * The enumeration `CommentType` encodes all the different types of comments that are |
| * recognized by the parser. |
| */ |
| class CommentType extends Enum<CommentType> { |
| |
| /** |
| * An end-of-line comment. |
| */ |
| static final CommentType END_OF_LINE = new CommentType('END_OF_LINE', 0); |
| |
| /** |
| * A block comment. |
| */ |
| static final CommentType BLOCK = new CommentType('BLOCK', 1); |
| |
| /** |
| * A documentation comment. |
| */ |
| static final CommentType DOCUMENTATION = new CommentType('DOCUMENTATION', 2); |
| static final List<CommentType> values = [END_OF_LINE, BLOCK, DOCUMENTATION]; |
| CommentType(String name, int ordinal) : super(name, ordinal); |
| } |
| /** |
| * Instances of the class `CommentReference` represent a reference to a Dart element that is |
| * found within a documentation comment. |
| * |
| * <pre> |
| * commentReference ::= |
| * '[' 'new'? [Identifier] ']' |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class CommentReference extends ASTNode { |
| |
| /** |
| * The token representing the 'new' keyword, or `null` if there was no 'new' keyword. |
| */ |
| Token newKeyword; |
| |
| /** |
| * The identifier being referenced. |
| */ |
| Identifier _identifier; |
| |
| /** |
| * Initialize a newly created reference to a Dart element. |
| * |
| * @param newKeyword the token representing the 'new' keyword |
| * @param identifier the identifier being referenced |
| */ |
| CommentReference.full(Token newKeyword, Identifier identifier) { |
| this.newKeyword = newKeyword; |
| this._identifier = becomeParentOf(identifier); |
| } |
| |
| /** |
| * Initialize a newly created reference to a Dart element. |
| * |
| * @param newKeyword the token representing the 'new' keyword |
| * @param identifier the identifier being referenced |
| */ |
| CommentReference({Token newKeyword, Identifier identifier}) : this.full(newKeyword, identifier); |
| accept(ASTVisitor visitor) => visitor.visitCommentReference(this); |
| Token get beginToken => _identifier.beginToken; |
| Token get endToken => _identifier.endToken; |
| |
| /** |
| * Return the identifier being referenced. |
| * |
| * @return the identifier being referenced |
| */ |
| Identifier get identifier => _identifier; |
| |
| /** |
| * Set the identifier being referenced to the given identifier. |
| * |
| * @param identifier the identifier being referenced |
| */ |
| void set identifier(Identifier identifier) { |
| identifier = becomeParentOf(identifier); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_identifier, visitor); |
| } |
| } |
| /** |
| * Instances of the class `CompilationUnit` represent a compilation unit. |
| * |
| * While the grammar restricts the order of the directives and declarations within a compilation |
| * unit, this class does not enforce those restrictions. In particular, the children of a |
| * compilation unit will be visited in lexical order even if lexical order does not conform to the |
| * restrictions of the grammar. |
| * |
| * <pre> |
| * compilationUnit ::= |
| * directives declarations |
| * |
| * directives ::= |
| * [ScriptTag]? [LibraryDirective]? namespaceDirective* [PartDirective]* |
| * | [PartOfDirective] |
| * |
| * namespaceDirective ::= |
| * [ImportDirective] |
| * | [ExportDirective] |
| * |
| * declarations ::= |
| * [CompilationUnitMember]* |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class CompilationUnit extends ASTNode { |
| |
| /** |
| * The first token in the token stream that was parsed to form this compilation unit. |
| */ |
| Token _beginToken; |
| |
| /** |
| * The script tag at the beginning of the compilation unit, or `null` if there is no script |
| * tag in this compilation unit. |
| */ |
| ScriptTag _scriptTag; |
| |
| /** |
| * The directives contained in this compilation unit. |
| */ |
| NodeList<Directive> directives; |
| |
| /** |
| * The declarations contained in this compilation unit. |
| */ |
| NodeList<CompilationUnitMember> declarations; |
| |
| /** |
| * The last token in the token stream that was parsed to form this compilation unit. This token |
| * should always have a type of [TokenType.EOF]. |
| */ |
| Token _endToken; |
| |
| /** |
| * The element associated with this compilation unit, or `null` if the AST structure has not |
| * been resolved. |
| */ |
| CompilationUnitElement element; |
| |
| /** |
| * The line information for this compilation unit. |
| */ |
| LineInfo lineInfo; |
| |
| /** |
| * The parsing errors encountered when the receiver was parsed. |
| */ |
| List<AnalysisError> _parsingErrors = AnalysisError.NO_ERRORS; |
| |
| /** |
| * The resolution errors encountered when the receiver was resolved. |
| */ |
| List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| |
| /** |
| * The hints reported when the receiver was analyzed. |
| */ |
| List<AnalysisError> _hints = AnalysisError.NO_ERRORS; |
| |
| /** |
| * Initialize a newly created compilation unit to have the given directives and declarations. |
| * |
| * @param beginToken the first token in the token stream |
| * @param scriptTag the script tag at the beginning of the compilation unit |
| * @param directives the directives contained in this compilation unit |
| * @param declarations the declarations contained in this compilation unit |
| * @param endToken the last token in the token stream |
| */ |
| CompilationUnit.full(Token beginToken, ScriptTag scriptTag, List<Directive> directives, List<CompilationUnitMember> declarations, Token endToken) { |
| this.directives = new NodeList<Directive>(this); |
| this.declarations = new NodeList<CompilationUnitMember>(this); |
| this._beginToken = beginToken; |
| this._scriptTag = becomeParentOf(scriptTag); |
| this.directives.addAll(directives); |
| this.declarations.addAll(declarations); |
| this._endToken = endToken; |
| } |
| |
| /** |
| * Initialize a newly created compilation unit to have the given directives and declarations. |
| * |
| * @param beginToken the first token in the token stream |
| * @param scriptTag the script tag at the beginning of the compilation unit |
| * @param directives the directives contained in this compilation unit |
| * @param declarations the declarations contained in this compilation unit |
| * @param endToken the last token in the token stream |
| */ |
| CompilationUnit({Token beginToken, ScriptTag scriptTag, List<Directive> directives, List<CompilationUnitMember> declarations, Token endToken}) : this.full(beginToken, scriptTag, directives, declarations, endToken); |
| accept(ASTVisitor visitor) => visitor.visitCompilationUnit(this); |
| Token get beginToken => _beginToken; |
| Token get endToken => _endToken; |
| |
| /** |
| * Return an array containing all of the errors associated with the receiver. The array will be |
| * empty if the receiver has not been resolved and there were no parse errors. |
| * |
| * @return the errors associated with the receiver |
| */ |
| List<AnalysisError> get errors { |
| List<AnalysisError> parserErrors = parsingErrors; |
| List<AnalysisError> resolverErrors = resolutionErrors; |
| List<AnalysisError> hints = this.hints; |
| if (resolverErrors.length == 0 && hints.length == 0) { |
| return parserErrors; |
| } else if (parserErrors.length == 0 && hints.length == 0) { |
| return resolverErrors; |
| } else if (parserErrors.length == 0 && resolverErrors.length == 0) { |
| return hints; |
| } else { |
| List<AnalysisError> allErrors = new List<AnalysisError>(parserErrors.length + resolverErrors.length + hints.length); |
| JavaSystem.arraycopy(parserErrors, 0, allErrors, 0, parserErrors.length); |
| JavaSystem.arraycopy(resolverErrors, 0, allErrors, parserErrors.length, resolverErrors.length); |
| JavaSystem.arraycopy(hints, 0, allErrors, parserErrors.length + resolverErrors.length, hints.length); |
| return allErrors; |
| } |
| } |
| |
| /** |
| * Return an array containing all of the hints associated with the receiver. The array will be |
| * empty if the receiver has not been analyzed. |
| * |
| * @return the hints associated with the receiver |
| */ |
| List<AnalysisError> get hints => _hints; |
| int get length { |
| Token endToken = this.endToken; |
| if (endToken == null) { |
| return 0; |
| } |
| return endToken.offset + endToken.length; |
| } |
| int get offset => 0; |
| |
| /** |
| * Return an array containing all of the parsing errors associated with the receiver. |
| * |
| * @return the parsing errors associated with the receiver |
| */ |
| List<AnalysisError> get parsingErrors => _parsingErrors; |
| |
| /** |
| * Return an array containing all of the resolution errors associated with the receiver. The array |
| * will be empty if the receiver has not been resolved. |
| * |
| * @return the resolution errors associated with the receiver |
| */ |
| List<AnalysisError> get resolutionErrors => _resolutionErrors; |
| |
| /** |
| * Return the script tag at the beginning of the compilation unit, or `null` if there is no |
| * script tag in this compilation unit. |
| * |
| * @return the script tag at the beginning of the compilation unit |
| */ |
| ScriptTag get scriptTag => _scriptTag; |
| |
| /** |
| * Set the reported hints associated with this compilation unit. |
| * |
| * @param the hints to be associated with this compilation unit |
| */ |
| void set hints(List<AnalysisError> errors) { |
| _hints = errors == null ? AnalysisError.NO_ERRORS : errors; |
| } |
| |
| /** |
| * Set the parse errors associated with this compilation unit to the given errors. |
| * |
| * @param the parse errors to be associated with this compilation unit |
| */ |
| void set parsingErrors(List<AnalysisError> errors) { |
| _parsingErrors = errors == null ? AnalysisError.NO_ERRORS : errors; |
| } |
| |
| /** |
| * Set the resolution errors associated with this compilation unit to the given errors. |
| * |
| * @param the resolution errors to be associated with this compilation unit |
| */ |
| void set resolutionErrors(List<AnalysisError> errors) { |
| _resolutionErrors = errors == null ? AnalysisError.NO_ERRORS : errors; |
| } |
| |
| /** |
| * Set the script tag at the beginning of the compilation unit to the given script tag. |
| * |
| * @param scriptTag the script tag at the beginning of the compilation unit |
| */ |
| void set scriptTag(ScriptTag scriptTag) { |
| this._scriptTag = becomeParentOf(scriptTag); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_scriptTag, visitor); |
| if (directivesAreBeforeDeclarations()) { |
| directives.accept(visitor); |
| declarations.accept(visitor); |
| } else { |
| for (ASTNode child in sortedDirectivesAndDeclarations) { |
| child.accept(visitor); |
| } |
| } |
| } |
| |
| /** |
| * Return `true` if all of the directives are lexically before any declarations. |
| * |
| * @return `true` if all of the directives are lexically before any declarations |
| */ |
| bool directivesAreBeforeDeclarations() { |
| if (directives.isEmpty || declarations.isEmpty) { |
| return true; |
| } |
| Directive lastDirective = directives[directives.length - 1]; |
| CompilationUnitMember firstDeclaration = declarations[0]; |
| return lastDirective.offset < firstDeclaration.offset; |
| } |
| |
| /** |
| * Return an array containing all of the directives and declarations in this compilation unit, |
| * sorted in lexical order. |
| * |
| * @return the directives and declarations in this compilation unit in the order in which they |
| * appeared in the original source |
| */ |
| List<ASTNode> get sortedDirectivesAndDeclarations { |
| List<ASTNode> childList = new List<ASTNode>(); |
| childList.addAll(directives); |
| childList.addAll(declarations); |
| List<ASTNode> children = new List.from(childList); |
| children.sort(ASTNode.LEXICAL_ORDER); |
| return children; |
| } |
| } |
| /** |
| * Instances of the class `CompilationUnitMember` defines the behavior common to nodes that |
| * declare a name within the scope of a compilation unit. |
| * |
| * <pre> |
| * compilationUnitMember ::= |
| * [ClassDeclaration] |
| * | [TypeAlias] |
| * | [FunctionDeclaration] |
| * | [MethodDeclaration] |
| * | [VariableDeclaration] |
| * | [VariableDeclaration] |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| abstract class CompilationUnitMember extends Declaration { |
| |
| /** |
| * Initialize a newly created generic compilation unit member. |
| * |
| * @param comment the documentation comment associated with this member |
| * @param metadata the annotations associated with this member |
| */ |
| CompilationUnitMember.full(Comment comment, List<Annotation> metadata) : super.full(comment, metadata); |
| |
| /** |
| * Initialize a newly created generic compilation unit member. |
| * |
| * @param comment the documentation comment associated with this member |
| * @param metadata the annotations associated with this member |
| */ |
| CompilationUnitMember({Comment comment, List<Annotation> metadata}) : this.full(comment, metadata); |
| } |
| /** |
| * Instances of the class `ConditionalExpression` represent a conditional expression. |
| * |
| * <pre> |
| * conditionalExpression ::= |
| * [Expression] '?' [Expression] ':' [Expression] |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class ConditionalExpression extends Expression { |
| |
| /** |
| * The condition used to determine which of the expressions is executed next. |
| */ |
| Expression _condition; |
| |
| /** |
| * The token used to separate the condition from the then expression. |
| */ |
| Token question; |
| |
| /** |
| * The expression that is executed if the condition evaluates to `true`. |
| */ |
| Expression _thenExpression; |
| |
| /** |
| * The token used to separate the then expression from the else expression. |
| */ |
| Token colon; |
| |
| /** |
| * The expression that is executed if the condition evaluates to `false`. |
| */ |
| Expression _elseExpression; |
| |
| /** |
| * Initialize a newly created conditional expression. |
| * |
| * @param condition the condition used to determine which expression is executed next |
| * @param question the token used to separate the condition from the then expression |
| * @param thenExpression the expression that is executed if the condition evaluates to |
| * `true` |
| * @param colon the token used to separate the then expression from the else expression |
| * @param elseExpression the expression that is executed if the condition evaluates to |
| * `false` |
| */ |
| ConditionalExpression.full(Expression condition, Token question, Expression thenExpression, Token colon, Expression elseExpression) { |
| this._condition = becomeParentOf(condition); |
| this.question = question; |
| this._thenExpression = becomeParentOf(thenExpression); |
| this.colon = colon; |
| this._elseExpression = becomeParentOf(elseExpression); |
| } |
| |
| /** |
| * Initialize a newly created conditional expression. |
| * |
| * @param condition the condition used to determine which expression is executed next |
| * @param question the token used to separate the condition from the then expression |
| * @param thenExpression the expression that is executed if the condition evaluates to |
| * `true` |
| * @param colon the token used to separate the then expression from the else expression |
| * @param elseExpression the expression that is executed if the condition evaluates to |
| * `false` |
| */ |
| ConditionalExpression({Expression condition, Token question, Expression thenExpression, Token colon, Expression elseExpression}) : this.full(condition, question, thenExpression, colon, elseExpression); |
| accept(ASTVisitor visitor) => visitor.visitConditionalExpression(this); |
| Token get beginToken => _condition.beginToken; |
| |
| /** |
| * Return the condition used to determine which of the expressions is executed next. |
| * |
| * @return the condition used to determine which expression is executed next |
| */ |
| Expression get condition => _condition; |
| |
| /** |
| * Return the expression that is executed if the condition evaluates to `false`. |
| * |
| * @return the expression that is executed if the condition evaluates to `false` |
| */ |
| Expression get elseExpression => _elseExpression; |
| Token get endToken => _elseExpression.endToken; |
| |
| /** |
| * Return the expression that is executed if the condition evaluates to `true`. |
| * |
| * @return the expression that is executed if the condition evaluates to `true` |
| */ |
| Expression get thenExpression => _thenExpression; |
| |
| /** |
| * Set the condition used to determine which of the expressions is executed next to the given |
| * expression. |
| * |
| * @param expression the condition used to determine which expression is executed next |
| */ |
| void set condition(Expression expression) { |
| _condition = becomeParentOf(expression); |
| } |
| |
| /** |
| * Set the expression that is executed if the condition evaluates to `false` to the given |
| * expression. |
| * |
| * @param expression the expression that is executed if the condition evaluates to `false` |
| */ |
| void set elseExpression(Expression expression) { |
| _elseExpression = becomeParentOf(expression); |
| } |
| |
| /** |
| * Set the expression that is executed if the condition evaluates to `true` to the given |
| * expression. |
| * |
| * @param expression the expression that is executed if the condition evaluates to `true` |
| */ |
| void set thenExpression(Expression expression) { |
| _thenExpression = becomeParentOf(expression); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_condition, visitor); |
| safelyVisitChild(_thenExpression, visitor); |
| safelyVisitChild(_elseExpression, visitor); |
| } |
| } |
| /** |
| * Instances of the class `ConstructorDeclaration` represent a constructor declaration. |
| * |
| * <pre> |
| * constructorDeclaration ::= |
| * constructorSignature [FunctionBody]? |
| * | constructorName formalParameterList ':' 'this' ('.' [SimpleIdentifier])? arguments |
| * |
| * constructorSignature ::= |
| * 'external'? constructorName formalParameterList initializerList? |
| * | 'external'? 'factory' factoryName formalParameterList initializerList? |
| * | 'external'? 'const' constructorName formalParameterList initializerList? |
| * |
| * constructorName ::= |
| * [SimpleIdentifier] ('.' [SimpleIdentifier])? |
| * |
| * factoryName ::= |
| * [Identifier] ('.' [SimpleIdentifier])? |
| * |
| * initializerList ::= |
| * ':' [ConstructorInitializer] (',' [ConstructorInitializer])* |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class ConstructorDeclaration extends ClassMember { |
| |
| /** |
| * The token for the 'external' keyword, or `null` if the constructor is not external. |
| */ |
| Token externalKeyword; |
| |
| /** |
| * The token for the 'const' keyword, or `null` if the constructor is not a const |
| * constructor. |
| */ |
| Token constKeyword; |
| |
| /** |
| * The token for the 'factory' keyword, or `null` if the constructor is not a factory |
| * constructor. |
| */ |
| Token factoryKeyword; |
| |
| /** |
| * The type of object being created. This can be different than the type in which the constructor |
| * is being declared if the constructor is the implementation of a factory constructor. |
| */ |
| Identifier _returnType; |
| |
| /** |
| * The token for the period before the constructor name, or `null` if the constructor being |
| * declared is unnamed. |
| */ |
| Token period; |
| |
| /** |
| * The name of the constructor, or `null` if the constructor being declared is unnamed. |
| */ |
| SimpleIdentifier _name; |
| |
| /** |
| * The parameters associated with the constructor. |
| */ |
| FormalParameterList _parameters; |
| |
| /** |
| * The token for the separator (colon or equals) before the initializer list or redirection, or |
| * `null` if there are no initializers. |
| */ |
| Token separator; |
| |
| /** |
| * The initializers associated with the constructor. |
| */ |
| NodeList<ConstructorInitializer> initializers; |
| |
| /** |
| * The name of the constructor to which this constructor will be redirected, or `null` if |
| * this is not a redirecting factory constructor. |
| */ |
| ConstructorName _redirectedConstructor; |
| |
| /** |
| * The body of the constructor, or `null` if the constructor does not have a body. |
| */ |
| FunctionBody _body; |
| |
| /** |
| * The element associated with this constructor, or `null` if the AST structure has not been |
| * resolved or if this constructor could not be resolved. |
| */ |
| ConstructorElement _element; |
| |
| /** |
| * Initialize a newly created constructor declaration. |
| * |
| * @param externalKeyword the token for the 'external' keyword |
| * @param comment the documentation comment associated with this constructor |
| * @param metadata the annotations associated with this constructor |
| * @param constKeyword the token for the 'const' keyword |
| * @param factoryKeyword the token for the 'factory' keyword |
| * @param returnType the return type of the constructor |
| * @param period the token for the period before the constructor name |
| * @param name the name of the constructor |
| * @param parameters the parameters associated with the constructor |
| * @param separator the token for the colon or equals before the initializers |
| * @param initializers the initializers associated with the constructor |
| * @param redirectedConstructor the name of the constructor to which this constructor will be |
| * redirected |
| * @param body the body of the constructor |
| */ |
| ConstructorDeclaration.full(Comment comment, List<Annotation> metadata, Token externalKeyword, Token constKeyword, Token factoryKeyword, Identifier returnType, Token period, SimpleIdentifier name, FormalParameterList parameters, Token separator, List<ConstructorInitializer> initializers, ConstructorName redirectedConstructor, FunctionBody body) : super.full(comment, metadata) { |
| this.initializers = new NodeList<ConstructorInitializer>(this); |
| this.externalKeyword = externalKeyword; |
| this.constKeyword = constKeyword; |
| this.factoryKeyword = factoryKeyword; |
| this._returnType = becomeParentOf(returnType); |
| this.period = period; |
| this._name = becomeParentOf(name); |
| this._parameters = becomeParentOf(parameters); |
| this.separator = separator; |
| this.initializers.addAll(initializers); |
| this._redirectedConstructor = becomeParentOf(redirectedConstructor); |
| this._body = becomeParentOf(body); |
| } |
| |
| /** |
| * Initialize a newly created constructor declaration. |
| * |
| * @param externalKeyword the token for the 'external' keyword |
| * @param comment the documentation comment associated with this constructor |
| * @param metadata the annotations associated with this constructor |
| * @param constKeyword the token for the 'const' keyword |
| * @param factoryKeyword the token for the 'factory' keyword |
| * @param returnType the return type of the constructor |
| * @param period the token for the period before the constructor name |
| * @param name the name of the constructor |
| * @param parameters the parameters associated with the constructor |
| * @param separator the token for the colon or equals before the initializers |
| * @param initializers the initializers associated with the constructor |
| * @param redirectedConstructor the name of the constructor to which this constructor will be |
| * redirected |
| * @param body the body of the constructor |
| */ |
| ConstructorDeclaration({Comment comment, List<Annotation> metadata, Token externalKeyword, Token constKeyword, Token factoryKeyword, Identifier returnType, Token period, SimpleIdentifier name, FormalParameterList parameters, Token separator, List<ConstructorInitializer> initializers, ConstructorName redirectedConstructor, FunctionBody body}) : this.full(comment, metadata, externalKeyword, constKeyword, factoryKeyword, returnType, period, name, parameters, separator, initializers, redirectedConstructor, body); |
| accept(ASTVisitor visitor) => visitor.visitConstructorDeclaration(this); |
| |
| /** |
| * Return the body of the constructor, or `null` if the constructor does not have a body. |
| * |
| * @return the body of the constructor |
| */ |
| FunctionBody get body => _body; |
| ConstructorElement get element => _element; |
| Token get endToken { |
| if (_body != null) { |
| return _body.endToken; |
| } else if (!initializers.isEmpty) { |
| return initializers.endToken; |
| } |
| return _parameters.endToken; |
| } |
| |
| /** |
| * Return the name of the constructor, or `null` if the constructor being declared is |
| * unnamed. |
| * |
| * @return the name of the constructor |
| */ |
| SimpleIdentifier get name => _name; |
| |
| /** |
| * Return the parameters associated with the constructor. |
| * |
| * @return the parameters associated with the constructor |
| */ |
| FormalParameterList get parameters => _parameters; |
| |
| /** |
| * Return the name of the constructor to which this constructor will be redirected, or |
| * `null` if this is not a redirecting factory constructor. |
| * |
| * @return the name of the constructor to which this constructor will be redirected |
| */ |
| ConstructorName get redirectedConstructor => _redirectedConstructor; |
| |
| /** |
| * Return the type of object being created. This can be different than the type in which the |
| * constructor is being declared if the constructor is the implementation of a factory |
| * constructor. |
| * |
| * @return the type of object being created |
| */ |
| Identifier get returnType => _returnType; |
| |
| /** |
| * Set the body of the constructor to the given function body. |
| * |
| * @param functionBody the body of the constructor |
| */ |
| void set body(FunctionBody functionBody) { |
| _body = becomeParentOf(functionBody); |
| } |
| |
| /** |
| * Set the element associated with this constructor to the given element. |
| * |
| * @param element the element associated with this constructor |
| */ |
| void set element(ConstructorElement element) { |
| this._element = element; |
| } |
| |
| /** |
| * Set the name of the constructor to the given identifier. |
| * |
| * @param identifier the name of the constructor |
| */ |
| void set name(SimpleIdentifier identifier) { |
| _name = becomeParentOf(identifier); |
| } |
| |
| /** |
| * Set the parameters associated with the constructor to the given list of parameters. |
| * |
| * @param parameters the parameters associated with the constructor |
| */ |
| void set parameters(FormalParameterList parameters) { |
| this._parameters = becomeParentOf(parameters); |
| } |
| |
| /** |
| * Set the name of the constructor to which this constructor will be redirected to the given |
| * constructor name. |
| * |
| * @param redirectedConstructor the name of the constructor to which this constructor will be |
| * redirected |
| */ |
| void set redirectedConstructor(ConstructorName redirectedConstructor) { |
| this._redirectedConstructor = becomeParentOf(redirectedConstructor); |
| } |
| |
| /** |
| * Set the type of object being created to the given type name. |
| * |
| * @param typeName the type of object being created |
| */ |
| void set returnType(Identifier typeName) { |
| _returnType = becomeParentOf(typeName); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| super.visitChildren(visitor); |
| safelyVisitChild(_returnType, visitor); |
| safelyVisitChild(_name, visitor); |
| safelyVisitChild(_parameters, visitor); |
| initializers.accept(visitor); |
| safelyVisitChild(_redirectedConstructor, visitor); |
| safelyVisitChild(_body, visitor); |
| } |
| Token get firstTokenAfterCommentAndMetadata { |
| Token leftMost = this.leftMost([externalKeyword, constKeyword, factoryKeyword]); |
| if (leftMost != null) { |
| return leftMost; |
| } |
| return _returnType.beginToken; |
| } |
| |
| /** |
| * Return the left-most of the given tokens, or `null` if there are no tokens given or if |
| * all of the given tokens are `null`. |
| * |
| * @param tokens the tokens being compared to find the left-most token |
| * @return the left-most of the given tokens |
| */ |
| Token leftMost(List<Token> tokens) { |
| Token leftMost = null; |
| int offset = 2147483647; |
| for (Token token in tokens) { |
| if (token != null && token.offset < offset) { |
| leftMost = token; |
| } |
| } |
| return leftMost; |
| } |
| } |
| /** |
| * Instances of the class `ConstructorFieldInitializer` represent the initialization of a |
| * field within a constructor's initialization list. |
| * |
| * <pre> |
| * fieldInitializer ::= |
| * ('this' '.')? [SimpleIdentifier] '=' [Expression] |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| class ConstructorFieldInitializer extends ConstructorInitializer { |
| |
| /** |
| * The token for the 'this' keyword, or `null` if there is no 'this' keyword. |
| */ |
| Token keyword; |
| |
| /** |
| * The token for the period after the 'this' keyword, or `null` if there is no 'this' |
| * keyword. |
| */ |
| Token period; |
| |
| /** |
| * The name of the field being initialized. |
| */ |
| SimpleIdentifier _fieldName; |
| |
| /** |
| * The token for the equal sign between the field name and the expression. |
| */ |
| Token equals; |
| |
| /** |
| * The expression computing the value to which the field will be initialized. |
| */ |
| Expression _expression; |
| |
| /** |
| * Initialize a newly created field initializer to initialize the field with the given name to the |
| * value of the given expression. |
| * |
| * @param keyword the token for the 'this' keyword |
| * @param period the token for the period after the 'this' keyword |
| * @param fieldName the name of the field being initialized |
| * @param equals the token for the equal sign between the field name and the expression |
| * @param expression the expression computing the value to which the field will be initialized |
| */ |
| ConstructorFieldInitializer.full(Token keyword, Token period, SimpleIdentifier fieldName, Token equals, Expression expression) { |
| this.keyword = keyword; |
| this.period = period; |
| this._fieldName = becomeParentOf(fieldName); |
| this.equals = equals; |
| this._expression = becomeParentOf(expression); |
| } |
| |
| /** |
| * Initialize a newly created field initializer to initialize the field with the given name to the |
| * value of the given expression. |
| * |
| * @param keyword the token for the 'this' keyword |
| * @param period the token for the period after the 'this' keyword |
| * @param fieldName the name of the field being initialized |
| * @param equals the token for the equal sign between the field name and the expression |
| * @param expression the expression computing the value to which the field will be initialized |
| */ |
| ConstructorFieldInitializer({Token keyword, Token period, SimpleIdentifier fieldName, Token equals, Expression expression}) : this.full(keyword, period, fieldName, equals, expression); |
| accept(ASTVisitor visitor) => visitor.visitConstructorFieldInitializer(this); |
| Token get beginToken { |
| if (keyword != null) { |
| return keyword; |
| } |
| return _fieldName.beginToken; |
| } |
| Token get endToken => _expression.endToken; |
| |
| /** |
| * Return the expression computing the value to which the field will be initialized. |
| * |
| * @return the expression computing the value to which the field will be initialized |
| */ |
| Expression get expression => _expression; |
| |
| /** |
| * Return the name of the field being initialized. |
| * |
| * @return the name of the field being initialized |
| */ |
| SimpleIdentifier get fieldName => _fieldName; |
| |
| /** |
| * Set the expression computing the value to which the field will be initialized to the given |
| * expression. |
| * |
| * @param expression the expression computing the value to which the field will be initialized |
| */ |
| void set expression(Expression expression) { |
| this._expression = becomeParentOf(expression); |
| } |
| |
| /** |
| * Set the name of the field being initialized to the given identifier. |
| * |
| * @param identifier the name of the field being initialized |
| */ |
| void set fieldName(SimpleIdentifier identifier) { |
| _fieldName = becomeParentOf(identifier); |
| } |
| void visitChildren(ASTVisitor visitor) { |
| safelyVisitChild(_fieldName, visitor); |
| safelyVisitChild(_expression, visitor); |
| } |
| } |
| /** |
| * Instances of the class `ConstructorInitializer` defines the behavior of nodes that can |
| * occur in the initializer list of a constructor declaration. |
| * |
| * <pre> |
| * constructorInitializer ::= |
| * [SuperConstructorInvocation] |
| * | [ConstructorFieldInitializer] |
| * </pre> |
| * |
| * @coverage dart.engine.ast |
| */ |
| abstract class ConstructorInitializer extends ASTNode { |
|