File: ExternalAccess\VSTypeScript\VSTypeScriptEditorInlineRenameService.cs
Web Access
Project: ..\..\..\src\EditorFeatures\Core\Microsoft.CodeAnalysis.EditorFeatures.csproj (Microsoft.CodeAnalysis.EditorFeatures)
// 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.
 
using System;
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.Implementation.InlineRename;
using Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api;
using Microsoft.CodeAnalysis.Host.Mef;
 
namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript
{
    [Shared]
    [ExportLanguageService(typeof(IEditorInlineRenameService), InternalLanguageNames.TypeScript)]
    internal sealed class VSTypeScriptEditorInlineRenameService : IEditorInlineRenameService
    {
        private readonly Lazy<VSTypeScriptEditorInlineRenameServiceImplementation>? _service;
 
        [ImportingConstructor]
        [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
        public VSTypeScriptEditorInlineRenameService(
            [Import(AllowDefault = true)] Lazy<VSTypeScriptEditorInlineRenameServiceImplementation>? service)
        {
            _service = service;
        }
 
        public async Task<IInlineRenameInfo> GetRenameInfoAsync(Document document, int position, CancellationToken cancellationToken)
        {
            if (_service != null)
            {
                return await _service.Value.GetRenameInfoAsync(document, position, cancellationToken).ConfigureAwait(false);
            }
 
            return AbstractEditorInlineRenameService.DefaultFailureInfo;
        }
    }
}