diff --git a/Client/server/Upsilon.dll b/Client/server/Upsilon.dll index f37bd89..edfc977 100644 Binary files a/Client/server/Upsilon.dll and b/Client/server/Upsilon.dll differ diff --git a/Client/server/Upsilon.pdb b/Client/server/Upsilon.pdb index 7514b26..942327b 100644 Binary files a/Client/server/Upsilon.pdb and b/Client/server/Upsilon.pdb differ diff --git a/Client/server/UpsilonLanguageServer.dll b/Client/server/UpsilonLanguageServer.dll index 1d27801..270c4d5 100644 Binary files a/Client/server/UpsilonLanguageServer.dll and b/Client/server/UpsilonLanguageServer.dll differ diff --git a/Client/server/UpsilonLanguageServer.pdb b/Client/server/UpsilonLanguageServer.pdb index 929f54c..480f6de 100644 Binary files a/Client/server/UpsilonLanguageServer.pdb and b/Client/server/UpsilonLanguageServer.pdb differ diff --git a/Client/upsilon-language-extension-1.0.0.vsix b/Client/upsilon-language-extension-1.0.0.vsix index 0faef6f..202a1ce 100644 Binary files a/Client/upsilon-language-extension-1.0.0.vsix and b/Client/upsilon-language-extension-1.0.0.vsix differ diff --git a/UpsilonLanguageServer/Lib/Upsilon.dll b/UpsilonLanguageServer/Lib/Upsilon.dll index f37bd89..edfc977 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 7514b26..942327b 100644 Binary files a/UpsilonLanguageServer/Lib/Upsilon.pdb and b/UpsilonLanguageServer/Lib/Upsilon.pdb differ diff --git a/UpsilonLanguageServer/UpsilonLanguageServer/BoundTypeParser.cs b/UpsilonLanguageServer/UpsilonLanguageServer/BoundTypeParser.cs index 6f73e4c..58e1c42 100644 --- a/UpsilonLanguageServer/UpsilonLanguageServer/BoundTypeParser.cs +++ b/UpsilonLanguageServer/UpsilonLanguageServer/BoundTypeParser.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.Diagnostics; using System.Linq; using System.Text.RegularExpressions; using Newtonsoft.Json.Linq; @@ -183,6 +182,11 @@ namespace UpsilonLanguageServer } private static readonly Regex TableMatcher = new Regex(@"table *\((?'catch'.*)\)", RegexOptions.IgnoreCase); + + private static readonly Regex TableKeyValueMatcher = + new Regex( + @"(?'keyType'(?:\w| )+) *(?:\((?'keyInternalType'.*)\))* *, *(?'valueType'(?:\w| )+)(?:\((?'valueInternalType'.*)\))*", + RegexOptions.IgnoreCase); private static TypeContainer ParseType(string input) { input = input.Trim(); @@ -193,8 +197,7 @@ namespace UpsilonLanguageServer if (string.Equals(input, "bool", StringComparison.InvariantCultureIgnoreCase)) return Type.Boolean; if (string.Equals(input, "table", StringComparison.InvariantCultureIgnoreCase)) - { - } + return Type.Table; if (string.Equals(input, "function", StringComparison.InvariantCultureIgnoreCase)) return Type.Function; if (string.Equals(input, "unknown", StringComparison.InvariantCultureIgnoreCase)) @@ -203,13 +206,27 @@ namespace UpsilonLanguageServer if (match.Success) { var group = match.Groups["catch"].Value; - var split = group.Split(',', StringSplitOptions.RemoveEmptyEntries); - return new CompositeTypeContainer() - { - Types = split.Select(ParseType).ToImmutableArray() - }; + return ParseTableKeyValue(group); } return new TypeContainer(input); } + + private static CompositeTypeContainer ParseTableKeyValue(string s) + { + var match = TableKeyValueMatcher.Match(s); + var dictionary = match.Groups.Where(x => x.Success).ToDictionary(x => x.Name, x => x.Value); + var keyType = ParseType(dictionary["keyType"]); + var valueType = ParseType(dictionary["valueType"]); + if (keyType == Type.Table && dictionary.TryGetValue("keyInternalType", out var keyInternalType)) + { + keyType = ParseTableKeyValue(keyInternalType); + } + if (valueType == Type.Table && dictionary.TryGetValue("valueInternalType", out var valueInternalType)) + { + valueType = ParseTableKeyValue(valueInternalType); + } + + return new CompositeTypeContainer(new[] {keyType, valueType}.ToImmutableArray()); + } } } \ No newline at end of file diff --git a/UpsilonLanguageServer/UpsilonLanguageServer/Services/InitializationService.cs b/UpsilonLanguageServer/UpsilonLanguageServer/Services/InitializationService.cs index 36e0251..0cb4c84 100644 --- a/UpsilonLanguageServer/UpsilonLanguageServer/Services/InitializationService.cs +++ b/UpsilonLanguageServer/UpsilonLanguageServer/Services/InitializationService.cs @@ -64,12 +64,16 @@ namespace UpsilonLanguageServer.Services await Client.Window.ShowMessage(MessageType.Info, "Upsilon Language Server Initialized"); } + public void Shutdown() + { + Session.StopServer(); + } + [JsonRpcMethod(IsNotification = true)] public void Exit() { Client.Window.ShowMessage(MessageType.Info, "Upsilon Language Server exited"); Session.StopServer(); - Process.GetCurrentProcess().Kill(); } [JsonRpcMethod("$/cancelRequest", IsNotification = true)] diff --git a/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs b/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs index 6c9ddaa..249a067 100644 --- a/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs +++ b/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs @@ -48,6 +48,10 @@ namespace UpsilonLanguageServer.Services contents.Append($"\n\nReturns: {fVar.FunctionOption.First().ResultType}"); } } + else if (findNode is BoundVariableAssignment variableAssignment) + { + contents.Append($"\n\nType: {variableAssignment.Variable.Type}"); + } else if (findNode is BoundFunctionExpression fe) { contents.Append($"\n\nReturns: {fe.ReturnType}");