Use GodotTask everywhere
This commit is contained in:
@@ -47,43 +47,35 @@ public partial class IdeRoot : Control
|
|||||||
|
|
||||||
private void OnFileSelected(string path)
|
private void OnFileSelected(string path)
|
||||||
{
|
{
|
||||||
_ = Task.Run(async () =>
|
_ = GodotTask.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
GD.Print($"Selected: {path}");
|
||||||
{
|
var solutionModel = await VsPersistenceMapper.GetSolutionModel(path);
|
||||||
GD.Print($"Selected: {path}");
|
_solutionExplorerPanel.SolutionModel = solutionModel;
|
||||||
var solutionModel = await VsPersistenceMapper.GetSolutionModel(path);
|
Callable.From(_solutionExplorerPanel.RepopulateTree).CallDeferred();
|
||||||
_solutionExplorerPanel.SolutionModel = solutionModel;
|
RoslynAnalysis.StartSolutionAnalysis(path);
|
||||||
Callable.From(_solutionExplorerPanel.RepopulateTree).CallDeferred();
|
|
||||||
RoslynAnalysis.StartSolutionAnalysis(path);
|
|
||||||
|
|
||||||
var tasks = solutionModel.AllProjects.Select(p => p.MsBuildEvaluationProjectTask).ToList();
|
var tasks = solutionModel.AllProjects.Select(p => p.MsBuildEvaluationProjectTask).ToList();
|
||||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||||
var runnableProjects = solutionModel.AllProjects.Where(p => p.IsRunnable).ToList();
|
var runnableProjects = solutionModel.AllProjects.Where(p => p.IsRunnable).ToList();
|
||||||
await this.InvokeAsync(() =>
|
await this.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
var runMenuPopupVbox = _runMenuPopup.GetNode<VBoxContainer>("MarginContainer/VBoxContainer");
|
||||||
|
foreach (var project in runnableProjects)
|
||||||
{
|
{
|
||||||
var runMenuPopupVbox = _runMenuPopup.GetNode<VBoxContainer>("MarginContainer/VBoxContainer");
|
var runMenuItem = _runMenuItemScene.Instantiate<RunMenuItem>();
|
||||||
foreach (var project in runnableProjects)
|
runMenuItem.Project = project;
|
||||||
{
|
runMenuPopupVbox.AddChild(runMenuItem);
|
||||||
var runMenuItem = _runMenuItemScene.Instantiate<RunMenuItem>();
|
}
|
||||||
runMenuItem.Project = project;
|
_runMenuButton.Disabled = false;
|
||||||
runMenuPopupVbox.AddChild(runMenuItem);
|
});
|
||||||
}
|
|
||||||
_runMenuButton.Disabled = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
var infraProject = solutionModel.AllProjects.Single(s => s.Name == "Infrastructure");
|
var infraProject = solutionModel.AllProjects.Single(s => s.Name == "Infrastructure");
|
||||||
var diFile = infraProject.Files.Single(s => s.Name == "DependencyInjection.cs");
|
var diFile = infraProject.Files.Single(s => s.Name == "DependencyInjection.cs");
|
||||||
await this.InvokeAsync(async () => await _sharpIdeCodeEdit.SetSharpIdeFile(diFile));
|
await this.InvokeAsync(async () => await _sharpIdeCodeEdit.SetSharpIdeFile(diFile));
|
||||||
|
|
||||||
//var runnableProject = solutionModel.AllProjects.First(s => s.IsRunnable);
|
//var runnableProject = solutionModel.AllProjects.First(s => s.IsRunnable);
|
||||||
//await this.InvokeAsync(() => _runPanel.NewRunStarted(runnableProject));
|
//await this.InvokeAsync(() => _runPanel.NewRunStarted(runnableProject));
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
GD.PrintErr($"Error loading solution: {e.Message}");
|
|
||||||
GD.PrintErr(e.StackTrace);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,22 +114,15 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
{
|
{
|
||||||
// update the MSBuildWorkspace
|
// update the MSBuildWorkspace
|
||||||
RoslynAnalysis.UpdateDocument(_currentFile, Text);
|
RoslynAnalysis.UpdateDocument(_currentFile, Text);
|
||||||
_ = Task.Run(async () =>
|
_ = GodotTask.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
var syntaxHighlighting = await RoslynAnalysis.GetDocumentSyntaxHighlighting(_currentFile);
|
||||||
|
var diagnostics = await RoslynAnalysis.GetDocumentDiagnostics(_currentFile);
|
||||||
|
Callable.From(() =>
|
||||||
{
|
{
|
||||||
var syntaxHighlighting = await RoslynAnalysis.GetDocumentSyntaxHighlighting(_currentFile);
|
SetSyntaxHighlightingModel(syntaxHighlighting);
|
||||||
var diagnostics = await RoslynAnalysis.GetDocumentDiagnostics(_currentFile);
|
SetDiagnosticsModel(diagnostics);
|
||||||
Callable.From(() =>
|
}).CallDeferred();
|
||||||
{
|
|
||||||
SetSyntaxHighlightingModel(syntaxHighlighting);
|
|
||||||
SetDiagnosticsModel(diagnostics);
|
|
||||||
}).CallDeferred();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GD.PrintErr($"Error Calling OnTextChanged: {ex.Message}");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,30 +133,23 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
if (codeAction is null) return;
|
if (codeAction is null) return;
|
||||||
var currentCaretPosition = GetCaretPosition();
|
var currentCaretPosition = GetCaretPosition();
|
||||||
var vScroll = GetVScroll();
|
var vScroll = GetVScroll();
|
||||||
_ = Task.Run(async () =>
|
_ = GodotTask.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
await RoslynAnalysis.ApplyCodeActionAsync(codeAction);
|
||||||
|
var fileContents = await File.ReadAllTextAsync(_currentFile.Path);
|
||||||
|
var syntaxHighlighting = await RoslynAnalysis.GetDocumentSyntaxHighlighting(_currentFile);
|
||||||
|
var diagnostics = await RoslynAnalysis.GetDocumentDiagnostics(_currentFile);
|
||||||
|
Callable.From(() =>
|
||||||
{
|
{
|
||||||
await RoslynAnalysis.ApplyCodeActionAsync(codeAction);
|
BeginComplexOperation();
|
||||||
var fileContents = await File.ReadAllTextAsync(_currentFile.Path);
|
SetText(fileContents);
|
||||||
var syntaxHighlighting = await RoslynAnalysis.GetDocumentSyntaxHighlighting(_currentFile);
|
SetSyntaxHighlightingModel(syntaxHighlighting);
|
||||||
var diagnostics = await RoslynAnalysis.GetDocumentDiagnostics(_currentFile);
|
SetDiagnosticsModel(diagnostics);
|
||||||
Callable.From(() =>
|
SetCaretLine(currentCaretPosition.line);
|
||||||
{
|
SetCaretColumn(currentCaretPosition.col);
|
||||||
BeginComplexOperation();
|
SetVScroll(vScroll);
|
||||||
SetText(fileContents);
|
EndComplexOperation();
|
||||||
SetSyntaxHighlightingModel(syntaxHighlighting);
|
}).CallDeferred();
|
||||||
SetDiagnosticsModel(diagnostics);
|
|
||||||
SetCaretLine(currentCaretPosition.line);
|
|
||||||
SetCaretColumn(currentCaretPosition.col);
|
|
||||||
SetVScroll(vScroll);
|
|
||||||
EndComplexOperation();
|
|
||||||
}).CallDeferred();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GD.PrintErr($"Error applying code fix: {ex.Message}");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,30 +287,23 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
_popupMenu.AddItem("Getting Context Actions...", 0);
|
_popupMenu.AddItem("Getting Context Actions...", 0);
|
||||||
_popupMenu.Popup();
|
_popupMenu.Popup();
|
||||||
GD.Print($"Code fixes requested at line {caretLine}, column {caretColumn}");
|
GD.Print($"Code fixes requested at line {caretLine}, column {caretColumn}");
|
||||||
_ = Task.Run(async () =>
|
_ = GodotTask.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
var linePos = new LinePosition(caretLine, caretColumn);
|
||||||
|
var codeActions = await RoslynAnalysis.GetCodeFixesForDocumentAtPosition(_currentFile, linePos);
|
||||||
|
Callable.From(() =>
|
||||||
{
|
{
|
||||||
var linePos = new LinePosition(caretLine, caretColumn);
|
_popupMenu.Clear();
|
||||||
var codeActions = await RoslynAnalysis.GetCodeFixesForDocumentAtPosition(_currentFile, linePos);
|
foreach (var (index, codeAction) in codeActions.Index())
|
||||||
Callable.From(() =>
|
|
||||||
{
|
{
|
||||||
_popupMenu.Clear();
|
_currentCodeActionsInPopup = codeActions;
|
||||||
foreach (var (index, codeAction) in codeActions.Index())
|
_popupMenu.AddItem(codeAction.Title, index);
|
||||||
{
|
//_popupMenu.SetItemMetadata(menuItem, codeAction);
|
||||||
_currentCodeActionsInPopup = codeActions;
|
}
|
||||||
_popupMenu.AddItem(codeAction.Title, index);
|
|
||||||
//_popupMenu.SetItemMetadata(menuItem, codeAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (codeActions.Length is not 0) _popupMenu.SetFocusedItem(0);
|
if (codeActions.Length is not 0) _popupMenu.SetFocusedItem(0);
|
||||||
GD.Print($"Code fixes found: {codeActions.Length}, displaying menu");
|
GD.Print($"Code fixes found: {codeActions.Length}, displaying menu");
|
||||||
}).CallDeferred();
|
}).CallDeferred();
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GD.Print(ex);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,29 +312,22 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
var (caretLine, caretColumn) = GetCaretPosition();
|
var (caretLine, caretColumn) = GetCaretPosition();
|
||||||
|
|
||||||
GD.Print($"Code completion requested at line {caretLine}, column {caretColumn}");
|
GD.Print($"Code completion requested at line {caretLine}, column {caretColumn}");
|
||||||
_ = Task.Run(async () =>
|
_ = GodotTask.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
var linePos = new LinePosition(caretLine, caretColumn);
|
||||||
{
|
|
||||||
var linePos = new LinePosition(caretLine, caretColumn);
|
|
||||||
|
|
||||||
var completions = await RoslynAnalysis.GetCodeCompletionsForDocumentAtPosition(_currentFile, linePos);
|
var completions = await RoslynAnalysis.GetCodeCompletionsForDocumentAtPosition(_currentFile, linePos);
|
||||||
Callable.From(() =>
|
Callable.From(() =>
|
||||||
{
|
|
||||||
foreach (var completionItem in completions.ItemsList)
|
|
||||||
{
|
|
||||||
AddCodeCompletionOption(CodeCompletionKind.Class, completionItem.DisplayText, completionItem.DisplayText);
|
|
||||||
}
|
|
||||||
// partially working - displays menu only when caret is what CodeEdit determines as valid
|
|
||||||
UpdateCodeCompletionOptions(true);
|
|
||||||
//RequestCodeCompletion(true);
|
|
||||||
GD.Print($"Found {completions.ItemsList.Count} completions, displaying menu");
|
|
||||||
}).CallDeferred();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
GD.Print(ex);
|
foreach (var completionItem in completions.ItemsList)
|
||||||
}
|
{
|
||||||
|
AddCodeCompletionOption(CodeCompletionKind.Class, completionItem.DisplayText, completionItem.DisplayText);
|
||||||
|
}
|
||||||
|
// partially working - displays menu only when caret is what CodeEdit determines as valid
|
||||||
|
UpdateCodeCompletionOptions(true);
|
||||||
|
//RequestCodeCompletion(true);
|
||||||
|
GD.Print($"Found {completions.ItemsList.Count} completions, displaying menu");
|
||||||
|
}).CallDeferred();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user