-
Notifications
You must be signed in to change notification settings - Fork 415
Expand file tree
/
Copy pathLanguageServiceHostEnvironment.cs
More file actions
32 lines (27 loc) · 1.46 KB
/
LanguageServiceHostEnvironment.cs
File metadata and controls
32 lines (27 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information.
using Microsoft.VisualStudio.Composition;
using Microsoft.VisualStudio.ProjectSystem.LanguageServices;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Threading;
namespace Microsoft.VisualStudio.ProjectSystem.VS.LanguageServices;
[Export(typeof(ILanguageServiceHostEnvironment))]
[AppliesTo(ProjectCapability.DotNetLanguageService)]
internal sealed class LanguageServiceHostEnvironment : ILanguageServiceHostEnvironment
{
private readonly AsyncLazy<bool> _isEnabled;
[ImportingConstructor]
public LanguageServiceHostEnvironment(IVsShellServices vsShell, JoinableTaskContext joinableTaskContext)
{
_isEnabled = new(
async () =>
{
// If VS is running in command line mode (e.g. "devenv.exe /build my.sln"),
// the language service host is not enabled. The one exception to this is
// when we're populating a solution cache via "/populateSolutionCache".
return !await vsShell.IsCommandLineModeAsync()
|| await vsShell.IsPopulateSolutionCacheModeAsync();
},
joinableTaskContext.Factory);
}
public Task<bool> IsEnabledAsync(CancellationToken cancellationToken) => _isEnabled.GetValueAsync(cancellationToken);
}