Commits

camlspotter committed b7a1bd4

ported diff from custom-3.12.0: repeating p4 location warninsg are now surpressed

Comments (0)

Files changed (5)

Add a comment to this file

ocamlspot/BRAIN_DEAD_INSTALL.sh

File contents unchanged.

File contents unchanged.

ocamlspot/spotapi.ml

     | -1 | 0 -> { start = start; end_ = end_ }
     | _ -> 
         let pos = { start = start; end_ = end_ } in
-        Format.eprintf "MALFORMED LOCATION %s@." (to_string pos);
+        Format.eprintf "ILLFORMED LOCATION %s: ignored@." (to_string pos);
         { start = start; end_ = start }
 
   let compare l1 l2 = 

parsing/location.mli

 val input_lexbuf: Lexing.lexbuf option ref
 
 val get_pos_info : Lexing.position -> string * int * int (* file, line, char *)
+val print: formatter -> t -> unit
 val print_error: formatter -> t -> unit
 val print_error_cur_file: formatter -> unit
 val print_warning: t -> formatter -> Warnings.t -> unit
   let clear () = Hashtbl.clear recorded
 
   let record loc t = 
+    let location_wellformed loc =
+      match 
+        compare 
+          loc.Location.loc_start.Lexing.pos_cnum 
+          loc.Location.loc_end.Lexing.pos_cnum 
+      with
+      | -1 | 0 -> true
+      | _ -> false
+    in
+
     if !Clflags.annotations then begin
-      let num_records, records = 
-        try Hashtbl.find recorded loc with Not_found -> 0, []
-      in
-      (* This caching works horribly when too many things are defined 
-         at the same locations. For example, a type definition of more than 
-         3000 variants, with sexp camlp4 extension, the compile time explodes
-         from 10secs to 4mins! Therefore this works 
-         only if [num_records <= 10] 
-      *)
-      if num_records <= 10 && List.exists (equal t) records then ()
-      else Hashtbl.replace recorded loc (num_records + 1, t :: records)
+      if not (location_wellformed loc) then
+        Format.eprintf "%aWarning: ill-formed location. Ignored for spot.@." Location.print loc
+      else begin
+        let num_records, records = 
+          try Hashtbl.find recorded loc with Not_found -> 0, []
+        in
+        (* This caching works horribly when too many things are defined 
+           at the same locations. For example, a type definition of more than 
+           3000 variants, with sexp camlp4 extension, the compile time explodes
+           from 10secs to 4mins! Therefore this works 
+           only if [num_records <= 10] 
+        *)
+        if num_records <= 10 && List.exists (equal t) records then ()
+        else Hashtbl.replace recorded loc (num_records + 1, t :: records)
+      end
     end
 
   let record_constr_type_use loc ty =
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.