-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-IDEConcept-Continuous ImprovementLSPissues related to the roslyn language server protocol implementationissues related to the roslyn language server protocol implementation
Description
Currently, it is not easy to share types that must be instantiated per server between different IRequestHandler objects from the same server. This is a useful thing to do to share things like caches between completion and completion resolve requests for the same server (but should not be accessible outside of it). Or access information about the current LSP solution via the LSPWorkspaceManager (without passing them along in the request context).
Desired characteristics
- Allow services to be simply exported (similar to MEF) and import their non-shared dependencies (e.g. import the shared diagnostics service).
- Language server services should be newly instantiated each time a new LSP server is created and disposed of when they shutdown.
- Services should be part of the request context so handlers can easily access the services.
- Language server services can import other language server services and share the same instance for them in the same server.
Example
Exporting an LSP server service
interface ILspService
{
}
// We should have a single instance of this type per language server.
// All handlers for the same server should get the same instance of this.
[ExportLspService]
public class CompletionCacheService : ILspService
{
CacheList(CompletionList list)....
TryGetCachedList(TextDocumentIdentifier textDoc)...
}
public class CompletionHandler : IRequestHandler<...>
{
async Task<CompletionList> HandleAsync(RequestContext context, ...)
{
var completionList = await CalculateListAsync(...);
context.GetRequiredService<CompletionCacheService>().CacheList(completionList);
...
}
}
public class CompletionResolveHandler : IRequestHandler<...>
{
async Task<CompletionItem> HandleAsync(RequestContext context, ...)
{
// Should retrieve the list that was cached in the completion handler for the same server, but not
// a list cached by a different server
var cachedList = context.GetRequiredService<CompletionCacheService>().TryGetCachedList(textDoc);
...
}
}
Notes
- this might be possible via non-shared mef exports - during creation of the server we explicitly request the services once and store them.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-IDEConcept-Continuous ImprovementLSPissues related to the roslyn language server protocol implementationissues related to the roslyn language server protocol implementation