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

Report on status of loaded symbols #882

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions src/LanguageServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ include("requests/actions.jl")
include("requests/init.jl")
include("requests/signatures.jl")
include("utilities.jl")
include("ss_report.jl")

end
1 change: 1 addition & 0 deletions src/languageserverinstance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ function Base.run(server::LanguageServerInstance)
msg_dispatcher[workspace_symbol_request_type] = (conn, params) -> workspace_symbol_request(params, server, conn)
msg_dispatcher[julia_refreshLanguageServer_notification_type] = (conn, params) -> julia_refreshLanguageServer_notification(params, server, conn)
msg_dispatcher[julia_getDocFromWord_request_type] = (conn, params) -> julia_getDocFromWord_request(params, server, conn)
msg_dispatcher[julia_symbolServerReport_request_type] = (conn, params) -> julia_symbolServerReport_request(params, server, conn)

while true
message = take!(server.combined_msg_queue)
Expand Down
1 change: 1 addition & 0 deletions src/protocol/messagedefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const workspace_applyEdit_request_type = JSONRPC.RequestType("workspace/applyEdi
const workspace_configuration_request_type = JSONRPC.RequestType("workspace/configuration", ConfigurationParams, Vector{Any})
const julia_activateenvironment_notification_type = JSONRPC.NotificationType("julia/activateenvironment", NamedTuple{(:envPath,),Tuple{String}})
const julia_refreshLanguageServer_notification_type = JSONRPC.NotificationType("julia/refreshLanguageServer", Nothing)
const julia_symbolServerReport_request_type = JSONRPC.RequestType("julia/symbolServerReport", String, Vector{Any})

const initialize_request_type = JSONRPC.RequestType("initialize", InitializeParams, InitializeResult)
const initialized_notification_type = JSONRPC.NotificationType("initialized", InitializedParams)
Expand Down
52 changes: 52 additions & 0 deletions src/ss_report.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
function julia_symbolServerReport_request(params, server::LanguageServerInstance, conn)
# params could specify which env if we allow multiple envs
report = symbolserver_status(server.env_path, server.symbol_store)
for t in report
if !t.loaded
@info "$(t.name) doesn't have a cached."
# What info do we want to show?
end
end
[] # How would we want to display this in the client?
end

function symbolserver_status(env, symbols)
isdefined(SymbolServer.Pkg.Types, :Manifest) || return # julia 1.0.- doesn't have this.
manifest_file = Base.project_file_manifest_path(env)
project_file = Base.env_project_file(env)
!isfile(manifest_file) && return
!isfile(project_file) && return
manifest = SymbolServer.Pkg.Types.Manifest(Base.parsed_toml(manifest_file))
project = SymbolServer.Pkg.Types.Project(Base.parsed_toml(project_file))
out = Dict()
for (uuid, pe) in manifest
loaded = haskey(symbols, Symbol(pe.name)) && !isempty(symbols[Symbol(pe.name)].vals)
deved = pe.path !== nothing
project_dep = pe.name in keys(project.deps)
parents = get_parent(pe.name, manifest)
project_parents = get_project_dep_parent(pe.name, manifest, project)
out[pe.name] = (name = pe.name, uuid = string(uuid), loaded = loaded, deved = deved, project_dep = project_dep, parents = parents, project_parents = project_parents)
end
out
end

function get_parent(name, manifest)
parents = []
for (u,pe) in manifest
if haskey(pe.deps, name)
push!(parents, u => pe.name)
end
end
parents
end

function get_project_dep_parent(name, manifest, project, parents = [])
name in parents && return parents
name in keys(project.deps) && push!(parents, name)
for (u,pe) in manifest
if haskey(pe.deps, name)
get_project_dep_parent(pe.name, manifest, project, parents)
end
end
parents
end