public static string Format(Definitions definitions)
 {
     var f = new WebIDLFormatter();
     f.Visit(definitions);
     return f._sb.ToString();
 }
 private void Visit(Definitions definitions)
 {
     foreach (var def in definitions.Items) {
         Visit(def);
         _sb.AppendLine().AppendLine();
     }
 }
Exemple #3
0
 private static Tuple<IReadOnlyList<Definitions>, IReadOnlyList<string>> Parse(IReadOnlyList<string> files)
 {
     var errors = new ConcurrentStack<string>();
     var allParts = new Definitions[files.Count];
     Parallel.ForEach(files, (file, _, i) => {
         try {
             allParts[i] = WebIDLParser.Parse(new StreamReader(file, Encoding.UTF8));
         }
         catch (IOException ex) {
             errors.Push("Error reading file " + file + ": " + ex.Message);
         }
         catch (RecognitionException ex) {
             errors.Push(file + "(" + ex.Line + ":" + ex.CharPositionInLine + "): " + ex.GetType().Name + ": " + ex.Message);
         }
     });
     return Tuple.Create<IReadOnlyList<Definitions>, IReadOnlyList<string>>(allParts, errors.ToList());
 }