<commit_before>const LINE = {};
const BLOCK = {};

export default class CodeBuilder {
	constructor () {
		this.result = '';

		this.first = null;
		this.last = null;

		this.lastCondition = null;
	}

	addConditionalLine ( condition, line ) {
		if ( condition === this.lastCondition ) {
			this.result += `\n\t${line}`;
		} else {
			if ( this.lastCondition ) {
				this.result += `\n}`;
			}

			this.result += `if ( ${condition} ) {\n\t${line}`;
			this.lastCondition = condition;
		}

		this.last = BLOCK;
	}

	addLine ( line ) {
		if ( this.lastCondition ) {
			this.result += `\n}`;
			this.lastCondition = null;
		}

		if ( this.last === BLOCK ) {
			this.result += `\n\n${line}`;
		} else if ( this.last === LINE ) {
			this.result += `\n${line}`;
		} else {
			this.result += line;
		}

		this.last = LINE;
		if ( !this.first ) this.first = LINE;
	}

	addLineAtStart ( line ) {
		if ( this.first === BLOCK ) {
			this.result = `${line}\n\n${this.result}`;
		} else if ( this.first === LINE ) {
			this.result = `${line}\n${this.result}`;
		} else {
			this.result += line;
		}

		this.first = LINE;
		if ( !this.last ) this.last = LINE;
	}

	addBlock ( block ) {
		if ( this.lastCondition ) {
			this.result += `\n}`;
			this.lastCondition = null;
		}

		if ( this.result ) {
			this.result += `\n\n${block}`;
		} else {
			this.result += block;
		}

		this.last = BLOCK;
		if ( !this.first ) this.first = BLOCK;
	}

	addBlockAtStart ( block ) {
		if ( this.result ) {
			this.result = `${block}\n\n${this.result}`;
		} else {
			this.result += block;
		}

		this.first = BLOCK;
		if ( !this.last ) this.last = BLOCK;
	}

	isEmpty () {
		return this.result === '';
	}

	toString () {
		return this.result.trim() + ( this.lastCondition ? `\n}` : `` );
	}
}
<commit_msg>separate if statements in codebuilder<commit_after>const LINE = {};
const BLOCK = {};

export default class CodeBuilder {
	constructor () {
		this.result = '';

		this.first = null;
		this.last = null;

		this.lastCondition = null;
	}

	addConditionalLine ( condition, line ) {
		if ( condition === this.lastCondition ) {
			this.result += `\n\t${line}`;
		} else {
			if ( this.lastCondition ) {
				this.result += `\n}\n\n`;
			}

			this.result += `if ( ${condition} ) {\n\t${line}`;
			this.lastCondition = condition;
		}

		this.last = BLOCK;
	}

	addLine ( line ) {
		if ( this.lastCondition ) {
			this.result += `\n}`;
			this.lastCondition = null;
		}

		if ( this.last === BLOCK ) {
			this.result += `\n\n${line}`;
		} else if ( this.last === LINE ) {
			this.result += `\n${line}`;
		} else {
			this.result += line;
		}

		this.last = LINE;
		if ( !this.first ) this.first = LINE;
	}

	addLineAtStart ( line ) {
		if ( this.first === BLOCK ) {
			this.result = `${line}\n\n${this.result}`;
		} else if ( this.first === LINE ) {
			this.result = `${line}\n${this.result}`;
		} else {
			this.result += line;
		}

		this.first = LINE;
		if ( !this.last ) this.last = LINE;
	}

	addBlock ( block ) {
		if ( this.lastCondition ) {
			this.result += `\n}`;
			this.lastCondition = null;
		}

		if ( this.result ) {
			this.result += `\n\n${block}`;
		} else {
			this.result += block;
		}

		this.last = BLOCK;
		if ( !this.first ) this.first = BLOCK;
	}

	addBlockAtStart ( block ) {
		if ( this.result ) {
			this.result = `${block}\n\n${this.result}`;
		} else {
			this.result += block;
		}

		this.first = BLOCK;
		if ( !this.last ) this.last = BLOCK;
	}

	isEmpty () {
		return this.result === '';
	}

	toString () {
		return this.result.trim() + ( this.lastCondition ? `\n}` : `` );
	}
}

{'fraction_non_alphanumeric': 0.19731693683622134, 'fraction_numerical': 0.0, 'mean_word_length': 2.498533724340176, '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': '1747082', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1355, 'n_words': 266}