瀏覽代碼

allow `--display File.hx@0@resolve@TypeName` (see #2996)

Simon Krajewski 11 年之前
父節點
當前提交
790e67ef6a
共有 4 個文件被更改,包括 23 次插入3 次删除
  1. 1 0
      common.ml
  2. 11 2
      main.ml
  3. 9 1
      typeload.ml
  4. 2 0
      typer.ml

+ 1 - 0
common.ml

@@ -106,6 +106,7 @@ type display_mode =
 	| DMUsage
 	| DMPosition
 	| DMToplevel
+	| DMResolve of string
 
 type context = {
 	(* config *)

+ 11 - 2
main.ml

@@ -1193,9 +1193,18 @@ try
 					| "toplevel" ->
 						activate_special_display_mode();
 						DMToplevel
-					| _ ->
+					| "" ->
 						Parser.use_parser_resume := true;
 						DMDefault
+					| _ ->
+						let smode,arg = try ExtString.String.split smode "@" with _ -> pos,"" in
+						match smode with
+							| "resolve" ->
+								activate_special_display_mode();
+								DMResolve arg
+							| _ ->
+								Parser.use_parser_resume := true;
+								DMDefault
 				in
 				let pos = try int_of_string pos with _ -> failwith ("Invalid format : "  ^ pos) in
 				com.display <- mode;
@@ -1447,7 +1456,7 @@ try
 		t();
 		if ctx.has_error then raise Abort;
 		begin match com.display with
-			| DMNone | DMUsage | DMPosition ->
+			| DMNone | DMUsage | DMPosition | DMResolve _ ->
 				()
 			| _ ->
 				if ctx.has_next then raise Abort;

+ 9 - 1
typeload.ml

@@ -1673,7 +1673,15 @@ let init_class ctx c p context_init herits fields =
 
 	(* ----------------------- COMPLETION ----------------------------- *)
 
-	let display_file = if ctx.com.display <> DMNone then Common.unique_full_path p.pfile = (!Parser.resume_display).pfile else false in
+	let display_file = match ctx.com.display with
+		| DMNone -> false
+		| DMResolve s ->
+			let mt = load_type_def ctx p {tname = s; tpackage = []; tsub = None; tparams = []} in
+			let p = (t_infos mt).mt_pos in
+			raise (DisplayPosition [p]);
+		| _ ->
+			Common.unique_full_path p.pfile = (!Parser.resume_display).pfile
+	in
 
 	let cp = !Parser.resume_display in
 

+ 2 - 0
typer.ml

@@ -3484,6 +3484,8 @@ and handle_display ctx e_ast iscall p =
 		cf.cf_meta <- (Meta.Usage,[],p) :: cf.cf_meta;
 	in
 	match ctx.com.display with
+	| DMResolve _ ->
+		assert false
 	| DMUsage | DMPosition ->
 		begin match e.eexpr with
 		| TField(_,FEnum(_,ef)) ->