Skip to content

Commit

Permalink
(maint) - Rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbreen28 committed Nov 24, 2023
1 parent c48c003 commit eeeea80
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
15 changes: 3 additions & 12 deletions lib/puppet-languageserver/global_queues/validation_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ def execute_job(job_object)
session_state = session_state_from_connection_id(job_object.connection_id)
document_store = session_state.nil? ? nil : session_state.documents
raise "Document store is not available for connection id #{job_object.connection_id}" unless document_store

# Check if the document still exists
doc = document_store.get_document(job_object.file_uri)
unless doc
# Send an empty diagnostics message to clear the diagnostics
send_remove_diagnostic(job_object.connection_id, job_object.file_uri, nil)
send_diagnostics(job_object.connection_id, job_object.file_uri, [])
PuppetLanguageServer.log_message(:debug, "#{self.class.name}: Ignoring #{job_object.file_uri} as it is has been removed.")
return
end

# Check if the document is the latest version
content = document_store.document_content(job_object.file_uri, job_object.doc_version)
unless content
Expand Down Expand Up @@ -97,15 +97,6 @@ def send_diagnostics(connection_id, file_uri, diagnostics)
::PuppetEditorServices::Protocol::JsonRPCMessages.new_notification('textDocument/publishDiagnostics', 'uri' => file_uri, 'diagnostics' => diagnostics)
)
end

def send_remove_diagnostic(connection_id, file_uri, diagnostics)
connection = PuppetEditorServices::Server.current_server.connection(connection_id)
return if connection.nil?

connection.protocol.encode_and_send(
::PuppetEditorServices::Protocol::JsonRPCMessages.new_notification('textDocument/publishDiagnostics', 'uri' => file_uri, 'diagnostics' => [])
)
end
end
end
end
6 changes: 2 additions & 4 deletions lib/puppet-languageserver/message_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,8 @@ def notification_textdocument_didopen(client_handler_id, json_rpc_message)
def notification_textdocument_didclose(client_handler_id, json_rpc_message)
PuppetLanguageServer.log_message(:info, 'Received textDocument/didClose notification.')
file_uri = json_rpc_message.params['textDocument']['uri']
doc_version = json_rpc_message.params['textDocument']['version']
documents.remove_document(file_uri)
enqueue_validation(file_uri, doc_version, client_handler_id)
enqueue_validation(file_uri, nil, client_handler_id)
end

def notification_textdocument_didchange(client_handler_id, json_rpc_message)
Expand Down Expand Up @@ -392,8 +391,7 @@ def unhandled_exception(error, options)

private

def enqueue_validation(file_uri, doc_version, client_handler_id)
options = {}
def enqueue_validation(file_uri, doc_version, client_handler_id, options = {})
if documents.document_type(file_uri) == :puppetfile
options[:resolve_puppetfile] = language_client.use_puppetfile_resolver
options[:puppet_version] = Puppet.version
Expand Down

0 comments on commit eeeea80

Please sign in to comment.