Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make autocomplete show methods suggestions for overriding at subclass context on Intellij IDEA?

Say I have:

public class A extends B {
  /* autocompletion doesn't suggests protected methods from B to 
     override with Ctrl+SPACE
  */
}

I'm currently using Intellij IDEA 11.0.2.

like image 475
kaneda Avatar asked Mar 31 '12 23:03

kaneda


People also ask

How can I see override methods in IntelliJ?

On the Code menu, click Override methods Ctrl+O . Alternatively, you can right-click anywhere in the class file, then click Generate Alt+Insert , and select Override methods. Select the methods to override (hold the Shift or Ctrl key to perform a multiple select).

How do I get auto suggestions on IntelliJ?

I have tried the following according to this thread (Intellij IDEA CE 12 Android XML Code Completion not working): Go to File->Power Save Mode and disable it - it is off. Go to Preferences->Editor->Code Completion and check Autopopup code completion - this has been checked.

Why is IntelliJ autocomplete not working?

By default, IntelliJ IDEA displays the code completion popup automatically as you type. If automatic completion is disabled, press Ctrl+Shift+Space or choose Code | Code Completion | Type-Matching from the main menu. If necessary, press Ctrl+Shift+Space once again.

How do we override a method from the superclass?

When overriding a method, you might want to use the @Override annotation that instructs the compiler that you intend to override a method in the superclass. If, for some reason, the compiler detects that the method does not exist in one of the superclasses, then it will generate an error.


2 Answers

Right click in your editor pane for class A, go to 'Generate...' -> 'Override Methods...'.

You'll then be presented with a list of all methods that can be overridden.

'Generate...' can also be called up via keyboard shortcuts, I'm on a Mac currently and it's ^N. IIRC the shortcut on Windows/Linux is Alt-Insert.

like image 88
darrengorman Avatar answered Sep 29 '22 14:09

darrengorman


Tried to add this as a comment but the keyboard shortcuts are clear when added as a reply ;)

Once in your subclass do CTRL + O (Windows) this will list the methods that you can override, which includes the standard ones as well as the methods from your superclass.

Additional Info (Not related to question): Also posted a link that contains some other very useful intelliJ shorcuts if they are of use to you. IntelliJ shortcuts that I can't find

like image 25
MalsR Avatar answered Sep 29 '22 15:09

MalsR