<commit_before>package in.twizmwaz.cardinal.util;

import org.bukkit.Bukkit;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;

public class DomUtils {

    public static Document parse(File file) throws JDOMException, IOException {
        SAXBuilder saxBuilder = new SAXBuilder();
        Document original = saxBuilder.build(file);
        for (Element include : original.getRootElement().getChildren("include")) {
            File path = file.getParentFile();
            String source = include.getAttributeValue("src");
            while (source.startsWith("../")) {
                source = source.replace("../", "");
                path = path.getParentFile();
            }
            File including = new File(path, source);
            try {
                for (Element element : parse(including).getRootElement().getChildren()) {
                    original.getRootElement().addContent(element.clone().detach());
                }
            } catch (JDOMException | IOException e) {
                Bukkit.getLogger().log(Level.WARNING, "File '" + including.getName() + "' was not found nor included!");
            }
        }
        return original;
    }
}<commit_msg>Check in more locations for included files<commit_after>package in.twizmwaz.cardinal.util;

import org.bukkit.Bukkit;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;

public class DomUtils {

    public static Document parse(File file) throws JDOMException, IOException {
        SAXBuilder saxBuilder = new SAXBuilder();
        Document original = saxBuilder.build(file);
        for (Element include : original.getRootElement().getChildren("include")) {
            boolean found = false;
            File path = file.getParentFile();
            String source = include.getAttributeValue("src");
            File including = new File(path, source);
            if (including.exists()) {
                found = true;
                try {
                    for (Element element : parse(including).getRootElement().getChildren()) {
                        original.getRootElement().addContent(element.clone().detach());
                    }
                } catch (JDOMException | IOException ignored) {}
            } else {
                while (source.startsWith("../")) {
                    source = source.replace("../", "");
                }
                including = new File(path, source);
                if (including.exists()) {
                    found = true;
                    try {
                        for (Element element : parse(including).getRootElement().getChildren()) {
                            original.getRootElement().addContent(element.clone().detach());
                        }
                    } catch (JDOMException | IOException ignored) {
                    }
                }
                including = new File(path.getParentFile(), source);
                if (including.exists()) {
                    found = true;
                    try {
                        for (Element element : parse(including).getRootElement().getChildren()) {
                            original.getRootElement().addContent(element.clone().detach());
                        }
                    } catch (JDOMException | IOException ignored) {
                    }
                }
            }
            if (!found) Bukkit.getLogger().log(Level.WARNING, "File '" + including.getName() + "' was not found nor included!");
        }
        return original;
    }
}
{'fraction_non_alphanumeric': 0.11440566780372606, 'fraction_numerical': 0.0020991865652059826, 'mean_word_length': 1.7988252569750367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3222437', 'n_tokens_mistral': 953, 'n_tokens_neox': 914, 'n_words': 204}