diff --git a/UpsilonLanguageServer/Lib/Upsilon.dll b/UpsilonLanguageServer/Lib/Upsilon.dll index 639ee96..c1160e1 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 b0b1ad8..95cbcc8 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 a4e933d..2f8ca1f 100644 --- a/UpsilonLanguageServer/UpsilonLanguageServer/BoundTypeParser.cs +++ b/UpsilonLanguageServer/UpsilonLanguageServer/BoundTypeParser.cs @@ -17,12 +17,25 @@ namespace UpsilonLanguageServer foreach (var prop in json.Properties()) { var typeName = prop.Name; + if (!(prop.Value is JObject obj)) + continue; + var dic = new Dictionary(); - var innerProperties = ((JObject)prop.Value).Properties(); + var specialMod = obj.GetValue("__type", StringComparison.InvariantCultureIgnoreCase)?.ToString(); + if (string.Equals(specialMod, "enum", StringComparison.InvariantCultureIgnoreCase)) + { + var values = obj.GetValue("values", StringComparison.InvariantCultureIgnoreCase)?.ToObject(); + if (values == null) + continue; + BoundTypeHandler.LoadUserDataTypeDefinition(new UserDataBoundEnumDefinition(values, typeName)); + continue; + } + var innerProperties = obj.Properties(); foreach (var innerProperty in innerProperties) { var propertyName = innerProperty.Name; - var value = (JObject)innerProperty.Value; + if (!(innerProperty.Value is JObject value)) + continue; var type = value.GetValue("type", StringComparison.InvariantCultureIgnoreCase)?.ToString(); var comment = value.GetValue("comment", StringComparison.InvariantCultureIgnoreCase)?.ToString(); if (string.Equals("function", type, StringComparison.InvariantCultureIgnoreCase)) diff --git a/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs b/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs index b8f3d73..b7ea2bd 100644 --- a/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs +++ b/UpsilonLanguageServer/UpsilonLanguageServer/Services/TextDocumentServer.cs @@ -233,6 +233,10 @@ namespace UpsilonLanguageServer.Services { var kind = CompletionItemKind.Variable; var data = new JObject(); + var documentation = symbol.CommentValue == null + ? "" + : $"{string.Join(" \n", symbol.CommentValue)}"; + if (symbol is FunctionVariableSymbol fun) { kind = CompletionItemKind.Function; @@ -252,11 +256,15 @@ namespace UpsilonLanguageServer.Services { } + else if (boundVar.Type == Type.UserData) + { + if (boundVar.BoundTypeDefinition is UserDataBoundEnumDefinition) + { + kind = CompletionItemKind.Enum; + } + } } - var documentation = symbol.CommentValue == null - ? "" - : $"{string.Join(" \n", symbol.CommentValue)}"; return new CompletionItem(symbol.Name, kind, symbol.Type.ToString(), documentation, data); }