Commits

Anonymous committed 810632b

PIdent can point to the whole file

Comments (0)

Files changed (1)

ocamlspot/ocamlspot.ml

   module PIdent = struct
     type t = {
       path : string;
-      ident : Ident.t;
+      ident : Ident.t option; (* None means the top module *)
     }
 
     let format ppf id = 
-      Format.fprintf ppf "%s:%s" id.path (Ident.name id.ident)
+      Format.fprintf ppf "%s:%s" id.path 
+	(match id.ident with
+	| Some id -> Ident.name id
+	| None -> "TOP")
   end
 
   module Value = struct
           eager (Structure str), flat
       | Mod_functor (id, mexp) -> 
           eager (Closure (env, id, mexp)),
-          snd (module_expr { env with structure = (id, eager (Parameter { PIdent.path = env.path; ident = id })) ^:: env.structure } mexp)
+          snd (module_expr { env with structure = (id, eager (Parameter { PIdent.path = env.path; ident = Some id })) ^:: env.structure } mexp)
       | Mod_constraint (mexp, _mty) -> 
           (* [_mty] may not be a simple signature but an ident which is
              hard to get its definition at this point. 
 	    end
 	| _, Some id -> 
             (* CR jfuruse: ??? *)
-            (id, eager (Ident { PIdent.path = env.Env.path; ident = id})) ^:: str,
-            (id, eager (Ident { PIdent.path = env.Env.path; ident = id})) ^:: flat
+            (id, eager (Ident { PIdent.path = env.Env.path; ident = Some id})) ^:: str,
+            (id, eager (Ident { PIdent.path = env.Env.path; ident = Some id})) ^:: flat
 	| Str_include (mexp, ids), None ->
             let v, flat' = module_expr env mexp in
 	    let str' =
         (* CR jfuruse: loading twice... *)
         Debug.format "Finding %a@." PIdent.format id;
         let file = Load.load ~load_paths: [] (spot_of_file id.PIdent.path) in
-        Hashtbl.find file.id_def_locations id.PIdent.ident
+	match id.PIdent.ident with
+	| Some id -> Hashtbl.find file.id_def_locations id
+	| None -> Location.none (* the whole file *)
       in
       
       let find_local_identifier id =
 
       match path with
       | Path.Pident id ->
-          begin try find_local_identifier id with Not_found ->
+          begin try find_local_identifier (Some id) with Not_found ->
             (* local identifiers may be defined indirectly by include *)
             eval_and_find path
           end