From d04fdf82c44e8d3223df70780efa4ac40affc26c Mon Sep 17 00:00:00 2001 From: Benjamin Friedman Wilson Date: Fri, 17 Nov 2023 17:10:04 +0100 Subject: [PATCH] unsafe downcasts until service registry is changed --- packages/langium/src/lsp/language-server.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/langium/src/lsp/language-server.ts b/packages/langium/src/lsp/language-server.ts index 146a74b52..33b805178 100644 --- a/packages/langium/src/lsp/language-server.ts +++ b/packages/langium/src/lsp/language-server.ts @@ -533,9 +533,10 @@ export function createCallHierarchyRequestHandler

services.lsp.TypeHierarchyProvider)) { + // TODO @montymxb downcast is not safe, needs additional work + if (!sharedServices.ServiceRegistry.all.some(services => (services as LangiumCombinedServices).lsp.TypeHierarchyProvider)) { return; } @@ -547,13 +548,15 @@ export function addTypeHierarchyHandler(connection: Connection, sharedServices: connection.languages.typeHierarchy.onSupertypes( createTypeHierarchyRequestHandler((services, params, cancelToken) => { - return services.lsp.TypeHierarchyProvider?.supertypes(params, cancelToken) ?? null; + // TODO @montymxb downcast is not safe, needs additional work + return (services as LangiumCombinedServices).lsp.TypeHierarchyProvider?.supertypes(params, cancelToken) ?? null; }, sharedServices), ); connection.languages.typeHierarchy.onSubtypes( createTypeHierarchyRequestHandler((services, params, cancelToken) => { - return services.lsp.TypeHierarchyProvider?.subtypes(params, cancelToken) ?? null; + // TODO @montymxb downcast is not safe, needs additional work + return (services as LangiumCombinedServices).lsp.TypeHierarchyProvider?.subtypes(params, cancelToken) ?? null; }, sharedServices), ); }