예제 #1
0
 public override object VisitArrayObjectCreateExpression(ArrayObjectCreateExpression arrayObjectCreateExpression, object data)
 {
     foreach (INode node in arrayObjectCreateExpression.Children)
     {
         if (node.Role == ArrayObjectCreateExpression.Roles.Comma)
         {
             ForceSpacesBefore(node, policy.SpacesBeforeComma);
             ForceSpacesAfter(node, policy.SpacesAfterComma);
         }
     }
     return(base.VisitArrayObjectCreateExpression(arrayObjectCreateExpression, data));
 }
예제 #2
0
			public override object Visit (ArrayCreation arrayCreationExpression)
			{
				var result = new ArrayObjectCreateExpression ();
				
				var location = LocationsBag.GetLocations (arrayCreationExpression);
				result.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Location), "new".Length), ArrayObjectCreateExpression.Roles.Keyword);
				
				if (arrayCreationExpression.NewType != null)
					result.AddChild ((INode)arrayCreationExpression.NewType.Accept (this), ArrayObjectCreateExpression.Roles.ReturnType);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ArrayObjectCreateExpression.Roles.LBracket);
				if (arrayCreationExpression.Arguments != null) {
					var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Arguments);
					for (int i = 0 ;i < arrayCreationExpression.Arguments.Count; i++) {
						result.AddChild ((INode)arrayCreationExpression.Arguments[i].Accept (this), ObjectCreateExpression.Roles.Initializer);
						if (commaLocations != null && i > 0)
							result.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), IndexerExpression.Roles.Comma);
					}
				}
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ArrayObjectCreateExpression.Roles.RBracket);
				
				if (arrayCreationExpression.Initializers != null && arrayCreationExpression.Initializers.Elements != null) {
					var initLocation = LocationsBag.GetLocations (arrayCreationExpression.Initializers);
					result.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Initializers.Location), 1), ArrayObjectCreateExpression.Roles.LBrace);
					if (arrayCreationExpression.Initializers.Elements != null) {
						var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Initializers.Elements);
						for (int i = 0; i < arrayCreationExpression.Initializers.Elements.Count; i++) {
							result.AddChild ((INode)arrayCreationExpression.Initializers.Elements[i].Accept (this), ObjectCreateExpression.Roles.Initializer);
							if (commaLocations != null && i > 0)
								result.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), IndexerExpression.Roles.Comma);
						}
					}
					if (initLocation != null)
						result.AddChild (new CSharpTokenNode (Convert (initLocation[0]), 1), ArrayObjectCreateExpression.Roles.RBrace);
				}
				
				return result;
			}