فهرست منبع

[diagnostics] remove legacy diagnostics handling

Rudy Ges 1 سال پیش
والد
کامیت
f7ea10a9fe

+ 2 - 8
src/compiler/compiler.ml

@@ -7,10 +7,7 @@ let run_or_diagnose ctx f =
 	let handle_diagnostics msg p kind =
 		ctx.has_error <- true;
 		add_diagnostics_message com msg p kind Error;
-		match com.report_mode with
-		| RMLegacyDiagnostics _ -> DisplayOutput.emit_legacy_diagnostics ctx.com
-		| RMDiagnostics _ -> DisplayOutput.emit_diagnostics ctx.com
-		| _ -> die "" __LOC__
+		DisplayOutput.emit_diagnostics ctx.com
 	in
 	if is_diagnostics com then begin try
 			f ()
@@ -20,10 +17,7 @@ let run_or_diagnose ctx f =
 			Error.recurse_error (fun depth err ->
 				add_diagnostics_message ~depth com (Error.error_msg err.err_message) err.err_pos DKCompilerMessage Error
 			) err;
-			(match com.report_mode with
-			| RMLegacyDiagnostics _ -> DisplayOutput.emit_legacy_diagnostics ctx.com
-			| RMDiagnostics _ -> DisplayOutput.emit_diagnostics ctx.com
-			| _ -> die "" __LOC__)
+			DisplayOutput.emit_diagnostics ctx.com;
 		| Parser.Error(msg,p) ->
 			handle_diagnostics (Parser.error_msg msg) p DKParserError
 		| Lexer.Error(msg,p) ->

+ 0 - 6
src/compiler/displayOutput.ml

@@ -368,12 +368,6 @@ let handle_type_path_exception ctx p c is_import pos =
 		api.send_result (DisplayException.fields_to_json ctx fields kind (DisplayTypes.make_subject None pos));
 	end
 
-let emit_legacy_diagnostics com =
-	let dctx = Diagnostics.run com in
-	let s = Json.string_of_json (DiagnosticsPrinter.json_of_diagnostics com dctx) in
-	DisplayPosition.display_position#reset;
-	raise (Completion s)
-
 let emit_diagnostics com =
 	(match com.Common.json_out with
 	| None -> die "" __LOC__

+ 0 - 9
src/compiler/displayProcessing.ml

@@ -21,12 +21,9 @@ let handle_display_argument_old com file_pos actx =
 	| "memory" ->
 		actx.did_something <- true;
 		(try Memory.display_memory com with e -> prerr_endline (Printexc.get_backtrace ()));
-	| "diagnostics" ->
-		com.report_mode <- RMLegacyDiagnostics []
 	| _ ->
 		let file, pos = try ExtString.String.split file_pos "@" with _ -> failwith ("Invalid format: " ^ file_pos) in
 		let file = Helper.unquote file in
-		let file_unique = com.file_keys#get file in
 		let pos, smode = try ExtString.String.split pos "@" with _ -> pos,"" in
 		let create mode =
 			Parser.display_mode := mode;
@@ -45,10 +42,6 @@ let handle_display_argument_old com file_pos actx =
 				create DMDefault
 			| "module-symbols" ->
 				create (DMModuleSymbols None)
-			| "diagnostics" ->
-				com.report_mode <- RMLegacyDiagnostics [file_unique];
-				let dm = create DMNone in
-				{dm with dms_display_file_policy = DFPAlso; dms_per_file = true; dms_populate_cache = !ServerConfig.populate_cache_from_display}
 			| "statistics" ->
 				com.report_mode <- RMStatistics;
 				let dm = create DMNone in
@@ -348,8 +341,6 @@ let handle_display_after_finalization ctx tctx display_file_dot_path =
 	end;
 	process_global_display_mode com tctx;
 	begin match com.report_mode with
-	| RMLegacyDiagnostics _ ->
-		DisplayOutput.emit_legacy_diagnostics com
 	| RMDiagnostics _ ->
 		DisplayOutput.emit_diagnostics com
 	| RMStatistics ->

+ 3 - 8
src/compiler/server.ml

@@ -3,7 +3,6 @@ open Common
 open CompilationCache
 open Timer
 open Type
-open DisplayProcessingGlobals
 open Ipaddr
 open Json
 open CompilationContext
@@ -28,15 +27,11 @@ let check_display_flush ctx f_otherwise = match ctx.com.json_out with
 			api.send_error errors
 		end
 	| _ ->
-		if is_diagnostics ctx.com then begin
+		if is_diagnostics ctx.com then
 			List.iter (fun cm ->
 				add_diagnostics_message ~depth:cm.cm_depth ctx.com cm.cm_message cm.cm_pos cm.cm_kind cm.cm_severity
-			) (List.rev ctx.messages);
-			(match ctx.com.report_mode with
-			| RMDiagnostics _ -> ()
-			| RMLegacyDiagnostics _ -> raise (Completion (Diagnostics.print ctx.com))
-			| _ -> die "" __LOC__)
-		end else
+			) (List.rev ctx.messages)
+		else
 			f_otherwise ()
 
 let current_stdin = ref None

+ 1 - 2
src/context/common.ml

@@ -289,7 +289,6 @@ let s_compiler_stage = function
 
 type report_mode =
 	| RMNone
-	| RMLegacyDiagnostics of (Path.UniqueKey.t list)
 	| RMDiagnostics of (Path.UniqueKey.t list)
 	| RMStatistics
 
@@ -893,7 +892,7 @@ let create compilation_step cs version args =
 	com
 
 let is_diagnostics com = match com.report_mode with
-	| RMLegacyDiagnostics _ | RMDiagnostics _ -> true
+	| RMDiagnostics _ -> true
 	| _ -> false
 
 let disable_report_mode com =

+ 2 - 2
src/context/display/diagnosticsPrinter.ml

@@ -26,8 +26,8 @@ let make_diagnostic kd p sev code args = {
 
 let is_diagnostics_file com file_key =
 	match com.report_mode with
-	| RMLegacyDiagnostics [] | RMDiagnostics [] -> true
-	| RMLegacyDiagnostics file_keys | RMDiagnostics file_keys -> List.mem file_key file_keys
+	| RMDiagnostics [] -> true
+	| RMDiagnostics file_keys -> List.mem file_key file_keys
 	| _ -> false
 
 module UnresolvedIdentifierSuggestion = struct