<commit_before>﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Shared.Extensions;

namespace Microsoft.CodeAnalysis.CSharp.Debugging
{
    internal partial class CSharpProximityExpressionsService
    {
        internal class Worker
        {
            private readonly SyntaxTree _syntaxTree;
            private readonly int _position;

            private StatementSyntax _parentStatement;
            private SyntaxToken _token;
            private readonly List<string> _expressions = new List<string>();

            public Worker(SyntaxTree syntaxTree, int position)
            {
                _syntaxTree = syntaxTree;
                _position = position;
            }

            internal IList<string> Do(CancellationToken cancellationToken)
            {
                // First, find the containing statement.  We'll want to add the expressions in this
                // statement to the result.
                _token = _syntaxTree.GetRoot(cancellationToken).FindToken(_position);
                _parentStatement = _token.GetAncestor<StatementSyntax>();
                if (_parentStatement == null)
                {
                    return null;
                }

                AddRelevantExpressions(_parentStatement, _expressions, includeDeclarations: false);
                AddPrecedingRelevantExpressions();
                AddFollowingRelevantExpressions(cancellationToken);
                AddCurrentDeclaration();
                AddMethodParameters();
                AddIndexerParameters();
                AddCatchParameters();
                AddThisExpression();
                AddValueExpression();

                var result = _expressions.Distinct().Where(e => e.Length > 0).ToList();
                return result.Count == 0 ? null : result;
            }

            private void AddValueExpression()
            {
                // If we're in a setter/adder/remover then add "value".
                if (_parentStatement.GetAncestorOrThis<AccessorDeclarationSyntax>().Kind() is<commit_msg>Fix test<commit_after>﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Shared.Extensions;

namespace Microsoft.CodeAnalysis.CSharp.Debugging
{
    internal partial class CSharpProximityExpressionsService
    {
        internal class Worker
        {
            private readonly SyntaxTree _syntaxTree;
            private readonly int _position;

            private StatementSyntax _parentStatement;
            private SyntaxToken _token;
            private readonly List<string> _expressions = new List<string>();

            public Worker(SyntaxTree syntaxTree, int position)
            {
                _syntaxTree = syntaxTree;
                _position = position;
            }

            internal IList<string> Do(CancellationToken cancellationToken)
            {
                // First, find the containing statement.  We'll want to add the expressions in this
                // statement to the result.
                _token = _syntaxTree.GetRoot(cancellationToken).FindToken(_position);
                _parentStatement = _token.GetAncestor<StatementSyntax>();
                if (_parentStatement == null)
                {
                    return null;
                }

                AddRelevantExpressions(_parentStatement, _expressions, includeDeclarations: false);
                AddPrecedingRelevantExpressions();
                AddFollowingRelevantExpressions(cancellationToken);
                AddCurrentDeclaration();
                AddMethodParameters();
                AddIndexerParameters();
                AddCatchParameters();
                AddThisExpression();
                AddValueExpression();

                var result = _expressions.Distinct().Where(e => e.Length > 0).ToList();
                return result.Count == 0 ? null : result;
            }

            private void AddValueExpression()
            {
                // If we're in a setter/adder/remover then add "value".
                if (_parentStatement.GetAncestorOrThis<AccessorDeclarationSyntax>()?.Kind() is
{'fraction_non_alphanumeric': 0.07011447260834015, 'fraction_numerical': 0.0008176614881439084, 'mean_word_length': 2.0890151515151514, 'pattern_counts': {'":': 0, '<': 13, '<?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': '683153', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1083, 'n_words': 308}