Prechádzať zdrojové kódy

[python] don't print same debug lines multiple times

frabbit 10 rokov pred
rodič
commit
67eabafee4
1 zmenil súbory, kde vykonal 10 pridanie a 1 odobranie
  1. 10 1
      genpy.ml

+ 10 - 1
genpy.ml

@@ -1554,11 +1554,20 @@ module Printer = struct
 	and print_exprs pctx sep el =
 		String.concat sep (List.map (print_expr pctx) el)
 
+	and last_debug_comment = ref ("")
+
 	and print_block_exprs pctx sep print_debug_comment el =
 		if print_debug_comment then begin
 			let el = List.fold_left (fun acc e ->
 				let line = Lexer.get_error_line e.epos in
-				(print_expr pctx e) :: (Printf.sprintf "# %s:%i" e.epos.pfile line) :: acc
+				let debug_line = (Printf.sprintf "# %s:%i" e.epos.pfile line) in
+				let res = if (!last_debug_comment) <> debug_line then
+					(print_expr pctx e) :: debug_line :: acc
+				else
+					(print_expr pctx e) :: acc
+				in
+				last_debug_comment := debug_line;
+				res
 			) [] el in
 			String.concat sep (List.rev el)
 		end else