提交 67ce37ff 编写于 作者: H HeeJae Chang

updated following feedbacks

上级 35973ef0
......@@ -16,6 +16,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.LanguageClient
// currently, platform doesn't allow multiple content types
// to be associated with 1 ILanguageClient forcing us to
// create multiple ILanguageClients for each content type
// https://devdiv.visualstudio.com/DevDiv/_workitems/edit/952373
[ContentType(ContentTypeNames.CSharpContentType)]
[Export(typeof(ILanguageClient))]
[ExportMetadata("Capabilities", "WorkspaceStreamingSymbolProvider")]
......@@ -30,8 +31,8 @@ internal class CSharpLanguageServerClient : AbstractLanguageServerClient
: base(workspace,
eventListener,
listenerProvider,
WellKnownServiceHubServices.CSharpLanguageServer,
"ManagedLanguage.IDE.CSharpLanguageServer")
languageServerName: WellKnownServiceHubServices.CSharpLanguageServer,
serviceHubClientName: "ManagedLanguage.IDE.CSharpLanguageServer")
{
}
......
......@@ -12,7 +12,6 @@
using Microsoft.VisualStudio.LanguageServices.Remote;
using Microsoft.CodeAnalysis.Host;
using System.Composition;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Shared.TestHooks;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService
......@@ -23,7 +22,7 @@ internal abstract class AbstractLanguageServerClient : ILanguageClient
private readonly LanguageServerClientEventListener _eventListener;
private readonly IAsynchronousOperationListener _asyncListener;
private readonly string _clientName;
private readonly string _serviceHubClientName;
private readonly string _languageServerName;
/// <summary>
......@@ -60,13 +59,13 @@ internal abstract class AbstractLanguageServerClient : ILanguageClient
LanguageServerClientEventListener eventListener,
IAsynchronousOperationListenerProvider listenerProvider,
string languageServerName,
string clientName)
string serviceHubClientName)
{
_workspace = workspace;
_eventListener = eventListener;
_asyncListener = listenerProvider.GetListener(FeatureAttribute.FindReferences);
_clientName = clientName;
_serviceHubClientName = serviceHubClientName;
_languageServerName = languageServerName;
}
......@@ -80,7 +79,7 @@ public async Task<Connection> ActivateAsync(CancellationToken cancellationToken)
}
var hostGroup = new HostGroup(client.ClientId);
var hubClient = new HubClient(_clientName);
var hubClient = new HubClient(_serviceHubClientName);
var stream = await ServiceHubRemoteHostClient.Connections.RequestServiceAsync(
_workspace,
......@@ -104,7 +103,10 @@ public Task OnLoadedAsync()
// set up event stream so that we start LSP server once Roslyn is loaded
_eventListener.WorkspaceStarted.ContinueWith(async _ =>
{
EnsureRemoteHost();
// this might get called before solution is fully loaded and before file is opened.
// we delay our OOP start until then, but user might do vsstart before that. so we make sure we start OOP if
// it is not running yet. multiple start is no-op
((RemoteHostClientServiceFactory.RemoteHostClientService)_workspace.Services.GetService<IRemoteHostClientService>()).Enable();
// wait until remote host is available before let platform know that they can activate our LSP
var client = await _workspace.TryGetRemoteHostClientAsync(CancellationToken.None).ConfigureAwait(false);
......@@ -120,14 +122,6 @@ public Task OnLoadedAsync()
}, TaskScheduler.Default).CompletesAsyncOperation(token);
return Task.CompletedTask;
void EnsureRemoteHost()
{
// this might get called before solution is fully loaded and before file is opened.
// we delay our OOP start until then, but user might do vsstart before that. so we make sure we start OOP if
// it is not running yet. multiple start is no-op
((RemoteHostClientServiceFactory.RemoteHostClientService)_workspace.Services.GetService<IRemoteHostClientService>()).Enable();
}
}
/// <summary>
......
......@@ -14,6 +14,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.LanguageClient
' currently, platform doesn't allow multiple content types
' to be associated with 1 ILanguageClient forcing us to
' create multiple ILanguageClients for each content type
' https://devdiv.visualstudio.com/DevDiv/_workitems/edit/952373
<ContentType(ContentTypeNames.VisualBasicContentType)>
<Export(GetType(ILanguageClient))>
<ExportMetadata("Capabilities", "WorkspaceStreamingSymbolProvider")>
......@@ -28,8 +29,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.LanguageClient
MyBase.New(workspace,
eventListener,
listenerProvider,
WellKnownServiceHubServices.VisualBasicLanguageServer,
"ManagedLanguage.IDE.VisualBasicLanguageServer")
languageServerName:=WellKnownServiceHubServices.VisualBasicLanguageServer,
serviceHubClientName:="ManagedLanguage.IDE.VisualBasicLanguageServer")
End Sub
Public Overrides ReadOnly Property Name As String
......
......@@ -38,7 +38,7 @@ internal partial class FeatureAttribute
public const string Snippets = nameof(Snippets);
public const string SolutionCrawler = nameof(SolutionCrawler);
public const string TodoCommentList = nameof(TodoCommentList);
public const string VsSearch = nameof(VsSearch);
public const string LanguageServerWorkspaceSymbolSearch = nameof(LanguageServerWorkspaceSymbolSearch);
public const string Workspace = nameof(Workspace);
}
}
......@@ -98,7 +98,7 @@ public void Exit()
}
[JsonRpcMethod(VSSymbolMethods.WorkspaceBeginSymbolName)]
public Task<VSBeginSymbolParams> WorkspaceBeginSymbolAsync(string query, int searchId, CancellationToken cancellationToken)
public Task<VSBeginSymbolParams> BeginWorkspaceSymbolAsync(string query, int searchId, CancellationToken cancellationToken)
{
return RunServiceAsync(async () =>
{
......@@ -130,7 +130,7 @@ async Task SearchProjectAsync(Project project, CancellationToken cancellationTok
s_supportedKinds,
cancellationToken).ConfigureAwait(false);
var convertedResults = await Convert(results, cancellationToken).ConfigureAwait(false);
var convertedResults = await ConvertAsync(results, cancellationToken).ConfigureAwait(false);
await InvokeAsync(
VSSymbolMethods.WorkspacePublishSymbolName,
......@@ -139,7 +139,7 @@ async Task SearchProjectAsync(Project project, CancellationToken cancellationTok
}
}
private static async Task<VSSymbolInformation[]> Convert(
private static async Task<VSSymbolInformation[]> ConvertAsync(
ImmutableArray<INavigateToSearchResult> results, CancellationToken cancellationToken)
{
var symbols = new VSSymbolInformation[results.Length];
......
......@@ -84,7 +84,15 @@ private static Task<Solution> GetSolutionAsync(RoslynServices roslynService, Pin
}
/// <summary>
/// Base type with helper methods. this is not tied to how Roslyn OOP works. just servicehub helpers.
/// Base type with servicehub helper methods. this is not tied to how Roslyn OOP works.
///
/// any type that derived from this type is supposed to be an entry point for servicehub services.
/// name of the type should match one appears in GenerateServiceHubConfigurationFiles.targets
/// and signature of either its constructor or static CreateAsync must follow the convension
/// ctor(Stream stream, IServiceProvider serviceProvider).
///
/// see servicehub detail from here
/// https://microsoft.sharepoint.com/teams/DD_VSIDE/_layouts/15/WopiFrame.aspx?sourcedoc={bd8fab44-c988-4f11-9866-bb12f906bb53}&action=edit&wd=target%28Extensibility%2FFrom%20ConEx%2FServiceHub.one%7Cbafb6e9b-5988-4995-8135-f152abd28a0d%2FOnboarding%20%28for%20partners%5C%29%7Ccc54c21c-2894-4f05-8ce4-9530bacdb9c8%2F%29&wdorigin=703
/// </summary>
internal abstract class ServiceBase : IDisposable
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册