提交 ef13cfc4 编写于 作者: D Dustin Campbell

Introduce ILibraryService language service for Class View/Object Browser

上级 0c2095a6
......@@ -81,18 +81,40 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="envdte, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="envdte80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="microsoft.msxml, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.CoreUtility, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.Editor, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="envdte, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="envdte80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="microsoft.msxml, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.CoreUtility, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Editor, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.GraphModel, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Language.Intellisense, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.Shell.14.0, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.Language.Intellisense, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.14.0, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
......@@ -102,14 +124,30 @@
<Reference Include="Microsoft.VisualStudio.Shell.Interop.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.Text.Data, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.Text.Logic, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.Text.UI, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.Text.UI.Wpf, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.TextManager.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.TextManager.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"><Private>false</Private></Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.Data, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.Logic, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.UI, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.UI.Wpf, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextManager.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextManager.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Utilities, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
......@@ -159,6 +197,8 @@
<Compile Include="Debugging\DataTipInfoGetter.cs" />
<Compile Include="Debugging\LocationInfoGetter.cs" />
<Compile Include="LanguageService\HACK_CSharpCreateServicesOnUIThread.cs" />
<Compile Include="ObjectBrowser\CSharpLibraryService.cs" />
<Compile Include="ObjectBrowser\CSharpLibraryServiceFactory.cs" />
<Compile Include="ObjectBrowser\ListItemFactory.cs" />
<Compile Include="Options\AdvancedOptionPageStrings.cs" />
<Compile Include="Options\IntelliSenseOptionPageStrings.cs" />
......@@ -284,4 +324,4 @@
<ImportGroup Label="Targets">
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</ImportGroup>
</Project>
</Project>
\ 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 Microsoft.VisualStudio.LanguageServices.Implementation.Library;
using Microsoft.VisualStudio.Shell.Interop;
namespace Microsoft.VisualStudio.LanguageServices.CSharp.ObjectBrowser
{
internal class CSharpLibraryService : AbstractLibraryService
{
public CSharpLibraryService()
: base(Guids.CSharpLibraryId, __SymbolToolLanguage.SymbolToolLanguage_CSharp)
{
}
}
}
// 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.Composition;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.VisualStudio.LanguageServices.Implementation.Library;
namespace Microsoft.VisualStudio.LanguageServices.CSharp.ObjectBrowser
{
[ExportLanguageServiceFactory(typeof(ILibraryService), LanguageNames.CSharp), Shared]
internal class CSharpLibraryServiceFactory : ILanguageServiceFactory
{
public ILanguageService CreateLanguageService(HostLanguageServices languageServices)
{
return new CSharpLibraryService();
}
}
}
// 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 Microsoft.VisualStudio.LanguageServices.Implementation.Library.VsNavInfo;
using Microsoft.VisualStudio.Shell.Interop;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.Library
{
internal abstract class AbstractLibraryService : ILibraryService
{
public Guid LibraryId { get; }
public __SymbolToolLanguage PreferredLanguage { get; }
public NavInfoFactory NavInfo { get; }
protected AbstractLibraryService(Guid libraryId, __SymbolToolLanguage preferredLanguage)
{
this.LibraryId = libraryId;
this.PreferredLanguage = preferredLanguage;
this.NavInfo = new NavInfoFactory(libraryId, preferredLanguage);
}
}
}
// 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 Microsoft.CodeAnalysis.Host;
using Microsoft.VisualStudio.LanguageServices.Implementation.Library.VsNavInfo;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.Library
{
internal interface ILibraryService : ILanguageService
{
NavInfoFactory NavInfo { get; }
}
}
......@@ -44,7 +44,7 @@ private Compilation GetCompilation()
protected void AddAssemblyLink(IAssemblySymbol assemblySymbol)
{
var name = assemblySymbol.Identity.Name;
var navInfo = _libraryManager.NavInfoFactory.CreateForAssembly(assemblySymbol);
var navInfo = _libraryManager.LibraryService.NavInfo.CreateForAssembly(assemblySymbol);
_description.AddDescriptionText3(name, VSOBDESCRIPTIONSECTION.OBDS_TYPE, navInfo);
}
......@@ -82,7 +82,7 @@ protected void AddNamespaceLink(INamespaceSymbol namespaceSymbol)
}
var text = namespaceSymbol.ToDisplayString();
var navInfo = _libraryManager.NavInfoFactory.CreateForNamespace(namespaceSymbol, _project, GetCompilation(), useExpandedHierarchy: false);
var navInfo = _libraryManager.LibraryService.NavInfo.CreateForNamespace(namespaceSymbol, _project, GetCompilation(), useExpandedHierarchy: false);
_description.AddDescriptionText3(text, VSOBDESCRIPTIONSECTION.OBDS_TYPE, navInfo);
}
......@@ -131,7 +131,7 @@ protected void AddTypeLink(ITypeSymbol typeSymbol, LinkFlags flags)
miscellaneousOptions: miscellaneousOptions);
var text = typeSymbol.ToDisplayString(typeDisplayFormat);
var navInfo = _libraryManager.NavInfoFactory.CreateForType(typeSymbol, _project, GetCompilation(), useExpandedHierarchy: false);
var navInfo = _libraryManager.LibraryService.NavInfo.CreateForType(typeSymbol, _project, GetCompilation(), useExpandedHierarchy: false);
_description.AddDescriptionText3(text, VSOBDESCRIPTIONSECTION.OBDS_TYPE, navInfo);
}
......
......@@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.LanguageServices.Implementation.Library.ObjectBrowser.Lists;
using Microsoft.VisualStudio.LanguageServices.Implementation.Library.VsNavInfo;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
......@@ -19,9 +18,8 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Library.ObjectB
{
internal abstract partial class AbstractObjectBrowserLibraryManager : AbstractLibraryManager, IDisposable
{
internal NavInfoFactory NavInfoFactory { get; }
internal readonly VisualStudioWorkspace Workspace;
internal readonly ILibraryService LibraryService;
private readonly string _languageName;
private readonly __SymbolToolLanguage _preferredLanguage;
......@@ -39,10 +37,10 @@ protected AbstractObjectBrowserLibraryManager(string languageName, Guid libraryG
{
_languageName = languageName;
_preferredLanguage = preferredLanguage;
NavInfoFactory = new NavInfoFactory(libraryGuid, preferredLanguage);
var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
this.Workspace = componentModel.GetService<VisualStudioWorkspace>();
this.LibraryService = this.Workspace.Services.GetLanguageServices(languageName).GetService<ILibraryService>();
this.Workspace.WorkspaceChanged += OnWorkspaceChanged;
}
......@@ -401,7 +399,7 @@ protected override int CreateNavInfo(SYMBOL_DESCRIPTION_NODE[] rgSymbolNodes, ui
SharedPools.Default<StringBuilder>().ClearAndFree(className);
// TODO: Make sure we pass the right value for Visual Basic.
ppNavInfo = NavInfoFactory.Create(libraryName, referenceOwnerName, namespaceName.ToString(), className.ToString(), memberName);
ppNavInfo = this.LibraryService.NavInfo.Create(libraryName, referenceOwnerName, namespaceName.ToString(), className.ToString(), memberName);
return VSConstants.S_OK;
}
......@@ -428,18 +426,18 @@ internal IVsNavInfo GetNavInfo(SymbolListItem symbolListItem, bool useExpandedHi
if (symbolListItem is MemberListItem)
{
return NavInfoFactory.CreateForMember(symbol, project, compilation, useExpandedHierarchy);
return this.LibraryService.NavInfo.CreateForMember(symbol, project, compilation, useExpandedHierarchy);
}
else if (symbolListItem is TypeListItem)
{
return NavInfoFactory.CreateForType((INamedTypeSymbol)symbol, project, compilation, useExpandedHierarchy);
return this.LibraryService.NavInfo.CreateForType((INamedTypeSymbol)symbol, project, compilation, useExpandedHierarchy);
}
else if (symbolListItem is NamespaceListItem)
{
return NavInfoFactory.CreateForNamespace((INamespaceSymbol)symbol, project, compilation, useExpandedHierarchy);
return this.LibraryService.NavInfo.CreateForNamespace((INamespaceSymbol)symbol, project, compilation, useExpandedHierarchy);
}
return NavInfoFactory.CreateForProject(project);
return this.LibraryService.NavInfo.CreateForProject(project);
}
protected override bool TryQueryStatus(Guid commandGroup, uint commandId, ref OLECMDF commandFlags)
......
......@@ -564,14 +564,14 @@ protected override IVsNavInfo GetNavInfo(uint index)
var project = this.LibraryManager.GetProject(projectListItem.ProjectId);
if (project != null)
{
return this.LibraryManager.NavInfoFactory.CreateForProject(project);
return this.LibraryManager.LibraryService.NavInfo.CreateForProject(project);
}
}
var referenceListItem = listItem as ReferenceListItem;
if (referenceListItem != null)
{
return this.LibraryManager.NavInfoFactory.CreateForReference(referenceListItem.MetadataReference);
return this.LibraryManager.LibraryService.NavInfo.CreateForReference(referenceListItem.MetadataReference);
}
var symbolListItem = listItem as SymbolListItem;
......
......@@ -44,9 +44,11 @@
<Compile Include="Implementation\AnalyzerDependency\IBindingRedirectionService.cs" />
<Compile Include="Implementation\Interop\CleanableWeakComHandleTable.cs" />
<Compile Include="Implementation\LanguageService\AbstractLanguageService`2.IVsLanguageBlock.cs" />
<Compile Include="Implementation\Library\AbstractLibraryService.cs" />
<Compile Include="Implementation\Library\FindResults\TreeItems\AbstractSourceTreeItem.cs" />
<Compile Include="Implementation\Library\FindResults\TreeItems\MetadataDefinitionTreeItem.cs" />
<Compile Include="Implementation\Library\FindResults\TreeItems\SourceDefinitionTreeItem.cs" />
<Compile Include="Implementation\Library\ILibraryService.cs" />
<Compile Include="Implementation\Library\VsNavInfo\NavInfoNodeEnum.cs" />
<Compile Include="Implementation\Library\VsNavInfo\Extensions.cs" />
<Compile Include="Implementation\Library\VsNavInfo\NavInfo.cs" />
......
......@@ -127,6 +127,8 @@
<Compile Include="ObjectBrowser\DescriptionBuilder.vb" />
<Compile Include="ObjectBrowser\ListItemFactory.vb" />
<Compile Include="ObjectBrowser\ObjectBrowserLibraryManager.vb" />
<Compile Include="ObjectBrowser\VisualBasicLibraryService.vb" />
<Compile Include="ObjectBrowser\VisualBasicLibraryServiceFactory.vb" />
<Compile Include="Options\AdvancedOptionPageStrings.vb" />
<Compile Include="Options\AutomationObject.vb" />
<Compile Include="Options\VisualBasicLanguageSettingsSerializer.vb" />
......@@ -293,4 +295,4 @@
<ImportGroup Label="Targets">
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</ImportGroup>
</Project>
</Project>
\ 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.
Imports Microsoft.VisualStudio.LanguageServices.Implementation.Library
Imports Microsoft.VisualStudio.Shell.Interop
Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ObjectBrowser
Friend Class VisualBasicLibraryService
Inherits AbstractLibraryService
Public Sub New()
MyBase.New(Guids.VisualBasicLibraryId, __SymbolToolLanguage.SymbolToolLanguage_VB)
End Sub
End Class
End Namespace
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Composition
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Host
Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.VisualStudio.LanguageServices.Implementation.Library
Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ObjectBrowser
<ExportLanguageServiceFactory(GetType(ILibraryService), LanguageNames.VisualBasic), [Shared]>
Friend Class VisualBasicLibraryServiceFactory
Implements ILanguageServiceFactory
Public Function CreateLanguageService(languageServices As HostLanguageServices) As ILanguageService Implements ILanguageServiceFactory.CreateLanguageService
Return New VisualBasicLibraryService()
End Function
End Class
End Namespace
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册