diff --git a/UpsilonLanguageServer/Lib/Upsilon.dll b/UpsilonLanguageServer/Lib/Upsilon.dll index 5b06ce4..69524f3 100644 Binary files a/UpsilonLanguageServer/Lib/Upsilon.dll and b/UpsilonLanguageServer/Lib/Upsilon.dll differ diff --git a/UpsilonLanguageServer/Lib/Upsilon.pdb b/UpsilonLanguageServer/Lib/Upsilon.pdb index 9f1541a..9344757 100644 Binary files a/UpsilonLanguageServer/Lib/Upsilon.pdb and b/UpsilonLanguageServer/Lib/Upsilon.pdb differ diff --git a/UpsilonLanguageServer/UpsilonLanguageServer/Services/CompletionItemService.cs b/UpsilonLanguageServer/UpsilonLanguageServer/Services/CompletionItemService.cs index a89a71b..b58c08c 100644 --- a/UpsilonLanguageServer/UpsilonLanguageServer/Services/CompletionItemService.cs +++ b/UpsilonLanguageServer/UpsilonLanguageServer/Services/CompletionItemService.cs @@ -13,7 +13,7 @@ namespace UpsilonLanguageServer.Services { var item = RequestContext.Request.Parameters.ToObject(Utility.CamelCaseJsonSerializer); // Add a pair of square brackets around the inserted text. - item.InsertText = $"[{item.Label}]"; + item.InsertText = item.Label; return item; } } diff --git a/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs b/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs index b350447..ab20f19 100644 --- a/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs +++ b/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -108,25 +109,35 @@ namespace UpsilonLanguageServer.Services Session.Documents.TryRemove(textDocument.Uri, out _); } - private static readonly CompletionItem[] PredefinedCompletionItems = - { - new CompletionItem(".NET", CompletionItemKind.Keyword, - "Keyword1", - "Short for **.NET Framework**, a software framework by Microsoft (possibly its subsets) or later open source .NET Core.", - null), - new CompletionItem(".NET Standard", CompletionItemKind.Keyword, - "Keyword2", - "The .NET Standard is a formal specification of .NET APIs that are intended to be available on all .NET runtimes.", - null), - new CompletionItem(".NET Framework", CompletionItemKind.Keyword, - "Keyword3", - ".NET Framework (pronounced dot net) is a software framework developed by Microsoft that runs primarily on Microsoft Windows.", null), - }; - [JsonRpcMethod] public async Task Completion(TextDocumentIdentifier textDocument, Position position, CompletionContext context) { - return new CompletionList(PredefinedCompletionItems, false); + if (Session.Documents.TryGetValue(textDocument.Uri, out var doc) && doc.Bound != null) + { + if (context.TriggerCharacter == '.') + { + var linePos = doc.SourceText.GetLineStartPos(position.Line); + var findNode = doc.Bound.GetNodeAtPosition(linePos + position.Character - 2); + if (findNode is BoundVariableSymbol variableSymbol) + { + if (variableSymbol.VariableSymbol is TableVariableSymbol tableSymbol) + { + return new CompletionList( + tableSymbol.Variables.Select(x => new CompletionItem(x.Name, + CompletionItemKind.Variable, x.Type.ToString(), + $"\n\n{string.Join(" \n", x.CommentValue)}"))); + } + return new CompletionList( + new[] + { + new CompletionItem(findNode.Kind.ToString(), CompletionItemKind.Variable, + variableSymbol.VariableSymbol.Name, ""), + }, + false); + } + } + } + return new CompletionList(new CompletionItem[0], false); } }