<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using dotless.Core.engine.CssNodes;
using dotless.Core.utils;

namespace dotless.Core.engine.Pipeline
{
    public class CssPropertyMerger : ICssDomPreprocessor
    {
        public CssDocument Process(CssDocument document)
        {
            document.Elements = MergeElements(document.Elements).ToList();
            return document;
        }

        private static IEnumerable<CssElement> MergeElements(IEnumerable<CssElement> elements)
        {
            return from e in elements
                   group e by e.Identifiers
                   into g
                       let uniqueProperties = g.SelectMany(a => a.Properties)
                       select
                       new CssElement
                           {
                               Identifiers = g.Key,
                               Properties = new HashSet<CssProperty>(uniqueProperties),
                               // Note: There is no test requiring the InsertContent to be set here. Please create a failing test and uncomment.
                               //       Also shouldn't we need to join all insert contents together? (assuming it's required at all)
                               // InsertContent = g.First().InsertContent
                           };
        }
    }
}<commit_msg>Renamed uniqueProperties to properties since they are no longer unique<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using dotless.Core.engine.CssNodes;
using dotless.Core.utils;

namespace dotless.Core.engine.Pipeline
{
    public class CssPropertyMerger : ICssDomPreprocessor
    {
        public CssDocument Process(CssDocument document)
        {
            document.Elements = MergeElements(document.Elements).ToList();
            return document;
        }

        private static IEnumerable<CssElement> MergeElements(IEnumerable<CssElement> elements)
        {
            return from e in elements
                   group e by e.Identifiers
                   into g
                       let properties = g.SelectMany(a => a.Properties)
                       select
                       new CssElement
                           {
                               Identifiers = g.Key,
                               Properties = new HashSet<CssProperty>(properties),
                               // Note: There is no test requiring the InsertContent to be set here. Please create a failing test and uncomment.
                               //       Also shouldn't we need to join all insert contents together? (assuming it's required at all)
                               // InsertContent = g.First().InsertContent
                           };
        }
    }
}
{'fraction_non_alphanumeric': 0.0617151058485827, 'fraction_numerical': 0.0, 'mean_word_length': 1.4892857142857143, 'pattern_counts': {'":': 0, '<': 9, '<?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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4328440', 'n_tokens_mistral': 631, 'n_tokens_neox': 612, 'n_words': 185}