emacs-eclim icon indicating copy to clipboard operation
emacs-eclim copied to clipboard

display current method-signature in the echo area

Open senny opened this issue 16 years ago • 7 comments

It would be great, if we could make something like eldoc-mode for java. This would ease the development extremely, because can always check what types you need to pass to a given method.

senny avatar Oct 20 '09 10:10 senny

Here's a prototype/implementation of the function you've bound to "C-c C-e s"

(defun eclim-java-method-signature-at-point ()
  "Find and display the method signature at point."
  (interactive)
  (let ((i (eclim--java-identifier-at-point t)))
    ;note: for some reason the "-t 'method'" portion of command doesn't function as expected for non-methods.
    (eclim/with-results hits ("java_search" "-n" "-f" ("-o" (car i)) ("-l" (length (cdr i))) ("-t" "method") ("-x" "declarations"))
      (echo-signature hits))))

(defun eclim-java-echo-signature (results)
  (if (= 1 (length results))
      (let ((result (elt results 0)))
        (message (assoc-default 'message result)))
    (error "found more than 1 result")))

I think there is a bug in the eclim code that handles the type request. In theory, running this function on a member variable should throw an error, but eclim still returns a result.

lespaul avatar Jul 24 '12 21:07 lespaul

@ervandew do you have an insight on the problem @lespaul found?

senny avatar Aug 07 '12 06:08 senny

Is the question: Why is eclim returning a result when -t method was supplied with the offset of an non-method element?

If so then the answer is that -t ... argument is ignored for element based searches since the type of the element is known. It's only used for pattern searches where the type is not known.

If that's not the question, then I guess I need some clarification.

ervandew avatar Aug 08 '12 17:08 ervandew

Thanks for answering the question! You're answering what I was confused about.

lespaul avatar Aug 08 '12 19:08 lespaul

Sounds very promising this feature. It does seem that it's only half way there in the source, though. The shortcut is registered in emacs-eclim.el, but the function cannot be found anymore (I see it was there once upon a time):

command-execute: Symbol's function definition is void: eclim-java-method-signature-at-point

skybert avatar Mar 27 '13 22:03 skybert

My idea is to use info we have when completing symbol. There's info about method arguments so if I'll send smart arguments to complete (the right method name + maybe method arity) then I believe required eldoc info will be in place.

The problem I have right now is how to know that I'm in method call somewhere and how exactly is that method named. expand-region have special extension to eventually mark the method call... so I might look into this and maybe hack it somehow with it, but maybe (most probably) there's better way.

Is it reasonable approach?

kleewho avatar May 20 '15 07:05 kleewho

Any progress on this?

vspinu avatar Sep 22 '15 14:09 vspinu