Răsfoiți Sursa

fix for windows + use shortest path to class

Nicolas Cannasse 13 ani în urmă
părinte
comite
c60b813de8
1 a modificat fișierele cu 11 adăugiri și 6 ștergeri
  1. 11 6
      main.ml

+ 11 - 6
main.ml

@@ -242,7 +242,7 @@ let parse_hxml file =
 	IO.close_in ch;
 	parse_hxml_data data
 
-let lookup_classes com spath =	
+let lookup_classes com spath =
 	let rec loop = function
 		| [] -> []
 		| cp :: l ->
@@ -251,9 +251,12 @@ let lookup_classes com spath =
 			let clen = String.length c in
 			if clen < String.length spath && String.sub spath 0 clen = c then begin
 				let path = String.sub spath clen (String.length spath - clen) in
-				(* make sure the completion filename is capitalized - needed for Windows *)
-				let path = String.concat "/" (match List.rev (ExtString.String.nsplit path "/") with name :: l -> List.rev (String.capitalize name :: l) | [] -> []) in
-				(try [make_path path] with _ -> loop l)
+				(try
+					let path = make_path path in
+					(match loop l with
+					| [x] when String.length (Ast.s_type_path x) < String.length (Ast.s_type_path path) -> [x]
+					| _ -> [path])
+				with _ -> loop l)
 			end else
 				loop l
 	in
@@ -870,6 +873,8 @@ try
 		com.error <- error ctx;
 		com.main_class <- None;
 		classes := lookup_classes com (!Parser.resume_display).Ast.pfile;
+		Common.log com ("Display file : " ^ (!Parser.resume_display).Ast.pfile);
+		Common.log com ("Classes found : ["  ^ (String.concat "," (List.map Ast.s_type_path !classes)) ^ "]");
 	end;
 	let add_std dir =
 		com.class_path <- List.filter (fun s -> not (List.mem s com.std_path)) com.class_path @ List.map (fun p -> p ^ dir ^ "/_std/") com.std_path @ com.std_path
@@ -1063,11 +1068,11 @@ with
 		| Some (c,cur_package) ->
 			try
 				let ctx = Typer.create com in
-				let rec lookup p = 
+				let rec lookup p =
 					try
 						Typeload.load_module ctx (p,c) Ast.null_pos
 					with e ->
-						if cur_package then 
+						if cur_package then
 							match List.rev p with
 							| [] -> raise e
 							| _ :: p -> lookup (List.rev p)