<commit_before>// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;

namespace Microsoft.CodeAnalysis.CodeRefactorings.MoveType
{
    internal abstract partial class AbstractMoveTypeService<TService, TTypeDeclarationSyntax, TNamespaceDeclarationSyntax, TMemberDeclarationSyntax, TCompilationUnitSyntax>
    {
        private class RenameFileEditor : Editor
        {
            public RenameFileEditor(TService service, State state, string fileName, CancellationToken cancellationToken)
                : base(service, state, fileName, cancellationToken)
            {
            }

            internal override Task<IEnumerable<CodeActionOperation>> GetOperationsAsync()
            {
                return Task.FromResult(RenameFileToMatchTypeName());
            }

            /// <summary>
            /// Renames the file to match the type contained in it.
            /// </summary>
            private IEnumerable<CodeActionOperation> RenameFileToMatchTypeName()
            {
                var solution = SemanticDocument.Document.Project.Solution;
                var text = SemanticDocument.Text;
                var oldDocumentId = SemanticDocument.Document.Id;
                var newDocumentId = DocumentId.CreateNewId(SemanticDocument.Document.Project.Id, FileName);

                // currently, document rename is accomplished by a remove followed by an add.
                // the workspace takes care of resolving conflicts if the document name is not unique in the project
                // by adding numeric suffixes to the new document being added.
                var newSolution = solution.RemoveDocument(oldDocumentId);
                newSolution = newSolution.AddDocument(newDocumentId, FileName, text);

                return new CodeActionOperation[]
                {
                    new ApplyChangesOperation(newSolution),
                    new OpenDocumentOperation(newDocumentId)
                };
            }
        }
    }
}
<commit_msg>Activate the file in RenameFile scenario.<commit_after>// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;

namespace Microsoft.CodeAnalysis.CodeRefactorings.MoveType
{
    internal abstract partial class AbstractMoveTypeService<TService, TTypeDeclarationSyntax, TNamespaceDeclarationSyntax, TMemberDeclarationSyntax, TCompilationUnitSyntax>
    {
        private class RenameFileEditor : Editor
        {
            public RenameFileEditor(TService service, State state, string fileName, CancellationToken cancellationToken)
                : base(service, state, fileName, cancellationToken)
            {
            }

            internal override Task<IEnumerable<CodeActionOperation>> GetOperationsAsync()
            {
                return Task.FromResult(RenameFileToMatchTypeName());
            }

            /// <summary>
            /// Renames the file to match the type contained in it.
            /// </summary>
            private IEnumerable<CodeActionOperation> RenameFileToMatchTypeName()
            {
                var solution = SemanticDocument.Document.Project.Solution;
                var text = SemanticDocument.Text;
                var oldDocumentId = SemanticDocument.Document.Id;
                var newDocumentId = DocumentId.CreateNewId(SemanticDocument.Document.Project.Id, FileName);

                // currently, document rename is accomplished by a remove followed by an add.
                // the workspace takes care of resolving conflicts if the document name is not unique in the project
                // by adding numeric suffixes to the new document being added.
                var newSolution = solution.RemoveDocument(oldDocumentId);
                newSolution = newSolution.AddDocument(newDocumentId, FileName, text);

                return new CodeActionOperation[]
                {
                    new ApplyChangesOperation(newSolution),
                    new OpenDocumentOperation(newDocumentId, activateIfAlreadyOpen: true)
                };
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.06309497454062431, 'fraction_numerical': 0.0008855435023245517, 'mean_word_length': 2.31474688187821, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '7255047', 'n_tokens_mistral': 1031, 'n_tokens_neox': 987, 'n_words': 299}