<commit_before>﻿using System.Linq;
using System.Collections.Generic;

namespace SickDev.CommandSystem {
    public class CommandExecuter {

        readonly List<CommandBase> commands;
        readonly ParsedCommand parsedCommand;
        List<CommandBase> overloads = new List<CommandBase>();
        Dictionary<CommandBase, object[]> matches = new Dictionary<CommandBase, object[]>();

        public CommandExecuter(List<CommandBase> commands, ParsedCommand parsedCommand) {
            this.commands = commands;
            this.parsedCommand = parsedCommand;
        }

        public bool IsValidCommand() {
            for (int i = 0; i < commands.Count; i++)
                if (commands[i].IsOverloadOf(parsedCommand))
                    overloads.Add(commands[i]);

            FilterMatches();
            return overloads.Count >= 1;
        }

        void FilterMatches() {
            for (int i = 0; i < overloads.Count; i++) { 
                try {
                    if (overloads[i].signature.Matches(parsedCommand.args)) {
                        object[] arguments = overloads[i].signature.Convert(parsedCommand.args);
                        matches.Add(overloads[i], arguments);
                    }
                }
                catch (CommandSystemException exception) {
                    CommandsManager.SendException(exception);
                }
            }
        }

        public bool HasReturnType() {
            return matches.Keys.ToArray()[0].isFunc;
        }<commit_msg>encapsulated<commit_after>﻿using System.Linq;
using System.Collections.Generic;

namespace SickDev.CommandSystem {
    public class CommandExecuter {

        readonly List<CommandBase> commands;
        readonly ParsedCommand parsedCommand;
        List<CommandBase> overloads = new List<CommandBase>();
        Dictionary<CommandBase, object[]> matches = new Dictionary<CommandBase, object[]>();

        internal CommandExecuter(List<CommandBase> commands, ParsedCommand parsedCommand) {
            this.commands = commands;
            this.parsedCommand = parsedCommand;
        }

        public bool IsValidCommand() {
            for (int i = 0; i < commands.Count; i++)
                if (commands[i].IsOverloadOf(parsedCommand))
                    overloads.Add(commands[i]);

            FilterMatches();
            return overloads.Count >= 1;
        }

        void FilterMatches() {
            for (int i = 0; i < overloads.Count; i++) { 
                try {
                    if (overloads[i].signature.Matches(parsedCommand.args)) {
                        object[] arguments = overloads[i].signature.Convert(parsedCommand.args);
                        matches.Add(overloads[i], arguments);
                    }
                }
                catch (CommandSystemException exception) {
                    CommandsManager.SendException(exception);
                }
            }
        }

        public bool HasReturnType() {
            return matches.Keys.ToArray()[0].isFunc;
        }
{'fraction_non_alphanumeric': 0.09858692080184028, 'fraction_numerical': 0.0026289845547157412, 'mean_word_length': 1.8263695450324977, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, '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': '3187129', 'n_tokens_mistral': 759, 'n_tokens_neox': 731, 'n_words': 154}