go to usage/declaration
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using Godot;
|
||||
using Microsoft.CodeAnalysis.FindSymbols;
|
||||
using SharpIDE.Application.Features.Analysis;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery;
|
||||
|
||||
namespace SharpIDE.Godot.Features.SymbolLookup;
|
||||
|
||||
public partial class SymbolUsageComponent : MarginContainer
|
||||
{
|
||||
private Label _enclosingSymbolLabel = null!;
|
||||
private Label _fileNameLabel = null!;
|
||||
private Label _lineNumberLabel = null!;
|
||||
private Button _button = null!;
|
||||
|
||||
public SymbolLookupPopup ParentSearchWindow { get; set; } = null!;
|
||||
public ReferenceLocation? Location { get; set; }
|
||||
public SharpIdeFile File { get; set; } = null!;
|
||||
|
||||
[Inject] private readonly RoslynAnalysis _roslynAnalysis = null!;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_button = GetNode<Button>("Button");
|
||||
_enclosingSymbolLabel = GetNode<Label>("%EnclosingSymbolLabel");
|
||||
_fileNameLabel = GetNode<Label>("%FileNameLabel");
|
||||
_lineNumberLabel = GetNode<Label>("%LineNumberLabel");
|
||||
SetValue(Location);
|
||||
_button.Pressed += OnButtonPressed;
|
||||
}
|
||||
|
||||
private void OnButtonPressed()
|
||||
{
|
||||
var mappedLineSpan = Location!.Value.Location.GetMappedLineSpan();
|
||||
var fileLinePosition = new SharpIdeFileLinePosition { Line = mappedLineSpan.StartLinePosition.Line, Column = mappedLineSpan.StartLinePosition.Character };
|
||||
GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(File, fileLinePosition);
|
||||
ParentSearchWindow.Hide();
|
||||
}
|
||||
|
||||
private void SetValue(ReferenceLocation? result)
|
||||
{
|
||||
if (result is null) return;
|
||||
var mappedLineSpan = result.Value.Location.GetMappedLineSpan();
|
||||
|
||||
_fileNameLabel.Text = File.Name;
|
||||
_lineNumberLabel.Text = (mappedLineSpan.StartLinePosition.Line + 1).ToString();
|
||||
|
||||
_ = Task.GodotRun(async () =>
|
||||
{
|
||||
var enclosingSymbol = await _roslynAnalysis.GetEnclosingSymbolForReferenceLocation(result.Value);
|
||||
await this.InvokeAsync(() => _enclosingSymbolLabel.Text = enclosingSymbol?.Name);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user