<commit_before>﻿using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Simplification;
using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.PopulateSwitch
{
    internal abstract class AbstractPopulateSwitchCodeFixProvider<TSwitchBlockSyntax, TExpressionSyntax, TSwitchSectionSyntax> : CodeFixProvider 
            where TSwitchBlockSyntax : SyntaxNode
            where TSwitchSectionSyntax : SyntaxNode
            where TExpressionSyntax : SyntaxNode
    {
        public override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(IDEDiagnosticIds.PopulateSwitchDiagnosticId);

        public override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer;

        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            context.RegisterCodeFix(
                new MyCodeAction(
                    FeaturesResources.AddMissingSwitchCases,
                    c => AddMissingSwitchLabelsAsync(context)),
                context.Diagnostics);
        }

        protected abstract TExpressionSyntax GetSwitchExpression(TSwitchBlockSyntax switchBlock);

        protected abstract int InsertPosition(List<TSwitchSectionSyntax> sections);

        protected abstract List<TSwitchSectionSyntax> GetSwitchSections(TSwitchBlockSyntax switchBlock);

        protected abstract SyntaxNode NewSwitchNode(TSwitchBlockSyntax switchBlock, List<TSwitchSectionSyntax> sections);

        protected abstract TSwitchBlockSyntax GetSwitchStatementNode(SyntaxNode root, TextSpan span);

        protected abstract List<SyntaxNode> GetCaseLabels(TSwitchBlockSyntax switchBlock, out bool containsDefaultLabel);

        private async Task<Document> AddMissingSwitchLabelsAsync(CodeFixContext context)
        {<commit_msg>Instead of having an `async` method with no `await` commands, return `Task.FromResult(true)`<commit_after>﻿using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Simplification;
using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.PopulateSwitch
{
    internal abstract class AbstractPopulateSwitchCodeFixProvider<TSwitchBlockSyntax, TExpressionSyntax, TSwitchSectionSyntax> : CodeFixProvider 
            where TSwitchBlockSyntax : SyntaxNode
            where TSwitchSectionSyntax : SyntaxNode
            where TExpressionSyntax : SyntaxNode
    {
        public override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(IDEDiagnosticIds.PopulateSwitchDiagnosticId);

        public override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer;

        public sealed override Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            context.RegisterCodeFix(
                new MyCodeAction(
                    FeaturesResources.AddMissingSwitchCases,
                    c => AddMissingSwitchLabelsAsync(context)),
                context.Diagnostics);

            return Task.FromResult(true);
        }

        protected abstract TExpressionSyntax GetSwitchExpression(TSwitchBlockSyntax switchBlock);

        protected abstract int InsertPosition(List<TSwitchSectionSyntax> sections);

        protected abstract List<TSwitchSectionSyntax> GetSwitchSections(TSwitchBlockSyntax switchBlock);

        protected abstract SyntaxNode NewSwitchNode(TSwitchBlockSyntax switchBlock, List<TSwitchSectionSyntax> sections);

        protected abstract TSwitchBlockSyntax GetSwitchStatementNode(SyntaxNode root, TextSpan span);

        protected abstract List<SyntaxNode> GetCaseLabels(TSwitchBlockSyntax switchBlock, out bool containsDefaultLabel);

        private async Task<Document> AddMissingSwitchLabelsAsync(CodeFixContext context)
        {
{'fraction_non_alphanumeric': 0.05725879170423805, 'fraction_numerical': 0.0, 'mean_word_length': 4.410975609756098, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, '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': '20857', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1034, 'n_words': 232}