<commit_before>﻿namespace AngleSharp.Css.ValueConverters
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using AngleSharp.Dom.Css;
    using AngleSharp.Parser.Css;

    sealed class FunctionValueConverter<T> : IValueConverter<T>
    {
        readonly String _name;
        readonly IValueConverter<T> _arguments;

        public FunctionValueConverter(String name, IValueConverter<T> arguments)
        {
            _name = name;
            _arguments = arguments;
        }

        public Boolean TryConvert(IEnumerable<CssToken> value, Action<T> setResult)
        {
            var args = ExtractArguments(value);
            return args != null && _arguments.TryConvert(args, setResult);
        }

        public Boolean Validate(IEnumerable<CssToken> value)
        {
            var args = ExtractArguments(value);
            return args != null && _arguments.Validate(args);
        }

        List<CssToken> ExtractArguments(IEnumerable<CssToken> value)
        {
            var iter = value.GetEnumerator();

            if (iter.MoveNext() && IsFunction(iter.Current))
            {
                var tokens = new List<CssToken>();

                while (iter.MoveNext())
                {
                    tokens.Add(iter.Current);
                }

                if (tokens.Count > 0 && tokens[tokens.Count - 1].Type == CssTokenType.RoundBracketClose)
                {
                    return tokens;
                }
            }

            return null;<commit_msg>Remove closing bracket from arguments<commit_after>﻿namespace AngleSharp.Css.ValueConverters
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using AngleSharp.Dom.Css;
    using AngleSharp.Parser.Css;

    sealed class FunctionValueConverter<T> : IValueConverter<T>
    {
        readonly String _name;
        readonly IValueConverter<T> _arguments;

        public FunctionValueConverter(String name, IValueConverter<T> arguments)
        {
            _name = name;
            _arguments = arguments;
        }

        public Boolean TryConvert(IEnumerable<CssToken> value, Action<T> setResult)
        {
            var args = ExtractArguments(value);
            return args != null && _arguments.TryConvert(args, setResult);
        }

        public Boolean Validate(IEnumerable<CssToken> value)
        {
            var args = ExtractArguments(value);
            return args != null && _arguments.Validate(args);
        }

        List<CssToken> ExtractArguments(IEnumerable<CssToken> value)
        {
            var iter = value.GetEnumerator();

            if (iter.MoveNext() && IsFunction(iter.Current))
            {
                var tokens = new List<CssToken>();

                while (iter.MoveNext())
                {
                    tokens.Add(iter.Current);
                }

                if (tokens.Count > 0 && tokens[tokens.Count - 1].Type == CssTokenType.RoundBracketClose)
                {
                    tokens.RemoveAt(tokens.Count - 1);
                    return tokens;
                }
            }

            return null;
{'fraction_non_alphanumeric': 0.09059233449477352, 'fraction_numerical': 0.0015837820715869496, 'mean_word_length': 1.7484769364664925, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '1885931', 'n_tokens_mistral': 847, 'n_tokens_neox': 800, 'n_words': 169}