diff --git a/UpsilonLanguageServer/Lib/Upsilon.dll b/UpsilonLanguageServer/Lib/Upsilon.dll index 03755be..c4416fc 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 8e3df75..fb4279e 100644 Binary files a/UpsilonLanguageServer/Lib/Upsilon.pdb and b/UpsilonLanguageServer/Lib/Upsilon.pdb differ diff --git a/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs b/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs index a8414fe..aa53230 100644 --- a/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs +++ b/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs @@ -9,6 +9,7 @@ using LanguageServer.VsCode.Contracts; using LanguageServer.VsCode.Server; using Upsilon.Binder; using Upsilon.Parser; +using Upsilon.Utilities; namespace UpsilonLanguageServer.Services { @@ -25,7 +26,7 @@ namespace UpsilonLanguageServer.Services if (doc.Bound != null && doc.SourceText != null) { var linePos = doc.SourceText.GetLineStartPos(position.Line); - var findNode = doc.Bound.GetNodeAtPosition(linePos + position.Character); + var findNode = doc.Bound.GetBottomNodeAtPosition(linePos + position.Character); if (findNode != null) { var contents = new StringBuilder($"Kind: {findNode.Kind}"); @@ -117,7 +118,7 @@ namespace UpsilonLanguageServer.Services if (context.TriggerCharacter == '.') { var linePos = doc.SourceText.GetLineStartPos(position.Line); - var findNode = doc.Bound.GetNodeAtPosition(linePos + position.Character - 2); + var findNode = doc.Bound.GetBottomNodeAtPosition(linePos + position.Character - 2); if (findNode is BoundVariableSymbol variableSymbol) { if (variableSymbol.VariableSymbol is TableVariableSymbol tableSymbol) @@ -133,13 +134,25 @@ namespace UpsilonLanguageServer.Services : $"\n\n{string.Join(" \n", value.CommentValue)}"); })); } + } + } + else + { + var linePos = doc.SourceText.GetLineStartPos(position.Line); + var scope = doc.Bound.GetScopeAt(linePos + position.Character); + var variables = scope.GetBoundScopeVisibleVariables(); + if (scope != null) + { return new CompletionList( - new[] + variables.Select(x => { - new CompletionItem(findNode.Kind.ToString(), CompletionItemKind.Variable, - variableSymbol.VariableSymbol.Name, ""), - }, - false); + var (key, value) = x; + return new CompletionItem(key, + CompletionItemKind.Variable, value.Type.ToString(), + x.Value.CommentValue == null + ? "" + : $"\n\n{string.Join(" \n", value.CommentValue)}"); + })); } } }