patch for completion
Dimitris Dinodimos <[email protected]> Sun, 10 Aug 2008 22:37:23 +0300
| Newsgroups | gmane.comp.lang.erlang.distel.devel |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail-6--428324625
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
Hello,
I found an otp_doc server crash while trying to complete a function
in a non otp module.
To reproduce try to complete: distel:ap
Unexpected reply: [rex [badrpc [EXIT [[bad_return_value no_data]
[gen_server call (otp_doc [funcs "distel" "ap" nil])]]]]]
=ERROR REPORT==== 10-Aug-2008::21:57:38 ===
** Generic server otp_doc terminating
** Last message in was {funcs,"distel","ap",[]}
** When Server state == {state,"/opt/local/lib/erlang",file,"-"}
** Reason for termination ==
** {bad_return_value,no_data}
I found out that e_get({file,M}) thows no_data since M is not an otp
module and does not exist in the cache.
The attached patch solves this problem and modifies distel:modules
and distel:functions to use xref if the otp_doc returns an empty list.
Cheers,
Dimitris
--Apple-Mail-6--428324625
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream; x-unix-mode=0644;
name=distel-otp-doc.patch
Content-Disposition: attachment;
filename=distel-otp-doc.patch
Index: src/distel.erl
===================================================================
--- src/distel.erl (revision 72)
+++ src/distel.erl (working copy)
@@ -658,13 +658,13 @@
modules(Prefix) ->
case otp_doc:modules(Prefix) of
- {ok,Ans} -> {ok,Ans};
- {error,_}-> xref_modules(Prefix)
+ {ok,Ans} when Ans =/= [] -> {ok,Ans};
+ _ -> xref_modules(Prefix)
end.
functions(Mod, Prefix) ->
case otp_doc:functions(Mod,Prefix) of
- {ok,Ans} -> {ok,Ans};
- {error,_}-> xref_functions(Mod,Prefix)
+ {ok,Ans} when Ans =/= [] -> {ok,Ans};
+ _ -> xref_functions(Mod,Prefix)
end.
-define(COMPLETION_SERVER, distel_complete).
Index: src/otp_doc.erl
===================================================================
--- src/otp_doc.erl (revision 72)
+++ src/otp_doc.erl (working copy)
@@ -176,7 +176,10 @@
end.
all_fs(Mo,Fu) ->
- maybe_cache(Mo),
+ try maybe_cache(Mo)
+ catch
+ throw:no_data -> []
+ end,
[{Mo,F} || F <- all_prefix_keys({{as,Mo},Fu})].
all_prefix_keys({Tag,X}) ->
--Apple-Mail-6--428324625
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
--Apple-Mail-6--428324625
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Distel-hackers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/distel-hackers
--Apple-Mail-6--428324625--