Browse files

Fixing error report for completion

  • Loading branch information...
1 parent 4618286 commit 51b574c6a85b2857df3760ece069b440da3a1b53 @tturpin tturpin committed Jul 10, 2011
View
2 .ocamlwizard
@@ -2,9 +2,11 @@ utils
parsing
typing
ocamlwizard/common
+ocamlwizard/main
ocamlwizard/completion
ocamlwizard/completion/syntactic
ocamlwizard/completion/typing
ocamlwizard/completion/extraction
ocamlwizard/completion/filtering
ocamlwizard/completion/printing
+ocamlwizard/refactor
View
2 ocamlwizard/TODO
@@ -1,5 +1,5 @@
- Rename: replace in multiple files
-
+- Grep: should be easy to implement using rename
- Rename: return a list of files that emacs should revert
- Rename: check that we always lookup in the right environment
- Rename: check that all Ident.t s in typedtree are processed
View
16 ocamlwizard/common/common_config.ml
@@ -100,7 +100,7 @@ let project_file_name = ".ocamlwizard"
let rec find_project_file d =
let pf = Filename.concat d project_file_name in
if Sys.file_exists pf then (
- if !debug then Printf.eprintf "Found project file in directory %s" d;
+ if !debug then Printf.eprintf "Found project file in directory %s\n" d;
d, pf
) else if d = "/" then
raise Not_found
@@ -140,7 +140,8 @@ let search_dirs source =
try
let d, pf = find_project_file dir in
if !find_project_dir then (
- print_endline d ; exit 0
+ let d = if d = "" then "" else d ^ "/" in
+ print_endline d ; exit 0
);
project_directories d pf @ dirs
with
@@ -265,17 +266,6 @@ let anonymous = function
begin
match !command with
- | Refactor Rename ->
- if Array.length Sys.argv -i <> 7 then
- raise (Arg.Bad "refactor: too few arguments");
- let old_id = Sys.argv.(i + 3)
- and new_id = Sys.argv.(i + 4)
- and file = Sys.argv.(i + 5) in
- compile_index := i + 5;
- Rename.rename loc old_id new_id file
-(*
- Arg.current := Array.length Sys.argv;
-*)
| _ -> failwith "not yet"
(*
View
10 ocamlwizard/common/typedtreeOps.ml
@@ -22,11 +22,6 @@ type 'a sfun =
[ `structure of Typedtree.structure | `signature of Typedtree.signature]
-> 'a
-type 'a funs = {
- structure : structure -> 'a;
- signature : signature -> 'a
-}
-
module MakeIterator
(Arg : IteratorArgument) = struct
@@ -36,11 +31,6 @@ module MakeIterator
| `structure s -> iter_structure s
| `signature s -> iter_signature s
- let process' = {
- structure = iter_structure;
- signature = iter_signature
- }
-
end
type node = [
View
12 ocamlwizard/common/typedtreeOps.mli
@@ -25,14 +25,6 @@ type 'a sfun =
[ `structure of Typedtree.structure | `signature of Typedtree.signature]
-> 'a
-(*
-(** The same, but as a record of two functions. *)
-type 'a funs = {
- structure : Typedtree.structure -> 'a;
- signature : Typedtree.signature -> 'a
-}
-*)
-
(** The common type for all typedtree nodes. *)
type node = [
`structure of structure
@@ -92,7 +84,7 @@ val locate_map : [`outermost | `innermost] -> (node -> 'a option) ->
int * int -> 'a sfun
(*
-(** The same as locate, but with *)
+(** The same as locate, but with exceptions *)
val locate_map_exn : [`outermost | `innermost] -> (node -> 'a) ->
int * int -> 'a sfun
*)
@@ -104,8 +96,10 @@ val find_pattern :
val find_expression :
[`outermost | `innermost] -> (Typedtree.expression -> 'a option) -> 'a sfun
+(* Not used anymore
module NodeTbl : Hashtbl.S with type key = node
type father_table = node NodeTbl.t
val reverse : father_table sfun
+*)
View
5 ocamlwizard/completion/completion.ml
@@ -167,7 +167,4 @@ let main ce =
(* 5 - Printing the result in a formatter *)
step "Proposal printing";
Proposal_printing.main ~miss:Parsing_env.parser_state.miss std_formatter ty_lis c_res ce.c_printer;
-
- (* Exiting with the error code (for auto-test) *)
- Debug.exit_with_code (!Common_config.dot_test) se.comp
-
+
View
33 ocamlwizard/emacs/ocamlwizard.el
@@ -130,24 +130,33 @@
(setq arrow (point)))
(setq file (buffer-name))
(setq buffer (get-buffer-create "*ocamlwizard*"))
+ (do-auto-save)
(save-excursion
(set-buffer buffer)
(compilation-minor-mode 1)
- (erase-buffer)
- (insert "\n\n"))
- (do-auto-save)
- (goto-char start)
- (delete-char (- end start))
+ (erase-buffer))
+ ; don't put this inside save-excursion, or pwd will be incorrect
(setq exit-status
(call-process
- "ocamlwizard" nil (list t nil) nil
+ "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)))
+ "-expand" (concat (int-to-string (- start 1)) "-"
+ (int-to-string (- end 1)))
file))
- (if (not (eq exit-status 10))
- (message "ocamlwizard: no completion"))
- (search-backward "$")
- (delete-char 1)
+ (save-excursion
+ (set-buffer buffer)
+ (setq output (buffer-string)))
+ (if (eq exit-status 0)
+ (progn
+ (goto-char start)
+ (delete-char (- end start))
+ (insert output)
+ (search-backward "$")
+ (delete-char 1)
+ (message "Expanded"))
+ (display-message-or-buffer buffer))
+; (if (not (eq exit-status 10))
+; (message "ocamlwizard: no completion"))
)
(defun ocamlwizard-rename (name)
@@ -168,7 +177,7 @@
(compilation-minor-mode 1)
(erase-buffer))
(do-auto-save)
- (setq exit-status
+ (setq exit-status
(call-process
"ocamlwizard" nil buffer nil
"completion" "refactor" "-rename"
View
7 ocamlwizard/main/ocamlwizard.ml
@@ -81,14 +81,19 @@ 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) ->
View
4 ocamlwizard/owz.sh
@@ -1,7 +1,7 @@
#!/bin/bash
OWZ=owz.opt
PROJECT_DIR=`$OWZ -find-project-dir $* 2>/dev/null`
-echo ocamlwizard $* >$PROJECT_DIR/.ocamlwizard-stderr
+echo ocamlwizard $* >$PROJECT_DIR.ocamlwizard-stderr
OCAMLLIB=/usr/local/lib/ocaml $OWZ -debug -backtrace $* \
-2>>$PROJECT_DIR/.ocamlwizard-stderr | tee $PROJECT_DIR/.ocamlwizard-stdout
+2>>$PROJECT_DIR.ocamlwizard-stderr | tee $PROJECT_DIR.ocamlwizard-stdout
exit ${PIPESTATUS[0]}

0 comments on commit 51b574c

Please sign in to comment.