Skip to content

Commit 4ce8896

Browse files
committed
Complete version
1 parent af3483c commit 4ce8896

File tree

1 file changed

+30
-13
lines changed

1 file changed

+30
-13
lines changed

eldoc-meta-net.el

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
;; Description: Eldoc support for meta-net
88
;; Keyword: eldoc c# dotnet sdk
99
;; Version: 0.1.0
10-
;; Package-Requires: ((emacs "25.1") (meta-net "1.1.0") (ht "2.3"))
10+
;; Package-Requires: ((emacs "26.1") (meta-net "1.1.0") (ht "2.3"))
1111
;; URL: https://github.com/emacs-vs/eldoc-meta-net
1212

1313
;; This file is NOT part of GNU Emacs.
@@ -235,7 +235,7 @@ We use this to eliminate not possible candidates."
235235
match))
236236

237237
(defun eldoc-meta-net--grab-data (function-name)
238-
"Return data that matches FUNCTION-NAME."
238+
"Return data that match FUNCTION-NAME."
239239
(unless meta-net-csproj-current (meta-net-read-project)) ; read it
240240
(eldoc-meta-net--grab-namespaces) ; first grab the data from `meta-net'
241241

@@ -295,19 +295,21 @@ We use this to eliminate not possible candidates."
295295
(eldoc-meta-net-debug "Arg Bounds: %s" arg-bounds)
296296
(eldoc-meta-net-debug "Arg Count: k%s" arg-count)
297297
;; Find match arguments count, for function overloading
298-
(let ((index 0) (len (length methods)) data break
299-
name info match-arg-count target)
300-
(while (and (not break) (< index len))
298+
(let ((index 0) (len (length methods)) data found
299+
name info match-arg-count match-bounds)
300+
(while (and (not found) (< index len))
301301
(setq data (nth index methods)
302302
index (1+ index)
303303
name (car data) info (cdr data)
304304
match-arg-count 0)
305+
(jcs-print "name" name)
305306
(with-temp-buffer
306307
(insert name)
307308
(goto-char (point-min))
308309
(when (search-forward "(" nil t)
309310
(forward-char -1)
310-
(setq match-arg-count (length (eldoc-meta-net--arg-boundaries)))
311+
(setq match-bounds (eldoc-meta-net--arg-boundaries)
312+
match-arg-count (length match-bounds))
311313
;; Notice that function overloading can has same argument count
312314
;; but with different type.
313315
;;
@@ -323,13 +325,28 @@ We use this to eliminate not possible candidates."
323325
;; Since we cannot know the type from the uesr, we just pick one
324326
;; that matches.
325327
(when (= match-arg-count arg-count)
326-
(setq target data ; found
327-
break t))))
328-
(jcs-print name)
329-
(jcs-print (ht-get info 'summary))
330-
(jcs-print "Match arg count: "match-arg-count))
331-
name)
332-
)))
328+
(setq found t)))))
329+
330+
;; Shoud we still display information if we cannot find the matching?
331+
(when found
332+
(with-temp-buffer
333+
(delay-mode-hooks (funcall 'csharp-mode))
334+
(ignore-errors (font-lock-ensure))
335+
(insert name)
336+
(let ((params (ht-get info 'params)) (param-index (1- (length match-bounds)))
337+
param param-name param-summary)
338+
(dolist (bound (reverse match-bounds)) ; we replace from the back
339+
(delete-region (car bound) (cdr bound))
340+
(goto-char (car bound))
341+
(setq param (nth param-index params)
342+
param-name (car param)
343+
param-summary (cdr param))
344+
(when (= param-index arg-index)
345+
(setq param-name (propertize param-name 'face 'eldoc-highlight-function-argument)))
346+
;; Make sure we don't add a space infront of (
347+
(insert (if (= param-index 0) "" " ") param-name)
348+
(setq param-index (1- param-index))))
349+
(buffer-string)))))))
333350

334351
(defun eldoc-meta-net--turn-on ()
335352
"Start the `eldoc-meta-net' worker."

0 commit comments

Comments
 (0)