Class: RubyLsp::Notification

Inherits:
Message
  • Object
show all
Defined in:
lib/ruby_lsp/utils.rb

Instance Attribute Summary

Attributes inherited from Message

#method, #params

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

#initialize

Constructor Details

This class inherits a constructor from RubyLsp::Message

Class Method Details

.progress_begin(id, title, percentage: nil, message: nil) ⇒ Object

: (String id, String title, ?percentage: Integer?, ?message: String?) -> Notification



87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/ruby_lsp/utils.rb', line 87

def progress_begin(id, title, percentage: nil, message: nil)
  new(
    method: "$/progress",
    params: Interface::ProgressParams.new(
      token: id,
      value: Interface::WorkDoneProgressBegin.new(
        kind: "begin",
        title: title,
        percentage: percentage,
        message: message,
      ),
    ),
  )
end

.progress_end(id) ⇒ Object

: (String id) -> Notification



118
119
120
121
122
123
124
125
126
# File 'lib/ruby_lsp/utils.rb', line 118

def progress_end(id)
  Notification.new(
    method: "$/progress",
    params: Interface::ProgressParams.new(
      token: id,
      value: Interface::WorkDoneProgressEnd.new(kind: "end"),
    ),
  )
end

.progress_report(id, percentage: nil, message: nil) ⇒ Object

: (String id, ?percentage: Integer?, ?message: String?) -> Notification



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/ruby_lsp/utils.rb', line 103

def progress_report(id, percentage: nil, message: nil)
  new(
    method: "$/progress",
    params: Interface::ProgressParams.new(
      token: id,
      value: Interface::WorkDoneProgressReport.new(
        kind: "report",
        percentage: percentage,
        message: message,
      ),
    ),
  )
end

.publish_diagnostics(uri, diagnostics, version: nil) ⇒ Object

: (String uri, Array diagnostics, ?version: Integer?) -> Notification



129
130
131
132
133
134
# File 'lib/ruby_lsp/utils.rb', line 129

def publish_diagnostics(uri, diagnostics, version: nil)
  new(
    method: "textDocument/publishDiagnostics",
    params: Interface::PublishDiagnosticsParams.new(uri: uri, diagnostics: diagnostics, version: version),
  )
end

.telemetry(data) ⇒ Object

: (Hash[Symbol, untyped] data) -> Notification



79
80
81
82
83
84
# File 'lib/ruby_lsp/utils.rb', line 79

def telemetry(data)
  new(
    method: "telemetry/event",
    params: data,
  )
end

.window_log_message(message, type: Constant::MessageType::LOG) ⇒ Object

: (String message, ?type: Integer) -> Notification



71
72
73
74
75
76
# File 'lib/ruby_lsp/utils.rb', line 71

def window_log_message(message, type: Constant::MessageType::LOG)
  new(
    method: "window/logMessage",
    params: Interface::LogMessageParams.new(type: type, message: message),
  )
end

.window_show_message(message, type: Constant::MessageType::INFO) ⇒ Object

: (String message, ?type: Integer) -> Notification



63
64
65
66
67
68
# File 'lib/ruby_lsp/utils.rb', line 63

def window_show_message(message, type: Constant::MessageType::INFO)
  new(
    method: "window/showMessage",
    params: Interface::ShowMessageParams.new(type: type, message: message),
  )
end

Instance Method Details

#to_hashObject

: -> Hash[Symbol, untyped]



139
140
141
142
143
144
145
146
147
148
# File 'lib/ruby_lsp/utils.rb', line 139

def to_hash
  hash = { method: @method }

  if @params
    hash[:params] = @params #: as untyped
      .to_hash
  end

  hash
end