refactor opening diagnostic location
This commit is contained in:
@@ -112,16 +112,13 @@ public partial class ProblemsPanel : Control
|
|||||||
var parentTreeItem = selected.GetParent();
|
var parentTreeItem = selected.GetParent();
|
||||||
var projectContainer = parentTreeItem.GetMetadata(0).As<RefCountedContainer<SharpIdeProjectModel>?>();
|
var projectContainer = parentTreeItem.GetMetadata(0).As<RefCountedContainer<SharpIdeProjectModel>?>();
|
||||||
if (projectContainer is null) return;
|
if (projectContainer is null) return;
|
||||||
var projectModel = projectContainer.Item;
|
OpenDocumentContainingDiagnostic(diagnostic);
|
||||||
OpenDocumentContainingDiagnostic(diagnostic, projectModel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OpenDocumentContainingDiagnostic(Diagnostic diagnostic, SharpIdeProjectModel projectModel)
|
private void OpenDocumentContainingDiagnostic(Diagnostic diagnostic)
|
||||||
{
|
{
|
||||||
// TODO: probably store a flat list of all files in each project to avoid recursion
|
var filePath = diagnostic.Location.SourceTree?.GetMappedLineSpan(diagnostic.Location.SourceSpan).Path;
|
||||||
var file = projectModel.Files
|
var file = Solution!.AllFiles.Single(f => f.Path == filePath);
|
||||||
.Concat(projectModel.Folders.SelectMany(f => f.GetAllFiles()))
|
|
||||||
.Single(s => s.Path == diagnostic.Location.SourceTree?.GetMappedLineSpan(diagnostic.Location.SourceSpan).Path);
|
|
||||||
GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(file, null);
|
GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(file, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user