Generating methods from unknown usages

I'm switching over from Eclipse, and things have been pretty smooth so far :). One feature I use heavily in Eclipse is to call a nonexistent method on a class and use the Cmd + 1 hints to create the method I just called. Intellij has Alt + Enter for a similar hints dialogue, but it does not include the ability to create a nonexistent method. After searching google, this forum, and documentation, I did find this a blurb about a quick fix suggestion to do just this: http://www.jetbrains.com/idea/features/code_generation.html (Generating methods, constants, parameters from unknown usages). However when I try this in my ide, the quick fix popup claims it has no suggestions.

My goal:
foo.myNewMethod("bar", "baz");
hit magic keystroke
class Foo has myNewMethod defined

I'm on 12.1 CE on OSX, waiting for me UE license from IT :). I tried to get quick fix to define a method internal to the class I'm in, like the example in the above link, and that also didnt work.
I'm writing Java with JDK 1.6 with imported maven projects.

Thanks for any help, tips, or insight!

0
Avatar
Permanently deleted user

Hi Chris,

This functionality (quick fix for generating non-existing method) is available at both Community and Ultimate editions.

I created a small screencast which illustrates how it works - https://dl.dropboxusercontent.com/u/1648086/video/new-method.m4v

You can trigger the quick fix by locating caret on a non-existing method reference and then clicking red bulb or by pressing Alt+Enter.

Denis

0
Avatar
Permanently deleted user

Yes, locating caret on a non-existing method reference works well.


____________
agile methodology

0
Avatar
Permanently deleted user

Thanks Denis that is exactly what I'm looking for! I believe I discovered the problem I'm experiencing. The project I imported is very large, more than 100 projects. It compiles on save which completes quickly, but initially the only feedback of the compilation error is the make window and a curly red line on the file name in the tab, but the code in the editor does not actually highlight the missing method in red. While typing this response, I tabbed back to the editor and finally the missing method turned red in the editor itself, allowing me to use the red bulb. It seems that it's taking ~30 seconds or more before the editor catches up. My teammates are not experiencing this, so maybe I will try to rebuild my project and import fewer mvn poms.

Thanks very much, I'm looking forward to becoming proficient in intellij :)

-Chris

0
Avatar
Permanently deleted user

You are welcome :)

Btw, 30 seconds is a way too long for regular highlighting. You can create a cpu snapshot for that situation (i.e. type a symbol, wait until the highlighting is done, type another one, wait until the highlighting is done etc). We'll check what's wrong there.

Denis

0

请先登录再写评论。