Skip to content

Commit 5280119

Browse files
committed
Extract method
1 parent 7c496dd commit 5280119

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/RazorFilePathToContentTypeProviderBase.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,34 @@ internal abstract class RazorFilePathToContentTypeProviderBase(
1717
private readonly LanguageServerFeatureOptions _options = options;
1818

1919
public bool TryGetContentTypeForFilePath(string filePath, [NotNullWhen(true)] out IContentType? contentType)
20+
{
21+
if (UseLSPEditor(filePath))
22+
{
23+
contentType = _contentTypeRegistryService.GetContentType(RazorConstants.RazorLSPContentTypeName);
24+
return true;
25+
}
26+
27+
contentType = null;
28+
return false;
29+
}
30+
31+
private bool UseLSPEditor(string filePath)
2032
{
2133
// When cohosting is on, it's on for all non .NET Framework projects, regardless of feature flags or
2234
// project capabilities.
2335
if (_options.UseRazorCohostServer &&
2436
_lspEditorFeatureDetector.IsDotNetCoreProject(filePath))
2537
{
26-
contentType = _contentTypeRegistryService.GetContentType(RazorConstants.RazorLSPContentTypeName);
2738
return true;
2839
}
2940

41+
// Otherwise, we just check for the lack of feature flag feature or project capability.
3042
if (_lspEditorFeatureDetector.IsLspEditorEnabled() &&
3143
_lspEditorFeatureDetector.IsLspEditorSupported(filePath))
3244
{
33-
contentType = _contentTypeRegistryService.GetContentType(RazorConstants.RazorLSPContentTypeName);
3445
return true;
3546
}
3647

37-
contentType = null;
3848
return false;
3949
}
4050
}

0 commit comments

Comments
 (0)