Skip to content

Commit 8d8bbbe

Browse files
authored
Format files using DocumentFormat
1 parent 2079986 commit 8d8bbbe

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

src/core.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const RPCErrorStrings = Base.IdDict(
8787
METHOD_NOT_FOUND => "MethodNotFound",
8888
INVALID_PARAMS => "InvalidParams",
8989
INTERNAL_ERROR => "InternalError",
90-
[ i => "ServerError" for i in SERVER_ERROR_START:SERVER_ERROR_END]...,
90+
[i => "ServerError" for i in SERVER_ERROR_START:SERVER_ERROR_END]...,
9191
-32002 => "ServerNotInitialized",
9292
-32001 => "UnknownErrorCode",
9393
)
@@ -105,7 +105,7 @@ function Base.showerror(io::IO, ex::JSONRPCError)
105105
end
106106
end
107107

108-
mutable struct JSONRPCEndpoint{IOIn <: IO,IOOut <: IO}
108+
mutable struct JSONRPCEndpoint{IOIn<:IO,IOOut<:IO}
109109
pipe_in::IOIn
110110
pipe_out::IOOut
111111

@@ -122,7 +122,7 @@ mutable struct JSONRPCEndpoint{IOIn <: IO,IOOut <: IO}
122122
write_task::Union{Nothing,Task}
123123
end
124124

125-
JSONRPCEndpoint(pipe_in, pipe_out, err_handler = nothing) =
125+
JSONRPCEndpoint(pipe_in, pipe_out, err_handler=nothing) =
126126
JSONRPCEndpoint(pipe_in, pipe_out, Channel{Any}(Inf), Channel{Any}(Inf), Dict{String,Channel{Any}}(), err_handler, :idle, nothing, nothing)
127127

128128
function write_transport_layer(stream, response)
@@ -213,7 +213,7 @@ function Base.run(x::JSONRPCEndpoint)
213213
put!(channel_for_response, message_dict)
214214
end
215215
end
216-
216+
217217
close(x.in_msg_queue)
218218

219219
for i in values(x.outstanding_requests)
@@ -280,7 +280,7 @@ function get_next_message(endpoint::JSONRPCEndpoint)
280280
return msg
281281
end
282282

283-
function Base.iterate(endpoint::JSONRPCEndpoint, state = nothing)
283+
function Base.iterate(endpoint::JSONRPCEndpoint, state=nothing)
284284
check_dead_endpoint!(endpoint)
285285

286286
try

src/interface_def.jl

Lines changed: 5 additions & 5 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 6 additions & 6 deletions
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)