Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions lib/steep/path_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ module Steep
module PathHelper
module_function

def to_pathname(uri)
path = URI.parse(uri).path
path.sub!(%r{^/([a-zA-Z])(:|%3A)//?}i, '\1:/') if Gem.win_platform?
Pathname(path)
def to_pathname(uri, dosish: Gem.win_platform?)
uri = URI.parse(uri)
if uri.scheme == "file"
path = uri.path
path.sub!(%r{^/([a-zA-Z])(:|%3A)//?}i, '\1:/') if dosish
Pathname(path)
end
end

def to_uri(path)
def to_uri(path, dosish: Gem.win_platform?)
str_path = path.to_s
if Gem.win_platform?
if dosish
str_path.insert(0, "/") if str_path[0] != "/"
end
URI.parse(str_path).tap {|uri| uri.scheme = "file"}
URI::File.build(path: str_path)
end
end
end
end
91 changes: 57 additions & 34 deletions lib/steep/server/master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -517,40 +517,54 @@ def process_message_from_client(message)
end

when "textDocument/didChange"
broadcast_notification(message)
path = pathname(message[:params][:textDocument][:uri])
controller.push_changes(path)
if path = pathname(message[:params][:textDocument][:uri])
broadcast_notification(message)
controller.push_changes(path)
end

when "textDocument/didSave"
if typecheck_automatically
if request = controller.make_request(last_request: current_type_check_request)
start_type_check(
request,
last_request: current_type_check_request,
start_progress: request.total > 10
)
if path = pathname(message[:params][:textDocument][:uri])
if typecheck_automatically
if request = controller.make_request(last_request: current_type_check_request)
start_type_check(
request,
last_request: current_type_check_request,
start_progress: request.total > 10
)
end
end
end

when "textDocument/didOpen"
path = pathname(message[:params][:textDocument][:uri])
controller.update_priority(open: path)
if path = pathname(message[:params][:textDocument][:uri])
controller.update_priority(open: path)
end

when "textDocument/didClose"
path = pathname(message[:params][:textDocument][:uri])
controller.update_priority(close: path)
if path = pathname(message[:params][:textDocument][:uri])
controller.update_priority(close: path)
end

when "textDocument/hover", "textDocument/completion"
if interaction_worker
result_controller << send_request(method: message[:method], params: message[:params], worker: interaction_worker) do |handler|
handler.on_completion do |response|
job_queue << SendMessageJob.to_client(
message: {
id: message[:id],
result: response[:result]
}
)
if path = pathname(message[:params][:textDocument][:uri])
result_controller << send_request(method: message[:method], params: message[:params], worker: interaction_worker) do |handler|
handler.on_completion do |response|
job_queue << SendMessageJob.to_client(
message: {
id: message[:id],
result: response[:result]
}
)
end
end
else
job_queue << SendMessageJob.to_client(
message: {
id: message[:id],
result: nil
}
)
end
end

Expand Down Expand Up @@ -587,20 +601,29 @@ def process_message_from_client(message)
end

when "textDocument/definition", "textDocument/implementation"
result_controller << group_request do |group|
typecheck_workers.each do |worker|
group << send_request(method: message[:method], params: message[:params], worker: worker)
end
if path = pathname(message[:params][:textDocument][:uri])
result_controller << group_request do |group|
typecheck_workers.each do |worker|
group << send_request(method: message[:method], params: message[:params], worker: worker)
end

group.on_completion do |handlers|
links = handlers.flat_map(&:result)
job_queue << SendMessageJob.to_client(
message: {
id: message[:id],
result: links
}
)
group.on_completion do |handlers|
links = handlers.flat_map(&:result)
job_queue << SendMessageJob.to_client(
message: {
id: message[:id],
result: links
}
)
end
end
else
job_queue << SendMessageJob.to_client(
message: {
id: message[:id],
result: []
}
)
end

when "$/typecheck"
Expand Down
Loading