<commit_before>package main.nl.uva.parser.expression;

import main.nl.uva.parser.Line;
import main.nl.uva.ui.element.DeclarationUI;
import main.nl.uva.ui.types.ValueUI;
import main.nl.uva.validation.ASTValidation;
import main.nl.uva.validation.Scope;
import main.nl.uva.validation.error.InvalidTypeError;
import main.nl.uva.validation.type.Value;

public class Variable extends Expression implements ExpressionChangeListener {

    private final Value.Type _value;

    private final String _name;

    private Expression _expression;

    public Variable(final Value.Type type, final String name, final Expression expression, final Line lineInfo) {
        super(lineInfo);
        _value = type;
        _name = name;
        _expression = expression;

        _expression.registerListener(this);
    }

    public Variable(final Value.Type type, final String name, final Line lineInfo) {
        this(type, name, type.getAtom(), lineInfo);
    }

    public boolean setExpression(final Expression newExpression) {
        if (!newExpression.getValue().isTypeOf(_value)) {
            // Type is not acceptable
            return false;
        }

        _expression = newExpression;
        _expression.registerListener(this);

        return true;
    }

    @Override
    public ASTValidation validateAndCalculate(final Scope scope) {
        ASTValidation valid = _expression.validateAndCalculate(scope);

        if (!_expression.getValue().isTypeOf(_value)) {
            valid.addError(new InvalidTypeError(this.toString(), getLineInfo()));
        }

        return valid;
    }

    public String getName() {
        return _name;
    }

    @Override
    public Value getValue() {
        return _expression.getValue();<commit_msg>Changed variable name to a more descriptive one<commit_after>package main.nl.uva.parser.expression;

import main.nl.uva.parser.Line;
import main.nl.uva.ui.element.DeclarationUI;
import main.nl.uva.ui.types.ValueUI;
import main.nl.uva.validation.ASTValidation;
import main.nl.uva.validation.Scope;
import main.nl.uva.validation.error.InvalidTypeError;
import main.nl.uva.validation.type.Value;

public class Variable extends Expression implements ExpressionChangeListener {

    private final Value.Type _type;

    private final String _name;

    private Expression _expression;

    public Variable(final Value.Type type, final String name, final Expression expression, final Line lineInfo) {
        super(lineInfo);
        _type = type;
        _name = name;
        _expression = expression;

        _expression.registerListener(this);
    }

    public Variable(final Value.Type type, final String name, final Line lineInfo) {
        this(type, name, type.getAtom(), lineInfo);
    }

    public boolean setExpression(final Expression newExpression) {
        if (!newExpression.getValue().isTypeOf(_type)) {
            // Type is not acceptable
            return false;
        }

        _expression = newExpression;
        _expression.registerListener(this);

        return true;
    }

    @Override
    public ASTValidation validateAndCalculate(final Scope scope) {
        ASTValidation valid = _expression.validateAndCalculate(scope);

        if (!_expression.getValue().isTypeOf(_type)) {
            valid.addError(new InvalidTypeError(this.toString(), getLineInfo()));
        }

        return valid;
    }

    public String getName() {
        return _name;
    }

    @Override
    public Value getValue() {
        return _expression.getValue();
{'fraction_non_alphanumeric': 0.09152927799886298, 'fraction_numerical': 0.0, 'mean_word_length': 2.971783295711061, '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': '4823757', 'n_tokens_mistral': 966, 'n_tokens_neox': 921, 'n_words': 234}