summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-02-19 10:50:10 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-02-19 10:50:10 -0800
commitc914063fd0eb8c02d8362b86a61933c656a938bc (patch)
treea81db16032450b5ece94b70c2d824e6bd2c79571
parentf20db9ab6cacd73f4276c6541d3009e731811a7e (diff)
downloadtxr-c914063fd0eb8c02d8362b86a61933c656a938bc.tar.gz
txr-c914063fd0eb8c02d8362b86a61933c656a938bc.tar.bz2
txr-c914063fd0eb8c02d8362b86a61933c656a938bc.zip
listener: restore and improve method completion.
The recent autoload changes have degraded method completion, which didn't work well in the first place. Test case: with this change you can type term.(go[Tab] to complete to term.(go-raw or term.(go-cbreak. * parser.c (find_matching_syms): Do not use the get_slot_syms function for finding method and slot symbols. Just use get_visible_syms, like for other bindings. Instead, in the switch statement in the loop, for the 'M' (method) and 'S' (slot) completion types, we use the static_slot_types and slot_types functions to inquire whether a symbol has a binding. And these two functions do something important: unlike get_slot_syms, they trigger autoload. * struct.c (get_slot_syms): Function removed. * struct.h (get_slot_syms): Declaration removed.
-rw-r--r--parser.c10
-rw-r--r--struct.c40
-rw-r--r--struct.h1
3 files changed, 7 insertions, 44 deletions
diff --git a/parser.c b/parser.c
index 2937ecd8..ee2ab6df 100644
--- a/parser.c
+++ b/parser.c
@@ -972,9 +972,7 @@ static void find_matching_syms(lino_completions_t *cpl,
if3(package == keyword_package && !force_qualify,
null_string,
package_name(package)));
- val syms = ((kind == 'S' || kind == 'M')
- ? hash_keys((get_slot_syms(package, is_cur, tnil(kind == 'M'))))
- : get_visible_syms(package, is_cur != nil && !qualify));
+ val syms = get_visible_syms(package, is_cur != nil && !qualify);
for ( ; syms; syms = cdr(syms)) {
val sym = car(syms);
@@ -992,7 +990,13 @@ static void find_matching_syms(lino_completions_t *cpl,
break;
continue;
case 'M':
+ if (static_slot_types(sym))
+ break;
+ continue;
case 'S':
+ if (slot_types(sym))
+ break;
+ continue;
break;
case 'Q':
if (mboundp(sym) || special_operator_p(sym))
diff --git a/struct.c b/struct.c
index f38e306f..d68b222e 100644
--- a/struct.c
+++ b/struct.c
@@ -1951,46 +1951,6 @@ val method_name(val fun)
return nil;
}
-val get_slot_syms(val package, val is_current, val method_only)
-{
- val result_hash = make_hash(hash_weak_none, nil);
- struct hash_iter sthi;
- val sth_cell;
-
- us_hash_iter_init(&sthi, struct_type_hash);
-
- while ((sth_cell = hash_iter_next(&sthi))) {
- val stype = us_cdr(sth_cell);
- val sl_iter;
- struct struct_type *st = coerce(struct struct_type *, stype->co.handle);
-
- for (sl_iter = st->slots; sl_iter; sl_iter = cdr(sl_iter)) {
- val slot = car(sl_iter);
-
- if (gethash(result_hash, slot))
- continue;
-
- if (!is_current && symbol_package(slot) != package)
- continue;
-
- if (!symbol_visible(package, slot))
- continue;
-
- if (method_only) {
- loc ptr = lookup_static_slot(st, slot);
- if (nullocp(ptr))
- continue;
- if (!functionp(deref(ptr)))
- continue;
- }
-
- sethash(result_hash, slot, t);
- }
- }
-
- return result_hash;
-}
-
val slot_types(val slot)
{
uses_or2;
diff --git a/struct.h b/struct.h
index 0fd3c067..87587f8f 100644
--- a/struct.h
+++ b/struct.h
@@ -86,7 +86,6 @@ val super_method(val strct, val slotsym);
val uslot(val slot);
val umethod(val slot, struct args *);
val method_name(val fun);
-val get_slot_syms(val package, val is_current, val method_only);
val slot_types(val slot);
val static_slot_types(val slot);
val slot_type_reg(val slot, val strct);