@@ -163,8 +163,6 @@ defmodule ElixirLS.LanguageServer.Parser do
163
163
164
164
case { files [ uri ] , Map . has_key? ( state . parse_pids , { uri , current_version } ) } do
165
165
{ % Context { parsed_version: ^ current_version } = file , _ } ->
166
- file = maybe_fix_missing_env ( file , position )
167
-
168
166
{ :reply , file , state }
169
167
170
168
{ _ , true } ->
@@ -269,8 +267,7 @@ defmodule ElixirLS.LanguageServer.Parser do
269
267
queue =
270
268
Enum . reduce ( state . queue , [ ] , fn
271
269
{ { ^ uri , ^ parsed_file_version , position } , from } , acc ->
272
- file = maybe_fix_missing_env ( updated_file , position )
273
- GenServer . reply ( from , file )
270
+ GenServer . reply ( from , updated_file )
274
271
acc
275
272
276
273
{ request , from } , acc ->
@@ -311,49 +308,6 @@ defmodule ElixirLS.LanguageServer.Parser do
311
308
source_file . language_id in [ "elixir" , "eex" , "html-eex" , "phoenix-heex" ]
312
309
end
313
310
314
- defp maybe_fix_missing_env ( % Context { } = file , nil ) , do: file
315
-
316
- defp maybe_fix_missing_env (
317
- % Context { metadata: metadata , flag: flag , source_file: source_file = % SourceFile { } } =
318
- file ,
319
- { line , _character } = cursor_position
320
- ) do
321
- if Map . has_key? ( metadata . lines_to_env , line ) do
322
- file
323
- else
324
- case flag do
325
- { _ , ^ cursor_position } ->
326
- # give up - we already tried
327
- file
328
-
329
- { :exact , _ } ->
330
- # file does not have parse errors, try to parse again with marker
331
- metadata =
332
- case ElixirSense.Core.Parser . try_fix_line_not_found_by_inserting_marker (
333
- source_file . text ,
334
- cursor_position
335
- ) do
336
- { :ok , acc } ->
337
- ElixirSense.Core.Metadata . fill ( source_file . text , acc )
338
-
339
- _ ->
340
- metadata
341
- end
342
-
343
- % Context { file | metadata: metadata , flag: { :exact , cursor_position } }
344
-
345
- :not_parsable ->
346
- # give up - no support in fault tolerant parser
347
- file
348
-
349
- { f , _cursor_position } when f in [ :not_parsable , :fixed ] ->
350
- # reparse with cursor position
351
- { flag , ast , metadata } = fault_tolerant_parse ( source_file , cursor_position )
352
- % Context { file | ast: ast , metadata: metadata , flag: flag }
353
- end
354
- end
355
- end
356
-
357
311
def do_parse (
358
312
% Context { source_file: source_file = % SourceFile { } , path: path } = file ,
359
313
cursor_position \\ nil
@@ -363,9 +317,8 @@ defmodule ElixirLS.LanguageServer.Parser do
363
317
{ flag , ast , metadata } =
364
318
if ast do
365
319
# no syntax errors
366
- metadata =
367
- MetadataBuilder . build ( ast )
368
- |> fix_missing_env ( source_file . text , cursor_position )
320
+ acc = MetadataBuilder . build ( ast )
321
+ metadata = ElixirSense.Core.Metadata . fill ( source_file . text , acc )
369
322
370
323
{ { :exact , cursor_position } , ast , metadata }
371
324
else
@@ -397,9 +350,8 @@ defmodule ElixirLS.LanguageServer.Parser do
397
350
398
351
case ElixirSense.Core.Parser . string_to_ast ( source_file . text , options ) do
399
352
{ :ok , ast , modified_source , _error } ->
400
- metadata =
401
- MetadataBuilder . build ( ast )
402
- |> fix_missing_env ( modified_source , cursor_position )
353
+ acc = MetadataBuilder . build ( ast )
354
+ metadata = ElixirSense.Core.Metadata . fill ( modified_source , acc )
403
355
404
356
{ { :fixed , cursor_position } , ast , metadata }
405
357
@@ -427,28 +379,6 @@ defmodule ElixirLS.LanguageServer.Parser do
427
379
{ { :not_parsable , cursor_position } , @ dummy_ast , @ dummy_metadata }
428
380
end
429
381
430
- defp fix_missing_env ( acc , source , nil ) , do: ElixirSense.Core.Metadata . fill ( source , acc )
431
-
432
- defp fix_missing_env ( acc , source , { line , _ } = cursor_position ) do
433
- acc =
434
- if Map . has_key? ( acc . lines_to_env , line ) do
435
- acc
436
- else
437
- case ElixirSense.Core.Parser . try_fix_line_not_found_by_inserting_marker (
438
- source ,
439
- cursor_position
440
- ) do
441
- { :ok , acc } ->
442
- acc
443
-
444
- _ ->
445
- acc
446
- end
447
- end
448
-
449
- ElixirSense.Core.Metadata . fill ( source , acc )
450
- end
451
-
452
382
defp get_path ( uri ) do
453
383
case uri do
454
384
"file:" <> _ ->
0 commit comments