Skip to content

Commit

Permalink
fix: remove procedure name definition from proc_refs
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoKaios committed Aug 8, 2024
1 parent 48c2947 commit 0442593
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
19 changes: 14 additions & 5 deletions src/lsp/cobol_typeck/typeck_procedure.ml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ let references ~(data_definitions: Cobol_unit.Types.data_definitions) procedure
{ acc with diags = Proc_error err :: acc.diags }
in

let visitor = object
let visitor = object (v)
inherit [acc] Cobol_unit.Visitor.folder

method! fold_qualname qn acc = (* TODO: data_name' instead *)
Expand Down Expand Up @@ -212,10 +212,19 @@ let references ~(data_definitions: Cobol_unit.Types.data_definitions) procedure
error acc @@ Ambiguous_data_name { given_qualname = qn &@ loc;
matching_qualnames }

method! fold_procedure_section s ({ current_section; _ } as acc) =
Visitor.do_children_and_then
{ acc with current_section = Some s }
(fun acc -> { acc with current_section })
method! fold_procedure_section ({ section_paragraphs; _ } as s)
({ current_section; _ } as acc) =
{ acc with current_section = Some s }
|> Cobol_common.Visitor.fold_list v section_paragraphs.list
~fold:Cobol_unit.Visitor.fold_procedure_paragraph'
|> (fun acc -> { acc with current_section })
|> Cobol_common.Visitor.skip

method! fold_procedure_paragraph { paragraph; _ } acc =
acc
|> Cobol_ptree.Proc_division_visitor.fold_paragraph' v paragraph
|> Cobol_common.Visitor.skip


method! fold_procedure_name' ({ loc; _ } as qn)
({ current_section = in_section; _ } as acc) =
Expand Down
8 changes: 4 additions & 4 deletions test/lsp/lsp_codelens.ml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ let%expect_test "codelens-procedure" =
---- ^
6 BB.
7 PERFORM BB.
4 references
2 references
__rootdir__/prog.cob:6.12:
3 PROGRAM-ID. prog.
4 PROCEDURE DIVISION.
Expand All @@ -205,7 +205,7 @@ let%expect_test "codelens-procedure" =
---- ^
7 PERFORM BB.
8 CC.
4 references
3 references
__rootdir__/prog.cob:8.12:
5 AA SECTION.
6 BB.
Expand All @@ -214,7 +214,7 @@ let%expect_test "codelens-procedure" =
---- ^
9 DD SECTION.
10 PERFORM AA.
2 references
1 reference
__rootdir__/prog.cob:9.12:
6 BB.
7 PERFORM BB.
Expand All @@ -223,4 +223,4 @@ let%expect_test "codelens-procedure" =
---- ^
10 PERFORM AA.
11 PERFORM BB.
4 references |}];;
2 references |}];;

0 comments on commit 0442593

Please sign in to comment.