提交 db9b0906 编写于 作者: C CyrusNajmabadi

Introduce abstraction layer to allow VS15 to create new types of NavigateTo item displays.

上级 4751badc
......@@ -273,7 +273,8 @@
<Compile Include="Implementation\Intellisense\Completion\Presentation\VisualStudio14CompletionSetFactory.cs" />
<Compile Include="Implementation\Interactive\IAbstractResetInteractiveCommand.cs" />
<Compile Include="Implementation\LineSeparators\LineSeparatorAdornmentManagerProvider.cs" />
<Compile Include="Implementation\NavigateTo\INavigateToOptionsService.cs" />
<Compile Include="Implementation\NavigateTo\Dev14NavigateToHostVersionService.cs" />
<Compile Include="Implementation\NavigateTo\INavigateToHostVersionService.cs" />
<Compile Include="Implementation\Structure\InvalidOutliningRegionException.cs" />
<Compile Include="Implementation\Structure\AbstractStructureTaggerProvider.cs" />
<Compile Include="Implementation\Preview\DifferenceViewerPreview.cs" />
......@@ -540,8 +541,8 @@
<Compile Include="Implementation\NavigateTo\INavigateToPreviewService.cs" />
<Compile Include="Implementation\NavigateTo\NavigateToIconFactory.cs" />
<Compile Include="Implementation\NavigateTo\NavigateToItemProvider.cs" />
<Compile Include="Implementation\NavigateTo\NavigateToItemProvider.ItemDisplayFactory.cs" />
<Compile Include="Implementation\NavigateTo\NavigateToItemProvider.NavigateToItemDisplay.cs" />
<Compile Include="Implementation\NavigateTo\Dev14NavigateToHostVersionService.ItemDisplayFactory.cs" />
<Compile Include="Implementation\NavigateTo\Dev14NavigateToHostVersionService.NavigateToItemDisplay.cs" />
<Compile Include="Implementation\NavigateTo\NavigateToItemProvider.Searcher.cs" />
<Compile Include="Implementation\NavigateTo\NavigateToItemProviderFactory.cs" />
<Compile Include="Implementation\NavigationBar\NavigationBarController.cs" />
......
......@@ -7,13 +7,13 @@
namespace Microsoft.CodeAnalysis.Editor.Implementation.NavigateTo
{
internal partial class NavigateToItemProvider
internal partial class Dev14NavigateToHostVersionService
{
private class ItemDisplayFactory : INavigateToItemDisplayFactory, IDisposable
protected class Dev14ItemDisplayFactory : INavigateToItemDisplayFactory, IDisposable
{
private readonly NavigateToIconFactory _iconFactory;
public ItemDisplayFactory(NavigateToIconFactory iconFactory)
public Dev14ItemDisplayFactory(NavigateToIconFactory iconFactory)
{
Contract.ThrowIfNull(iconFactory);
......@@ -23,7 +23,7 @@ public ItemDisplayFactory(NavigateToIconFactory iconFactory)
public INavigateToItemDisplay CreateItemDisplay(NavigateToItem item)
{
var searchResult = (INavigateToSearchResult)item.Tag;
return new NavigateToItemDisplay(searchResult, _iconFactory);
return new Dev14NavigateToItemDisplay(searchResult, _iconFactory);
}
public void Dispose()
......
......@@ -11,9 +11,9 @@
namespace Microsoft.CodeAnalysis.Editor.Implementation.NavigateTo
{
internal partial class NavigateToItemProvider
internal partial class Dev14NavigateToHostVersionService
{
private class NavigateToItemDisplay : INavigateToItemDisplay2
private class Dev14NavigateToItemDisplay : INavigateToItemDisplay2
{
private readonly INavigateToSearchResult _searchResult;
private readonly NavigateToIconFactory _iconFactory;
......@@ -21,27 +21,15 @@ private class NavigateToItemDisplay : INavigateToItemDisplay2
private Icon _glyph;
private ReadOnlyCollection<DescriptionItem> _descriptionItems;
public NavigateToItemDisplay(INavigateToSearchResult searchResult, NavigateToIconFactory iconFactory)
public Dev14NavigateToItemDisplay(INavigateToSearchResult searchResult, NavigateToIconFactory iconFactory)
{
_searchResult = searchResult;
_iconFactory = iconFactory;
}
public string AdditionalInformation
{
get
{
return _searchResult.AdditionalInformation;
}
}
public string AdditionalInformation => _searchResult.AdditionalInformation;
public string Description
{
get
{
return null;
}
}
public string Description => null;
public ReadOnlyCollection<DescriptionItem> DescriptionItems
{
......@@ -160,4 +148,4 @@ public void PreviewItem()
}
}
}
}
}
\ No newline at end of file
// 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;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Language.NavigateTo.Interfaces;
namespace Microsoft.CodeAnalysis.Editor.Implementation.NavigateTo
{
[ExportVersionSpecific(typeof(INavigateToHostVersionService), VisualStudioVersion.Dev14)]
internal partial class Dev14NavigateToHostVersionService : INavigateToHostVersionService
{
private readonly IGlyphService _glyphService;
[ImportingConstructor]
public Dev14NavigateToHostVersionService(
IGlyphService glyphService)
{
_glyphService = glyphService;
}
public virtual bool GetSearchCurrentDocument(INavigateToOptions options)
{
return false;
}
public virtual INavigateToItemDisplayFactory CreateDisplayFactory()
{
return new Dev14ItemDisplayFactory(new NavigateToIconFactory(_glyphService));
}
}
}
\ No newline at end of file
......@@ -4,17 +4,13 @@
namespace Microsoft.CodeAnalysis.Editor.Implementation.NavigateTo
{
internal interface INavigateToOptionsService
/// <summary>
/// Contains navigate-to specific operations that depend on the version of the
/// host they're running under.
/// </summary>
internal interface INavigateToHostVersionService
{
bool GetSearchCurrentDocument(INavigateToOptions options);
}
[ExportVersionSpecific(typeof(INavigateToOptionsService), VisualStudioVersion.Dev14)]
internal class Dev14NavigateToOptionsService : INavigateToOptionsService
{
public bool GetSearchCurrentDocument(INavigateToOptions options)
{
return false;
}
INavigateToItemDisplayFactory CreateDisplayFactory();
}
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ internal partial class NavigateToItemProvider
private class Searcher
{
private readonly Solution _solution;
private readonly ItemDisplayFactory _displayFactory;
private readonly INavigateToItemDisplayFactory _displayFactory;
private readonly INavigateToCallback _callback;
private readonly string _searchPattern;
private readonly bool _searchCurrentDocument;
......@@ -29,7 +29,7 @@ private class Searcher
public Searcher(
Solution solution,
IAsynchronousOperationListener asyncListener,
ItemDisplayFactory displayFactory,
INavigateToItemDisplayFactory displayFactory,
INavigateToCallback callback,
string searchPattern,
bool searchCurrentDocument,
......
......@@ -16,8 +16,8 @@ internal partial class NavigateToItemProvider : INavigateToItemProvider
{
private readonly Workspace _workspace;
private readonly IAsynchronousOperationListener _asyncListener;
private readonly ImmutableArray<Lazy<INavigateToOptionsService, VisualStudioVersionMetadata>> _optionsServices;
private readonly ItemDisplayFactory _displayFactory;
private readonly INavigateToItemDisplayFactory _displayFactory;
private readonly ImmutableArray<Lazy<INavigateToHostVersionService, VisualStudioVersionMetadata>> _hostServices;
private CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
......@@ -25,7 +25,7 @@ internal partial class NavigateToItemProvider : INavigateToItemProvider
Workspace workspace,
IGlyphService glyphService,
IAsynchronousOperationListener asyncListener,
IEnumerable<Lazy<INavigateToOptionsService, VisualStudioVersionMetadata>> optionsServices)
IEnumerable<Lazy<INavigateToHostVersionService, VisualStudioVersionMetadata>> hostServices)
{
Contract.ThrowIfNull(workspace);
Contract.ThrowIfNull(glyphService);
......@@ -33,8 +33,8 @@ internal partial class NavigateToItemProvider : INavigateToItemProvider
_workspace = workspace;
_asyncListener = asyncListener;
_optionsServices = optionsServices.ToImmutableArray();
_displayFactory = new ItemDisplayFactory(new NavigateToIconFactory(glyphService));
_hostServices = hostServices.ToImmutableArray();
_displayFactory = VersionSelector.SelectHighest(hostServices).CreateDisplayFactory();
}
public void StopSearch()
......@@ -46,7 +46,7 @@ public void StopSearch()
public void Dispose()
{
this.StopSearch();
_displayFactory.Dispose();
(_displayFactory as IDisposable)?.Dispose();
}
public void StartSearch(INavigateToCallback callback, string searchValue)
......@@ -90,11 +90,11 @@ private bool GetSearchCurrentDocumentOption(INavigateToCallback callback)
private bool GetSearchCurrentDocumentOptionWorker(INavigateToCallback callback)
{
var optionsService = _optionsServices.Length > 0
? VersionSelector.SelectHighest(_optionsServices)
var hostService = _hostServices.Length > 0
? VersionSelector.SelectHighest(_hostServices)
: null;
var searchCurrentDocument = optionsService?.GetSearchCurrentDocument(callback.Options) ?? false;
var searchCurrentDocument = hostService?.GetSearchCurrentDocument(callback.Options) ?? false;
return searchCurrentDocument;
}
}
}
}
\ No newline at end of file
......@@ -15,12 +15,12 @@ internal class NavigateToItemProviderFactory : INavigateToItemProviderFactory
{
private readonly IGlyphService _glyphService;
private readonly IAsynchronousOperationListener _asyncListener;
private readonly IEnumerable<Lazy<INavigateToOptionsService, VisualStudioVersionMetadata>> _optionsServices;
private readonly IEnumerable<Lazy<INavigateToHostVersionService, VisualStudioVersionMetadata>> _hostServices;
[ImportingConstructor]
public NavigateToItemProviderFactory(
IGlyphService glyphService,
[ImportMany] IEnumerable<Lazy<INavigateToOptionsService, VisualStudioVersionMetadata>> optionsServices,
[ImportMany] IEnumerable<Lazy<INavigateToHostVersionService, VisualStudioVersionMetadata>> hostServices,
[ImportMany] IEnumerable<Lazy<IAsynchronousOperationListener, FeatureMetadata>> asyncListeners)
{
if (glyphService == null)
......@@ -34,7 +34,7 @@ internal class NavigateToItemProviderFactory : INavigateToItemProviderFactory
}
_glyphService = glyphService;
_optionsServices = optionsServices;
_hostServices = hostServices;
_asyncListener = new AggregateAsynchronousOperationListener(asyncListeners, FeatureAttribute.NavigateTo);
}
......@@ -49,7 +49,7 @@ public bool TryCreateNavigateToItemProvider(IServiceProvider serviceProvider, ou
return false;
}
provider = new NavigateToItemProvider(workspace, _glyphService, _asyncListener, _optionsServices);
provider = new NavigateToItemProvider(workspace, _glyphService, _asyncListener, _hostServices);
return true;
}
}
......
// 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.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Editor.Implementation.NavigateTo;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Language.NavigateTo.Interfaces;
namespace Microsoft.CodeAnalysis.Editor.NavigateTo
{
[ExportVersionSpecific(typeof(INavigateToOptionsService), VisualStudioVersion.Dev15)]
internal class Dev15NavigateToOptionsService : INavigateToOptionsService
[ExportVersionSpecific(typeof(INavigateToHostVersionService), VisualStudioVersion.Dev15)]
internal class Dev15NavigateToHostVersionService : Dev14NavigateToHostVersionService, INavigateToHostVersionService
{
public bool GetSearchCurrentDocument(INavigateToOptions options)
[ImportingConstructor]
public Dev15NavigateToHostVersionService(IGlyphService glyphService)
: base(glyphService)
{
}
public override bool GetSearchCurrentDocument(INavigateToOptions options)
{
var options2 = options as INavigateToOptions2;
return options2?.SearchCurrentDocument ?? false;
......
{
"dependencies": {
"Dev15BinariesForRoslyn": "4.0.0.0",
"Dev15BinariesForRoslyn": "5.0.0.0",
"System.Collections.Immutable": "1.2.0",
"Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime": {
"version": "14.3.25407",
......
{
"dependencies": {
"Dev15BinariesForRoslyn": "4.0.0.0",
"Dev15BinariesForRoslyn": "5.0.0.0",
"Microsoft.VisualStudio.ImageCatalog": "15.0.25604-Preview4",
"NuGet.VisualStudio": {
"version": "3.3.0",
......
......@@ -3,7 +3,7 @@
"Newtonsoft.Json": "8.0.3",
"Moq": "4.2.1402.2112",
"Microsoft.VisualStudio.Composition": "14.2.19-pre",
"Dev15BinariesForRoslyn": "4.0.0.0",
"Dev15BinariesForRoslyn": "5.0.0.0",
"Microsoft.VisualStudio.Imaging": "15.0.25604-Preview4",
"Microsoft.VisualStudio.Utilities": "15.0.25604-Preview4",
"Microsoft.VisualStudio.ImageCatalog": "15.0.25604-Preview4",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册