<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Code2Xml.Core.Generators;

namespace SimpleOccf {
    internal class Program {
        private const string BackupExtension = ".soccf_backup";

        private static void Main(string[] args) {
            var iStatement = 0;
            var paths = args.SelectMany(arg => {
                if (Directory.Exists(arg)) {
                    return Directory.GetFiles(arg, "*.java", SearchOption.AllDirectories);
                } else if (File.Exists(arg)) {
                    return Enumerable.Repeat(arg, 1);
                } else {
                    return Enumerable.Repeat(arg, 0);
                }
            }).Select(Path.GetFileName).Distinct();

            foreach (var path in paths) {
                var backupPath = path + BackupExtension;
                if (!File.Exists(backupPath)) {
                    File.Copy(path, backupPath);
                }
                var gen = CstGenerators.JavaUsingAntlr3;
                var tree = gen.GenerateTreeFromCodePath(backupPath);

                foreach (var node in FindLackingBlockNodes(tree)) {
                    node.InsertCodeBeforeSelf("{");
                    node.InsertCodeAfterSelf("}");
                }

                foreach (var stmt in JavaElements.Statement(tree)) {
                    stmt.InsertCodeAfterSelf("randoop.multi.OCCF.stmt(" + iStatement + ");");
                    iStatement++;
                }

                gen.GenerateTreeFromCodeText(tree.Code, true);

                File.WriteAllText(path, tree.Code);
                Console.Write(".");
            }<commit_msg>Fix bug to find java files.<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Code2Xml.Core.Generators;

namespace SimpleOccf {
    internal class Program {
        private const string BackupExtension = ".soccf_backup";

        private static void Main(string[] args) {
            var iStatement = 0;
            var paths = args.SelectMany(arg => {
                if (Directory.Exists(arg)) {
                    return Directory.GetFiles(arg, "*.java", SearchOption.AllDirectories);
                } else if (File.Exists(arg)) {
                    return Enumerable.Repeat(arg, 1);
                } else {
                    return Enumerable.Repeat(arg, 0);
                }
            }).Select(Path.GetFullPath).Distinct();

            foreach (var path in paths) {
                var backupPath = path + BackupExtension;
                if (!File.Exists(backupPath)) {
                    File.Copy(path, backupPath);
                }
                var gen = CstGenerators.JavaUsingAntlr3;
                var tree = gen.GenerateTreeFromCodePath(backupPath);

                foreach (var node in FindLackingBlockNodes(tree)) {
                    node.InsertCodeBeforeSelf("{");
                    node.InsertCodeAfterSelf("}");
                }

                foreach (var stmt in JavaElements.Statement(tree)) {
                    stmt.InsertCodeAfterSelf("randoop.multi.OCCF.stmt(" + iStatement + ");");
                    iStatement++;
                }

                gen.GenerateTreeFromCodeText(tree.Code, true);

                File.WriteAllText(path, tree.Code);
                Console.Write(".");
            }
{'fraction_non_alphanumeric': 0.10329605650382578, 'fraction_numerical': 0.002942907592701589, 'mean_word_length': 1.5887281035795888, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1509572', 'n_tokens_mistral': 897, 'n_tokens_neox': 825, 'n_words': 179}