@@ -354,16 +354,21 @@ def report_error(message, project):
354
354
project .disabled = True
355
355
356
356
def completion_icon (type ):
357
- if type is None or type == "?" : return " (?)"
358
- if type .startswith ("fn(" ): return " (fn)"
359
- if type .startswith ("[" ): return " ([])"
360
- if type == "number" : return " (num)"
361
- if type == "string" : return " (str)"
362
- if type == "bool" : return " (bool)"
363
- return " (obj)"
364
-
365
- def fn_completion_icon (arguments ):
366
- return " (fn/" + str (len (arguments ))+ ")"
357
+ if type is None or type == "?" : return "\t ? "
358
+ if type .startswith ("fn(" ): return "\t fn "
359
+ if type .startswith ("[" ): return "\t [] "
360
+ if type == "number" : return "\t num "
361
+ if type == "string" : return "\t str "
362
+ if type == "bool" : return "\t bool "
363
+ return "\t {} "
364
+
365
+ def fn_completion_icon (arguments , retval ):
366
+ # return " (fn/"+str(len(arguments))+")"
367
+ ret = ""
368
+ if retval is not None :
369
+ ret = retval
370
+
371
+ return "(" + ", " .join (arguments ) + ")" + ret + ("\t fn " )
367
372
368
373
# create auto complete string from list arguments
369
374
def create_arg_str (arguments ):
@@ -421,14 +426,22 @@ def ensure_completions_cached(pfile, view):
421
426
for rec in data ["completions" ]:
422
427
rec_name = rec .get ('name' ).replace ('$' , '\\ $' )
423
428
rec_type = rec .get ("type" , None )
424
- if arg_completion_enabled and completion_icon (rec_type ) == " (fn)" :
429
+ if arg_completion_enabled and rec_type is not None and rec_type .startswith ("fn(" ):
430
+ retval = parse_function_type (rec ).get ('retval' )
431
+
432
+ if retval is None or retval == "()" :
433
+ retval = ""
434
+ elif retval .startswith ("{" ):
435
+ retval = "{}"
436
+ elif retval .startswith ("[" ):
437
+ retval = "[]"
438
+
439
+ if retval != "" :
440
+ retval = " -> " + retval
441
+
425
442
arguments = get_arguments (rec_type )
426
443
fn_name = rec_name + "(" + create_arg_str (arguments ) + ")"
427
- completions .append ((rec .get ("name" ) + fn_completion_icon (arguments ), fn_name ))
428
-
429
- for i in range (len (arguments ) - 1 , - 1 , - 1 ):
430
- fn_name = rec_name + "(" + create_arg_str (arguments [0 :i ]) + ")"
431
- completions_arity .append ((rec .get ("name" ) + fn_completion_icon (arguments [0 :i ]), fn_name ))
444
+ completions .append ((rec .get ("name" ) + fn_completion_icon (arguments , retval ), fn_name ))
432
445
else :
433
446
completions .append ((rec .get ("name" ) + completion_icon (rec_type ), rec_name ))
434
447
0 commit comments