IntelliJ IDEA 14.0.0 Web Help

Basic Code Completion. Completing Names and Keywords

Basic code completion helps you complete the names of classes, methods, fields, and keywords within the visibility scope. When you invoke code completion, IntelliJ IDEA analyses the context and suggests the choices that are reachable from the current position of the caret.

If basic code completion is applied to a part of a field, parameter, or variable declaration, IntelliJ IDEA suggests a list of possible names with regard to the type of the item.

Invoking Basic code completion for the second time shows the names of classes available through the module dependencies.

When invoked once more (for the third time in a row), the suggestion list expands to the whole project, regardless of the dependencies.

This action completes the names of classes and interfaces , searching through the entire project. If the desired class is not yet imported, it will be imported automatically.

Code completion covers supported file types and custom file types. However, IntelliJ IDEA does not recognize the structure of custom file types and suggests completion options regardless of whether a specific type is appropriate in the current context.

To automatically complete names in the current visibility scope, follow these general steps:

  1. Type a name or a part of a name.

    While typing, use the following techniques:

    • 12.0+Narrow down the suggestion list by typing any part of a word, even the characters somewhere in the middle, or invoking code completion after a dot separator. IntelliJ IDEA will show suggestion list that includes occurrences with all the possible positions of the entered characters. 12.0+

      This makes the use of the asterisk wildcard unnecessary:

      codeCompletionWildcard.png
    • In case of CamelCase or snake_case names, type the initial letters only. So doing, IntelliJ IDEA automatically recognizes and matches the initial letters.
  2. Do one of the following:
    • On the main menu, choose Code | Completion | Basic .
    • Press Ctrl+Space.
    basicCodeCompletion.png
  3. 12.0+
    If necessary, press Ctrl+Space for the second time.

    This shows all classes, available through the module dependencies. The second completion shows also static fields and methods.

    codeCompletionSecondClass1.png

    When invoked for the third time, basic code completion expands the suggestion list to all classes throughout the project, regardless of the dependencies.

  4. Select the desired class from the suggestion list, and do one of the following:
    • Press Enter or double-click the desired choice .
    • Press Tab .

See Also

Last modified: 12 November 2014
comments powered by Disqus