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

UI for setting compiled funcs/mods #1888

Merged
merged 11 commits into from May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
171 changes: 171 additions & 0 deletions package.json
Expand Up @@ -254,6 +254,57 @@
{
"command": "language-julia.activateFromDir",
"title": "Julia: Activate Parent Environment"
},
{
"command": "language-julia.switchToInterpreted",
"title": "Remove from compiled modules/functions",
"icon": "$(remove)"
},
{
"command": "language-julia.switchToCompiled",
"title": "Julia: Add to compiled modules/functions",
"icon": "$(add)"
},
{
"command": "language-julia.switchAllToInterpreted",
"title": "Julia: Switch all to interpreted"
},
{
"command": "language-julia.switchAllToCompiled",
"title": "Julia: Switch all to compiled",
"icon": "$(diff-added)"
},
{
"command": "language-julia.apply-compiled-defaults",
"title": "Julia: Apply default compiled modules/functions"
},
{
"command": "language-julia.reset-compiled",
"title": "Julia: Clear compiled modules/functions",
"icon": "$(remove)"
},
{
"command": "language-julia.refreshCompiled",
"title": "Julia: Refresh Compiled/Interpreted Pane"
},
{
"command": "language-julia.set-compiled-for-name",
"title": "Julia: Add symbol to compiled modules/functions",
"icon": "$(add)"
},
{
"command": "language-julia.set-current-as-default-compiled",
"title": "Julia: Set current compiled modules/functions as default"
},
{
"command": "language-julia.enable-compiled-mode",
"title": "Julia: Enable Compiled Mode for the debugger",
"icon": "$(debug-breakpoint)"
},
{
"command": "language-julia.disable-compiled-mode",
"title": "Julia: Disable Compiled Mode for the debugger",
"icon": "$(debug-breakpoint-unverified)"
}
],
"menus": {
Expand Down Expand Up @@ -374,6 +425,26 @@
"command": "language-julia.showInVSCode",
"when": "view == REPLVariables && viewItem == globalvariable",
"group": "inline"
},
{
"command": "language-julia.switchToInterpreted",
"when": "view == debugger-compiled && viewItem =~ /\\bcompiled\\b/",
"group": "inline@1"
},
{
"command": "language-julia.switchToCompiled",
"when": "view == debugger-compiled && viewItem =~ /\\binterpreted\\b/",
"group": "inline@1"
},
{
"command": "language-julia.switchAllToCompiled",
"when": "view == debugger-compiled && viewItem =~ /\\binterpreted\\b/ && viewItem =~ /\\bhasChildren\\b/",
"group": "inline@2"
},
{
"command": "language-julia.reset-compiled",
"when": "view == debugger-compiled && viewItem == isRootCompiled",
"group": "inline"
}
],
"view/title": [
Expand All @@ -386,6 +457,36 @@
"command": "language-julia.browse-forward-documentation",
"when": "view == julia-documentation",
"group": "navigation"
},
{
"command": "language-julia.apply-compiled-defaults",
"when": "view == debugger-compiled",
"group": "menu"
},
{
"command": "language-julia.reset-compiled",
"when": "view == debugger-compiled",
"group": "menu"
},
{
"command": "language-julia.set-current-as-default-compiled",
"when": "view == debugger-compiled",
"group": "menu"
},
{
"command": "language-julia.set-compiled-for-name",
"when": "view == debugger-compiled",
"group": "navigation"
},
{
"command": "language-julia.disable-compiled-mode",
"when": "view == debugger-compiled && juliaCompiledMode == true",
"group": "navigation"
},
{
"command": "language-julia.enable-compiled-mode",
"when": "view == debugger-compiled && juliaCompiledMode == false",
"group": "navigation"
}
],
"editor/context": [
Expand Down Expand Up @@ -789,6 +890,69 @@
"default": "test/runtests.jl",
"description": "A workspace relative path to a Julia file that contains the tests that should be run for live testing.",
"scope": "window"
},
"julia.debuggerDefaultCompiled": {
"type": "array",
"default": [
"Base.",
"-Base.!",
"-Base.all",
"-Base.all!",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these by defining module, or by namespace module?
i.e. will this also compile my overoads of Base.map(f, ::MyType) etc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are for all methods of that function, so -Base.map will force interpreted mode for all overloads.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should look into working out how to do it by definitition location, but that can be a follow up PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this list could be method based instead of function based, but I'm not sure whether that's particularly useful.

"-Base.any",
"-Base.any!",
"-Base.cd",
"-Base.iterate",
"-Base.collect",
"-Base.collect_similar",
"-Base._collect",
"-Base.collect_to!",
"-Base.collect_to_with_first!",
"-Base.filter",
"-Base.filter!",
"-Base.foreach",
"-Base.findall",
"-Base.findfirst",
"-Base.findlast",
"-Base.findnext",
"-Base.findprev",
pfitzseb marked this conversation as resolved.
Show resolved Hide resolved
"-Base.Generator",
"-Base.map",
"-Base.map!",
"-Base.maximum!",
"-Base.minimum!",
"-Base.mktemp",
"-Base.mktempdir",
"-Base.open",
"-Base.prod!",
"-Base.redirect_stderr",
"-Base.redirect_stdin",
"-Base.redirect_stdout",
"-Base.reenable_sigint",
"-Base.setindex!",
"-Base.setprecision",
"-Base.setrounding",
"-Base.show",
"-Base.sprint",
"-Base.sum",
"-Base.sum!",
pfitzseb marked this conversation as resolved.
Show resolved Hide resolved
"-Base.task_local_storage",
"-Base.timedwait",
"-Base.withenv",
"Core",
"Core.Compiler.",
"Core.IR",
"Core.Intrinsics",
"DelimitedFiles",
"Distributed",
"LinearAlgebra.",
"Serialization",
pfitzseb marked this conversation as resolved.
Show resolved Hide resolved
"Statistics",
"-Statistics.mean",
"SparseArrays",
"Mmap"
],
"description": "Functions or modules that are set to compiled mode when setting the defaults.",
"scope": "window"
}
}
},
Expand Down Expand Up @@ -832,6 +996,13 @@
"id": "julia-documentation",
"name": "Documentation"
}
],
"debug": [
{
"type": "tree",
"id": "debugger-compiled",
"name": "Julia: Compiled Code"
}
]
},
"breakpoints": [
Expand Down
2 changes: 1 addition & 1 deletion scripts/packages/ChromeProfileFormat
2 changes: 1 addition & 1 deletion scripts/packages/LoweredCodeUtils
2 changes: 1 addition & 1 deletion scripts/packages/Revise
2 changes: 1 addition & 1 deletion scripts/packages/Tokenize
2 changes: 1 addition & 1 deletion scripts/packages/URIParser
1 change: 1 addition & 0 deletions scripts/packages/VSCodeServer/src/VSCodeServer.jl
Expand Up @@ -101,6 +101,7 @@ function serve(args...; is_dev=false, crashreporting_pipename::Union{AbstractStr
msg_dispatcher[repl_toggle_progress_notification_type] = toggle_progress
msg_dispatcher[cd_notification_type] = cd_to_uri
msg_dispatcher[activate_project_notification_type] = activate_uri
msg_dispatcher[repl_getdebugitems_request_type] = debugger_getdebugitems_request

while true
msg = JSONRPC.get_next_message(conn_endpoint[])
Expand Down
60 changes: 60 additions & 0 deletions scripts/packages/VSCodeServer/src/debugger.jl
Expand Up @@ -29,6 +29,66 @@ function remove_lln!(ex::Expr)
end
end

function debugger_getdebugitems_request(conn, params)
accessor = params.juliaAccessor
out = DebugConfigTreeItem[]
loaded_modules = Base.loaded_modules_array()
if accessor == "#root"
# root modules
for mod in loaded_modules
push!(out, DebugConfigTreeItem(string(mod), true, string(mod)))
end
else
obj = get_obj_by_accessor(accessor)
if obj isa Module
for name in names(obj; all = true)
isdefined(obj, name) || continue
strname = string(name)
startswith(strname, '#') && continue
this = getfield(obj, name)
this === obj && continue

if this isa Base.Callable || this isa Module
push!(out, DebugConfigTreeItem(strname, this isa Module, string(accessor, ".", strname)))
end
end
end
end
return sort!(out, lt = (x, y) -> x.hasChildren == y.hasChildren ? x.label < y.label : x.hasChildren)
end

function get_obj_by_accessor(accessor, super = nothing)
parts = split(accessor, '.')
@assert length(parts) > 0
top = popfirst!(parts)
if super === nothing
# try getting module from loaded_modules_array first and then from Main:
loaded_modules = Base.loaded_modules_array()
ind = findfirst(==(top), string.(loaded_modules))
if ind !== nothing
root = loaded_modules[ind]
if length(parts) > 0
return get_obj_by_accessor(join(parts, '.'), root)
end
return root
else
return get_obj_by_accessor(accessor, Main)
end
else
if isdefined(super, Symbol(top))
this = getfield(super, Symbol(top))
if length(parts) > 0
if this isa Module
return get_obj_by_accessor(join(parts, '.'), this)
end
else
return this
end
end
end
return nothing
end

macro enter(command)
remove_lln!(command)
:(JSONRPC.send_notification(conn_endpoint[], "debugger/enter", (code = $(string(command)), filename = $(string(__source__.file)))))
Expand Down
7 changes: 7 additions & 0 deletions scripts/packages/VSCodeServer/src/repl_protocol.jl
Expand Up @@ -33,6 +33,12 @@ JSONRPC.@dict_readable mutable struct ReplWorkspaceItem <: JSONRPC.Outbound
type::String
end

JSONRPC.@dict_readable mutable struct DebugConfigTreeItem <: JSONRPC.Outbound
label::String
hasChildren::Bool
juliaAccessor::String
end

const repl_runcode_request_type = JSONRPC.RequestType("repl/runcode", ReplRunCodeRequestParams, ReplRunCodeRequestReturn)
const repl_interrupt_notification_type = JSONRPC.NotificationType("repl/interrupt", Nothing)
const repl_getvariables_request_type = JSONRPC.RequestType("repl/getvariables", Nothing, Vector{ReplWorkspaceItem})
Expand All @@ -47,3 +53,4 @@ const repl_toggle_plot_pane_notification_type = JSONRPC.NotificationType("repl/t
const repl_toggle_progress_notification_type = JSONRPC.NotificationType("repl/toggleProgress", Bool)
const cd_notification_type = JSONRPC.NotificationType("repl/cd", NamedTuple{(:uri,),Tuple{String}})
const activate_project_notification_type = JSONRPC.NotificationType("repl/activateProject", NamedTuple{(:uri,),Tuple{String}})
const repl_getdebugitems_request_type = JSONRPC.RequestType("repl/getDebugItems", NamedTuple{(:juliaAccessor,),Tuple{String}}, Vector{DebugConfigTreeItem})