public async Task <FoldingRange[]?> HandleRequestAsync(FoldingRangeParams request, RequestContext context, CancellationToken cancellationToken) { var document = context.Document; if (document == null) { return(null); } var blockStructureService = document.Project.LanguageServices.GetService <BlockStructureService>(); if (blockStructureService == null) { return(Array.Empty <FoldingRange>()); } var options = _globalOptions.GetBlockStructureOptions(document.Project); var blockStructure = await blockStructureService.GetBlockStructureAsync(document, options, cancellationToken).ConfigureAwait(false); if (blockStructure == null) { return(Array.Empty <FoldingRange>()); } var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); return(GetFoldingRanges(blockStructure, text)); }