/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { MultiFieldDecl clone = (MultiFieldDecl)base.Clone(); clone._fieldDecls = ChildListHelpers.Clone(_fieldDecls, clone); return(clone); }
/// <summary> /// Parse a <see cref="FieldDecl"/>. /// </summary> public static FieldDecl Parse(Parser parser, CodeObject parent, ParseFlags flags) { // Validate that we have an unused identifier token preceeded by a type, and double-check the constraint that our // parent is a TypeDecl (necessary when constraints are relaxed for code embedded in doc comments). if (parser.HasUnusedTypeRefAndIdentifier && parent is TypeDecl) { FieldDecl fieldDecl = new FieldDecl(parser, parent, false); // Handle additional FieldDecls after any commas if (!fieldDecl.HasTerminator && parser.TokenText == Expression.ParseTokenSeparator) { // If it's a multi, create one, and transfer any new lines and annotations MultiFieldDecl multiFieldDecl = new MultiFieldDecl(fieldDecl) { NewLines = fieldDecl.NewLines, HasTerminator = false }; multiFieldDecl.SetLineCol(fieldDecl); fieldDecl.NewLines = 0; do { Token commaToken = parser.Token; parser.NextToken(); // Move past ',' // Associate any EOL comment on the ',' to the last FieldDecl fieldDecl.MoveEOLComment(commaToken, false, false); fieldDecl = new FieldDecl(parser, null, true); // Force the expression to first-on-line if the last comma was (handles special-case // formatting where the commas preceed the list items instead of following them). if (commaToken.IsFirstOnLine) { fieldDecl.IsFirstOnLine = true; } // Move any comments after the ',' to the current FieldDecl fieldDecl.MoveComments(commaToken); multiFieldDecl.Add(fieldDecl); }while (parser.TokenText == Expression.ParseTokenSeparator); fieldDecl = multiFieldDecl; multiFieldDecl.ParseTerminator(parser); } return(fieldDecl); } return(null); }