Skip to content

Commit 2ce8e6b

Browse files
authored
Format files using DocumentFormat
1 parent cc01b65 commit 2ce8e6b

33 files changed

+338
-345
lines changed

docs/make.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ using LanguageServer
22
using Documenter
33

44
makedocs(;
5-
modules=[LanguageServer],
6-
authors="Julia VSCode",
7-
repo="https://github.com/julia-vscode/LanguageServer.jl/blob/{commit}{path}#L{line}",
8-
sitename="LanguageServer.jl",
9-
format=Documenter.HTML(;
10-
prettyurls=prettyurls = get(ENV, "CI", nothing) == "true",
5+
modules = [LanguageServer],
6+
authors = "Julia VSCode",
7+
repo = "https://github.com/julia-vscode/LanguageServer.jl/blob/{commit}{path}#L{line}",
8+
sitename = "LanguageServer.jl",
9+
format = Documenter.HTML(;
10+
prettyurls = prettyurls = get(ENV, "CI", nothing) == "true"
1111
# canonical="https://www.julia-vscode.org/LanguageServer.jl",
1212
# assets=String[],
1313
),
14-
pages=[
14+
pages = [
1515
"Home" => "index.md",
1616
"Syntax Reference" => "syntax.md",
17-
],
17+
]
1818
)
1919

2020
deploydocs(;
21-
repo="github.com/julia-vscode/LanguageServer.jl",
21+
repo = "github.com/julia-vscode/LanguageServer.jl"
2222
)

src/document.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mutable struct Document
1111
_version::Int
1212
server
1313
root::Document
14-
function Document(uri::AbstractString, text::AbstractString, workspace_file::Bool, server=nothing)
14+
function Document(uri::AbstractString, text::AbstractString, workspace_file::Bool, server = nothing)
1515
path = something(uri2filepath(uri), "")
1616
path == "" || isabspath(path) || throw(LSRelativePath("Relative path `$path` is not valid."))
1717
cst = CSTParser.parse(text, true)
@@ -77,7 +77,7 @@ function get_offset(doc::Document, line::Integer, character::Integer)
7777
line_offsets = get_line_offsets(doc)
7878
io = IOBuffer(get_text(doc))
7979
try
80-
seek(io, line_offsets[line + 1])
80+
seek(io, line_offsets[line+1])
8181
while character > 0
8282
c = read(io, Char)
8383
character -= 1
@@ -102,7 +102,7 @@ get_offset(doc, p::Position) = get_offset(doc, p.line, p.character)
102102
get_offset(doc, r::Range) = get_offset(doc, r.start):get_offset(doc, r.stop)
103103

104104
# 1-based. Basically the index at which (line, character) can be found in the document.
105-
function get_offset2(doc::Document, line::Integer, character::Integer, forgiving_mode=false)
105+
function get_offset2(doc::Document, line::Integer, character::Integer, forgiving_mode = false)
106106
line_offsets = get_line_offsets2!(doc)
107107
text = get_text(doc)
108108

@@ -113,9 +113,9 @@ function get_offset2(doc::Document, line::Integer, character::Integer, forgiving
113113
throw(LSOffsetError("get_offset2 crashed. More diagnostics:\nline=$line\nline_offsets='$line_offsets'"))
114114
end
115115

116-
line_offset = line_offsets[line + 1]
116+
line_offset = line_offsets[line+1]
117117

118-
next_line_offset = line + 1 < length(line_offsets) ? line_offsets[line + 2] : nextind(text, lastindex(text))
118+
next_line_offset = line + 1 < length(line_offsets) ? line_offsets[line+2] : nextind(text, lastindex(text))
119119

120120
pos = line_offset
121121

@@ -134,7 +134,7 @@ function get_offset2(doc::Document, line::Integer, character::Integer, forgiving
134134
pos = nextind(text, pos)
135135
end
136136

137-
return pos
137+
return pos
138138
end
139139

140140
# Note: to be removed
@@ -168,33 +168,33 @@ Updates the doc._line_offsets field, an n length Array each entry of which
168168
gives the byte offset position of the start of each line. This always starts
169169
with 0 for the first line (even if empty).
170170
"""
171-
function get_line_offsets(doc::Document, force=false)
171+
function get_line_offsets(doc::Document, force = false)
172172
if force || doc._line_offsets === nothing
173173
doc._line_offsets = Int[0]
174174
text = get_text(doc)
175175
ind = firstindex(text)
176-
while ind <= lastindex(text)
176+
while ind <= lastindex(text)
177177
c = text[ind]
178178
nl = c == '\n' || c == '\r'
179-
if c == '\r' && ind + 1 <= lastindex(text) && text[ind + 1] == '\n'
179+
if c == '\r' && ind + 1 <= lastindex(text) && text[ind+1] == '\n'
180180
ind += 1
181181
end
182182
nl && push!(doc._line_offsets, ind)
183183
ind = nextind(text, ind)
184184
end
185-
end
185+
end
186186
return doc._line_offsets
187187
end
188188

189-
function get_line_offsets2!(doc::Document, force=false)
189+
function get_line_offsets2!(doc::Document, force = false)
190190
if force || doc._line_offsets2 === nothing
191191
doc._line_offsets2 = Int[1]
192192
text = get_text(doc)
193193
ind = firstindex(text)
194-
while ind <= lastindex(text)
194+
while ind <= lastindex(text)
195195
c = text[ind]
196196
if c == '\n' || c == '\r'
197-
if c == '\r' && ind + 1 <= lastindex(text) && text[ind + 1] == '\n'
197+
if c == '\r' && ind + 1 <= lastindex(text) && text[ind+1] == '\n'
198198
ind += 1
199199
end
200200
push!(doc._line_offsets2, ind + 1)
@@ -214,12 +214,12 @@ function get_line_of(line_offsets::Vector{Int}, offset::Integer)
214214
else
215215
line = 1
216216
while line < nlines
217-
if line_offsets[line] <= offset < line_offsets[line + 1]
217+
if line_offsets[line] <= offset < line_offsets[line+1]
218218
break
219219
end
220220
line += 1
221221
end
222-
end
222+
end
223223
return line, line_offsets[line]
224224
end
225225

@@ -240,7 +240,7 @@ function get_position_at(doc::Document, offset::Integer)
240240
c = read(io, Char)
241241
character += 1
242242
if UInt32(c) >= 0x010000
243-
character += 1
243+
character += 1
244244
end
245245
end
246246
close(io)

src/extensions/messagedefs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
const julia_getModuleAt_request_type = JSONRPC.RequestType("julia/getModuleAt", VersionedTextDocumentPositionParams, String)
2-
const julia_getCurrentBlockRange_request_type = JSONRPC.RequestType("julia/getCurrentBlockRange", VersionedTextDocumentPositionParams, Tuple{Position, Position, Position})
2+
const julia_getCurrentBlockRange_request_type = JSONRPC.RequestType("julia/getCurrentBlockRange", VersionedTextDocumentPositionParams, Tuple{Position,Position,Position})
33
const julia_getDocAt_request_type = JSONRPC.RequestType("julia/getDocAt", VersionedTextDocumentPositionParams, String)
44
const julia_getDocFromWord_request_type = JSONRPC.RequestType("julia/getDocFromWord", NamedTuple{(:word,),Tuple{String}}, String)

src/languageserverinstance.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ mutable struct LanguageServerInstance
6363

6464
shutdown_requested::Bool
6565

66-
function LanguageServerInstance(pipe_in, pipe_out, env_path="", depot_path="", err_handler=nothing, symserver_store_path=nothing, download=true, symbolcache_upstream = nothing)
66+
function LanguageServerInstance(pipe_in, pipe_out, env_path = "", depot_path = "", err_handler = nothing, symserver_store_path = nothing, download = true, symbolcache_upstream = nothing)
6767
new(
6868
JSONRPC.JSONRPCEndpoint(pipe_in, pipe_out, err_handler),
6969
Set{String}(),

src/multienv.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function get_env_for_root(doc::Document, server::LanguageServerInstance)
4949
(safe_isfile(env_proj_file) && safe_isfile(env_manifest_file)) || return
5050

5151
# Find which workspace folder the doc is in.
52-
parent_workspaceFolders = sort(filter(f->startswith(doc._path, f), collect(server.workspaceFolders)), by = length, rev = true)
52+
parent_workspaceFolders = sort(filter(f -> startswith(doc._path, f), collect(server.workspaceFolders)), by = length, rev = true)
5353

5454
isempty(parent_workspaceFolders) && return
5555
# arbitrarily pick one
@@ -94,7 +94,7 @@ function get_env_for_root(doc::Document, server::LanguageServerInstance)
9494
msg
9595
))
9696
end
97-
@error msg exception=(err, catch_backtrace())
97+
@error msg exception = (err, catch_backtrace())
9898
end
9999
end
100100

src/protocol/basic.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ end
6464
# Diagnostics
6565
const DiagnosticSeverity = Int
6666
const DiagnosticSeverities = (Error = 1,
67-
Warning = 2,
68-
Information = 3,
69-
Hint = 4)
67+
Warning = 2,
68+
Information = 3,
69+
Hint = 4)
7070

7171
const DiagnosticTag = Int
7272
const DiagnosticTags = (Unnecessary = 1,
73-
Deprecated = 2)
73+
Deprecated = 2)
7474

7575
@dict_readable struct DiagnosticRelatedInformation
7676
location::Location
@@ -105,7 +105,7 @@ end
105105
# Markup
106106
const MarkupKind = String
107107
const MarkupKinds = (PlainText = "plaintext",
108-
Markdown = "markdown")
108+
Markdown = "markdown")
109109

110110
mutable struct MarkupContent
111111
kind::MarkupKind
@@ -127,9 +127,9 @@ Base.hash(x::MarkedString) = hash(x.value) # for unique
127127
# Window
128128
const MessageType = Int
129129
const MessageTypes = (Error = 1,
130-
Warning = 2,
131-
Info = 3,
132-
Log = 4)
130+
Warning = 2,
131+
Info = 3,
132+
Log = 4)
133133

134134
struct ShowMessageParams <: Outbound
135135
type::MessageType

src/protocol/completion.jl

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
const CompletionItemKind = Int
22
const CompletionItemKinds = (Text = 1,
3-
Method = 2,
4-
Function = 3,
5-
Constructor = 4,
6-
Field = 5,
7-
Variable = 6,
8-
Class = 7,
9-
Interface = 8,
10-
Module = 9,
11-
Property = 10,
12-
Unit = 11,
13-
Value = 12,
14-
Enum = 13,
15-
Keyword = 14,
16-
Snippet = 15,
17-
Color = 16,
18-
File = 17,
19-
Reference = 18,
20-
Folder = 19,
21-
EnumMember = 20,
22-
Constant = 21,
23-
Struct = 22,
24-
Event = 23,
25-
Operator = 24,
26-
TypeParameter = 25)
3+
Method = 2,
4+
Function = 3,
5+
Constructor = 4,
6+
Field = 5,
7+
Variable = 6,
8+
Class = 7,
9+
Interface = 8,
10+
Module = 9,
11+
Property = 10,
12+
Unit = 11,
13+
Value = 12,
14+
Enum = 13,
15+
Keyword = 14,
16+
Snippet = 15,
17+
Color = 16,
18+
File = 17,
19+
Reference = 18,
20+
Folder = 19,
21+
EnumMember = 20,
22+
Constant = 21,
23+
Struct = 22,
24+
Event = 23,
25+
Operator = 24,
26+
TypeParameter = 25)
2727

2828
const CompletionItemTag = Int
2929
const CompletionItemTags = (Deprecated = 1)
3030

3131
const CompletionTriggerKind = Int
3232
const CompletionTriggerKinds = (Invoked = 1,
33-
TriggerCharacter = 2,
34-
TriggerForIncompleteCompletion = 3)
33+
TriggerCharacter = 2,
34+
TriggerForIncompleteCompletion = 3)
3535

3636
const InsertTextFormat = Int
3737
const InsertTextFormats = (PlainText = 1,
38-
Snippet = 2)
38+
Snippet = 2)
3939

4040
@dict_readable struct CompletionTagClientCapabilities
4141
valueSet::Vector{CompletionItemTag}

src/protocol/configuration.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ end
3131
# File watching
3232
const FileChangeType = Int
3333
const FileChangeTypes = (Created = 1,
34-
Changed = 2,
35-
Deleted = 3)
34+
Changed = 2,
35+
Deleted = 3)
3636

3737
const WatchKind = Int
3838
const WatchKinds = (Create = 1,
39-
Change = 2,
40-
Delete = 4)
39+
Change = 2,
40+
Delete = 4)
4141

4242

4343
@dict_readable struct FileEvent

src/protocol/document.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct CreateFile <: Outbound
1111
kind::String
1212
uri::DocumentUri
1313
options::Union{CreateFileOptions,Missing}
14-
CreateFile(uri, options=missing) = new("create", uri, options)
14+
CreateFile(uri, options = missing) = new("create", uri, options)
1515
end
1616

1717
struct RenameFileOptions <: Outbound
@@ -24,7 +24,7 @@ struct RenameFile <: Outbound
2424
oldUri::DocumentUri
2525
newUri::DocumentUri
2626
options::Union{RenameFileOptions,Missing}
27-
RenameFile(uri, options=missing) = new("rename", uri, options)
27+
RenameFile(uri, options = missing) = new("rename", uri, options)
2828
end
2929

3030
struct DeleteFileOptions <: Outbound
@@ -36,7 +36,7 @@ struct DeleteFile <: Outbound
3636
kind::String
3737
uri::DocumentUri
3838
options::Union{DeleteFileOptions,Missing}
39-
DeleteFile(uri, options=missing) = new("delete", uri, options)
39+
DeleteFile(uri, options = missing) = new("delete", uri, options)
4040
end
4141

4242

@@ -76,7 +76,7 @@ end
7676
textDocument::TextDocumentItem
7777
end
7878

79-
@dict_readable struct TextDocumentContentChangeEvent <: Outbound
79+
@dict_readable struct TextDocumentContentChangeEvent <: Outbound
8080
range::Union{Range,Missing}
8181
rangeLength::Union{Int,Missing}
8282
text::String
@@ -98,8 +98,8 @@ end
9898

9999
const TextDocumentSaveReason = Int
100100
const TextDocumentSaveReasons = (Manual = 1,
101-
AfterDelay = 2,
102-
FocusOut = 3)
101+
AfterDelay = 2,
102+
FocusOut = 3)
103103

104104
@dict_readable struct WillSaveTextDocumentParams
105105
textDocument::TextDocumentIdentifier

src/protocol/features.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import Base.==
1212
# Code Action
1313
const CodeActionKind = String
1414
const CodeActionKinds = (Empty = "",
15-
QuickFix = "quickfix",
16-
Refactor = "refactor",
17-
RefactorExtract = "refactor.extract",
18-
RefactorInline = "refactor.inline",
19-
RefactorRewrite = "refactor.rewrite",
20-
Source = "source",
21-
SourceOrganizeImports = "source.organiseImports")
15+
QuickFix = "quickfix",
16+
Refactor = "refactor",
17+
RefactorExtract = "refactor.extract",
18+
RefactorInline = "refactor.inline",
19+
RefactorRewrite = "refactor.rewrite",
20+
Source = "source",
21+
SourceOrganizeImports = "source.organiseImports")
2222

2323
@dict_readable struct CodeActionKindCapabilities
2424
valueSet::Vector{CodeActionKind}
@@ -210,8 +210,8 @@ end
210210
# Folding
211211
const FoldingRangeKind = String
212212
const FoldingRangeKinds = (Comment = "comment",
213-
Imports = "imports",
214-
Region = "region")
213+
Imports = "imports",
214+
Region = "region")
215215

216216
@dict_readable struct FoldingRangeClientCapabilities <: Outbound
217217
dynamicRegistration::Union{Bool,Missing}

0 commit comments

Comments
 (0)