Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Feb 1, 2022
1 parent f3ff5cd commit 2249e5e
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private async Task ProduceTagsAsync(
try
{
var diagnosticMode = GlobalOptions.GetDiagnosticMode(InternalDiagnosticsOptions.NormalDiagnosticMode);

var id = bucket.Id;
var diagnostics = await _diagnosticService.GetPushDiagnosticsAsync(
workspace, document.Project.Id, document.Id, id,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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.VSTypeScript.Api
{
internal interface IVSTypeScriptDiagnosticService
{
Task<ImmutableArray<VSTypeScriptDiagnosticData>> GetPushDiagnosticsAsync(Workspace workspace, ProjectId projectId, DocumentId documentId, object id, bool includeSuppressedDiagnostics, CancellationToken cancellationToken);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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 Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api
{
internal readonly struct VSTypeScriptDiagnosticData
{
private readonly DiagnosticData _data;

internal VSTypeScriptDiagnosticData(DiagnosticData data)
{
_data = data;
}

public DiagnosticSeverity Severity
=> _data.Severity;

public string? Message
=> _data.Message;

public string Id
=> _data.Id;

public ImmutableArray<string> CustomTags
=> _data.CustomTags;

public LinePositionSpan GetLinePositionSpan(SourceText sourceText, bool useMapped)
=> DiagnosticData.GetLinePositionSpan(_data.DataLocation, sourceText, useMapped);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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.Threading;
using System.Threading.Tasks;
using System.Composition;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript
{
[Export(typeof(IVSTypeScriptDiagnosticService)), Shared]
internal sealed class VSTypeScriptDiagnosticService : IVSTypeScriptDiagnosticService
{
private readonly IDiagnosticService _service;
private readonly IGlobalOptionService _globalOptions;

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public VSTypeScriptDiagnosticService(IDiagnosticService service, IGlobalOptionService globalOptions)
{
_service = service;
_globalOptions = globalOptions;
}

public async Task<ImmutableArray<VSTypeScriptDiagnosticData>> GetPushDiagnosticsAsync(Workspace workspace, ProjectId projectId, DocumentId documentId, object id, bool includeSuppressedDiagnostics, CancellationToken cancellationToken)
{
var result = await _service.GetPushDiagnosticsAsync(workspace, projectId, documentId, id, includeSuppressedDiagnostics, _globalOptions.GetDiagnosticMode(InternalDiagnosticsOptions.NormalDiagnosticMode), cancellationToken).ConfigureAwait(false);
return result.SelectAsArray(data => new VSTypeScriptDiagnosticData(data));
}
}
}

0 comments on commit 2249e5e

Please sign in to comment.