<commit_before>'use strict';

module.exports = function (babel) {
	var t = babel.types;

	return {
		inherits: require("babel-plugin-syntax-jsx"),
		name: "redom-jsx-transform",
		visitor: {
			JSXElement: function JSXElement(path, file) {
              	var isComponent = path.node.openingElement.name.name.match(/^[A-Z]/);
				var thisAttr = [];
              	var listAttr = [];
				var restAttr = [];
              	var list;
				var node = path.node;
				path.node.openingElement.attributes.forEach((attr) => { 
                  	if(attr.name.name === 'list'){
                      	listAttr.push(attr);
                    }else if(attr.name.name === 'this'){
                    	thisAttr.push(attr);
                    }else{
                      	restAttr.push(attr)
                    }
                }
				);
				if (isComponent) {
					var attribObj = restAttr.length ? buildOpeningElementAttributes(restAttr, file) : t.objectExpression([]);
					var children = t.react.buildChildren(path.node).map((node) => {
						if (t.isLiteral(node)) {
							return t.callExpression(t.identifier('text'), [node])
						}
						return node;
					});
					node = t.newExpression(path.node.openingElement.name, [attribObj].concat(children));
				}

				if (thisAttr.length) {
					var attr = thisAttr[thisAttr.length - 1];
					var thisMember = t.isJSXExpressionContainer(attr.value) ? attr.value.expression : attr.value;
					var assignToThis = t.assignmentExpression('=', t.memberExpression(t.thisExpression(), thisMember, true), node);
					path.node.openingElement.attributes = restAttr;
					node = t.isJSXElement(path.parent) ? t.jSXExpressionContainer(assignToThis) : assignToThis;
				}
              
              	if(listAttr.length){
                  list = listAttr[listAttr.length - 1];
                  var listMember = t.isJSXExpressionContainer(list.value) ? list.value.expression : list.value;
                  if(isComponent){
                    node = t.memberExpression(node, t.identifier('el'), false);
                  }
                  path.node.openingElement.attributes = restAttr;
                  node = t.callExpression(t.identifier('list'), [node, listMember]);
                }
              	
				if (node !== path.node) {
					path.replaceWith(node);
				}

			}
		}
	};

	function convertAttributeValue(node) {
		if (t.isJSXExpressionContainer(node)) {
			return node.expression;
		} else {
			return node;
		}
	}

	function convertAttribute(node) {
		let value = convertAttributeValue(node.value || t.booleanLiteral(true));

		if (t.isStringLiteral(value) && !t.isJSXExpressionContainer(node.value)) {
			value.value = value.value.replace(/\n\s+/g, " ");
		}

		if (t.isValidIdentifier(node.name.name)) {<commit_msg>change assign this to list<commit_after>'use strict';

module.exports = function (babel) {
	var t = babel.types;

	return {
		inherits: require("babel-plugin-syntax-jsx"),
		name: "redom-jsx-transform",
		visitor: {
			JSXElement: function JSXElement(path, file) {
              	var isComponent = path.node.openingElement.name.name.match(/^[A-Z]/);
				var thisAttr = [];
              	var listAttr = [];
				var restAttr = [];
              	var list;
				var node = path.node;
				path.node.openingElement.attributes.forEach((attr) => { 
                  	if(attr.name.name === 'list'){
                      	listAttr.push(attr);
                    }else if(attr.name.name === 'this'){
                    	thisAttr.push(attr);
                    }else{
                      	restAttr.push(attr)
                    }
                }
				);
				if (isComponent) {
					var attribObj = restAttr.length ? buildOpeningElementAttributes(restAttr, file) : t.objectExpression([]);
					var children = t.react.buildChildren(path.node).map((node) => {
						if (t.isLiteral(node)) {
							return t.callExpression(t.identifier('text'), [node])
						}
						return node;
					});
					node = t.newExpression(path.node.openingElement.name, [attribObj].concat(children));
				}
				if(listAttr.length){
                    list = listAttr[listAttr.length - 1];
                    var listMember = t.isJSXExpressionContainer(list.value) ? list.value.expression : list.value;
                    if(isComponent){
                      node = t.memberExpression(node, t.identifier('el'), false);
                    }
                    path.node.openingElement.attributes = restAttr;
                    node = t.callExpression(t.identifier('list'), [node, listMember]);
                }

				if (thisAttr.length) {
					var attr = thisAttr[thisAttr.length - 1];
					var thisMember = t.isJSXExpressionContainer(attr.value) ? attr.value.expression : attr.value;
					var assignToThis = t.assignmentExpression('=', t.memberExpression(t.thisExpression(), thisMember, true), node);
					path.node.openingElement.attributes = restAttr;
					node = t.isJSXElement(path.parent) ? t.jSXExpressionContainer(assignToThis) : assignToThis;
				}
              
              	
              	
				if (node !== path.node) {
					path.replaceWith(node);
				}

			}
		}
	};

	function convertAttributeValue(node) {
		if (t.isJSXExpressionContainer(node)) {
			return node.expression;
		} else {
			return node;
		}
	}

	function convertAttribute(node) {
		let value = convertAttributeValue(node.value || t.booleanLiteral(true));

		if (t.isStringLiteral(value) && !t.isJSXExpressionContainer(node.value)) {
			value.value = value.value.replace(/\n\s+/g, " ");
		}

		if (t.isValidIdentifier(node.name.name)) {
{'fraction_non_alphanumeric': 0.13551401869158877, 'fraction_numerical': 0.0007189072609633358, 'mean_word_length': 2.1583427922814984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3042642', 'n_tokens_mistral': 1930, 'n_tokens_neox': 1626, 'n_words': 270}