From 5ae73f52b99346be383cb0b8c904f5f8552fb6d8 Mon Sep 17 00:00:00 2001 From: Rio Sanjaya Date: Thu, 30 Jul 2026 13:57:20 +0700 Subject: [PATCH] Update properties type deemed optional in spec to TOptional... --- src/protocol/LSP.Basic.pas | 12 ++++++------ src/protocol/LSP.Completion.pas | 16 ++++++++-------- src/protocol/LSP.DocumentSymbol.pas | 4 ++-- src/protocol/LSP.General.pas | 4 ++-- src/protocol/LSP.InlayHint.pas | 4 ++-- src/serverprotocol/PasLS.General.pas | 8 +++++++- src/serverprotocol/lspserver.pas | 1 - 7 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/protocol/LSP.Basic.pas b/src/protocol/LSP.Basic.pas index df62c8b..c36c0b3 100644 --- a/src/protocol/LSP.Basic.pas +++ b/src/protocol/LSP.Basic.pas @@ -376,8 +376,8 @@ TDiagnostic = class (TCollectionItem) private fRange: TRange; fSeverity: TDiagnosticSeverity; - fCode: integer; - fSource: string; + fCode: TOptionalInteger; + fSource: TOptionalString; fMessage: string; procedure SetRange(AValue: TRange); Public @@ -391,10 +391,10 @@ TDiagnostic = class (TCollectionItem) // client to interpret diagnostics as error, warning, info or hint. property severity: TDiagnosticSeverity read fSeverity write fSeverity; // The diagnostic's code, which might appear in the user interface. - property code: integer read fCode write fCode; + property code: TOptionalInteger read fCode write fCode; // A human-readable string describing the source of this // diagnostic, e.g. 'typescript' or 'super lint'. - property source: string read fSource write fSource; + property source: TOptionalString read fSource write fSource; // The diagnostic's message. property message: string read fMessage write fMessage; @@ -1107,7 +1107,8 @@ procedure TDiagnostic.Assign(Source : TPersistent); Severity:=Src.severity; Code:=Src.Code; self.Source:=Src.Source; - Message:=Src.Source; + if Src.source.HasValue then + Message:=Src.Source.Value; end else inherited Assign(Source); @@ -1115,4 +1116,3 @@ procedure TDiagnostic.Assign(Source : TPersistent); end. - diff --git a/src/protocol/LSP.Completion.pas b/src/protocol/LSP.Completion.pas index 6f76c83..1144d1c 100644 --- a/src/protocol/LSP.Completion.pas +++ b/src/protocol/LSP.Completion.pas @@ -152,12 +152,12 @@ TCompletionItem = class(TCollectionItem) fLabel: string; fKind: TCompletionItemKind; fTags: TCompletionItemTags; - fDetail: string; + fDetail: TOptionalString; fDocumentation: TMarkupContent; fPreselect: Boolean; - fSortText: string; - fFilterText: string; - fInsertText: string; + fSortText: TOptionalString; + fFilterText: TOptionalString; + fInsertText: TOptionalString; fInsertTextFormat: TInsertTextFormat; fTextEdit: TTextEdit; fAdditionalTextEdits: TTextEdits; @@ -184,7 +184,7 @@ TCompletionItem = class(TCollectionItem) property tags: TCompletionItemTags read fTags write fTags; // A human-readable string with additional information about this // item, like type or symbol information. - property detail: string read fDetail write fDetail; + property detail: TOptionalString read fDetail write fDetail; // A human-readable string that represents a doc-comment. property documentation: TMarkupContent read fDocumentation write SetDocumentation; // Select this item when showing. @@ -195,10 +195,10 @@ TCompletionItem = class(TCollectionItem) property preselect: Boolean read fPreselect write fPreselect; // A string that should be used when comparing this item // with other items. When `falsy` the label is used. - property sortText: string read fSortText write fSortText; + property sortText: TOptionalString read fSortText write fSortText; // A string that should be used when filtering a set of // completion items. When `falsy` the label is used. - property filterText: string read fFilterText write fFilterText; + property filterText: TOptionalString read fFilterText write fFilterText; // A string that should be inserted into a document when selecting // this completion. When `falsy` the label is used. // @@ -209,7 +209,7 @@ TCompletionItem = class(TCollectionItem) // `insertText` of `console` is provided it will only insert // `sole`. Therefore it is recommended to use `textEdit` instead // since it avoids additional client side interpretation. - property insertText: string read fInsertText write fInsertText; + property insertText: TOptionalString read fInsertText write fInsertText; // The format of the insert text. The format applies to both the // `insertText` property and the `newText` property of a provided // `textEdit`. If omitted defaults to diff --git a/src/protocol/LSP.DocumentSymbol.pas b/src/protocol/LSP.DocumentSymbol.pas index 645dcf5..a479604 100644 --- a/src/protocol/LSP.DocumentSymbol.pas +++ b/src/protocol/LSP.DocumentSymbol.pas @@ -74,7 +74,7 @@ TDocumentSymbol = class; TDocumentSymbol = class(TCollectionItem) private fName: string; - fDetail: string; + fDetail: TOptionalString; fKind: TSymbolKind; fDeprecated: boolean; fRange: TRange; @@ -92,7 +92,7 @@ TDocumentSymbol = class(TCollectionItem) // an empty string or a string only consisting of white spaces. property name: string read fName write fName; // More detail for this symbol, e.g the signature of a function. - property detail: string read fDetail write fDetail; + property detail: TOptionalString read fDetail write fDetail; // The kind of this symbol. property kind: TSymbolKind read fKind write fKind; // Indicates if this symbol is deprecated. diff --git a/src/protocol/LSP.General.pas b/src/protocol/LSP.General.pas index bdc5985..98fe1c6 100644 --- a/src/protocol/LSP.General.pas +++ b/src/protocol/LSP.General.pas @@ -59,14 +59,14 @@ TVoidParams = class(TLSPStreamable); TClientInfo = class(TLSPStreamable) private fName: string; - fVersion: string; + fVersion: TOptionalString; Public Procedure Assign(aSource : TPersistent); override; published // The name of the client as defined by the client. property name: string read fName write fName; // The client's version as defined by the client. - property version: string read fVersion write fVersion; + property version: TOptionalString read fVersion write fVersion; end; diff --git a/src/protocol/LSP.InlayHint.pas b/src/protocol/LSP.InlayHint.pas index 4c14a80..b75b9f7 100644 --- a/src/protocol/LSP.InlayHint.pas +++ b/src/protocol/LSP.InlayHint.pas @@ -53,7 +53,7 @@ TInlayHint = class(TCollectionItem) fLabel: String; // string | InlayHintLabelPart[] (not supported now) fKind: TOptionalInlayHintKind; fTextEdits: TTextEdits; - fTooltip: String; + fTooltip: TOptionalString; public Constructor Create(ACollection: TCollection); override; published @@ -81,7 +81,7 @@ TInlayHint = class(TCollectionItem) // // Depending on the client capability `inlayHint.resolveSupport` clients // might resolve this property late using the resolve request. - property tooltip: String read fTooltip write fTooltip; + property tooltip: TOptionalString read fTooltip write fTooltip; public destructor Destroy; override; end; diff --git a/src/serverprotocol/PasLS.General.pas b/src/serverprotocol/PasLS.General.pas index 305e276..606f1d5 100644 --- a/src/serverprotocol/PasLS.General.pas +++ b/src/serverprotocol/PasLS.General.pas @@ -248,11 +248,17 @@ procedure TInitialize.CollectWorkSpacePaths(WorkspaceFolders: TWorkspaceFolderIt procedure TInitialize.ShowConfigStatus(Params: TInitializeParams; CodeToolsOptions: TCodeToolsOptions); var ExcludeList, Option: String; + clientInfoVersion: String; I: Integer; FPCOptions: TStringArray; begin + if Params.clientInfo.version.HasValue then + clientInfoVersion := ' ' + Params.clientInfo.version.Value + else + clientInfoVersion := ''; + DoLog(kStatusPrefix+'Server: ' + {$INCLUDE %DATE%}); - DoLog(kStatusPrefix+'Client: ' + Params.clientInfo.name + ' ' + Params.clientInfo.version); + DoLog(kStatusPrefix+'Client: ' + Params.clientInfo.name + clientInfoVersion); DoLog(kStatusPrefix+'FPCPath: ' + CodeToolsOptions.FPCPath); DoLog(kStatusPrefix+'FPCSrcDir: ' + CodeToolsOptions.FPCSrcDir); diff --git a/src/serverprotocol/lspserver.pas b/src/serverprotocol/lspserver.pas index 98ef08b..c4a1994 100644 --- a/src/serverprotocol/lspserver.pas +++ b/src/serverprotocol/lspserver.pas @@ -18,7 +18,6 @@ interface PasLS.DocumentSymbol, PasLS.Commands, PasLS.Formatter, PasLS.ExecuteCommand, PasLS.CodeUtils, PasLS.InvertAssign, PasLS.LazConfig, PasLS.Parser, PasLS.Symbols, PasLS.CheckInactiveRegions, PasLS.InactiveRegions, - PasLS.Command.RemoveUnusedUnits, PasLS.RemoveUnusedUnits, PasLS.Rename, LazarusPackageIntf; implementation