Skip to content

Commit 1a48fb0

Browse files
authored
Format files using DocumentFormat
1 parent 08dee4f commit 1a48fb0

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

src/core.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Base.showerror(io::IO, ex::JSONRPCError)
2525
"UnknownErrorCode"
2626
elseif ex.code == -32800
2727
"RequestCancelled"
28-
elseif ex.code == -32801
28+
elseif ex.code == -32801
2929
"ContentModified"
3030
else
3131
"Unkonwn"
@@ -41,7 +41,7 @@ function Base.showerror(io::IO, ex::JSONRPCError)
4141
end
4242
end
4343

44-
mutable struct JSONRPCEndpoint{IOIn <: IO,IOOut <: IO}
44+
mutable struct JSONRPCEndpoint{IOIn<:IO,IOOut<:IO}
4545
pipe_in::IOIn
4646
pipe_out::IOOut
4747

@@ -58,7 +58,7 @@ mutable struct JSONRPCEndpoint{IOIn <: IO,IOOut <: IO}
5858
write_task::Union{Nothing,Task}
5959
end
6060

61-
JSONRPCEndpoint(pipe_in, pipe_out, err_handler = nothing) =
61+
JSONRPCEndpoint(pipe_in, pipe_out, err_handler=nothing) =
6262
JSONRPCEndpoint(pipe_in, pipe_out, Channel{Any}(Inf), Channel{Any}(Inf), Dict{String,Channel{Any}}(), err_handler, :idle, nothing, nothing)
6363

6464
function write_transport_layer(stream, response)
@@ -208,7 +208,7 @@ function get_next_message(endpoint::JSONRPCEndpoint)
208208
return msg
209209
end
210210

211-
function Base.iterate(endpoint::JSONRPCEndpoint, state = nothing)
211+
function Base.iterate(endpoint::JSONRPCEndpoint, state=nothing)
212212
check_dead_endpoint!(endpoint)
213213

214214
try

src/interface_def.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ end
2323

2424
function field_allows_missing(field::Expr)
2525
field.head == :(::) && field.args[2] isa Expr &&
26-
field.args[2].head == :curly && field.args[2].args[1] == :Union &&
27-
any(i -> i == :Missing, field.args[2].args)
26+
field.args[2].head == :curly && field.args[2].args[1] == :Union &&
27+
any(i -> i == :Missing, field.args[2].args)
2828
end
2929

3030
function field_type(field::Expr, typename::String)
@@ -55,9 +55,9 @@ macro dict_readable(arg)
5555
$((arg))
5656

5757
$(count_real_fields > 0 ? :(
58-
function $tname(; $((get_kwsignature_for_field(field) for field in arg.args[3].args if !(field isa LineNumberNode))...))
59-
$tname($((field.args[1] for field in arg.args[3].args if !(field isa LineNumberNode))...))
60-
end
58+
function $tname(; $((get_kwsignature_for_field(field) for field in arg.args[3].args if !(field isa LineNumberNode))...))
59+
$tname($((field.args[1] for field in arg.args[3].args if !(field isa LineNumberNode))...))
60+
end
6161
) : nothing)
6262

6363
function $tname(dict::Dict)

src/typed.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ end
2929
# so that we get an error in the typecast at the end of `send`
3030
# if that is not the case.
3131
typed_res(res, TR::Type{Nothing}) = res
32-
typed_res(res, TR::Type{<:T}) where {T <: AbstractArray{Any}} = T(res)
32+
typed_res(res, TR::Type{<:T}) where {T<:AbstractArray{Any}} = T(res)
3333
typed_res(res, TR::Type{<:AbstractArray{T}}) where T = T.(res)
3434
typed_res(res, TR::Type) = TR(res)
3535

@@ -62,7 +62,7 @@ function dispatch_msg(x::JSONRPCEndpoint, dispatcher::MsgDispatcher, msg)
6262
handler = get(dispatcher._handlers, method_name, nothing)
6363
if handler !== nothing
6464
param_type = get_param_type(handler.message_type)
65-
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"])
65+
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"])
6666

6767
res = handler.func(x, params)
6868

@@ -73,7 +73,7 @@ function dispatch_msg(x::JSONRPCEndpoint, dispatcher::MsgDispatcher, msg)
7373
send_success_response(x, msg, res)
7474
else
7575
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."
76-
send_error_response(x, msg, -32603, error_msg, nothing)
76+
send_error_response(x, msg, -32603, error_msg, nothing)
7777
error(error_msg)
7878
end
7979
end

test/shared_test_code.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ end
1212
fieldB::Vector{Int}
1313
end
1414

15-
Base.:(==)(a::Foo2,b::Foo2) = a.fieldA == b.fieldA && a.fieldB == b.fieldB
15+
Base.:(==)(a::Foo2, b::Foo2) = a.fieldA == b.fieldA && a.fieldB == b.fieldB

test/test_interface_def.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@testitem "Interface Definition" begin
22
using JSON
33
include("shared_test_code.jl")
4-
4+
55
@test_throws ErrorException Foo()
66

77
a = Foo(fieldA=1, fieldB="A")
@@ -21,14 +21,14 @@
2121
@test Foo(JSON.parse(JSON.json(a))) == a
2222
@test Foo(JSON.parse(JSON.json(b))) == b
2323

24-
c = Foo2(fieldA=nothing, fieldB=[1,2])
24+
c = Foo2(fieldA=nothing, fieldB=[1, 2])
2525

2626
@test c.fieldA === nothing
27-
@test c.fieldB == [1,2]
27+
@test c.fieldB == [1, 2]
2828
@test Foo2(JSON.parse(JSON.json(c))) == c
2929

30-
d = Foo2(fieldA=3, fieldB=[1,2])
30+
d = Foo2(fieldA=3, fieldB=[1, 2])
3131
@test d.fieldA === 3
32-
@test d.fieldB == [1,2]
32+
@test d.fieldB == [1, 2]
3333
@test Foo2(JSON.parse(JSON.json(d))) == d
3434
end

test/test_typed.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
global conn = JSONRPC.JSONRPCEndpoint(sock, sock)
8484
global msg_dispatcher = JSONRPC.MsgDispatcher()
8585

86-
msg_dispatcher[request2_type] = (conn, params)->34 # The request type requires a `String` return, so this tests whether we get an error.
86+
msg_dispatcher[request2_type] = (conn, params) -> 34 # The request type requires a `String` return, so this tests whether we get an error.
8787

8888
run(conn)
8989

@@ -113,11 +113,11 @@ end
113113

114114
@testitem "check response type" begin
115115
using JSONRPC: typed_res
116-
116+
117117
@test typed_res(nothing, Nothing) isa Nothing
118-
@test typed_res([1,"2",3], Vector{Any}) isa Vector{Any}
119-
@test typed_res([1,2,3], Vector{Int}) isa Vector{Int}
120-
@test typed_res([1,2,3], Vector{Float64}) isa Vector{Float64}
121-
@test typed_res(['f','o','o'], String) isa String
118+
@test typed_res([1, "2", 3], Vector{Any}) isa Vector{Any}
119+
@test typed_res([1, 2, 3], Vector{Int}) isa Vector{Int}
120+
@test typed_res([1, 2, 3], Vector{Float64}) isa Vector{Float64}
121+
@test typed_res(['f', 'o', 'o'], String) isa String
122122
@test typed_res("foo", String) isa String
123123
end

0 commit comments

Comments
 (0)