Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/protocol/LSP.Base.pas
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ TLSPLocalDispatcher = class(TLSPBaseDispatcher)
Class function GetLogFile: String; static;
procedure SetDispatcher(AValue: TLSPBaseDispatcher);
Class procedure SetLogFile(const AValue: String); static;
class procedure RemoveEmptyStringKeys(AData: TJSONData); static;
Protected
Class Procedure DoLog(const Msg : String);
Class Procedure DoLog(const Fmt : String; Const Args : Array of const);
Expand Down Expand Up @@ -556,13 +557,53 @@ class function TLSPContext.HaveLog: Boolean;
Result:=assigned(_LogFile);
end;


class procedure TLSPContext.RemoveEmptyStringKeys(AData: TJSONData);
var
i: Integer;
Child: TJSONData;
Obj: TJSONObject;
Arr: TJSONArray;
begin
if AData = nil then Exit;

case AData.JSONType of
jtObject:
begin
Obj := TJSONObject(AData);
for i := Obj.Count - 1 downto 0 do
begin
Child := Obj.Items[i];

if (Child.JSONType = jtString) and (Child.AsString = '') then
begin
if (Obj.Names[I] = 'sortText') or (Obj.Names[I] = 'filterText') or
(Obj.Names[I] = 'insertText') then
Obj.Delete(i);
end else
RemoveEmptyStringKeys(Child);
end;
end;

jtArray:
begin
Arr := TJSONArray(AData);
for i := 0 to Arr.Count - 1 do
RemoveEmptyStringKeys(Arr.Items[i]);
end;
end;
end;

function TLSPContext.Execute(aRequest: TJSONData): TJSONData;

begin
If HaveLog then
DoLog('Executing request: %s',[aRequest.AsJSON]);
try
Result:=Dispatcher.ExecuteRequest(aRequest);

TLSPContext.RemoveEmptyStringKeys(Result);

If HaveLog then
if Result<>Nil then
DoLog('Request response: %s',[Result.AsJSON])
Expand Down
6 changes: 6 additions & 0 deletions src/serverprotocol/PasLS.Completion.pas
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function TCompletion.Process(var Params: TCompletionParams): TCompletionList;
Identifier: TIdentifierListItem;
Completion: TCompletionItem;
OverloadMap: TFPHashList;
TextEdit: TTextEdit;
IdentContext, IdentDetails: ShortString;
ObjectMember: boolean;
Kind: TCompletionItemKind;
Expand Down Expand Up @@ -224,6 +225,11 @@ function TCompletion.Process(var Params: TCompletionParams): TCompletionList;

Completion := Completions.Add;
Completion.&label := Identifier.Identifier;
Completion.insertTextFormat := TInsertTextFormat.PlainText;
TextEdit := TTextEdit.Create(nil);
TextEdit.newText := Identifier.Identifier;
TextEdit.range.SetRange(Y, PStart - 1, Length(CodeToolBoss.IdentifierList.Prefix));
Completion.SetTextEdit(TextEdit);
if not ServerSettings.minimalisticCompletions then
Completion.detail := IdentDetails;
Completion.kind := Kind;
Expand Down