#846 add "julia/fileSearchUp" request

Closed Shuhei Kadowaki aviatesk

Flags

Flags have been temporarily removed from this view while the flagging feature is refactored for better performance and user experience.

You can still use flags when viewing individual files. Flag-level thresholds will also remain on pull and merge requests in your repository provider.

More information can be found in our documentation.


@@ -300,6 +300,7 @@
Loading
300 300
    msg_dispatcher[workspace_didChangeWorkspaceFolders_notification_type] = (conn, params) -> workspace_didChangeWorkspaceFolders_notification(params, server, conn)
301 301
    msg_dispatcher[workspace_symbol_request_type] = (conn, params) -> workspace_symbol_request(params, server, conn)
302 302
    msg_dispatcher[julia_refreshLanguageServer_notification_type] = (conn, params)->julia_refreshLanguageServer_notification(params, server, conn)
303 +
    msg_dispatcher[julia_file_search_up_request_type] = (conn, params) -> julia_file_search_up_request(params, server, conn)
303 304
304 305
    while true
305 306
        message = take!(server.combined_msg_queue)

@@ -96,6 +96,21 @@
Loading
96 96
    end
97 97
end
98 98
99 +
function search_up_file(target, from)
100 +
    parent_dir = dirname(from)
101 +
    return if begin
102 +
            parent_dir == from || # ensure to escape infinite recursion
103 +
            isempty(from)        # reached to the system root
104 +
        end
105 +
        nothing
106 +
    else
107 +
        path = joinpath(from, target)
108 +
        isfile′(path) ? path : search_up_file(target, parent_dir)
109 +
    end
110 +
end
111 +
112 +
isfile′(p) = try; isfile(p) catch; false end
113 +
99 114
# CompletionItemKind(t) = t in [:String, :AbstractString] ? 1 :
100 115
#                                 t == :Function ? 3 :
101 116
#                                 t == :DataType ? 7 :
@@ -107,9 +122,6 @@
Loading
107 122
#                         t == :Module ? 2 :
108 123
#                         t == :Bool ? 17 : 13
109 124
110 -
111 -
112 -
113 125
# Find location of default datatype constructor
114 126
const DefaultTypeConstructorLoc = let def = first(methods(Int))
115 127
    Base.find_source_file(string(def.file)), def.line

@@ -68,3 +68,5 @@
Loading
68 68
69 69
julia_refreshLanguageServer_notification(_, server::LanguageServerInstance, conn) =
70 70
    trigger_symbolstore_reload(server)
71 +
72 +
julia_file_search_up_request(params::FileSearchUpParams, _...) = search_up_file(params.target, params.from)

@@ -197,3 +197,9 @@
Loading
197 197
struct PartialResultParams <: Outbound
198 198
    partialResultToken::Union{Int,String,Missing} # ProgressToken
199 199
end
200 +
201 +
# misc
202 +
@dict_readable struct FileSearchUpParams
203 +
    target::String
204 +
    from::String
205 +
end

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
src -0.27% 60.79%
Project Totals (29 files) 60.79%
Loading