Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove incorrect textDocument/diagnostic request handler #601

Merged
merged 1 commit into from
Apr 24, 2024
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
8 changes: 3 additions & 5 deletions lib/standard/lsp/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(writer, logger, standardizer)
end

def self.handle(name, &block)
define_method("handle_#{name}", &block)
define_method(:"handle_#{name}", &block)
end

def for(name)
Expand Down Expand Up @@ -51,10 +51,8 @@ def for(name)
end
end

handle "textDocument/diagnostic" do |request|
doc = request[:params][:textDocument]
result = diagnostic(doc[:uri], doc[:text])
@writer.write(result)
handle "textDocument/diagnostic" do |_request|
# no op, diagnostics are handled in textDocument/didChange
end

handle "textDocument/didChange" do |request|
Expand Down
31 changes: 2 additions & 29 deletions test/standard/runners/lsp_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,40 +72,13 @@ def test_diagnotic_route
jsonrpc: "2.0",
params: {
textDocument: {
languageId: "ruby",
text: "def hi\n [1, 2,\n 3 ]\nend\n",
uri: "file:///path/to/file.rb",
version: 0
uri: "file:///path/to/file.rb"
}
}
})

assert_equal "", err.string
assert_equal 1, msgs.count
assert_equal({
method: "textDocument/publishDiagnostics",
params: {
diagnostics: [
{code: "Layout/ArrayAlignment",
message: "Use one level of indentation for elements following the first line of a multi-line array.",
range: {start: {character: 3, line: 2}, end: {character: 3, line: 2}},
severity: 3,
source: "standard"},
{code: "Layout/ExtraSpacing",
message: "Unnecessary spacing detected.",
range: {start: {character: 4, line: 2}, end: {character: 4, line: 2}},
severity: 3,
source: "standard"},
{code: "Layout/SpaceInsideArrayLiteralBrackets",
message: "Do not use space inside array brackets.",
range: {start: {character: 4, line: 2}, end: {character: 5, line: 2}},
severity: 3,
source: "standard"}
],
uri: "file:///path/to/file.rb"
},
jsonrpc: "2.0"
}, msgs.first)
assert_equal 0, msgs.count
end

def test_format
Expand Down
Loading