Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More complete document state request #844

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions language-server/dm/document.ml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ let code_lines_sorted_by_loc parsed =
[] (* todo comments *)
]

let code_lines_by_end_sorted_by_loc parsed =
List.sort compare_code_line @@ List.concat [
(List.map (fun (_,x) -> Sentence x) @@ LM.bindings parsed.sentences_by_end) ;
(List.map (fun (_,x) -> ParsingError x) @@ LM.bindings parsed.parsing_errors_by_end) ;
[] (* todo comments *)
]

let sentences_sorted_by_loc parsed =
List.sort (fun ({start = s1} : sentence) {start = s2} -> s1 - s2) @@ List.map snd @@ SM.bindings parsed.sentences_by_id

Expand Down
1 change: 1 addition & 0 deletions language-server/dm/document.mli
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ type code_line =

val sentences : document -> sentence list
val code_lines_sorted_by_loc : document -> code_line list
val code_lines_by_end_sorted_by_loc : document -> code_line list
val sentences_sorted_by_loc : document -> sentence list

val get_sentence : document -> sentence_id -> sentence option
Expand Down
7 changes: 5 additions & 2 deletions language-server/dm/documentManager.ml
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ module Internal = struct
validate_document st

let string_of_state st =
let code_lines = Document.code_lines_sorted_by_loc st.document in
let code_lines_by_id = Document.code_lines_sorted_by_loc st.document in
let code_lines_by_end = Document.code_lines_by_end_sorted_by_loc st.document in
let string_of_state id =
if ExecutionManager.is_executed st.execution_state id then "(executed)"
else if ExecutionManager.is_remotely_executed st.execution_state id then "(executed in worker)"
Expand All @@ -626,6 +627,8 @@ module Internal = struct
| ParsingError _ -> "(error)"
| Comment _ -> "(comment)"
in
String.concat "\n" @@ List.map string_of_item code_lines
let string_by_id = String.concat "\n" @@ List.map string_of_item code_lines_by_id in
let string_by_end = String.concat "\n" @@ List.map string_of_item code_lines_by_end in
String.concat "\n" ["Document using sentences_by_id map\n"; string_by_id; "\nDocument using sentences_by_end map\n"; string_by_end]

end
Loading