private void PrepareUsings(UsingCache cache, TypeConstraintNode node) { if (node == null) { return; } node.Constraints?.ForEach(c => PrepareUsings(cache, c)); }
public AstNode VisitTypeConstraint(TypeConstraintNode n) { Append("where "); Visit(n.Type); Append(" : "); Visit(n.Constraints[0]); foreach (var c in n.Constraints.Skip(1)) { Append(", "); Visit(c); } return(n); }
protected virtual void VisitTypeConstraint(TypeConstraintNode node) { }
public virtual AstNode VisitTypeConstraint(TypeConstraintNode n) { Visit(n.Type); Visit(n.Constraints); return(n); }
protected override void VisitTypeConstraint(TypeConstraintNode node) { if (node == null) { return; } AppendIndentation(); Append("where "); Append(node.Name); Append(" : "); switch (node.Base) { case ConstraintBaseType.Struct: Append("struct"); break; case ConstraintBaseType.Class: Append("class"); break; case ConstraintBaseType.NullableClass: Append("class?"); break; case ConstraintBaseType.NotNull: Append("notnull"); break; case ConstraintBaseType.Unmanaged: Append("unmanaged"); break; case ConstraintBaseType.Enum: Append("struct, System.Enum"); break; } if (node.Base != ConstraintBaseType.None) { if (node.Constraints.Length > 0) { Append(", "); } } void TryAppendComma(int index) { if (index > 0) { Append(", "); } } for (var i = 0; i < node.Constraints.Length; i++) { switch (node.Constraints[i]) { case TypeNameConstraint t: { TryAppendComma(i); Append(t.Value); break; } case StringConstraint s: { TryAppendComma(i); Append(s.Value); break; } } } if (node.HasDefaultConstructor && node.Base != ConstraintBaseType.Struct && node.Base != ConstraintBaseType.Unmanaged) { Append(", new()"); } AppendLine(); if (this.settings.BlankLine.Constraint) { AppendLine(); } }