camlspotter avatar camlspotter committed 2b31b4e Merge

merge

Comments (0)

Files changed (9)

README-ocamlspot.txt

+====================================
 OCamlSpotter : OCaml source browsing
 ====================================
 
    locations in emacs.
 
  - Interfaces for other editors such as vi can be built easily, if you
-   want. 
+   want. I do not want.
    
+Compilation information
+===============================
+
+SYNOPSIS
+
+      ocamlspot info [path]
+
+DESCRIPTION
+
+      Show how a .spot/.spit file is compiled. 
+      The following fields are printed:
+
+      Compile: 
+          The compilation command to create the file. 
+
+      Included_dirs:
+          The include paths used at the compilation.
+
+      Example:
+
+	$ ocamlspot info ocamlspot.spot
+	Compile: ../ocamlc -nostdlib -I ../stdlib -annot -annot -w Ae -warn-error Ae -I ../parsing -I ../utils -I ../typing -I ../driver -I ../bytecomp -I ../tools -I ../toplevel/ -I ../otherlibs/unix -c ocamlspot.ml
+	Included_dirs:
+	  /..../ocaml/ocamlspot/
+	  /..../ocaml/ocamlspot/../stdlib
+	  /..../ocaml/ocamlspot/../parsing
+	  /..../ocaml/ocamlspot/../utils
+	  /..../ocaml/ocamlspot/../typing
+	  /..../ocaml/ocamlspot/../driver
+	  /..../ocaml/ocamlspot/../bytecomp
+	  /..../ocaml/ocamlspot/../tools
+	  /..../ocaml/ocamlspot/../toplevel/
+	  /..../ocaml/ocamlspot/../otherlibs/unix
+	BYE!
+
+OPTIONS
+
+      No options are available.
+ 
 Spotting / Definition analysis
 ==============================
 
 SYNOPSIS
 
       ocamlspot [search]
-            search ::= [file] | [file]:[pos] | [file]:[kind]:[path]
+      ocamlspot query [search]
+            search ::= [file]:[pos] | [file]:[kind]:[path]
             pos ::= l[line]c[column_bytes] | b[bytes] | [bytes]
             kind ::= v|t|e|m|mt|c|ct
+            
+            where
+              v  : value
+	      t  : type
+	      e  : exception
+	      m  : module
+	      mt : module type
+	      c  : class
+	      ct : class type
 
 DESCRIPTION
 
           available. In XType, paths are printed with position
           informaiton: for example, "unit__6" instead of "unit".
 
-SEARCH
+      Use: kind, name
+          The kind and the name with id numbers of the identifier 
+          at the position, if exists.
 
-      Three kinds of searches are available: file-name-only, 
-      by-position and by-path:
+QUERIES
 
-      File-name-only search show the position independent information
-      of the module specified by [file].
-
-        Example:
-
-	$ ocamlspot -i ocamlspot.ml
-	Compile: ../ocamlc -nostdlib -I ../stdlib -annot -annot -w Ae -warn-error Ae -I ../parsing -I ../utils -I ../typing -I ../driver -I ../bytecomp -I ../tools -I ../toplevel/ -I ../otherlibs/unix -c ocamlspot.ml
-	Included_dirs:
-	  /..../ocaml/ocamlspot/
-	  /..../ocaml/ocamlspot/../stdlib
-	  /..../ocaml/ocamlspot/../parsing
-	  /..../ocaml/ocamlspot/../utils
-	  /..../ocaml/ocamlspot/../typing
-	  /..../ocaml/ocamlspot/../driver
-	  /..../ocaml/ocamlspot/../bytecomp
-	  /..../ocaml/ocamlspot/../tools
-	  /..../ocaml/ocamlspot/../toplevel/
-	  /..../ocaml/ocamlspot/../otherlibs/unix
-	BYE!
+      Two kinds of searches are available: by-position and by-path:
 
       By-position search has the form [file]:[pos]. [file] is the path
       of the target ml/mli file and [pos] is the position in the
 	BYE!
 
       Note that bytes are not chars in multi-byte-character
-      environment. If your source code contains multi-byte characters,
-      you might need to count chars by yourself. In Emacs, ocamlspot.el
-      does the job for you.
+      environment. OCaml is completely free from such mess and you
+      might need to count chars by yourself.
 
 
       By-path search shows the definition spot of the given path 
       with ident id numbers. It will be useful with conjunction with 
-      the path names obtained from XType: fields. No elisp wrapper
+      the path names obtained from XType: fields. No fancy elisp wrapper
       is not available for it, though.
 
         Example:
           Skips the spotting, which may takes time. Useful if you are
           interested in other things than the definition analysis,
           i.e. types, paths, etc.
-    
+
+
 Bugs and future works
 =====================
 

ocamlspot/.depend

 spotapi.cmx: utils.cmx ../typing/types.cmx treeset.cmx ../typing/spot.cmx \
     ../typing/printtyp.cmx ../typing/predef.cmx ../typing/path.cmx \
     ../typing/ident.cmx ../typing/btype.cmx ../typing/annot.cmi spotapi.cmi
-spotconfig.cmo: utils.cmi spoteval.cmi spotapi.cmi ../typing/spot.cmi \
-    ../typing/path.cmi spotconfig.cmi
-spotconfig.cmx: utils.cmx spoteval.cmx spotapi.cmx ../typing/spot.cmx \
-    ../typing/path.cmx spotconfig.cmi
+spotconfig.cmo: utils.cmi spotapi.cmi ../typing/spot.cmi ../typing/path.cmi \
+    spotconfig.cmi
+spotconfig.cmx: utils.cmx spotapi.cmx ../typing/spot.cmx ../typing/path.cmx \
+    spotconfig.cmi
 spotconfig_intf.cmo: spotapi.cmi
 spotconfig_intf.cmx: spotapi.cmx
 spoteval.cmo: utils.cmi ../typing/types.cmi spotapi.cmi ../typing/predef.cmi \
     ../typing/env.cmx dotfile.cmx ../typing/annot.cmi spotfile.cmi
 treeset.cmo: xset.cmi treeset.cmi
 treeset.cmx: xset.cmx treeset.cmi
-typeexpand.cmo: utils.cmi ../typing/types.cmi ../typing/env.cmi \
-    ../typing/ctype.cmi typeexpand.cmi
-typeexpand.cmx: utils.cmx ../typing/types.cmx ../typing/env.cmx \
-    ../typing/ctype.cmx typeexpand.cmi
+typeexpand.cmo: utils.cmi ../typing/types.cmi ../typing/path.cmi \
+    ../typing/ident.cmi ../typing/env.cmi ../typing/ctype.cmi \
+    ../typing/btype.cmi typeexpand.cmi
+typeexpand.cmx: utils.cmx ../typing/types.cmx ../typing/path.cmx \
+    ../typing/ident.cmx ../typing/env.cmx ../typing/ctype.cmx \
+    ../typing/btype.cmx typeexpand.cmi
 utils.cmo: utils.cmi
 utils.cmx: utils.cmi
 xmain.cmo: ../typing/spot.cmi xmain.cmi

ocamlspot/Changes

 1.4.0
 --------------
+
+- -i and --info options are now obsolete. Use ``ocamlspot info <filename>'' instead.
+
 ocamlspot.el:
 - ocamlspot-path is removed. Use ocamlspot-command custom variable.
 - ocamlspot-pop-jump-stack for going back to the latest query position. Experimental.

ocamlspot/ocamlspot.el

 	  nil)))))
 
 (defun ocamlspot-display-overlay (buffer emacs-start-end overlay)
-  (if start-end
+  (if emacs-start-end
       (progn
-	(destructuring-bind (start end) start-end
+	(destructuring-bind (start end) emacs-start-end
 	  ;; display the result
 	  (set-buffer buffer)
 	  (goto-char start)
-	  (move-overlay overlay start end buffer)))))
+	  (move-overlay overlay start end buffer)))
+    (message "ocamlspot-display-overlay: strange region")))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Warnings
 
   (interactive)
   (ocamlspot-message-init (buffer-file-name))
   (ocamlspot-type-init)
-  (ocamlspot-delete-overlays-now)
-  (ocamlspot-query-at-cursor "-n --show-typedecl")
+  (ocamlspot-query-at-cursor "-n --type-expand")
   (let ((expansion (ocamlspot-find-query-result "Expand")))
     (if expansion
 	(let ((start-end (ocamlspot-find-tree)))
 	  (if start-end
 	      (destructuring-bind (start end) start-end
-		(kill-region start end)
+                (ocamlspot-delete-overlays-now)
+		(delete-region start end) ; or kill-region ?
 		(goto-char start)
-		(insert expansion))
+		(insert expansion)
+		(let ((new-end (point)))
+		  (ocamlspot-display-overlay (current-buffer) (list start new-end) ocamlspot-tree-overlay))
+		(ocamlspot-delete-overlays)
+		)
 	    (ocamlspot-message-add "OCamlSpot -expand: no tree information found")))
       (ocamlspot-message-add "OCamlSpot -expand: no expand information found"))))
 	
-;   (if (ocamlspot-find-tree)
-;       (save-current-buffer
-;         (ocamlspot-find-val-or-type to-kill)))
-;   (ocamlspot-wait t))
-
 ;; Browsing of path-range <file:lxcxbx:lxcxbx>
 (defun ocamlspot-beginning-of-path-range ()
   (search-backward "<"

ocamlspot/ocamlspot.ml

     if C.dump_top then Dump.top file;
     if C.dump_flat then Dump.flat file;
 
-    if C.print_file_info then
-      printf "Compile: %s@."
-        (String.concat " " 
-            (List.map Command.escaped_for_shell 
-                (Array.to_list file.File.argv)));
-
-    if C.print_file_info then
-      printf "@[<v2>Included_dirs:@ %a@]@."
-        (Format.list "" pp_print_string)
-        file.File.load_paths;
-
     file
   ;;
 
+  let info path =
+    let file = load (File.spot_of_file path) in
+    printf "Compile: %s@."
+      (String.concat " " 
+         (List.map Command.escaped_for_shell 
+            (Array.to_list file.File.argv)));
+    printf "@[<v2>Included_dirs:@ %a@]@."
+      (Format.list "" pp_print_string)
+      file.File.load_paths
+
   let query_by_kind_path file kind path = 
     try Some (File.find_path_in_flat file (kind, path)) with Not_found -> None
   ;;
         print_sig_entry annots;
 
         (* print_type_decl: if one Type is found *)
-        if C.print_type_declaration then begin
+        if C.type_expand then begin
           match List.filter (function Annot.Type _ -> true | _ -> false) annots with
           (* CR jfuruse: Sometimes more than one Annot.Type are found at the same place... *)
           | Annot.Type (typ, env, `Expr) :: _ -> 
   let main () = 
     match C.mode with
     | `Dump path                   -> ignore (load path)
+    | `Info path                   -> info path
     | `Query (path, spec)          -> query path spec
     | `Typecheck args              -> typecheck args
     | `Recheck args                -> recheck args

ocamlspot/spotapi.ml

   include Kind
 
   let to_string = function
-    | Value -> "v"
-    | Type -> "t"
-    | Exception -> "e" 
-    | Module -> "m"
+    | Value       -> "v"
+    | Type        -> "t"
+    | Exception   -> "e" 
+    | Module      -> "m"
     | Module_type -> "mt"
-    | Class -> "c"
-    | Class_type -> "ct"
+    | Class       -> "c"
+    | Class_type  -> "ct"
 
   (* for messages *)
   let name = function
-    | Value -> "value"
-    | Type -> "type"
-    | Exception -> "exception" 
-    | Module -> "module"
+    | Value       -> "value"
+    | Type        -> "type"
+    | Exception   -> "exception" 
+    | Module      -> "module"
     | Module_type -> "module_type"
-    | Class -> "class"
-    | Class_type -> "class_type"
+    | Class       -> "class"
+    | Class_type  -> "class_type"
 
   (* used for query interface *)        
   let from_string = function
-    | "v" | "value" -> Value
-    | "t" | "type" -> Type
-    | "e" | "exception" -> Exception
-    | "m" | "module" -> Module
+    | "v"  | "value"       -> Value
+    | "t"  | "type"        -> Type
+    | "e"  | "exception"   -> Exception
+    | "m"  | "module"      -> Module
     | "mt" | "module_type" -> Module_type
-    | "c" | "class" -> Class
-    | "ct" | "class_type" -> Class_type
+    | "c"  | "class"       -> Class
+    | "ct" | "class_type"  -> Class_type
     | _ -> raise Not_found
 end
 

ocamlspot/spotconfig.ml

 open Utils
 
 open Spotapi
-open Spoteval
 
 let app_version = "1.4.0"
 
 let eager_dump             = ref false
 let no_definition_analysis = ref false
 let strict_time_stamp      = ref false
-let print_file_info        = ref false
 let print_interface        = ref false
-let print_type_declaration = ref false
+let type_expand            = ref false
 let rest_args_rev          = ref []
 
 let _ = 
-  Arg.parse 
+  Arg.parse (Arg.align
     [ "--version", 
-      Arg.Unit print_version, "\t: print version information";
+      Arg.Unit print_version, " : print version information";
 
       "-version", 
-      Arg.Unit print_version, "\t: (deprecated)";
+      Arg.Unit print_version, " : (deprecated)";
 
       "-n", 
-      Arg.Set no_definition_analysis, "\t: no definition analysis";
+      Arg.Set no_definition_analysis, " : no definition analysis";
 
       "--no-analysis", 
-      Arg.Set no_definition_analysis, "\t: no definition analysis";
+      Arg.Set no_definition_analysis, " : no definition analysis";
       
-      "-i", 
-      Arg.Set print_file_info, "\t: print file information";
-
-      "--info", 
-      Arg.Set print_file_info, "\t: print file information";
-
       "--strict-time-stamp", 
-      Arg.Set strict_time_stamp, "\t: error at newer source files than their spots";
+      Arg.Set strict_time_stamp, " : error at newer source files than their spots";
 
       "--interface", 
-      Arg.Set print_interface, "\t: show the interface rather than the definition (experimental)";
+      Arg.Set print_interface, " : show the interface rather than the definition (experimental)";
 
-      "--show-typedecl",
-      Arg.Set print_type_declaration, "\t: show corresponding type declaration (experimental)";
+      "--type-expand",
+      Arg.Set type_expand, " : expression/pattern expansion by type (experimental)";
 
       "--debug", 
-      Arg.Set Debug.on, "\t: print debug information";
+      Arg.Set Debug.on, " : print debug information";
 
       "-debug", 
-      Arg.Set Debug.on, "\t: (deprecated)";
+      Arg.Set Debug.on, " : (deprecated)";
 
       "--dump-file", 
-      Arg.Set dump_file, "\t: dump spot file"; 
+      Arg.Set dump_file, " : dump spot file"; 
 
       "--dump-rannots", 
-      Arg.Unit (fun () -> dump_rannots := `Full), "\t: dump loc-annots";
+      Arg.Unit (fun () -> dump_rannots    := `Full), " : dump loc-annots";
 
       "--dump-rannots-summary", 
-      Arg.Unit (fun () -> dump_rannots := `Summary), "\t: dump loc-annots";
+      Arg.Unit (fun () -> dump_rannots    := `Summary), " : dump loc-annots";
 
       "--dump-tree", 
-      Arg.Set dump_tree, "\t: dump annot tree";
+      Arg.Set dump_tree, " : dump annot tree";
 
       "--dump-top", 
-      Arg.Set dump_top, "\t: dump top"; 
+      Arg.Set dump_top, " : dump top"; 
 
       "--dump-flat", 
-      Arg.Set dump_flat, "\t: dump flat"; 
+      Arg.Set dump_flat, " : dump flat"; 
 
       "--eager-dump", 
-      Arg.Set eager_dump, "\t: eager evaluation at dump";
-    ]
+      Arg.Set eager_dump, " : eager evaluation at dump";
+    ])
     (fun s -> rev_anonargs := s :: !rev_anonargs)
     (Printf.sprintf 
         "ocamlspot version %s\n\
 let eager_dump             = !eager_dump
 let no_definition_analysis = !no_definition_analysis
 let strict_time_stamp      = !strict_time_stamp
-let print_file_info        = !print_file_info
 let print_interface        = !print_interface
-let print_type_declaration = !print_type_declaration
+let type_expand            = !type_expand
 
 let dump_any = 
   dump_file || dump_rannots <> `None || dump_tree || dump_top || dump_flat
       anonargs;
     match anonargs with
     | [ "query"; spec ]        -> `Query (SearchSpec.parse spec)
+    | [ "info"; file ]         -> `Info file
     | "use" :: spec :: targets -> `Use (SearchSpec.parse spec, targets)
     | "typecheck" :: rest      -> `Typecheck rest
     | "recheck" :: rest        -> `Recheck rest

ocamlspot/spotconfig_intf.ml

   
   val strict_time_stamp      : bool
   
-  val print_file_info        : bool
   val print_interface        : bool
-  val print_type_declaration : bool
+  val type_expand            : bool
 
   module SearchSpec : sig
     type t =
   end
   
   val mode : [ `Dump      of string
+             | `Info      of string
              | `Query     of string * SearchSpec.t
              | `Use       of (string * SearchSpec.t) * string list
              | `Recheck   of string list

ocamlspot/typeexpand.mli

 (*                                                                     *)
 (***********************************************************************)
 
-(* expansion(?) of expr/pattern by type *)
+(* expansion of expr/pattern by type *)
 
 open Asttypes
 open Types
 type t 
 
 val expand : string list (* load_path *) -> Env.t -> type_expr -> t
+(** Build expansion of the given type *)
 
-val format_as_expr : Format.formatter -> t -> unit
+val format_as_expr    : Format.formatter -> t -> unit
 val format_as_pattern : Format.formatter -> t -> unit
+(** Print expansion as an expression or a pattern *)
 
 module EnvSummary : sig
   val format : Format.formatter -> Env.summary -> unit
+  (** Debugging purpose. Show the summary of the environment *)
 end
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.