Moved RazorTextBufferProvider from Mef to ILanguageService
This commit is contained in:
parent
fb68a31ad5
commit
6b8223b544
|
|
@ -13,19 +13,6 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
||||||
[ExportLanguageServiceFactory(typeof(RazorCodeDocumentProvider), RazorLanguage.Name)]
|
[ExportLanguageServiceFactory(typeof(RazorCodeDocumentProvider), RazorLanguage.Name)]
|
||||||
internal class DefaultCodeDocumentProviderFactory : ILanguageServiceFactory
|
internal class DefaultCodeDocumentProviderFactory : ILanguageServiceFactory
|
||||||
{
|
{
|
||||||
private readonly RazorTextBufferProvider _textBufferProvider;
|
|
||||||
|
|
||||||
[ImportingConstructor]
|
|
||||||
public DefaultCodeDocumentProviderFactory(RazorTextBufferProvider bufferProvider)
|
|
||||||
{
|
|
||||||
if (bufferProvider == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(bufferProvider));
|
|
||||||
}
|
|
||||||
|
|
||||||
_textBufferProvider = bufferProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ILanguageService CreateLanguageService(HostLanguageServices languageServices)
|
public ILanguageService CreateLanguageService(HostLanguageServices languageServices)
|
||||||
{
|
{
|
||||||
if (languageServices == null)
|
if (languageServices == null)
|
||||||
|
|
@ -33,9 +20,10 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
||||||
throw new ArgumentNullException(nameof(languageServices));
|
throw new ArgumentNullException(nameof(languageServices));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var textBufferProvider = languageServices.GetRequiredService<RazorTextBufferProvider>();
|
||||||
var textBufferCodeDocumentProvider = languageServices.GetRequiredService<TextBufferCodeDocumentProvider>();
|
var textBufferCodeDocumentProvider = languageServices.GetRequiredService<TextBufferCodeDocumentProvider>();
|
||||||
|
|
||||||
return new DefaultCodeDocumentProvider(_textBufferProvider, textBufferCodeDocumentProvider);
|
return new DefaultCodeDocumentProvider(textBufferProvider, textBufferCodeDocumentProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.Composition;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.Text;
|
using Microsoft.CodeAnalysis.Text;
|
||||||
|
|
@ -11,13 +10,10 @@ using Microsoft.VisualStudio.Text.Projection;
|
||||||
|
|
||||||
namespace Microsoft.VisualStudio.Editor.Razor
|
namespace Microsoft.VisualStudio.Editor.Razor
|
||||||
{
|
{
|
||||||
[System.Composition.Shared]
|
|
||||||
[Export(typeof(RazorTextBufferProvider))]
|
|
||||||
internal class DefaultTextBufferProvider : RazorTextBufferProvider
|
internal class DefaultTextBufferProvider : RazorTextBufferProvider
|
||||||
{
|
{
|
||||||
private readonly IBufferGraphFactoryService _bufferGraphService;
|
private readonly IBufferGraphFactoryService _bufferGraphService;
|
||||||
|
|
||||||
[ImportingConstructor]
|
|
||||||
public DefaultTextBufferProvider(IBufferGraphFactoryService bufferGraphService)
|
public DefaultTextBufferProvider(IBufferGraphFactoryService bufferGraphService)
|
||||||
{
|
{
|
||||||
if (bufferGraphService == null)
|
if (bufferGraphService == null)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Composition;
|
||||||
|
using Microsoft.CodeAnalysis.Host;
|
||||||
|
using Microsoft.CodeAnalysis.Host.Mef;
|
||||||
|
using Microsoft.CodeAnalysis.Razor;
|
||||||
|
using Microsoft.VisualStudio.Text.Projection;
|
||||||
|
|
||||||
|
namespace Microsoft.VisualStudio.Editor.Razor
|
||||||
|
{
|
||||||
|
[Shared]
|
||||||
|
[ExportLanguageServiceFactory(typeof(RazorTextBufferProvider), RazorLanguage.Name)]
|
||||||
|
internal class DefaultTextBufferProviderFactory : ILanguageServiceFactory
|
||||||
|
{
|
||||||
|
private readonly IBufferGraphFactoryService _bufferGraphService;
|
||||||
|
|
||||||
|
[ImportingConstructor]
|
||||||
|
public DefaultTextBufferProviderFactory(IBufferGraphFactoryService bufferGraphService)
|
||||||
|
{
|
||||||
|
if (bufferGraphService == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(bufferGraphService));
|
||||||
|
}
|
||||||
|
|
||||||
|
_bufferGraphService = bufferGraphService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ILanguageService CreateLanguageService(HostLanguageServices languageServices)
|
||||||
|
{
|
||||||
|
if (languageServices == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(languageServices));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DefaultTextBufferProvider(_bufferGraphService);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,11 +2,12 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
|
using Microsoft.CodeAnalysis.Host;
|
||||||
using Microsoft.VisualStudio.Text;
|
using Microsoft.VisualStudio.Text;
|
||||||
|
|
||||||
namespace Microsoft.VisualStudio.Editor.Razor
|
namespace Microsoft.VisualStudio.Editor.Razor
|
||||||
{
|
{
|
||||||
internal abstract class RazorTextBufferProvider
|
internal abstract class RazorTextBufferProvider : ILanguageService
|
||||||
{
|
{
|
||||||
public abstract bool TryGetFromDocument(TextDocument document, out ITextBuffer textBuffer);
|
public abstract bool TryGetFromDocument(TextDocument document, out ITextBuffer textBuffer);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue