NetBeans-SCSNI

5.4-Demonstrate the ability to use editor hints, such as implementing all the methods for an implemented interface.

How to use Code Completion

Code completion has been improved in several ways.

  • Code completion behavior Ctrl+Space lists symbols which are already imported in your source file, plus of course symbols from the java.lang package. Pressing Ctrl+Space again will list all symbols from the project class path whether imported or not. If you want to go to the list of all types immediately you can use the All Symbols Completion, which is invoked by pressing Ctrl+Alt+Space.

  • Smart completion - Notice that the standard completion listbox is divided into two parts separated by a black line. The first section includes smart completion items. The editor chooses these items based on the current context (i.e. around the current caret position) when completion is invoked. See other bullet points below starting with "smart" for more information and examples of this smart completion feature.

  • Completing Keywords You may use code completion for completing keywords: the editor knows which keywords fit into which place in your code. Just don't be surprised if you don't see the keyword if. It is so short that we decided not to put it into code completion.
CC_Keywords.png

  • Field/Variable names When you introduce a new field or variable, you often want its name to mimic its type. Code completion now supports this. To prepend a prefix to the guessed name, simply type the prefix and then invoke code completion. This works for method names as well.
CC_VariableNames.png

  • Smart completion examples Here is a list of places where smart completion kicks in.

    • After new (with generics) This will help especially when you are declaring a field or variable with complicated generics.
CC_SmartNewGenerics.png

    • In method call parameters Smart completion will offer only those fields, variables, methods which can be passed as an argument to the method.
CC_SmartParameter.png

    • Smart code completion for types

    • For exceptions In a catch block smart completion will offer only those exceptions which have been thrown in the try block but not yet caught.
CC_SmartCatch.png

  • Parameter guessing Code completion of method calls guesses which variable, field or parameter should be used based on type and similarity of the name. See the screenshot to see how the correct variables were picked by code completion when completing the call to the createRectangle() method.
CC_ParameterGuessing.png

  • Code completion ending character Notice that you may select the item of choice with different keys. Selecting with Enter you'll get what you expect. Should you select the item with ".", "," or ";" code completion will append the character you typed at the end of the completed word.

  • Generics in generation of implementation

  • Creation of elements - Invoking code completion between class members will offer to create a constructor (either a default constructor or one initializing uninitialized fields), override methods or implementation methods. For more code generation features please look at the code generation dialog section.
CC_Constructors.png

  • Completion for annotations

  • Completion in Collections.<String>| - works fine when Collections is imported.
-- Wagner R. Santos