Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dape compatibility #95

Closed
wants to merge 2 commits into from
Closed
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
26 changes: 21 additions & 5 deletions src/DAPRPC/interface_def.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
end
) : nothing)

function $tname(_::Nothing)
$tname(Dict())

Check warning on line 64 in src/DAPRPC/interface_def.jl

View check run for this annotation

Codecov / codecov/patch

src/DAPRPC/interface_def.jl#L63-L64

Added lines #L63 - L64 were not covered by tests
end

function $tname(dict::Dict)
end
end
Expand All @@ -69,17 +73,29 @@
if !(field isa LineNumberNode)
fieldname = string(field.args[1])
fieldtype = field_type(field, string(tname))
val = :(dict[$fieldname])

if fieldtype isa Expr && fieldtype.head == :curly && fieldtype.args[1] == :Dict
f = :($fieldtype(dict[$fieldname]))
f = :($fieldtype($val))
elseif fieldtype isa Expr && fieldtype.head == :curly && fieldtype.args[2] != :Any
f = :($(fieldtype.args[2]).(dict[$fieldname]))
f = :($(fieldtype.args[2]).($val))
elseif fieldtype != :Any
f = :($(fieldtype)(dict[$fieldname]))
f = :($(fieldtype)($val))
else
f = :(dict[$fieldname])
f = val
end

if field_allows_missing(field)
f = :(haskey(dict, $fieldname) ? $f : missing)
f = :(if haskey(dict, $fieldname)
# We can still get a null value here, so we need to check for that.
if !isnothing($val)
$f
else
missing
end
else
missing
end)
end
push!(fex.args, f)
end
Expand Down
16 changes: 9 additions & 7 deletions src/DAPRPC/typed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,27 @@
else
error()
end
arg_key = request_type == :request ? "arguments" : "body"
arg = if haskey(msg, arg_key)
msg[arg_key]

Check warning on line 70 in src/DAPRPC/typed.jl

View check run for this annotation

Codecov / codecov/patch

src/DAPRPC/typed.jl#L68-L70

Added lines #L68 - L70 were not covered by tests
end
handler = get(dispatcher._handlers, method_name, nothing)
if handler !== nothing
param_type = get_param_type(handler.message_type)
params = if param_type === Nothing
nothing
elseif param_type isa Union
if param_type.a === Nothing || param_type.b === Nothing
if !haskey(msg, request_type == :request ? "arguments" : "body")
nothing
else
param_type(msg[request_type == :request ? "arguments" : "body"])
if !isnothing(arg)
param_type(arg)

Check warning on line 80 in src/DAPRPC/typed.jl

View check run for this annotation

Codecov / codecov/patch

src/DAPRPC/typed.jl#L79-L80

Added lines #L79 - L80 were not covered by tests
end
else
param_type(msg[request_type == :request ? "arguments" : "body"])
param_type(arg)

Check warning on line 83 in src/DAPRPC/typed.jl

View check run for this annotation

Codecov / codecov/patch

src/DAPRPC/typed.jl#L83

Added line #L83 was not covered by tests
end
elseif param_type <: NamedTuple
convert(param_type,(;(Symbol(i[1])=>i[2] for i in msg[request_type == :request ? "arguments" : "body"])...))
convert(param_type,(;(Symbol(i[1])=>i[2] for i in arg)...))

Check warning on line 86 in src/DAPRPC/typed.jl

View check run for this annotation

Codecov / codecov/patch

src/DAPRPC/typed.jl#L86

Added line #L86 was not covered by tests
else
param_type(msg[request_type == :request ? "arguments" : "body"])
param_type(arg)

Check warning on line 88 in src/DAPRPC/typed.jl

View check run for this annotation

Codecov / codecov/patch

src/DAPRPC/typed.jl#L88

Added line #L88 was not covered by tests
end

res = handler.func(params)
Expand Down
32 changes: 1 addition & 31 deletions src/debugger_requests.jl
Original file line number Diff line number Diff line change
@@ -1,37 +1,7 @@
# Request handlers

function initialize_request(debug_session::DebugSession, params::InitializeRequestArguments)
return Capabilities(
true, # supportsConfigurationDoneRequest::Union{Missing,Bool}
true, # supportsFunctionBreakpoints::Union{Missing,Bool}
true, #supportsConditionalBreakpoints::Union{Missing,Bool}
false, # supportsHitConditionalBreakpoints::Union{Missing,Bool}
true, # supportsEvaluateForHovers::Union{Missing,Bool}
ExceptionBreakpointsFilter[ExceptionBreakpointsFilter("error", "Uncaught Exceptions", true), ExceptionBreakpointsFilter("throw", "All Exceptions", false)], # exceptionBreakpointFilters::Vector{ExceptionBreakpointsFilter}
false, # supportsStepBack::Union{Missing,Bool}
true, # supportsSetVariable::Union{Missing,Bool}
true, # supportsRestartFrame::Union{Missing,Bool}
missing, # supportsGotoTargetsRequest::Union{Missing,Bool}
true, # supportsStepInTargetsRequest::Union{Missing,Bool}
false, # supportsCompletionsRequest::Union{Missing,Bool}
missing, # supportsModulesRequest::Union{Missing,Bool}
ColumnDescriptor[], #additionalModuleColumns::Vector{ColumnDescriptor}
ChecksumAlgorithm[], # supportedChecksumAlgorithms::Vector{ChecksumAlgorithm}
missing, # supportsRestartRequest::Union{Missing,Bool}
missing, # supportsExceptionOptions::Union{Missing,Bool}
missing, #supportsValueFormattingOptions::Union{Missing,Bool}
true, # supportsExceptionInfoRequest::Union{Missing,Bool}
missing, # supportTerminateDebuggee::Union{Missing,Bool}
missing, # supportsDelayedStackTraceLoading::Union{Missing,Bool}
missing, # supportsLoadedSourcesRequest::Union{Missing,Bool}
false, # supportsLogPoints::Union{Missing,Bool}
missing, # supportsTerminateThreadsRequest::Union{Missing,Bool}
missing, #supportsSetExpression::Union{Missing,Bool}
true, # supportsTerminateRequest::Union{Missing,Bool}
false, # supportsDataBreakpoints::Union{Missing,Bool}
missing, # supportsReadMemoryRequest::Union{Missing,Bool}
missing # supportsDisassembleRequest::Union{Missing,Bool}
)
debug_session.capabilities

Check warning on line 4 in src/debugger_requests.jl

View check run for this annotation

Codecov / codecov/patch

src/debugger_requests.jl#L4

Added line #L4 was not covered by tests

# response.body.supportsCancelRequest = false

Expand Down
38 changes: 37 additions & 1 deletion src/packagedef.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,40 @@
value
end

function capabilities()
Capabilities(

Check warning on line 24 in src/packagedef.jl

View check run for this annotation

Codecov / codecov/patch

src/packagedef.jl#L23-L24

Added lines #L23 - L24 were not covered by tests
true, # supportsConfigurationDoneRequest::Union{Missing,Bool}
true, # supportsFunctionBreakpoints::Union{Missing,Bool}
true, #supportsConditionalBreakpoints::Union{Missing,Bool}
false, # supportsHitConditionalBreakpoints::Union{Missing,Bool}
true, # supportsEvaluateForHovers::Union{Missing,Bool}
ExceptionBreakpointsFilter[ExceptionBreakpointsFilter("error", "Uncaught Exceptions", true), ExceptionBreakpointsFilter("throw", "All Exceptions", false)], # exceptionBreakpointFilters::Vector{ExceptionBreakpointsFilter}
false, # supportsStepBack::Union{Missing,Bool}
true, # supportsSetVariable::Union{Missing,Bool}
true, # supportsRestartFrame::Union{Missing,Bool}
missing, # supportsGotoTargetsRequest::Union{Missing,Bool}
true, # supportsStepInTargetsRequest::Union{Missing,Bool}
false, # supportsCompletionsRequest::Union{Missing,Bool}
missing, # supportsModulesRequest::Union{Missing,Bool}
ColumnDescriptor[], #additionalModuleColumns::Vector{ColumnDescriptor}
ChecksumAlgorithm[], # supportedChecksumAlgorithms::Vector{ChecksumAlgorithm}
missing, # supportsRestartRequest::Union{Missing,Bool}
missing, # supportsExceptionOptions::Union{Missing,Bool}
missing, #supportsValueFormattingOptions::Union{Missing,Bool}
true, # supportsExceptionInfoRequest::Union{Missing,Bool}
missing, # supportTerminateDebuggee::Union{Missing,Bool}
missing, # supportsDelayedStackTraceLoading::Union{Missing,Bool}
missing, # supportsLoadedSourcesRequest::Union{Missing,Bool}
false, # supportsLogPoints::Union{Missing,Bool}
missing, # supportsTerminateThreadsRequest::Union{Missing,Bool}
missing, #supportsSetExpression::Union{Missing,Bool}
true, # supportsTerminateRequest::Union{Missing,Bool}
false, # supportsDataBreakpoints::Union{Missing,Bool}
missing, # supportsReadMemoryRequest::Union{Missing,Bool}
missing # supportsDisassembleRequest::Union{Missing,Bool}
)
end

mutable struct DebugSession
conn
endpoint::Union{Nothing,DAPRPC.DAPEndpoint}
Expand All @@ -37,6 +71,7 @@
compiled_modules_or_functions::Vector{String}
compiled_mode::Bool
stop_on_entry::Bool
capabilities::Capabilities

function DebugSession(conn)
return new(
Expand All @@ -51,7 +86,8 @@
[],
String[],
false,
false
false,
capabilities()
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ end
width::Union{Missing,Int}
end

@dict_readable struct Capabilities <: Outbound
@dict_readable mutable struct Capabilities <: Outbound
supportsConfigurationDoneRequest::Union{Missing,Bool}
supportsFunctionBreakpoints::Union{Missing,Bool}
supportsConditionalBreakpoints::Union{Missing,Bool}
Expand Down
Loading