<commit_before>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Microsoft.VisualStudio.Text;

namespace VsTeXCommentsExtension.Integration
{
    internal class TextSnapshotTeXCommentBlocks
    {
        public static readonly HashSet<string> SupportedContentTypes = new HashSet<string>()
        {
            "CSharp",
            "F#", "C/C++",
            "Basic",
            "Python",
            "R",
            "Fortran",
        };

        public static readonly Dictionary<string, string> CommentPrefixPerContentType = new Dictionary<string, string>()
        {
            { "CSharp", "//" },
            { "F#", "//" },
            { "C/C++", "//" },
            { "Basic", "'" },
            { "Python", "#" },
            { "R", "#" },
            { "Fortran", "!" },
        };

        public static readonly Dictionary<string, string> TeXCommentPrefixPerContentType = new Dictionary<string, string>()
        {
            { "CSharp", "//tex:" },
            { "F#", "//tex:" },
            { "C/C++", "//tex:" },
            { "Basic", "'tex:" },
            { "Python", "#tex:" },
            { "R", "#tex:" },
            { "Fortran", "!tex:" },
        };

        public static readonly char[] WhiteSpaces = new char[] { ' ', '\t' };

        private readonly TextSnapshotValuesPerVersionCache<PooledStructEnumerable<TeXCommentBlockSpan>> blocksPerVersion;

        private readonly ObjectPool<List<TeXCommentBlockSpan>> blockListsPool = new ObjectPool<List<TeXCommentBlockSpan>>(() => new List<TeXCommentBlockSpan>());
        private readonly ObjectPool<List<SnapshotSpan>> snapshotSpansListsPool = new ObjectPool<List<SnapshotSpan>>(() => new List<SnapshotSpan>());

        public TextSnapshotTeXCommentBlocks()
        {
            blocksPerVersion = new TextSnapshotValuesPerVersionCache<PooledStructEnumerable<TeXCommentBlockSpan>>(GenerateTexCommentBlocks);

            Debug.Assert(SupportedContentTypes.All(type => CommentPrefixPerContentType.ContainsKey(type) && TeXCommentPrefixPerContentType.ContainsKey(type)));
        }

        public StructEnumerable<TeXCommentBlockSpan> GetTexCommentBlocks(ITextSnapshot snapshot) => blocksPerVersion.GetValue(snapshot);<commit_msg>d lang<commit_after>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Microsoft.VisualStudio.Text;

namespace VsTeXCommentsExtension.Integration
{
    internal class TextSnapshotTeXCommentBlocks
    {
        public static readonly HashSet<string> SupportedContentTypes = new HashSet<string>()
        {
            "CSharp",
            "F#", "C/C++",
            "Basic",
            "Python",
            "R",
            "Fortran",
            "d",
        };

        public static readonly Dictionary<string, string> CommentPrefixPerContentType = new Dictionary<string, string>()
        {
            { "CSharp", "//" },
            { "F#", "//" },
            { "C/C++", "//" },
            { "Basic", "'" },
            { "Python", "#" },
            { "R", "#" },
            { "Fortran", "!" },
            { "d", "//" },
        };

        public static readonly Dictionary<string, string> TeXCommentPrefixPerContentType = new Dictionary<string, string>()
        {
            { "CSharp", "//tex:" },
            { "F#", "//tex:" },
            { "C/C++", "//tex:" },
            { "Basic", "'tex:" },
            { "Python", "#tex:" },
            { "R", "#tex:" },
            { "Fortran", "!tex:" },
            { "d", "//tex:" },
        };

        public static readonly char[] WhiteSpaces = new char[] { ' ', '\t' };

        private readonly TextSnapshotValuesPerVersionCache<PooledStructEnumerable<TeXCommentBlockSpan>> blocksPerVersion;

        private readonly ObjectPool<List<TeXCommentBlockSpan>> blockListsPool = new ObjectPool<List<TeXCommentBlockSpan>>(() => new List<TeXCommentBlockSpan>());
        private readonly ObjectPool<List<SnapshotSpan>> snapshotSpansListsPool = new ObjectPool<List<SnapshotSpan>>(() => new List<SnapshotSpan>());

        public TextSnapshotTeXCommentBlocks()
        {
            blocksPerVersion = new TextSnapshotValuesPerVersionCache<PooledStructEnumerable<TeXCommentBlockSpan>>(GenerateTexCommentBlocks);

            Debug.Assert(SupportedContentTypes.All(type => CommentPrefixPerContentType.ContainsKey(type) && TeXCommentPrefixPerContentType.ContainsKey(type)));
        }

        public StructEnumerable<TeXCommentBlockSpan> GetTexCommentBlocks(ITextSnapshot snapshot) => blocksPerVersion.GetValue(snapshot);
{'fraction_non_alphanumeric': 0.14553376906318083, 'fraction_numerical': 0.0, 'mean_word_length': 2.5895230648944487, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 53, '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': '4153907', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1197, 'n_words': 222}