using System; using System.Collections.Generic; namespace ICSharpCode.NRefactory.CSharp { /// /// new Type[Dimensions] /// public class ArrayCreateExpression : Expression { public readonly static Role AdditionalArraySpecifierRole = new Role("AdditionalArraySpecifier"); public readonly static Role InitializerRole = new Role("Initializer", ArrayInitializerExpression.Null); public AstType Type { get { return GetChildByRole (Roles.Type); } set { SetChildByRole (Roles.Type, value); } } public AstNodeCollection Arguments { get { return GetChildrenByRole (Roles.Argument); } } /// /// Gets additional array ranks (those without size info). /// Empty for "new int[5,1]"; will contain a single element for "new int[5][]". /// public AstNodeCollection AdditionalArraySpecifiers { get { return GetChildrenByRole(AdditionalArraySpecifierRole); } } public ArrayInitializerExpression Initializer { get { return GetChildByRole (InitializerRole); } set { SetChildByRole (InitializerRole, value); } } public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitArrayCreateExpression (this, data); } protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { ArrayCreateExpression o = other as ArrayCreateExpression; return o != null && this.Type.DoMatch(o.Type, match) && this.Arguments.DoMatch(o.Arguments, match) && this.Initializer.DoMatch(o.Initializer, match); } } }