Permalink
Browse files

Print errors in emacs for all queries

  • Loading branch information...
1 parent 51b574c commit 4e320340c80a228666b46bb206d0929d65de6176 Tiphaine Turpin committed Jul 11, 2011
View
@@ -1,3 +1,4 @@
+- Git add renameException.ml
- Rename: replace in multiple files
- Grep: should be easy to implement using rename
- Rename: return a list of files that emacs should revert
@@ -67,24 +67,6 @@ let compile_file ast c_env =
let step msg =
Util.debugln "\n <+> Step : %s \n-----------------" msg
-(*
-let out_types_from ty_lis =
- if !Common_config.debug then (
- Format.eprintf "> Types: [";
- match ty_lis with
- | [] ->
- Format.eprintf "empty]@.";
- | [a] ->
- !Oprint.out_type Format.err_formatter a;
- Format.eprintf "]@."
- | [a;b]->
- !Oprint.out_type Format.err_formatter a;
- Format.eprintf "]@."
- | _ ->
- Debug.unreachable "Comletion" 7
- )
-*)
-
(** *)
let main ce =
(* 1 - parsing the file *)
@@ -100,10 +82,6 @@ let main ce =
let structure, sg, ce = compile_file se.ast ce in
Util.debugln "OK";
- (* Exiting with the error code (for auto-test) *)
- if !Common_config.compile_only then
- Debug.exit_with_code (!Common_config.dot_test) se.comp;
-
let pattern_env, pattern_type =
match se.comp with
| Match (AllCs | MissCs _) -> (* We should rather look at the pattern. *)
@@ -44,6 +44,10 @@
(defun ocamlwizard-match-with-completion ()
"complete an Ocaml match construct using Ocamlwizard"
(interactive)
+ (setq buffer (get-buffer-create "*ocamlwizard*"))
+ (save-excursion
+ (set-buffer buffer)
+ (erase-buffer))
; (save-excursion
(setq end (point))
(re-search-backward "[^ \t\n]")
@@ -53,12 +57,18 @@
;)
(do-auto-save)
(setq exit-status
- (call-process "ocamlwizard" nil (list t nil) nil "completion" "-printer" "ocaml-pp" "-pos"
- (int-to-string (- (point) 1)) (buffer-name)))
- (if (not (eq exit-status 10))
- (message "ocamlwizard: no completion"))
- (search-backward "$")
- (delete-char 1)
+ (call-process "ocamlwizard" nil (list buffer nil) nil
+ "completion" "-printer" "ocaml-pp"
+ "-pos" (int-to-string (- (point) 1)) (buffer-name)))
+ (save-excursion
+ (set-buffer buffer)
+ (setq output (buffer-string)))
+ (if (eq exit-status 0)
+ (progn
+ (insert output)
+ (search-backward "$")
+ (delete-char 1))
+ (display-message-or-buffer buffer))
)
@@ -71,48 +81,20 @@
(erase-buffer))
(do-auto-save)
(setq exit-status
- (call-process "ocamlwizard" nil buffer nil "completion" "-printer" "ocaml-pp" "-pos"
- (int-to-string (- (point) 1)) (buffer-name)))
- (message (concat "ocamlwizard: exit-status=" (int-to-string exit-status)))
- (save-excursion
- (set-buffer buffer)
- (let* ((text (buffer-string))
- (list (split-string text "[\n]+")))
- ;(message (int-to-string (length list)))
- (setq alist (mapcar (function (lambda (x) (list x x))) list))
- ;(message (int-to-string (length alist)))
- ))
- (setq choice
- (completing-read "possible completion: " alist nil t))
-; (backward-kill-word 1)
- (insert choice)
-)
-
-
-(defun ocamlwizard-expand-patvar ()
- "expands a pattern-matching variable using Ocamlwizard"
- (interactive)
- (save-excursion
- (search-backward-regexp "[^a-zA-Z._0-9]")
- (forward-char 1)
- (setq start (point))
- (search-forward-regexp "[^a-zA-Z._0-9]")
- (setq end (- (point) 1))
- (setq word (buffer-substring start end))
- (search-forward "->")
- (setq arrow (point)))
- (setq file (buffer-name))
- (setq buffer (get-buffer-create "*ocamlwizard*"))
- (save-excursion
- (set-buffer buffer)
- (compilation-minor-mode 1)
- (erase-buffer)
- (insert "\n\n"))
- (call-process
- "ocamlwizard" nil buffer nil
- "completion" "-printer" "ocaml-pp" "-pos" (int-to-string (- arrow 1))
- "-expand" (concat (int-to-string (- start 1)) "-" (int-to-string (- end 1)))
- file)
+ (call-process "ocamlwizard" nil buffer nil "completion" "-printer" "ocaml-pp"
+ "-pos" (int-to-string (- (point) 1)) (buffer-name)))
+ (if (eq exit-status 0)
+ (progn
+ (save-excursion
+ (set-buffer buffer)
+ (let* ((text (buffer-string))
+ (list (split-string text "[\n]+")))
+ (setq alist (mapcar (function (lambda (x) (list x x))) list))
+ ))
+ (setq choice
+ (completing-read "possible completion: " alist nil t))
+ (insert choice))
+ (display-message-or-buffer buffer))
)
@@ -155,21 +137,13 @@
(delete-char 1)
(message "Expanded"))
(display-message-or-buffer buffer))
-; (if (not (eq exit-status 10))
-; (message "ocamlwizard: no completion"))
)
+
(defun ocamlwizard-rename (name)
"rename a value using Ocamlwizard"
(interactive "sRename with: ")
(setq pos (point))
-; (save-excursion
-; (search-backward-regexp "[^a-zA-Z._0-9]")
-; (forward-char 1)
-; (setq start (point))
-; (search-forward-regexp "[^a-zA-Z._0-9]")
-; (setq end (- (point) 1))
-; (setq word (buffer-substring start end)))
(setq file (buffer-name))
(setq buffer (get-buffer-create "*ocamlwizard*"))
(save-excursion
@@ -193,6 +167,7 @@
(clear-visited-file-modtime)
(widen)
(delete-region (point-min) (point-max))
+; (erase-buffer)
(insert-file-contents (buffer-file-name)))
; (set-window-vscroll nil scroll)
; Problem: if we undo and then redo, emacs forgets the goto.
@@ -81,19 +81,15 @@ let main () =
()
| Completion ->
-(* need to correct all functions in .el first
catch_owz (function () ->
-*)
List.iter (fun s ->
Clflags.include_dirs := s :: !Clflags.include_dirs)
(List.rev (i_dirs ()));
let rg = {b=(-1);e=check_validity ()} in
let ci = mk_info rg in
let c_info = Completion.main ci in
c_info
-(*
)
-*)
| Refactor r ->
(match r with
| Rename (loc, name', file) ->
@@ -12,7 +12,8 @@ R_CASES=renameSimple.ml renameSigNewCaptured.ml renameSigOldCaptured.ml \
renameModtype.ml renameModtypeInSig.ml \
renameModule.ml renameModuleInSig.ml renameModuleInFunctor.ml \
renameModuleInFunctorType.ml \
- renameConstructor.ml renameException.ml renameField.ml
+ renameConstructor.ml renameField.ml
+# renameException.ml
R_TESTS=$(subst .ml,_rres.ml, $(R_CASES))
RES=match_cases_res.ml expansion_res.ml path_res.ml errors_res.ml \
@@ -12,5 +12,8 @@ let r = {a = () ; b = ()}
let () = match [] with$
=>
-let () = match [] withEOF
+let () = match [] withError: File "completion/completion.ml", line 150, characters 19-25: Assertion failed
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF
@@ -52,11 +52,22 @@ let () = match X ((), []) with X ((), [] | $_ :: _EOF
let () = match () with $foo -> ()
=>
-let () = match () with EOF
+let () = match () with Error: Not_found
+Raised at file "common/typedtreeOps.ml", line 181, characters 10-19
+Called from file "completion/completion.ml", line 120, characters 3-85
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF
let () = match None with Some $_€ -> ()
=>
-let () = match None with Some EOF
+let () = match None with Some Error: var
+Raised at file "pervasives.ml", line 22, characters 22-33
+Called from file "completion/extraction/proposal_extraction.ml", line 281, characters 11-25
+Called from file "completion/completion.ml", line 161, characters 14-56
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF
let () = match List.hd [`a ; `b ; `c] with $_€ -> () (* why only `a ?*)
=>
@@ -119,7 +119,13 @@ let () = match `a with
let () = match `a with `b -> ()$
=>
-let () = match `a with `b -> ()EOF
+let () = match `a with `b -> ()Error: Error while typing
+Raised at file "pervasives.ml", line 22, characters 22-33
+Called from file "completion/completion.ml", line 62, characters 6-35
+Called from file "completion/completion.ml", line 100, characters 26-48
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF
let () = match List.map2 with $
=>
@@ -134,19 +140,33 @@ let () = match {a = () ; b = ()} with
let (_ : unit -> 'a) = function $
=>
-let (_ : unit -> 'a) = function EOF
+let (_ : unit -> 'a) = function Error: File "completion/completion.ml", line 150, characters 19-25: Assertion failed
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF
let () = match () with | $
=>
-let () = match () with | EOF
+let () = match () with | Error: File "completion/completion.ml", line 150, characters 19-25: Assertion failed
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF
let () = match true with true -> $
=>
-let () = match true with true -> EOF
+let () = match true with true -> Error: Not_found
+Raised at file "common/typedtreeOps.ml", line 181, characters 10-19
+Called from file "completion/completion.ml", line 120, characters 3-85
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF
let () = match true with true -> () | $
=>
-let () = match true with true -> () | EOF
+let () = match true with true -> () | Error: File "completion/completion.ml", line 150, characters 19-25: Assertion failed
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF
let () = match [] with [_] -> () $ (* missing _ :: _ :: _ *)
=>
@@ -160,5 +180,11 @@ let () = match None with Some [] -> ()
let () = match `a with `b -> ()$ (* because it doesn't type... *)
=>
-let () = match `a with `b -> ()EOF
+let () = match `a with `b -> ()Error: Error while typing
+Raised at file "pervasives.ml", line 22, characters 22-33
+Called from file "completion/completion.ml", line 62, characters 6-35
+Called from file "completion/completion.ml", line 100, characters 26-48
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF
@@ -109,7 +109,13 @@ EOF
let () = so $ (* this does not work, purposely *)
=>
-let () = so EOF
+let () = so Error: Error while typing
+Raised at file "pervasives.ml", line 22, characters 22-33
+Called from file "completion/completion.ml", line 62, characters 6-35
+Called from file "completion/completion.ml", line 100, characters 26-48
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF
let () = comp$
=>
@@ -137,13 +143,22 @@ EOF
let _ = {a = () $
=>
-let _ = {a = () EOF
+let _ = {a = () Error: File "completion/completion.ml", line 149, characters 17-23: Assertion failed
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF
let _ = {a = () ; M$
=>
-let _ = {a = () ; MEOF
+let _ = {a = () ; MError: File "completion/completion.ml", line 150, characters 19-25: Assertion failed
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF
let _ = {r $
=>
-let _ = {r EOF
+let _ = {r Error: File "completion/completion.ml", line 149, characters 17-23: Assertion failed
+Called from file "main/ocamlwizard.ml", line 90, characters 14-32
+Called from file "main/ocamlwizard.ml", line 61, characters 6-10
+EOF

0 comments on commit 4e32034

Please sign in to comment.