Skip to content
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
54 changes: 38 additions & 16 deletions src/requests/init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,50 @@ function load_folder(wf::WorkspaceFolder, server)
load_folder(path, server)
end

function load_folder(path::String, server)
if load_rootpath(path)
for (root, dirs, files) in walkdir(path, onerror = x->x)
for file in files
filepath = joinpath(root, file)
if hasreadperm(filepath) && isvalidjlfile(filepath)
!isfile(filepath) && continue
uri = filepath2uri(filepath)
if URI2(uri) in keys(server.documents)
continue
else
content = read(filepath, String)
server.documents[URI2(uri)] = Document(uri, content, true, server)
doc = server.documents[URI2(uri)]
parse_all(doc, server)
end
function load_folder(dir::String, server)
if !isempty(dir) && isdir(dir) && hasreadperm(dir) && !has_too_many_files(dir)
for file in readdir(dir)
filepath = joinpath(dir, file)
!hasreadperm(filepath) && continue
if isfile(filepath) && isvalidjlfile(filepath)
uri = filepath2uri(filepath)
if URI2(uri) in keys(server.documents)
continue
else
content = read(filepath, String)
server.documents[URI2(uri)] = Document(uri, content, true, server)
doc = server.documents[URI2(uri)]
parse_all(doc, server)
end
elseif isdir(filepath)
load_folder(filepath, server)
end
end
end
end

# function load_folder(path::String, server)
# if load_rootpath(path)
# for (root, dirs, files) in walkdir(path, onerror = x->x)
# for file in files
# filepath = joinpath(root, file)
# if hasreadperm(filepath) && isvalidjlfile(filepath)
# !isfile(filepath) && continue
# uri = filepath2uri(filepath)
# if URI2(uri) in keys(server.documents)
# continue
# else
# content = read(filepath, String)
# server.documents[URI2(uri)] = Document(uri, content, true, server)
# doc = server.documents[URI2(uri)]
# parse_all(doc, server)
# end
# end
# end
# end
# end
# end


JSONRPC.parse_params(::Type{Val{Symbol("initialize")}}, params) = InitializeParams(params)
function process(r::JSONRPC.Request{Val{Symbol("initialize")},InitializeParams}, server)
Expand Down
8 changes: 5 additions & 3 deletions src/requests/textdocument.jl
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,13 @@ end
function search_for_parent(dir::String, file::String, drop = 3, parents = String[])
drop<1 && return parents
!isdir(dir) && return parents
!hasreadperm(dir) && return parents
for f in readdir(dir)
if endswith(f, ".jl")
fpath = joinpath(dir, f)
if endswith(f, ".jl") && hasreadperm(fpath) && isvalidjlfile(fpath)
# Could be sped up?
s = read(joinpath(dir, f), String)
occursin(file, s) && push!(parents, joinpath(dir, f))
s = read(fpath, String)
occursin(file, s) && push!(parents, fpath)
end
end
search_for_parent(splitdir(dir)[1], file, drop - 1, parents)
Expand Down