Browse Source

use accurate positions for import/using display

Simon Krajewski 9 years ago
parent
commit
c721e816bf
2 changed files with 17 additions and 15 deletions
  1. 10 8
      src/display/display.ml
  2. 7 7
      src/typing/typeload.ml

+ 10 - 8
src/display/display.ml

@@ -294,6 +294,8 @@ type import_display_kind =
 	| IDKSubTypeField of string list * string * string * string
 	| IDK
 
+type import_display = import_display_kind * pos
+
 let convert_import_to_something_usable path =
 	let rec loop pack m t = function
 		| (s,p) :: l ->
@@ -303,22 +305,22 @@ let convert_import_to_something_usable path =
 				| _,None,Some _ | false,Some _,Some _ ->
 					assert false (* impossible, I think *)
 				| true,Some m,None ->
-					if is_display_pos then IDKModuleField(List.rev pack,m,s)
-					else IDK (* assume that we're done *)
+					if is_display_pos then (IDKModuleField(List.rev pack,m,s),p)
+					else (IDK,p) (* assume that we're done *)
 				| true,Some m,Some t ->
-					if is_display_pos then IDKSubTypeField(List.rev pack,m,t,s)
-					else IDK
+					if is_display_pos then (IDKSubTypeField(List.rev pack,m,t,s),p)
+					else (IDK,p)
 				| true,None,None ->
-					if is_display_pos then IDKPackage (List.rev (s :: pack))
+					if is_display_pos then (IDKPackage (List.rev (s :: pack)),p)
 					else loop (s :: pack) m t l
 				| false,Some sm,None ->
-					if is_display_pos then IDKSubType (List.rev pack,sm,s)
+					if is_display_pos then (IDKSubType (List.rev pack,sm,s),p)
 					else loop pack m (Some s) l
 				| false,None,None ->
-					if is_display_pos then IDKModule (List.rev pack,s)
+					if is_display_pos then (IDKModule (List.rev pack,s),p)
 					else loop pack (Some s) None l
 			end
 		| [] ->
-			IDK
+			(IDK,null_pos)
 	in
 	loop [] None None path

+ 7 - 7
src/typing/typeload.ml

@@ -2859,22 +2859,22 @@ let add_module ctx m p =
 
 let handle_path_display ctx path p =
 	match Display.convert_import_to_something_usable path,ctx.com.display with
-		| Display.IDKPackage sl,_ ->
+		| (Display.IDKPackage sl,_),_ ->
 			raise (Parser.TypePath(sl,None,true))
-		| Display.IDKModule(sl,s),DMPosition ->
+		| (Display.IDKModule(sl,s),_),DMPosition ->
 			(* We assume that we want to go to the module file, not a specific type
 			   which might not even exist anyway. *)
 			let mt = ctx.g.do_load_module ctx (sl,s) p in
 			let p = { pfile = mt.m_extra.m_file; pmin = 0; pmax = 0} in
 			raise (Display.DisplayPosition [p])
-		| Display.IDKModule(sl,s),_ ->
+		| (Display.IDKModule(sl,s),_),_ ->
 			(* TODO: wait till nadako requests @type display for these, then implement it somehow *)
 			raise (Parser.TypePath(sl,Some(s,false),true))
-		| Display.IDKSubType(sl,sm,st),DMPosition ->
+		| (Display.IDKSubType(sl,sm,st),p),DMPosition ->
 			resolve_position_by_path ctx { tpackage = sl; tname = sm; tparams = []; tsub = Some st} p
-		| Display.IDKSubType(sl,sm,st),_ ->
+		| (Display.IDKSubType(sl,sm,st),_),_ ->
 			raise (Parser.TypePath(sl @ [sm],Some(st,false),true))
-		| (Display.IDKSubTypeField(sl,sm,st,sf) | Display.IDKModuleField(sl,(sm as st),sf)),_ ->
+		| ((Display.IDKSubTypeField(sl,sm,st,sf) | Display.IDKModuleField(sl,(sm as st),sf)),p),_ ->
 			let m = ctx.g.do_load_module ctx (sl,sm) p in
 			List.iter (fun t -> match t with
 				| TClassDecl c when snd c.cl_path = st ->
@@ -2884,7 +2884,7 @@ let handle_path_display ctx path p =
 				| _ ->
 					()
 			) m.m_types;
-		| Display.IDK,_ ->
+		| (Display.IDK,_),_ ->
 			()
 
 (*