2
0
Эх сурвалжийг харах

support display on placed names

Simon Krajewski 9 жил өмнө
parent
commit
f77249368d

+ 10 - 1
src/display/display.ml

@@ -12,6 +12,9 @@ let is_display_file p =
 let encloses_position p_target p =
 	p.pmin <= p_target.pmin && p.pmax >= p_target.pmax
 
+let is_display_position p =
+	is_display_file p && encloses_position !Parser.resume_display p
+
 let find_enclosing com e =
 	let display_pos = ref (!Parser.resume_display) in
 	let mk_null p = (EDisplay(((EConst(Ident "null")),p),false),p) in
@@ -82,7 +85,13 @@ let display_type dm t =
 		let ti = t_infos mt in
 		ti.mt_meta <- (Meta.Usage,[],ti.mt_pos) :: ti.mt_meta
 	| DMType -> raise (DisplayTypes [t])
-	| _ -> raise Exit
+	| _ -> ()
+
+let display_variable dm v = match dm with
+	| DMPosition -> raise (DisplayPosition [v.v_pos])
+	| DMUsage -> v.v_meta <- (Meta.Usage,[],v.v_pos) :: v.v_meta;
+	| DMType -> raise (DisplayTypes [v.v_type])
+	| _ -> ()
 
 module SymbolKind = struct
 	type t =

+ 3 - 1
src/typing/typeload.ml

@@ -467,7 +467,7 @@ let rec load_instance ?(allow_display=false) ctx (t,p) allow_no_params =
 			f params
 		end
 	in
-	if allow_display && ctx.com.display <> DMNone && Display.is_display_file p && Display.encloses_position !Parser.resume_display p then
+	if allow_display && ctx.com.display <> DMNone && Display.is_display_position p then
 		Display.display_type ctx.com.display t;
 	t
 
@@ -1547,6 +1547,8 @@ let type_function ctx args ret fmode f do_display p =
 		let c = type_function_arg_value ctx t c in
 		let v,c = add_local ctx n t pn, c in
 		v.v_meta <- m;
+		if do_display && Display.encloses_position !Parser.resume_display pn then
+			Display.display_variable ctx.com.display v;
 		if n = "this" then v.v_meta <- (Meta.This,[],p) :: v.v_meta;
 		v,c
 	) args f.f_args in

+ 6 - 1
src/typing/typer.ml

@@ -2828,7 +2828,10 @@ and type_vars ctx vl p =
 					Some e
 			) in
 			if v.[0] = '$' && ctx.com.display = DMNone then error "Variables names starting with a dollar are not allowed" p;
-			add_local ctx v t pv, e
+			let v,e = add_local ctx v t pv, e in
+			if Display.is_display_position pv then
+				Display.display_variable ctx.com.display v;
+			v,e
 		with
 			Error (e,p) ->
 				display_error ctx (error_msg e) p;
@@ -3221,6 +3224,8 @@ and type_try ctx e1 catches with_type p =
 		check_unreachable acc t2 (pos e);
 		let locals = save_locals ctx in
 		let v = add_local ctx v t pv in
+		if Display.is_display_position pv then
+			Display.display_variable ctx.com.display v;
 		let e = type_expr ctx e with_type in
 		v.v_type <- t2;
 		locals();