senny / emacs-eclim

This project brings some of the great eclipse features to emacs developers. It is based on the eclim project, which provides eclipse features for vim.
http://www.emacswiki.org/emacs/EmacsEclim
587 stars 102 forks source link

display current method-signature in the echo area #5

Open senny opened 15 years ago

senny commented 15 years ago

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.

lespaul commented 12 years ago

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.

senny commented 12 years ago

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

ervandew commented 12 years ago

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.

lespaul commented 12 years ago

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

skybert commented 11 years ago

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
kleewho commented 9 years ago

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?

vspinu commented 9 years ago

Any progress on this?