未验证 提交 a4e28751 编写于 作者: T Tomáš Matoušek 提交者: GitHub

Remove FSharpProjectDiagnosticAnalyzer (#42167)

上级 b73b999a
// 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 file in the project root for more information.
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics
{
internal interface IFSharpProjectDiagnosticAnalyzer
{
Task<ImmutableArray<Diagnostic>> AnalyzeProjectAsync(Project project, CancellationToken cancellationToken);
}
}
// 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 file in the project root for more information.
using System;
using System.Collections.Immutable;
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Diagnostics
{
[Shared]
[ExportLanguageService(typeof(FSharpProjectDiagnosticAnalyzerService), LanguageNames.FSharp)]
internal class FSharpProjectDiagnosticAnalyzerService : ILanguageService
{
private readonly IFSharpProjectDiagnosticAnalyzer _analyzer;
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public FSharpProjectDiagnosticAnalyzerService(IFSharpProjectDiagnosticAnalyzer analyzer)
{
_analyzer = analyzer;
}
public Task<ImmutableArray<Diagnostic>> AnalyzeProjectAsync(Project project, CancellationToken cancellationToken)
{
return _analyzer.AnalyzeProjectAsync(project, cancellationToken);
}
}
[DiagnosticAnalyzer(LanguageNames.FSharp)]
internal class FSharpProjectDiagnosticAnalyzer : ProjectDiagnosticAnalyzer
{
private readonly ImmutableArray<DiagnosticDescriptor> _supportedDiagnostics;
public FSharpProjectDiagnosticAnalyzer()
{
_supportedDiagnostics = FSharpDocumentDiagnosticAnalyzer.CreateSupportedDiagnostics();
}
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => _supportedDiagnostics;
public override Task<ImmutableArray<Diagnostic>> AnalyzeProjectAsync(Project project, CancellationToken cancellationToken)
{
var analyzer = project.LanguageServices.GetService<FSharpProjectDiagnosticAnalyzerService>();
if (analyzer == null)
{
return Task.FromResult(ImmutableArray<Diagnostic>.Empty);
}
return analyzer.AnalyzeProjectAsync(project, cancellationToken);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册