Completion features

Skip to end of metadata
Go to start of metadata

Feature list isn't complete, this page is subject to change.

There are three completion types:

Logical name Shortcut
Basic Ctrl+Space
Smart (SmartType) Ctrl+Shift+Space
Class Name, equivalent to second Basic completion invocation Ctrl+Alt+Space

Pressing the same shortcut twice results in 'second' completion, which may give more variants.

All languages

You may choose item in completion list not only with Enter, but also with variety of other keys: space, dot, colon, semicolon, '(' etc. Basically this will result in inserting that character after the completed identifier, but sometimes more will be done. For example, finishing Java method call with '(' will, of course, insert also ')'.

Choosing item with Tab has special meaning. In this case, if you are inside identifier, it will be overwritten completely instead of just inserting the item string into caret position.

Choosing item with Ctrl+Shift+Enter not only inserts an item, but also invokes Complete Statement to syntactically correct the code. For Java method calls this means that what's after the caret becomes an argument of the method call just inserted.

Class Name completion (Second Basic) works everywhere and typically displays all class names that are accessible from the current location. On one more invocation it displays all the classes that may become visible if you change their access modifiers or add necessary module dependencies.

If you don't like some suggested classes and you don't want to see it anymore, you may easily exclude it from import and completion.

Middle matching is used to filter suggestions.

Java

Basic

  • Context-specific reference and keyword completion, inserts parentheses, semicolons etc. where necessary.
  • Variable/method name suggestion based on type name, super methods and unresolved references in context file
  • Getter/setter name completion based on class fields
  • If prefix starts with an uppercase letter, shows all classes (like Class Name completion). Suggested in first completion invocation if there were no matching variants.
  • Property name/file path in string literal
  • Second: Inaccessible members (e.g. private fields) are shown.

Smart

  • Performs reference variants filtering based on expected type. If say an int is expected, only the variables/fields/methods of int type will be suggested.
  • If there is a one-element array of expected type (like the one created automatically to communicate with inner classes), and its name is say ref, then ref[0] is completed.
  • After new suggests all the classes descending from the expected type, inserts parentheses, if the selected class is abstract, will generate anonymous class body and suggest methods to implement.
  • After throw new suggests only the runtime exceptions merged with those explicitly declared in throws-clause.
  • In Javadoc throws tag suggests exceptions from method's throws-clause.
  • After catch suggests the exceptions that are thrown inside try.
  • After instanceof suggests inheritors of the checked expression type.
  • When Class<? extends X> is expected, suggests Class<Y> for all Y inheriting from X.
  • Completes generic parameters where missing: List<String> l = new ArrayList<|>();
  • Inserts explicit method type parameters where necessary: collect(Collections.emptyLis|) where collect expects List<String>
  • Suggests to cast to expected type after opening parenthesis: String s = (|
  • When calling a method or constructor with matching signature (e.g. a super method or a delegate), fills all the parameters immediately.
  • Suggests expression live templates whose result type can be determined from their text and enabled 'Smart completion' template context (e.g. one can create a template with a text like PsiManager.getInstance($END$))
  • Analyzes dataflow in search for typecasts and *instanceof*s and suggests to cast expressions to expected type where possible.
  • Keywords: class, this (possibly qualified), true, false, null
  • Second:
    • Iterates over the visible methods/fields to check if their return value contains members of expected type, resulting in chained calls like getModule().getProject(). Prefix matching is done on both the first and the second member in chain (so you may get this result from both getMo| and getPro|).
    • Converts between arrays and lists when you have one in context and need another.
    • Adds array member access when you have an array of expected type: int a = | will result in int a = intArray[|].

Both Basic & Smart

  • When completing a qualified expression analyzes dataflow and checks if there are any typecasts or *instanceof*s concerning the qualifier. If yes, suggests the variants based on the casted type and inserts the cast automatically.
  • In debugger's Evaluate Expression dialog does similar casting to runtime type. When expression is simple variable/field access, it's done immediately, when it involves method calls, on second completion.
  • If all variants are method overloads with the same name, lookup isn't shown, method name is inserted with caret placed inside parentheses.
  • When completing a method with boolean return type, you may finish completion with '!' and the call result will be negated.
  • Second invocation searches for static methods and fields in the project visible from the current location. By default they are inserted qualified, but if you press Alt+Enter, you may choose to import them statically. Exclude from completion works for them as well.
  • @MagicConstant support: expected values are suggested
  • Searches expected class's static members for matching values: Singleton s = | will result in Singleton s = Singleton.getInstance();
  • Searches method containing class for primitive constant fields which may be suitable

Groovy

Basic

  • Context-specific reference and keyword completion, inserts parentheses, semicolons etc. where necessary.
  • Runtime members:
    • DefaultGroovyMethods
    • SwingBuilder
    • New! Grails domain class & controller dynamic properties and methods
    • Gant script dynamic methods (e.g. depends, target) and properties (e.g. includeTargets, message)

Smart

  • New! After new in variable initializer with known type suggests possible inheritors: CharSequence c = new |
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.