<commit_before>package org.spoofax.jsglr2.incremental.parseforest;

import org.metaborg.parsetable.IProduction;
import org.metaborg.parsetable.IState;
import org.metaborg.parsetable.ProductionType;
import org.spoofax.jsglr2.parseforest.IDerivation;
import org.spoofax.jsglr2.util.TreePrettyPrinter;

public class IncrementalDerivation implements IDerivation<IncrementalParseForest> {
    private final int width;
    private final IProduction production;
    private final ProductionType productionType;
    public final IncrementalParseForest[] parseForests;
    public final IState state;
    private boolean changed;

    public IncrementalDerivation(IProduction production, ProductionType productionType,
        IncrementalParseForest[] parseForests, IState state) {

        this.production = production;
        this.productionType = productionType;
        this.parseForests = parseForests;
        this.state = state;
        int width = 0;
        for(IncrementalParseForest parseForest : parseForests) {
            if(parseForest == null)
                continue; // Skippable parse nodes are null
            width += parseForest.width();
        }
        this.width = width;
    }

    @Override public int width() {
        return width;
    }

    @Override public IProduction production() {
        return changed ? null : production;
    }

    @Override public ProductionType productionType() {
        return changed ? null : productionType;
    }

    @Override public IncrementalParseForest[] parseForests() {
        return parseForests;
    }

    public void markChanged() {
        this.changed = true;
    }

    protected void prettyPrint(TreePrettyPrinter printer) {
        if(production == null)
            printer.println("d null : {");
        else
            printer.println("d" + production.id() + " : " + production.descriptor() + "{ (s" + state.id() + ")");
        printer.indent(2);

        for(IncrementalParseForest parseForest : parseForests) {
            if(parseForest != null) {
                parseForest.prettyPrint(printer);
            } else
                printer.println("null");
        }

        printer.indent(-2);
        printer.println("}");
    }

<commit_msg>Remove `changed` field from IncrementalDerivation<commit_after>package org.spoofax.jsglr2.incremental.parseforest;

import org.metaborg.parsetable.IProduction;
import org.metaborg.parsetable.IState;
import org.metaborg.parsetable.ProductionType;
import org.spoofax.jsglr2.parseforest.IDerivation;
import org.spoofax.jsglr2.util.TreePrettyPrinter;

public class IncrementalDerivation implements IDerivation<IncrementalParseForest> {
    private final int width;
    private final IProduction production;
    private final ProductionType productionType;
    public final IncrementalParseForest[] parseForests;
    public final IState state;

    public IncrementalDerivation(IProduction production, ProductionType productionType,
        IncrementalParseForest[] parseForests, IState state) {

        this.production = production;
        this.productionType = productionType;
        this.parseForests = parseForests;
        this.state = state;
        int width = 0;
        for(IncrementalParseForest parseForest : parseForests) {
            if(parseForest == null)
                continue; // Skippable parse nodes are null
            width += parseForest.width();
        }
        this.width = width;
    }

    @Override public int width() {
        return width;
    }

    @Override public IProduction production() {
        return production;
    }

    @Override public ProductionType productionType() {
        return productionType;
    }

    @Override public IncrementalParseForest[] parseForests() {
        return parseForests;
    }

    protected void prettyPrint(TreePrettyPrinter printer) {
        if(production == null)
            printer.println("d null : {");
        else
            printer.println("d" + production.id() + " : " + production.descriptor() + "{ (s" + state.id() + ")");
        printer.indent(2);

        for(IncrementalParseForest parseForest : parseForests) {
            if(parseForest != null) {
                parseForest.prettyPrint(printer);
            } else
                printer.println("null");
        }

        printer.indent(-2);
        printer.println("}");
    }


{'fraction_non_alphanumeric': 0.09218069250171979, 'fraction_numerical': 0.002751662462737904, 'mean_word_length': 2.702886247877759, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3234198', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1163, 'n_words': 258}