open file from diagnostic
This commit is contained in:
@@ -4,6 +4,11 @@ namespace SharpIDE.Application.Features.SolutionDiscovery;
|
|||||||
|
|
||||||
public static class TreeMapperV2
|
public static class TreeMapperV2
|
||||||
{
|
{
|
||||||
|
public static IEnumerable<SharpIdeFile> GetAllFiles(this SharpIdeFolder folder)
|
||||||
|
{
|
||||||
|
return folder.Files
|
||||||
|
.Concat(folder.Folders.SelectMany(sub => sub.GetAllFiles()));
|
||||||
|
}
|
||||||
public static List<SharpIdeFolder> GetSubFolders(string csprojectPath)
|
public static List<SharpIdeFolder> GetSubFolders(string csprojectPath)
|
||||||
{
|
{
|
||||||
var projectDirectory = Path.GetDirectoryName(csprojectPath)!;
|
var projectDirectory = Path.GetDirectoryName(csprojectPath)!;
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
@using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence
|
@using SharpIDE.Application.Features.SolutionDiscovery
|
||||||
|
@using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence
|
||||||
|
|
||||||
<MudStack Style="height: 100%">
|
<MudStack Style="height: 100%">
|
||||||
<MudTreeView T="string" Dense="true" ExpandOnClick="true">
|
<MudTreeView T="string" Dense="true" ExpandOnClick="true">
|
||||||
@foreach (var project in SolutionModel.AllProjects)
|
@foreach (var project in SolutionModel.AllProjects)
|
||||||
{
|
{
|
||||||
<ProjectProblemComponent ProjectModel="@project"/>
|
<ProjectProblemComponent ProjectModel="@project" SelectedFile="@SelectedFile" SelectedFileChanged="@SelectedFileChanged"/>
|
||||||
}
|
}
|
||||||
</MudTreeView>
|
</MudTreeView>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
@@ -11,4 +13,10 @@
|
|||||||
@code {
|
@code {
|
||||||
[Parameter, EditorRequired]
|
[Parameter, EditorRequired]
|
||||||
public SharpIdeSolutionModel SolutionModel { get; set; } = null!;
|
public SharpIdeSolutionModel SolutionModel { get; set; } = null!;
|
||||||
|
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public SharpIdeFile SelectedFile { get; set; } = null!;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<SharpIdeFile> SelectedFileChanged { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
@using System.Collections.Immutable
|
@using System.Collections.Immutable
|
||||||
@using Microsoft.CodeAnalysis
|
@using Microsoft.CodeAnalysis
|
||||||
@using SharpIDE.Application.Features.Analysis
|
@using SharpIDE.Application.Features.Analysis
|
||||||
|
@using SharpIDE.Application.Features.SolutionDiscovery
|
||||||
@using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence
|
@using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence
|
||||||
|
|
||||||
@if (_diagnostics.Length is not 0)
|
@if (_diagnostics.Length is not 0)
|
||||||
@@ -24,6 +25,12 @@
|
|||||||
[Parameter, EditorRequired]
|
[Parameter, EditorRequired]
|
||||||
public SharpIdeProjectModel ProjectModel { get; set; } = null!;
|
public SharpIdeProjectModel ProjectModel { get; set; } = null!;
|
||||||
|
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public SharpIdeFile SelectedFile { get; set; } = null!;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<SharpIdeFile> SelectedFileChanged { get; set; }
|
||||||
|
|
||||||
private ImmutableArray<Diagnostic> _diagnostics = [];
|
private ImmutableArray<Diagnostic> _diagnostics = [];
|
||||||
|
|
||||||
private static Color GetDiagnosticIconColour(Diagnostic diagnostic) => diagnostic.Severity switch
|
private static Color GetDiagnosticIconColour(Diagnostic diagnostic) => diagnostic.Severity switch
|
||||||
@@ -36,7 +43,12 @@
|
|||||||
|
|
||||||
private async Task OpenDocumentContainingDiagnostic(Diagnostic diagnostic)
|
private async Task OpenDocumentContainingDiagnostic(Diagnostic diagnostic)
|
||||||
{
|
{
|
||||||
|
// TODO: probably store a flat list of all files in each project to avoid recursion
|
||||||
|
var file = ProjectModel.Files
|
||||||
|
.Concat(ProjectModel.Folders.SelectMany(f => f.GetAllFiles()))
|
||||||
|
.Single(s => s.Path == diagnostic.Location.SourceTree?.GetMappedLineSpan(diagnostic.Location.SourceSpan).Path);
|
||||||
|
|
||||||
|
await SelectedFileChanged.InvokeAsync(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
@@ -44,5 +56,4 @@
|
|||||||
var diagnostics = await RoslynAnalysis.GetProjectDiagnostics(ProjectModel);
|
var diagnostics = await RoslynAnalysis.GetProjectDiagnostics(ProjectModel);
|
||||||
_diagnostics = diagnostics;
|
_diagnostics = diagnostics;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
@if (_solutionFilePath is not null)
|
@if (_solutionFilePath is not null)
|
||||||
{
|
{
|
||||||
<DisplayNoneComponent Visible="@(_selectedBottomPanel is BottomPanelType.Problems)">
|
<DisplayNoneComponent Visible="@(_selectedBottomPanel is BottomPanelType.Problems)">
|
||||||
<ProblemsPanel SolutionModel="@_solutionModel" />
|
<ProblemsPanel SolutionModel="@_solutionModel" @bind-SelectedFile="@_selectedFile" />
|
||||||
</DisplayNoneComponent>
|
</DisplayNoneComponent>
|
||||||
<DisplayNoneComponent Visible="@(_selectedBottomPanel is BottomPanelType.Run)">
|
<DisplayNoneComponent Visible="@(_selectedBottomPanel is BottomPanelType.Run)">
|
||||||
<RunPanel SolutionModel="@_solutionModel"/>
|
<RunPanel SolutionModel="@_solutionModel"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user