Skip to content

Commit a0b010b

Browse files
committed
Cleanup option-handling code
1 parent e8d2ac2 commit a0b010b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/requests/workspace.jl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,18 @@ function request_julia_config(server::LanguageServerInstance)
100100
ConfigurationItem(missing, "julia.lint.missingrefs")
101101
]))
102102

103-
new_DF_opts = DocumentFormat.FormatOptions([isnothing(opt) ? DocumentFormat.default_options[i] : opt for (i,opt) in enumerate(response[1:11])]...)
104-
new_SL_opts = StaticLint.LintOptions([isnothing(opt) ? StaticLint.default_options[i] : opt for (i,opt) in enumerate(response[12:21])]...)
105-
new_lintrun = isnothing(response[22]) ? true : response[22]
106-
new_missingref = isnothing(response[23]) ? :all : Symbol(response[23])
107-
103+
server.format_options = DocumentFormat.FormatOptions(response[1:11]...)
104+
server.runlinter = something(response[22], true)
105+
server.lint_missingrefs = Symbol(something(response[23], :all))
106+
107+
new_SL_opts = StaticLint.LintOptions(response[12:21]...)
108+
# TODO: implement == for StaticLint.LintOptions
108109
rerun_lint = any(getproperty(server.lint_options, opt) != getproperty(new_SL_opts, opt) for opt in fieldnames(StaticLint.LintOptions))
109-
server.format_options = new_DF_opts
110110
server.lint_options = new_SL_opts
111-
server.runlinter = new_lintrun
112-
server.lint_missingrefs = new_missingref
113111

114112
if rerun_lint
115113
for doc in getdocuments_value(server)
114+
# TODO: wrap next 4 lines in function since it's repeated throughout project
116115
StaticLint.check_all(getcst(doc), server.lint_options, server)
117116
empty!(doc.diagnostics)
118117
mark_errors(doc, doc.diagnostics)
@@ -147,4 +146,4 @@ function process(r::JSONRPC.Request{Val{Symbol("workspace/symbol")},WorkspaceSym
147146
end
148147

149148
return syms
150-
end
149+
end

0 commit comments

Comments
 (0)