<commit_before>import { UNKNOWN_VALUE } from '../values';
import { ExpressionNode, StatementBase, StatementNode } from './shared/Node';
import MagicString from 'magic-string';
import { NodeType } from './NodeType';
import { RenderOptions } from '../../utils/renderHelpers';
import ExecutionPathOptions from '../ExecutionPathOptions';

export default class IfStatement extends StatementBase {
	type: NodeType.IfStatement;
	test: ExpressionNode;
	consequent: StatementNode;
	alternate: StatementNode | null;

	private hasUnknownTestValue = false;

	hasEffects(options: ExecutionPathOptions): boolean {
		return this.test.hasEffects(options) || this.hasUnknownTestValue
			? this.consequent.hasEffects(options) ||
					(this.alternate !== null && this.alternate.hasEffects(options))
			: this.someRelevantBranch(node => node.hasEffects(options));
	}

	includeInBundle() {
		let addedNewNodes = !this.included;
		this.included = true;
		const testValue = this.test.getValue();
		if (
			(testValue === UNKNOWN_VALUE || this.test.shouldBeIncluded()) &&
			this.test.includeInBundle()
		) {
			addedNewNodes = true;
		}
		if (testValue === UNKNOWN_VALUE) {
			if (this.consequent.includeInBundle()) addedNewNodes = true;
			if (this.alternate !== null && this.alternate.includeInBundle()) addedNewNodes = true;
		} else if (
			testValue
				? this.consequent.includeInBundle()
				: this.alternate !== null && this.alternate.includeInBundle()
		) {
			addedNewNodes = true;
		}
		return addedNewNodes;
	}

	render(code: MagicString, options: RenderOptions) {
		const testValue = this.test.getValue();
		if (
			!this.module.graph.treeshake ||
			this.test.included ||<commit_msg>Add missing brackets<commit_after>import { UNKNOWN_VALUE } from '../values';
import { ExpressionNode, StatementBase, StatementNode } from './shared/Node';
import MagicString from 'magic-string';
import { NodeType } from './NodeType';
import { RenderOptions } from '../../utils/renderHelpers';
import ExecutionPathOptions from '../ExecutionPathOptions';

export default class IfStatement extends StatementBase {
	type: NodeType.IfStatement;
	test: ExpressionNode;
	consequent: StatementNode;
	alternate: StatementNode | null;

	private hasUnknownTestValue = false;

	hasEffects(options: ExecutionPathOptions): boolean {
		return (
			this.test.hasEffects(options) ||
			(this.hasUnknownTestValue
				? this.consequent.hasEffects(options) ||
				  (this.alternate !== null && this.alternate.hasEffects(options))
				: this.someRelevantBranch(node => node.hasEffects(options)))
		);
	}

	includeInBundle() {
		let addedNewNodes = !this.included;
		this.included = true;
		const testValue = this.test.getValue();
		if (
			(testValue === UNKNOWN_VALUE || this.test.shouldBeIncluded()) &&
			this.test.includeInBundle()
		) {
			addedNewNodes = true;
		}
		if (testValue === UNKNOWN_VALUE) {
			if (this.consequent.includeInBundle()) addedNewNodes = true;
			if (this.alternate !== null && this.alternate.includeInBundle()) addedNewNodes = true;
		} else if (
			testValue
				? this.consequent.includeInBundle()
				: this.alternate !== null && this.alternate.includeInBundle()
		) {
			addedNewNodes = true;
		}
		return addedNewNodes;
	}

	render(code: MagicString, options: RenderOptions) {
		const testValue = this.test.getValue();
		if (
			!this.module.graph.treeshake ||
			this.test.included ||
{'fraction_non_alphanumeric': 0.13167259786476868, 'fraction_numerical': 0.0, 'mean_word_length': 4.422829581993569, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4796237', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1007, 'n_words': 214}