@@ -56,12 +56,12 @@ function JuliaWorkspace(workspace_folders::Set{URI})
56
56
text_documents = isempty (workspace_folders) ? Dict {URI,TextDocument} () : merge ((read_path_into_textdocuments (path) for path in workspace_folders). .. )
57
57
58
58
toml_syntax_trees = Dict {URI,Dict} ()
59
- for (k,v) in pairs (text_documents)
59
+ for (k, v) in pairs (text_documents)
60
60
if endswith (lowercase (string (k)), " .toml" )
61
61
# try
62
- toml_syntax_trees[k] = parse_toml_file (get_text (v))
62
+ toml_syntax_trees[k] = parse_toml_file (get_text (v))
63
63
# catch err
64
- # TODO Add some diagnostics
64
+ # TODO Add some diagnostics
65
65
# end
66
66
end
67
67
end
78
78
function is_path_project_file (path)
79
79
basename_lower_case = basename (lowercase (path))
80
80
81
- return basename_lower_case== " project.toml" || basename_lower_case== " juliaproject.toml"
81
+ return basename_lower_case == " project.toml" || basename_lower_case == " juliaproject.toml"
82
82
end
83
83
84
84
function is_path_manifest_file (path)
85
85
basename_lower_case = basename (lowercase (path))
86
86
87
- return basename_lower_case== " manifest.toml" || basename_lower_case== " juliamanifest.toml"
87
+ return basename_lower_case == " manifest.toml" || basename_lower_case == " juliamanifest.toml"
88
88
end
89
89
90
90
function read_textdocument_from_uri (uri:: URI )
@@ -109,21 +109,21 @@ function read_path_into_textdocuments(uri::URI)
109
109
110
110
if true
111
111
# T TODO Move this check into the LS logic
112
- # if load_rootpath(path)
113
- # TODO Think about this try catch block
112
+ # if load_rootpath(path)
113
+ # TODO Think about this try catch block
114
114
# try
115
- for (root, _, files) in walkdir (path, onerror= x -> x)
116
- for file in files
117
-
118
- filepath = joinpath (root, file)
119
- if is_path_project_file (filepath) || is_path_manifest_file (filepath)
120
- uri = filepath2uri (filepath)
121
- doc = read_textdocument_from_uri (uri)
122
- doc === nothing && continue
123
- result[uri] = doc
124
- end
115
+ for (root, _, files) in walkdir (path, onerror= x -> x)
116
+ for file in files
117
+
118
+ filepath = joinpath (root, file)
119
+ if is_path_project_file (filepath) || is_path_manifest_file (filepath)
120
+ uri = filepath2uri (filepath)
121
+ doc = read_textdocument_from_uri (uri)
122
+ doc === nothing && continue
123
+ result[uri] = doc
125
124
end
126
125
end
126
+ end
127
127
# catch err
128
128
# is_walkdir_error(err) || rethrow()
129
129
# end
@@ -137,7 +137,7 @@ function add_workspace_folder(jw::JuliaWorkspace, folder::URI)
137
137
new_toml_syntax_trees = copy (jw. _toml_syntax_trees)
138
138
139
139
additional_documents = read_path_into_textdocuments (folder)
140
- for (k,v) in pairs (additional_documents)
140
+ for (k, v) in pairs (additional_documents)
141
141
if endswith (lowercase (string (k)), " .toml" )
142
142
try
143
143
new_toml_syntax_trees[k] = parse_toml_file (get_text (v))
@@ -158,7 +158,7 @@ function remove_workspace_folder(jw::JuliaWorkspace, folder::URI)
158
158
159
159
new_text_documents = filter (jw. _text_documents) do i
160
160
# TODO Eventually use FilePathsBase functionality to properly test this
161
- return any (startswith (string (i. first), string (j)) for j in new_roots )
161
+ return any (startswith (string (i. first), string (j)) for j in new_roots)
162
162
end
163
163
164
164
new_toml_syntax_trees = filter (jw. _toml_syntax_trees) do i
@@ -174,7 +174,7 @@ function add_file(jw::JuliaWorkspace, uri::URI)
174
174
175
175
new_jw = jw
176
176
177
- if new_doc!= = nothing
177
+ if new_doc != = nothing
178
178
new_text_documents = copy (jw. _text_documents)
179
179
new_text_documents[uri] = new_doc
180
180
@@ -189,7 +189,7 @@ function add_file(jw::JuliaWorkspace, uri::URI)
189
189
nothing
190
190
end
191
191
192
- new_jw = JuliaWorkspace (jw. _workspace_folders, new_text_documents, new_toml_syntax_trees, semantic_pass_toml_files (new_toml_syntax_trees)... )
192
+ new_jw = JuliaWorkspace (jw. _workspace_folders, new_text_documents, new_toml_syntax_trees, semantic_pass_toml_files (new_toml_syntax_trees)... )
193
193
end
194
194
195
195
return new_jw
@@ -200,7 +200,7 @@ function update_file(jw::JuliaWorkspace, uri::URI)
200
200
201
201
new_jw = jw
202
202
203
- if new_doc!= = nothing
203
+ if new_doc != = nothing
204
204
new_text_documents = copy (jw. _text_documents)
205
205
new_text_documents[uri] = new_doc
206
206
@@ -240,11 +240,11 @@ function semantic_pass_toml_files(toml_syntax_trees)
240
240
# Extract all packages & paths with a manifest
241
241
packages = Dict {URI,JuliaPackage} ()
242
242
paths_with_manifest = Dict {String,Dict} ()
243
- for (k,v) in pairs (toml_syntax_trees)
243
+ for (k, v) in pairs (toml_syntax_trees)
244
244
# TODO Maybe also check the filename here and only do the package detection for Project.toml and JuliaProject.toml
245
245
if haskey (v, " name" ) && haskey (v, " uuid" ) && haskey (v, " version" )
246
246
parsed_uuid = tryparse (UUID, v[" uuid" ])
247
- if parsed_uuid!= = nothing
247
+ if parsed_uuid != = nothing
248
248
folder_uri = k |> uri2filepath |> dirname |> filepath2uri
249
249
packages[folder_uri] = JuliaPackage (k, v[" name" ], parsed_uuid)
250
250
end
@@ -261,29 +261,29 @@ function semantic_pass_toml_files(toml_syntax_trees)
261
261
262
262
# Extract all projects
263
263
projects = Dict {URI,JuliaProject} ()
264
- for (k,_) in pairs (toml_syntax_trees)
264
+ for (k, _) in pairs (toml_syntax_trees)
265
265
path = uri2filepath (k)
266
266
dname = dirname (path)
267
267
filename = basename (path)
268
268
filename_lc = lowercase (filename)
269
269
270
- if (filename_lc== " project.toml" || filename_lc== " juliaproject.toml" ) && haskey (paths_with_manifest, dname)
270
+ if (filename_lc == " project.toml" || filename_lc == " juliaproject.toml" ) && haskey (paths_with_manifest, dname)
271
271
manifest_content = paths_with_manifest[dname]
272
272
manifest_content isa Dict || continue
273
273
deved_packages = Dict {URI,JuliaDevedPackage} ()
274
274
manifest_version = get (manifest_content, " manifest_format" , " 1.0" )
275
275
276
- manifest_deps = if manifest_version== " 1.0"
276
+ manifest_deps = if manifest_version == " 1.0"
277
277
manifest_content
278
- elseif manifest_version== " 2.0" && haskey (manifest_content, " deps" ) && manifest_content[" deps" ] isa Dict
278
+ elseif manifest_version == " 2.0" && haskey (manifest_content, " deps" ) && manifest_content[" deps" ] isa Dict
279
279
manifest_content[" deps" ]
280
280
else
281
281
continue
282
282
end
283
283
284
284
for (k_entry, v_entry) in pairs (manifest_deps)
285
285
v_entry isa Vector || continue
286
- length (v_entry)== 1 || continue
286
+ length (v_entry) == 1 || continue
287
287
v_entry[1 ] isa Dict || continue
288
288
haskey (v_entry[1 ], " path" ) || continue
289
289
haskey (v_entry[1 ], " uuid" ) || continue
0 commit comments