Skip to content

Commit 15c3505

Browse files
committed
Refactor repeated linting steps into helper function
1 parent a0b010b commit 15c3505

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

src/languageserverinstance.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,7 @@ function Base.run(server::LanguageServerInstance)
264264
scopepass(root, doc)
265265
end
266266

267-
StaticLint.check_all(getcst(doc), server.lint_options, server)
268-
empty!(doc.diagnostics)
269-
mark_errors(doc, doc.diagnostics)
270-
publish_diagnostics(doc, server)
267+
lint!(doc, server)
271268
end
272269
end
273270
end

src/requests/textdocument.jl

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ function process(r::JSONRPC.Request{Val{Symbol("textDocument/didChange")},DidCha
8080
tdcce = first(r.params.contentChanges)
8181
new_cst = _partial_update(doc, tdcce)
8282
scopepass(getroot(doc), doc)
83-
StaticLint.check_all(getcst(doc), server.lint_options, server)
84-
empty!(doc.diagnostics)
85-
mark_errors(doc, doc.diagnostics)
86-
publish_diagnostics(doc, server)
83+
lint!(doc, server)
8784
else
8885
for tdcce in r.params.contentChanges
8986
applytextdocumentchanges(doc, tdcce)
@@ -234,11 +231,7 @@ function parse_all(doc::Document, server::LanguageServerInstance)
234231
end
235232

236233
scopepass(getroot(doc), doc)
237-
StaticLint.check_all(getcst(doc), server.lint_options, server)
238-
empty!(doc.diagnostics)
239-
mark_errors(doc, doc.diagnostics)
240-
241-
publish_diagnostics(doc, server)
234+
lint!(doc, server)
242235
end
243236

244237
function mark_errors(doc, out = Diagnostic[])

src/requests/workspace.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,7 @@ function request_julia_config(server::LanguageServerInstance)
111111

112112
if rerun_lint
113113
for doc in getdocuments_value(server)
114-
# TODO: wrap next 4 lines in function since it's repeated throughout project
115-
StaticLint.check_all(getcst(doc), server.lint_options, server)
116-
empty!(doc.diagnostics)
117-
mark_errors(doc, doc.diagnostics)
118-
publish_diagnostics(doc, server)
114+
lint!(doc, server)
119115
end
120116
end
121117

src/staticlint.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,11 @@ getserver(file::Document) = file.server
5656
function setserver(file::Document, server::LanguageServerInstance)
5757
file.server = server
5858
return file
59-
end
59+
end
60+
61+
function lint!(doc, server)
62+
StaticLint.check_all(getcst(doc), server.lint_options, server)
63+
empty!(doc.diagnostics)
64+
mark_errors(doc, doc.diagnostics)
65+
publish_diagnostics(doc, server)
66+
end

0 commit comments

Comments
 (0)