Skip to content

Commit 13991bd

Browse files
committed
absorb shared display information into part_scope
1 parent 2278f21 commit 13991bd

2 files changed

Lines changed: 5 additions & 19 deletions

File tree

src/context/common.ml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,12 @@ class file_keys = object(self)
140140

141141
end
142142

143-
type shared_display_information = {
144-
mutable diagnostics_messages : diagnostic list;
145-
}
146-
147143
type display_information = {
148144
mutable unresolved_identifiers : (string * pos * (string * CompletionItem.t * int) list) list;
149145
mutable display_module_has_macro_defines : bool;
150146
mutable module_diagnostics : DisplayTypes.module_diagnostics list;
151147
}
152148

153-
(* This information is shared between normal and macro context. *)
154-
type shared_context = {
155-
shared_display_information : shared_display_information;
156-
}
157-
158149
type json_api = {
159150
send_result : Json.t -> unit;
160151
send_result_raise : 'a . Json.t -> 'a;
@@ -288,6 +279,7 @@ end
288279

289280
type part_scope = {
290281
warned_positions : (string * int, string * Globals.pos * warning_option list list) Hashtbl.t;
282+
mutable diagnostics_messages : diagnostic list;
291283
}
292284

293285
type request_scope = {
@@ -346,7 +338,6 @@ type context = {
346338
(* typing state *)
347339
mutable std : tclass;
348340
mutable global_metadata : (string list * metadata_entry * (bool * bool * bool)) list;
349-
shared : shared_context;
350341
display_information : display_information;
351342
file_keys : file_keys;
352343
mutable file_contents : (Path.UniqueKey.t * string option) list;
@@ -749,6 +740,7 @@ let create io request_scope compilation_step sctx version args display_mode =
749740
request_scope;
750741
part_scope = {
751742
warned_positions = Hashtbl.create 0;
743+
diagnostics_messages = [];
752744
};
753745
compilation_step = compilation_step;
754746
sctx;
@@ -758,11 +750,6 @@ let create io request_scope compilation_step sctx version args display_mode =
758750
stage = CCreated;
759751
version = version;
760752
args = args;
761-
shared = {
762-
shared_display_information = {
763-
diagnostics_messages = [];
764-
}
765-
};
766753
display_information = {
767754
unresolved_identifiers = [];
768755
display_module_has_macro_defines = false;
@@ -888,7 +875,6 @@ let clone com is_macro_context =
888875
timer_ctx = com.timer_ctx;
889876
version = com.version;
890877
args = com.args;
891-
shared = com.shared;
892878
debug = com.debug;
893879
display = com.display;
894880
verbose = com.verbose;
@@ -1140,7 +1126,7 @@ let hash f =
11401126

11411127
let add_diagnostics_message ?(depth = 0) ?(code = None) com s p kind sev =
11421128
if sev = MessageSeverity.Error then com.has_error <- true;
1143-
let di = com.shared.shared_display_information in
1129+
let di = com.part_scope in
11441130
di.diagnostics_messages <- (make_diagnostic ~depth ~code s p kind sev) :: di.diagnostics_messages
11451131

11461132
let display_error_ext com err =

src/context/display/diagnostics.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ let prepare com =
147147
unresolved_identifiers = [];
148148
missing_fields = PMap.empty;
149149
} in
150-
if not (List.exists (fun diag -> diag.diag_severity = MessageSeverity.Error) com.shared.shared_display_information.diagnostics_messages) then
150+
if not (List.exists (fun diag -> diag.diag_severity = MessageSeverity.Error) com.part_scope.diagnostics_messages) then
151151
collect_diagnostics dctx com;
152152
let process_modules com =
153153
List.iter (fun m ->
@@ -177,7 +177,7 @@ let prepare com =
177177
| Some com -> process_modules com
178178
end;
179179
(* We do this at the end because some of the prepare functions might add information to the common context. *)
180-
dctx.diagnostics_messages <- com.shared.shared_display_information.diagnostics_messages;
180+
dctx.diagnostics_messages <- com.part_scope.diagnostics_messages;
181181
dctx.unresolved_identifiers <- com.display_information.unresolved_identifiers;
182182
dctx
183183

0 commit comments

Comments
 (0)