From 1cce4992b64cc5f2f20f35a792863d9122d3e4a9 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 25 Mar 2024 10:48:34 -0500 Subject: [PATCH] IEmbeddedLanguageClassificationService is optional in the workspaces layer The default implementation of IEmbeddedLanguageClassificationService is provided in the features layer, so make sure it is consumed as optional in the workspaces layer. Fixes #63921 --- src/Workspaces/Core/Portable/Classification/Classifier.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Workspaces/Core/Portable/Classification/Classifier.cs b/src/Workspaces/Core/Portable/Classification/Classifier.cs index 7a4fdb6b15726..83cbbd070f4a5 100644 --- a/src/Workspaces/Core/Portable/Classification/Classifier.cs +++ b/src/Workspaces/Core/Portable/Classification/Classifier.cs @@ -77,7 +77,6 @@ internal static IEnumerable GetClassifiedSpans( { var projectServices = services.GetLanguageServices(semanticModel.Language); var classificationService = projectServices.GetRequiredService(); - var embeddedLanguageService = projectServices.GetRequiredService(); var syntaxClassifiers = classificationService.GetDefaultSyntaxClassifiers(); @@ -94,8 +93,12 @@ internal static IEnumerable GetClassifiedSpans( classificationService.AddSemanticClassifications(semanticModel, textSpan, getNodeClassifiers, getTokenClassifiers, semanticClassifications, options, cancellationToken); // intentionally adding to the semanticClassifications array here. - if (includedEmbeddedClassifications && project != null) + if (includedEmbeddedClassifications + && project != null + && projectServices.GetService() is { } embeddedLanguageService) + { embeddedLanguageService.AddEmbeddedLanguageClassifications(services, project, semanticModel, textSpan, options, semanticClassifications, cancellationToken); + } var allClassifications = new List(semanticClassifications.Where(s => s.TextSpan.OverlapsWith(textSpan))); var semanticSet = semanticClassifications.Select(s => s.TextSpan).ToSet();