...
This commit is contained in:
@@ -118,30 +118,30 @@ internal class CompletionHandler(WorkspaceManager workspaceManager) : Completion
|
||||
var compilationUnit = workspaceManager.GetCompilationUnit(uri);
|
||||
if (compilationUnit != null)
|
||||
{
|
||||
var function = compilationUnit.Functions.FirstOrDefault(x => x.Body != null && x.Body.ContainsPosition(position.Line, position.Character));
|
||||
var function = compilationUnit.OfType<FuncNode>().FirstOrDefault(x => x.Body != null && x.Body.ContainsPosition(position.Line, position.Character));
|
||||
if (function != null)
|
||||
{
|
||||
completions.AddRange(_statementSnippets);
|
||||
|
||||
foreach (var (module, prototypes) in compilationUnit.ImportedFunctions)
|
||||
{
|
||||
foreach (var prototype in prototypes)
|
||||
{
|
||||
var parameterStrings = new List<string>();
|
||||
foreach (var (index, parameter) in prototype.Parameters.Index())
|
||||
{
|
||||
parameterStrings.AddRange($"${{{index + 1}:{parameter.NameToken.Value}}}");
|
||||
}
|
||||
|
||||
completions.Add(new CompletionItem
|
||||
{
|
||||
Kind = CompletionItemKind.Function,
|
||||
Label = $"{module.Value}::{prototype.NameToken.Value}",
|
||||
InsertTextFormat = InsertTextFormat.Snippet,
|
||||
InsertText = $"{module.Value}::{prototype.NameToken.Value}({string.Join(", ", parameterStrings)})",
|
||||
});
|
||||
}
|
||||
}
|
||||
// foreach (var (module, prototypes) in compilationUnit.ImportedFunctions)
|
||||
// {
|
||||
// foreach (var prototype in prototypes)
|
||||
// {
|
||||
// var parameterStrings = new List<string>();
|
||||
// foreach (var (index, parameter) in prototype.Parameters.Index())
|
||||
// {
|
||||
// parameterStrings.AddRange($"${{{index + 1}:{parameter.NameToken.Value}}}");
|
||||
// }
|
||||
//
|
||||
// completions.Add(new CompletionItem
|
||||
// {
|
||||
// Kind = CompletionItemKind.Function,
|
||||
// Label = $"{module.Value}::{prototype.NameToken.Value}",
|
||||
// InsertTextFormat = InsertTextFormat.Snippet,
|
||||
// InsertText = $"{module.Value}::{prototype.NameToken.Value}({string.Join(", ", parameterStrings)})",
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
foreach (var parameter in function.Prototype.Parameters)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user