<commit_before>using System;
using System.Collections.Generic;

namespace TSF.ADL {
  public class Construct {
    private String type;
    private String name;
    private List<String> annotations = new List<String>();
    private List<String>      supers = new List<String>();
    private List<Modifier> modifiers = new List<Modifier>();
    private List<Construct> children = new List<Construct>();

    public Construct setType(String type) {
      this.type = type.ToLower();
      return this;
    }

    public Construct setName(String name) {
      this.name = name;
      return this;
    }

    public Construct addAnnotation(String annotation) {
      this.annotations.Add(annotation);
      return this;
    }

    public Construct addSuper(String name) {
      this.supers.Add(name);
      return this;
    }

    public Construct addModifier(Modifier modifier) {
      this.modifiers.Add(modifier);
      return this;
    }

    public Construct addChild(Construct construct) {
      this.children.Add(construct);
      return this;
    }

    public String getType() {
      return this.type;
    }

    public String getName() {
      return this.name;
    }

    public String getAnnotationsAsString(String prefix) {
      String s = "";
      foreach( String annotation in this.annotations ) {
        s += prefix + "[@" + annotation + "]\r\n";
      }
      return s;
    }

    public String getSuperAsString() {
      String s = "";
      foreach( String zuper in this.supers ) {
        s += " :" + zuper;
      }
      return s;
    }

    public String getModifiersAsString() {
      String s = "";
      foreach( Modifier modifier in this.modifiers ) {
        s += modifier.ToString() + " ";
      }
      return s;
    }

    public String getChildrenAsString(String prefix) {
      if( this.children.Count < 1 ) { return ";"; }
      String s = " {\r\n";
      foreach( Construct child in this.children ) {
        s += child.ToString(prefix + "  ") + "\r\n";
      }
      s += prefix + "}";
      return s;
    }

    public List<String> getDependencies() {
      List<String> deps = new List<String>();
      foreach( Construct child in this.children ) {
        deps.AddRange(child.getDependencies());
      }
      deps.AddRange(this.supers);
      return deps;
    }

    public String ToString(String prefix) {
      return this.getAnnotationsAsString(prefix) 
          + prefix + this.type + " " + this.name
          + this.getSuperAsString()
          + this.getModifiersAsString()
          + this.getChildrenAsString(prefix);
    }
    
    public override String ToString() {
      return this.ToString("");<commit_msg>added mechanism to prepare before ToString is called.<commit_after>using System;
using System.Collections.Generic;

namespace TSF.ADL {
  public class Construct {
    private String type;
    private String name;
    private List<String> annotations = new List<String>();
    private List<String>      supers = new List<String>();
    private List<Modifier> modifiers = new List<Modifier>();
    private List<Construct> children = new List<Construct>();

    public Construct setType(String type) {
      this.type = type.ToLower();
      return this;
    }

    public Construct setName(String name) {
      this.name = name;
      return this;
    }

    public Construct addAnnotation(String annotation) {
      this.annotations.Add(annotation);
      return this;
    }

    public Construct addSuper(String name) {
      this.supers.Add(name);
      return this;
    }

    public Construct addModifier(Modifier modifier) {
      this.modifiers.Add(modifier);
      return this;
    }

    public Construct addChild(Construct construct) {
      this.children.Add(construct);
      return this;
    }

    public String getType() {
      return this.type;
    }

    public String getName() {
      return this.name;
    }

    public String getAnnotationsAsString(String prefix) {
      String s = "";
      foreach( String annotation in this.annotations ) {
        s += prefix + "[@" + annotation + "]\r\n";
      }
      return s;
    }

    public String getSuperAsString() {
      String s = "";
      foreach( String zuper in this.supers ) {
        s += " :" + zuper;
      }
      return s;
    }

    public String getModifiersAsString() {
      String s = "";
      foreach( Modifier modifier in this.modifiers ) {
        s += modifier.ToString() + " ";
      }
      return s;
    }

    public String getChildrenAsString(String prefix) {
      if( this.children.Count < 1 ) { return ";"; }
      String s = " {\r\n";
      foreach( Construct child in this.children ) {
        s += child.ToString(prefix + "  ") + "\r\n";
      }
      s += prefix + "}";
      return s;
    }

    public List<String> getDependencies() {
      List<String> deps = new List<String>();
      foreach( Construct child in this.children ) {
        deps.AddRange(child.getDependencies());
      }
      deps.AddRange(this.supers);
      return deps;
    }

    public virtual void prepare() {}

    public String ToString(String prefix) {
      this.prepare();
      return this.getAnnotationsAsString(prefix) 
          + prefix + this.type + " " + this.name
          + this.getSuperAsString()
          + this.getModifiersAsString()
          + this.getChildrenAsString(prefix);
    }
    
    public override String ToString() {
      return this.ToString("");
{'fraction_non_alphanumeric': 0.11453338251567687, 'fraction_numerical': 0.00036886757654002215, 'mean_word_length': 2.288659793814433, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6395460', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1518, 'n_words': 393}