From a955809cd9aefae8108b2eef61a9f48f97539398 Mon Sep 17 00:00:00 2001
From: davidanthoff <1036561+davidanthoff@users.noreply.github.com>
Date: Sat, 7 Sep 2024 22:54:14 +0000
Subject: [PATCH] Format files using DocumentFormat

---
 src/core.jl                | 10 +++++-----
 src/interface_def.jl       | 12 ++++++------
 src/typed.jl               | 14 +++++++-------
 test/shared_test_code.jl   |  2 +-
 test/test_interface_def.jl | 12 ++++++------
 test/test_typed.jl         | 18 +++++++++---------
 6 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/src/core.jl b/src/core.jl
index 81152ecb..7ff35149 100644
--- a/src/core.jl
+++ b/src/core.jl
@@ -87,7 +87,7 @@ const RPCErrorStrings = Base.IdDict(
     METHOD_NOT_FOUND => "MethodNotFound",
     INVALID_PARAMS => "InvalidParams",
     INTERNAL_ERROR => "InternalError",
-    [ i => "ServerError" for i in SERVER_ERROR_START:SERVER_ERROR_END]...,
+    [i => "ServerError" for i in SERVER_ERROR_START:SERVER_ERROR_END]...,
     -32002 => "ServerNotInitialized",
     -32001 => "UnknownErrorCode",
 )
@@ -105,7 +105,7 @@ function Base.showerror(io::IO, ex::JSONRPCError)
     end
 end
 
-mutable struct JSONRPCEndpoint{IOIn <: IO,IOOut <: IO}
+mutable struct JSONRPCEndpoint{IOIn<:IO,IOOut<:IO}
     pipe_in::IOIn
     pipe_out::IOOut
 
@@ -122,7 +122,7 @@ mutable struct JSONRPCEndpoint{IOIn <: IO,IOOut <: IO}
     write_task::Union{Nothing,Task}
 end
 
-JSONRPCEndpoint(pipe_in, pipe_out, err_handler = nothing) =
+JSONRPCEndpoint(pipe_in, pipe_out, err_handler=nothing) =
     JSONRPCEndpoint(pipe_in, pipe_out, Channel{Any}(Inf), Channel{Any}(Inf), Dict{String,Channel{Any}}(), err_handler, :idle, nothing, nothing)
 
 function write_transport_layer(stream, response)
@@ -213,7 +213,7 @@ function Base.run(x::JSONRPCEndpoint)
                 put!(channel_for_response, message_dict)
             end
         end
-        
+
         close(x.in_msg_queue)
 
         for i in values(x.outstanding_requests)
@@ -280,7 +280,7 @@ function get_next_message(endpoint::JSONRPCEndpoint)
     return msg
 end
 
-function Base.iterate(endpoint::JSONRPCEndpoint, state = nothing)
+function Base.iterate(endpoint::JSONRPCEndpoint, state=nothing)
     check_dead_endpoint!(endpoint)
 
     try
diff --git a/src/interface_def.jl b/src/interface_def.jl
index 0e047f99..5945dfcd 100644
--- a/src/interface_def.jl
+++ b/src/interface_def.jl
@@ -23,8 +23,8 @@ end
 
 function field_allows_missing(field::Expr)
     field.head == :(::) && field.args[2] isa Expr &&
-    field.args[2].head == :curly && field.args[2].args[1] == :Union &&
-    any(i -> i == :Missing, field.args[2].args)
+        field.args[2].head == :curly && field.args[2].args[1] == :Union &&
+        any(i -> i == :Missing, field.args[2].args)
 end
 
 function field_type(field::Expr, typename::String)
@@ -55,9 +55,9 @@ macro dict_readable(arg)
         $((arg))
 
         $(count_real_fields > 0 ? :(
-        function $tname(; $((get_kwsignature_for_field(field) for field in arg.args[3].args if !(field isa LineNumberNode))...))
-            $tname($((field.args[1] for field in arg.args[3].args if !(field isa LineNumberNode))...))
-        end
+            function $tname(; $((get_kwsignature_for_field(field) for field in arg.args[3].args if !(field isa LineNumberNode))...))
+                $tname($((field.args[1] for field in arg.args[3].args if !(field isa LineNumberNode))...))
+            end
         ) : nothing)
 
         function $tname(dict::Dict)
@@ -69,7 +69,7 @@ macro dict_readable(arg)
         if !(field isa LineNumberNode)
             fieldname = string(field.args[1])
             fieldtype = field_type(field, string(tname))
-            if fieldtype isa Expr && fieldtype.head == :curly && length(fieldtype.args)==3 && fieldtype.args[1]==:Dict
+            if fieldtype isa Expr && fieldtype.head == :curly && length(fieldtype.args) == 3 && fieldtype.args[1] == :Dict
                 f = :($(fieldtype)(i for i in pairs(dict[$fieldname])))
             elseif fieldtype isa Expr && fieldtype.head == :curly && fieldtype.args[2] != :Any
                 f = :($(fieldtype.args[2]).(dict[$fieldname]))
diff --git a/src/typed.jl b/src/typed.jl
index 72e22bc3..3cdffe6a 100644
--- a/src/typed.jl
+++ b/src/typed.jl
@@ -29,7 +29,7 @@ end
 # so that we get an error in the typecast at the end of `send`
 # if that is not the case.
 typed_res(res, TR::Type{Nothing}) = res
-typed_res(res, TR::Type{<:T}) where {T <: AbstractArray{Any}} = T(res)
+typed_res(res, TR::Type{<:T}) where {T<:AbstractArray{Any}} = T(res)
 typed_res(res, TR::Type{<:AbstractArray{T}}) where T = T.(res)
 typed_res(res, TR::Type) = TR(res)
 
@@ -62,7 +62,7 @@ function dispatch_msg(x::JSONRPCEndpoint, dispatcher::MsgDispatcher, msg)
         handler = get(dispatcher._handlers, method_name, nothing)
         if handler !== nothing
             param_type = get_param_type(handler.message_type)
-            params = param_type === Nothing ? nothing : param_type <: NamedTuple ? convert(param_type,(;(Symbol(i[1])=>i[2] for i in msg["params"])...)) : param_type(msg["params"])
+            params = param_type === Nothing ? nothing : param_type <: NamedTuple ? convert(param_type, (; (Symbol(i[1]) => i[2] for i in msg["params"])...)) : param_type(msg["params"])
 
             res = handler.func(x, params)
 
@@ -73,7 +73,7 @@ function dispatch_msg(x::JSONRPCEndpoint, dispatcher::MsgDispatcher, msg)
                     send_success_response(x, msg, res)
                 else
                     error_msg = "The handler for the '$method_name' request returned a value of type $(typeof(res)), which is not a valid return type according to the request definition."
-                    send_error_response(x, msg, -32603, error_msg, nothing)                    
+                    send_error_response(x, msg, -32603, error_msg, nothing)
                     error(error_msg)
                 end
             end
@@ -97,9 +97,9 @@ macro message_dispatcher(name, body)
                     :(
                         if method_name == $(esc(i.args[2])).method
                             param_type = get_param_type($(esc(i.args[2])))
-                            params = param_type === Nothing ? nothing : param_type <: NamedTuple ? convert(param_type,(;(Symbol(i[1])=>i[2] for i in msg["params"])...)) : param_type(msg["params"])
+                            params = param_type === Nothing ? nothing : param_type <: NamedTuple ? convert(param_type, (; (Symbol(i[1]) => i[2] for i in msg["params"])...)) : param_type(msg["params"])
 
-                            if context===nothing
+                            if context === nothing
                                 res = $(esc(i.args[3]))(x, params)
                             else
                                 res = $(esc(i.args[3]))(x, params, context)
@@ -112,14 +112,14 @@ macro message_dispatcher(name, body)
                                     send_success_response(x, msg, res)
                                 else
                                     error_msg = "The handler for the '$method_name' request returned a value of type $(typeof(res)), which is not a valid return type according to the request definition."
-                                    send_error_response(x, msg, -32603, error_msg, nothing)                    
+                                    send_error_response(x, msg, -32603, error_msg, nothing)
                                     error(error_msg)
                                 end
                             end
 
                             return
                         end
-                    ) for i in filter(i->i isa Expr, body.args)
+                    ) for i in filter(i -> i isa Expr, body.args)
                 )...
             )
 
diff --git a/test/shared_test_code.jl b/test/shared_test_code.jl
index a40f1904..684f556e 100644
--- a/test/shared_test_code.jl
+++ b/test/shared_test_code.jl
@@ -15,6 +15,6 @@
         fieldB::Vector{Int}
     end
 
-    Base.:(==)(a::Foo2,b::Foo2) = a.fieldA == b.fieldA && a.fieldB == b.fieldB
+    Base.:(==)(a::Foo2, b::Foo2) = a.fieldA == b.fieldA && a.fieldB == b.fieldB
 
 end
diff --git a/test/test_interface_def.jl b/test/test_interface_def.jl
index 43ee29d2..cbc9f928 100644
--- a/test/test_interface_def.jl
+++ b/test/test_interface_def.jl
@@ -1,7 +1,7 @@
-@testitem "Interface Definition" setup=[TestStructs] begin
+@testitem "Interface Definition" setup = [TestStructs] begin
     using JSON
     using .TestStructs: Foo, Foo2
-    
+
     @test_throws ErrorException Foo()
 
     a = Foo(fieldA=1, fieldB="A")
@@ -21,14 +21,14 @@
     @test Foo(JSON.parse(JSON.json(a))) == a
     @test Foo(JSON.parse(JSON.json(b))) == b
 
-    c = Foo2(fieldA=nothing, fieldB=[1,2])
+    c = Foo2(fieldA=nothing, fieldB=[1, 2])
 
     @test c.fieldA === nothing
-    @test c.fieldB == [1,2]
+    @test c.fieldB == [1, 2]
     @test Foo2(JSON.parse(JSON.json(c))) == c
 
-    d = Foo2(fieldA=3, fieldB=[1,2])
+    d = Foo2(fieldA=3, fieldB=[1, 2])
     @test d.fieldA === 3
-    @test d.fieldB == [1,2]
+    @test d.fieldB == [1, 2]
     @test Foo2(JSON.parse(JSON.json(d))) == d
 end
diff --git a/test/test_typed.jl b/test/test_typed.jl
index d2c88bd2..b5f065d0 100644
--- a/test/test_typed.jl
+++ b/test/test_typed.jl
@@ -1,4 +1,4 @@
-@testitem "Dynamic message dispatcher" setup=[TestStructs] begin
+@testitem "Dynamic message dispatcher" setup = [TestStructs] begin
     using Sockets
     using .TestStructs: Foo, Foo2
 
@@ -70,7 +70,7 @@
         global conn = JSONRPC.JSONRPCEndpoint(sock, sock)
         global msg_dispatcher = JSONRPC.MsgDispatcher()
 
-        msg_dispatcher[request2_type] = (conn, params)->34 # The request type requires a `String` return, so this tests whether we get an error.
+        msg_dispatcher[request2_type] = (conn, params) -> 34 # The request type requires a `String` return, so this tests whether we get an error.
 
         run(conn)
 
@@ -100,19 +100,19 @@ end
 
 @testitem "check response type" begin
     using JSONRPC: typed_res
-    
+
     @test typed_res(nothing, Nothing) isa Nothing
-    @test typed_res([1,"2",3], Vector{Any}) isa Vector{Any}
-    @test typed_res([1,2,3], Vector{Int}) isa Vector{Int}
-    @test typed_res([1,2,3], Vector{Float64}) isa Vector{Float64}
-    @test typed_res(['f','o','o'], String) isa String
+    @test typed_res([1, "2", 3], Vector{Any}) isa Vector{Any}
+    @test typed_res([1, 2, 3], Vector{Int}) isa Vector{Int}
+    @test typed_res([1, 2, 3], Vector{Float64}) isa Vector{Float64}
+    @test typed_res(['f', 'o', 'o'], String) isa String
     @test typed_res("foo", String) isa String
 end
 
-@testitem "Static message dispatcher" setup=[TestStructs] begin
+@testitem "Static message dispatcher" setup = [TestStructs] begin
     using Sockets
     using .TestStructs: Foo, Foo2
-    
+
     global_socket_name1 = JSONRPC.generate_pipe_name()
 
     request1_type = JSONRPC.RequestType("request1", Foo, String)