From 081374c0546e3f9122476cf7ec67c860e6ea6a76 Mon Sep 17 00:00:00 2001 From: penev92 Date: Sun, 23 Oct 2022 23:43:57 +0300 Subject: [PATCH] Added completion items for boolean fields --- .../TextDocumentCompletionHandler.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/server/Oraide.LanguageServer/LanguageServerProtocolHandlers/TextDocument/TextDocumentCompletionHandler.cs b/server/Oraide.LanguageServer/LanguageServerProtocolHandlers/TextDocument/TextDocumentCompletionHandler.cs index d0b08ee..e599820 100644 --- a/server/Oraide.LanguageServer/LanguageServerProtocolHandlers/TextDocument/TextDocumentCompletionHandler.cs +++ b/server/Oraide.LanguageServer/LanguageServerProtocolHandlers/TextDocument/TextDocumentCompletionHandler.cs @@ -50,6 +50,20 @@ public class TextDocumentCompletionHandler : BaseRpcMessageHandler CommitCharacters = new[] { ":" } }; + readonly CompletionItem trueCompletionItem = new () + { + Label = "true", + Kind = CompletionItemKind.Value, + Detail = "A boolean value." + }; + + readonly CompletionItem falseCompletionItem = new () + { + Label = "false", + Kind = CompletionItemKind.Value, + Detail = "A boolean value." + }; + public TextDocumentCompletionHandler(SymbolCache symbolCache, OpenFileCache openFileCache) : base(symbolCache, openFileCache) { } @@ -329,6 +343,11 @@ protected override IEnumerable HandleRulesValue(CursorTarget cur }); } + if (fieldInfo.InternalType == "bool") + { + return new[] { trueCompletionItem, falseCompletionItem }; + } + return Enumerable.Empty(); } @@ -481,6 +500,11 @@ protected override IEnumerable HandleWeaponValue(CursorTarget cu }); } + if (fieldInfo.InternalType == "bool") + { + return new[] { trueCompletionItem, falseCompletionItem }; + } + return Enumerable.Empty(); } @@ -593,6 +617,11 @@ IEnumerable HandleSpriteSequenceProperty() } } + if (fieldInfo.InternalType == "bool") + { + return new[] { trueCompletionItem, falseCompletionItem }; + } + return Enumerable.Empty(); }