display underline for diagnostics
This commit is contained in:
@@ -10,6 +10,7 @@ using Microsoft.CodeAnalysis.Host.Mef;
|
||||
using Microsoft.CodeAnalysis.MSBuild;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using NuGet.Packaging;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||
|
||||
namespace SharpIDE.Application.Features.Analysis;
|
||||
@@ -125,6 +126,23 @@ public static class RoslynAnalysis
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
public static async Task<ImmutableArray<Diagnostic>> GetDocumentDiagnostics(SharpIdeFile fileModel)
|
||||
{
|
||||
await _solutionLoadedTcs.Task;
|
||||
var cancellationToken = CancellationToken.None;
|
||||
var project = _workspace!.CurrentSolution.Projects.Single(s => s.FilePath == ((IChildSharpIdeNode)fileModel).GetNearestProjectNode()!.FilePath);
|
||||
var document = project.Documents.Single(s => s.FilePath == fileModel.Path);
|
||||
//var document = _workspace!.CurrentSolution.GetDocument(fileModel.Path);
|
||||
Guard.Against.Null(document, nameof(document));
|
||||
|
||||
var semanticModel = await document.GetSemanticModelAsync(cancellationToken);
|
||||
Guard.Against.Null(semanticModel, nameof(semanticModel));
|
||||
|
||||
var diagnostics = semanticModel.GetDiagnostics(cancellationToken: cancellationToken);
|
||||
diagnostics = diagnostics.Where(d => d.Severity is not DiagnosticSeverity.Hidden).ToImmutableArray();
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
public static async Task<ImmutableArray<CodeAction>> GetCodeFixesAsync(Diagnostic diagnostic)
|
||||
{
|
||||
var cancellationToken = CancellationToken.None;
|
||||
|
||||
@@ -14,6 +14,17 @@ public interface IExpandableSharpIdeNode
|
||||
public interface IChildSharpIdeNode
|
||||
{
|
||||
public IExpandableSharpIdeNode Parent { get; set; }
|
||||
|
||||
// TODO: Profile/redesign
|
||||
public SharpIdeProjectModel? GetNearestProjectNode()
|
||||
{
|
||||
var current = this;
|
||||
while (current is not SharpIdeProjectModel && current?.Parent is not null)
|
||||
{
|
||||
current = current.Parent as IChildSharpIdeNode;
|
||||
}
|
||||
return current as SharpIdeProjectModel;
|
||||
}
|
||||
}
|
||||
|
||||
public class SharpIdeSolutionModel : ISharpIdeNode, IExpandableSharpIdeNode
|
||||
|
||||
Reference in New Issue
Block a user