From 095211d0ecb3f3b2d098ab42e48abb17caaa82c4 Mon Sep 17 00:00:00 2001 From: Henk-Jan Lebbink Date: Fri, 6 Oct 2023 16:07:07 +0200 Subject: [PATCH] bumped Microsoft.VisualStudio.LanguageServer.Protocol 17.2.8 -> 18.8.9-preview bumped Microsoft.VisualStudio.LanguageServer 17.2.8 -> 18.8.9-preview --- VS/CSHARP/asm-dude2-ls-lib/AsmFoldingRange.cs | 49 ------------------- VS/CSHARP/asm-dude2-ls-lib/LanguageServer.cs | 38 +++++++++----- .../asm-dude2-ls-lib/asm-dude2-ls-lib.csproj | 7 ++- .../asm-dude2-vsix/asm-dude2-vsix.csproj | 3 +- 4 files changed, 34 insertions(+), 63 deletions(-) delete mode 100644 VS/CSHARP/asm-dude2-ls-lib/AsmFoldingRange.cs diff --git a/VS/CSHARP/asm-dude2-ls-lib/AsmFoldingRange.cs b/VS/CSHARP/asm-dude2-ls-lib/AsmFoldingRange.cs deleted file mode 100644 index 188a0800..00000000 --- a/VS/CSHARP/asm-dude2-ls-lib/AsmFoldingRange.cs +++ /dev/null @@ -1,49 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2023 Henk-Jan Lebbink -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using Microsoft.VisualStudio.LanguageServer.Protocol; - -using Newtonsoft.Json; - -using System.Runtime.Serialization; - -namespace AsmDude2LS -{ - // - // Summary: - // Class representing a folding range in a document. See the Language Server Protocol - // specification for additional information. - [DataContract] - public class AsmFoldingRange : FoldingRange - { - /** - * The text that the client should show when the specified range is - * collapsed. If not defined or not supported by the client, a default - * will be chosen by the client. - * - * @since 3.17.0 - proposed - */ - [DataMember(Name = "collapsedText")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string CollapsedText { get; set; } - } -} diff --git a/VS/CSHARP/asm-dude2-ls-lib/LanguageServer.cs b/VS/CSHARP/asm-dude2-ls-lib/LanguageServer.cs index cdd04b3f..cbbbdaa6 100644 --- a/VS/CSHARP/asm-dude2-ls-lib/LanguageServer.cs +++ b/VS/CSHARP/asm-dude2-ls-lib/LanguageServer.cs @@ -61,7 +61,7 @@ public class LanguageServer : INotifyPropertyChanged private readonly Dictionary textDocumentLines; private readonly Dictionary parsedDocuments; - private readonly Dictionary> foldingRanges; + private readonly Dictionary> foldingRanges; private readonly Dictionary labelGraphs; private readonly int referencesChunkSize = 10; @@ -102,7 +102,7 @@ private LanguageServer(Stream sender, Stream reader) this.parsedDocuments = new Dictionary(); this.labelGraphs = new Dictionary(); - this.foldingRanges = new Dictionary>(); + this.foldingRanges = new Dictionary>(); this.diagnostics = new List(); this.Symbols = Array.Empty(); @@ -401,7 +401,7 @@ static string GetCollapsedText(int startPos, string line) int startKeywordLength = StartKeyword.Length; int endKeywordLength = EndKeyword.Length; - List foldingRanges = new(); + List foldingRanges = new(); Stack startLineNumbers = new(); Stack startCharacters = new(); @@ -437,7 +437,7 @@ static string GetCollapsedText(int startPos, string line) { int startLine = startLineNumbers.Pop(); int startCharacter = startCharacters.Pop(); - foldingRanges.Add(new AsmFoldingRange + foldingRanges.Add(new FoldingRange { StartLine = startLine, StartCharacter = startCharacter, @@ -951,23 +951,23 @@ public SignatureHelp GetTextDocumentSignatureHelp(SignatureHelpParams parameter) } } - public void SetFoldingRanges(IEnumerable foldingRanges, Uri uri) + public void SetFoldingRanges(IEnumerable foldingRanges, Uri uri) { this.foldingRanges.Remove(uri); this.foldingRanges.Add(uri, foldingRanges); } - public AsmFoldingRange[] GetFoldingRanges(FoldingRangeParams parameter) + public FoldingRange[] GetFoldingRanges(FoldingRangeParams parameter) { if (!this.options.CodeFolding_On) { - return Array.Empty(); + return Array.Empty(); } - if (this.foldingRanges.TryGetValue(parameter.TextDocument.Uri, out IEnumerable value)) + if (this.foldingRanges.TryGetValue(parameter.TextDocument.Uri, out IEnumerable value)) { return value.ToArray(); } - return Array.Empty(); + return Array.Empty(); } private HashSet Mnemonic_Operand_Completions(bool useCapitals, HashSet allowedOperands, int lineNumber) @@ -1557,7 +1557,7 @@ public Hover GetHover(TextDocumentPositionParams parameter) Language = MarkupKind.PlainText.ToString(), Value = full_Descr + "\n", }), - new SumType(new MarkedString + new(new MarkedString { Language = MarkupKind.Markdown.ToString(), Value = ((performanceInfoAvailable) ? "**Performance:**\n```text\n" + performanceStr + "\n```" : "No performance info"), @@ -1613,7 +1613,7 @@ public Hover GetHover(TextDocumentPositionParams parameter) } descr = AsmTools.AsmSourceTools.Linewrap(descr, MaxNumberOfCharsInToolTips); hoverContent = new SumType[]{ - new SumType(new MarkedString + new(new MarkedString { Language = MarkupKind.PlainText.ToString(), Value = $"Keyword {keyword}: {descr}", @@ -1795,8 +1795,24 @@ public Hover GetHover(TextDocumentPositionParams parameter) } */ + if (hoverContent != null) { + //return new Microsoft.VisualStudio.LanguageServer.Protocol.VSInternalHover + //{ + // Range = new Range() + // { + // Start = new Position(parameter.Position.Line, startPos), + // End = new Position(parameter.Position.Line, endPos), + // }, + // Contents = new MarkupContent + // { + // Kind = MarkupKind.Markdown, + // Value = "TODO **bold**" + // }, + // //RawContent = new ClassifiedTextElement(descriptionBuilder.Select(tp => new ClassifiedTextRun(tp.Tag.ToClassificationTypeName(), tp.Text))) + //}; + return new Hover() { Contents = hoverContent, diff --git a/VS/CSHARP/asm-dude2-ls-lib/asm-dude2-ls-lib.csproj b/VS/CSHARP/asm-dude2-ls-lib/asm-dude2-ls-lib.csproj index adc7b77b..c311ed5e 100644 --- a/VS/CSHARP/asm-dude2-ls-lib/asm-dude2-ls-lib.csproj +++ b/VS/CSHARP/asm-dude2-ls-lib/asm-dude2-ls-lib.csproj @@ -73,8 +73,11 @@ - - + + + + + diff --git a/VS/CSHARP/asm-dude2-vsix/asm-dude2-vsix.csproj b/VS/CSHARP/asm-dude2-vsix/asm-dude2-vsix.csproj index b7864a9a..dbdd27db 100644 --- a/VS/CSHARP/asm-dude2-vsix/asm-dude2-vsix.csproj +++ b/VS/CSHARP/asm-dude2-vsix/asm-dude2-vsix.csproj @@ -111,7 +111,8 @@ - + + all