<commit_before>var path = require('path'),
	_ = require('../../../lib/alloy/underscore')._,
	CU = require('../compilerUtils'),
	U = require('../../../utils'),
	TYPES = ['view','widget'];

exports.parse = function(node, state) {
	return require('./base').parse(node, state, parse);
};

function parse(node, state, args) {
	var code = '',
		type = node.getAttribute('type') || 'view',
		src = node.getAttribute('src'),
		method;

	// validate src
	if (!src) {
		U.die('<Require> elements must have a "src" attribute.');
	} else if (U.XML.getElementsFromNodes(node.childNodes).length !== 0) {
		U.die('<Require> elements may not have child elements.');
	}

	// determine which Alloy method to use
	var extraArgs = '';
	switch(type) {
		case 'view':
			method = 'getController';
			break;
		case 'widget':
			method = 'getWidget';
			extraArgs = "'widget',";
			break;
		default:
			U.die('Invalid <Require> type "' + type + '"');
	}

	// TODO: do a compile time check to make sure the src exists based on 
	//       its location determined by type

	// Remove <Require>-specific attributes from createArgs
	args.createArgs = _.reject(args.createArgs, function(v,k) {
		return _.contains(['type','src'], k);
	});

	// Generate runtime code
	code += args.symbol + " = Alloy." + method + "('" + src + "'," + extraArgs + CU.generateStyleParams(
		state.styles, 
		args.classes, 
		args.id, 
		node.nodeName, 
		args.createArgs<commit_msg>remove reserved attributes properly from Alloy.Require args<commit_after>var path = require('path'),
	_ = require('../../../lib/alloy/underscore')._,
	CU = require('../compilerUtils'),
	U = require('../../../utils'),
	TYPES = ['view','widget'];

exports.parse = function(node, state) {
	return require('./base').parse(node, state, parse);
};

function parse(node, state, args) {
	var code = '',
		type = node.getAttribute('type') || 'view',
		src = node.getAttribute('src'),
		method;

	// validate src
	if (!src) {
		U.die('<Require> elements must have a "src" attribute.');
	} else if (U.XML.getElementsFromNodes(node.childNodes).length !== 0) {
		U.die('<Require> elements may not have child elements.');
	}

	// determine which Alloy method to use
	var extraArgs = '';
	switch(type) {
		case 'view':
			method = 'getController';
			break;
		case 'widget':
			method = 'getWidget';
			extraArgs = "'widget',";
			break;
		default:
			U.die('Invalid <Require> type "' + type + '"');
	}

	// TODO: do a compile time check to make sure the src exists based on 
	//       its location determined by type

	// Remove <Require>-specific attributes from createArgs
	delete args.createArgs.type;
	delete args.createArgs.src;

	// Generate runtime code
	code += args.symbol + " = Alloy." + method + "('" + src + "'," + extraArgs + CU.generateStyleParams(
		state.styles, 
		args.classes, 
		args.id, 
		node.nodeName, 
		args.createArgs
{'fraction_non_alphanumeric': 0.17965746242572528, 'fraction_numerical': 0.0006990562740300594, 'mean_word_length': 3.437209302325581, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '245791', 'n_tokens_mistral': 974, 'n_tokens_neox': 904, 'n_words': 247}