网页
综合
更新时间 2026-11-14 01:37:28
Code completion | AppCode Documentation
自动蜘蛛
www.jetbrains.com
正文约 4970 字
This section covers various techniques of context-aware code completion that allow you to speed up your coding process.
Basic code completion helps you complete the names of classes, methods, and keywords within the visibility scope.
When you invoke code completion, AppCode analyses the context and suggests the choices that are reachable from the current caret position (suggestions also include Live templates).
Code completion is available for custom file types. However, AppCode does not recognize the structure of such files, and suggests options regardless of whether they are appropriate in the current context.
Basic completion is also available for a non-English keyboard layout.
Start typing a name. By default, AppCode displays the code completion popup automatically as you type.
If automatic completion is disabled, press Ctrl+Space or choose Code | Code Completion | Basic from the main menu.
To narrow down the suggestions list, type any part of the expected name or keyword (even characters from somewhere in the middle are accepted) or invoke code completion after a dot separator. AppCode shows the suggestions that include the typed characters in any positions.
In case of CamelCase or snake_case names, you can type the initial letters only, and AppCode will show appropriate suggestions.
Accept an appropriate suggestion pressing Enter. You can also do the following:
Double-click a list item to insert it to the left of the caret.
Press Tab to replace the characters to the right from the caret.
Use Ctrl+Shift+Enter to make the current code construct syntactically correct (balance parentheses, add missing braces and semicolons, and so on).
Smart type-matching code completion filters the suggestions list and shows only the types applicable to the current context. For example, it can suggest a constructor or factory method of a class expected.
Start typing. By default, AppCode 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.
Press Ctrl+Shift+Space or choose Code | Code Completion | Type-Matching from the main menu.
If necessary, press Ctrl+Shift+Space once again. AppCode will look up values of the expected type which can be retrieved through a chained method call.
You can create syntactically correct code constructs by using statement completion. It inserts the necessary syntax elements (parentheses, braces, and semicolons) and gets you in a position where you can start typing the next statement.
Start typing a method declaration and press Ctrl+Shift+Enter.
Start typing a code construct and press Ctrl+Shift+Enter.
AppCode automatically completes the construct and adds the required punctuation. The caret is placed at the next editing position.
Hippie completion is a completion engine that analyses your text in the visible scope and generates suggestions from the current context. It helps you complete any word from any of the currently opened files.
Type the initial string and do one of the following:
Press Alt+/ or choose Code | Code Completion | Cyclic Expand Word to search for matching words before the caret.
Press Alt+Shift+/ or choose Code | Code Completion | Cyclic Expand Word (Backward) to search for matching words after the caret and in other open files.
The first suggested value appears, and the prototype is highlighted in the source code.
Accept the suggestion, or hold the Alt key and keep pressing / until the desired word is found.
Postfix code completion helps you reduce backward caret jumps as you write code. You can transform an already-typed expression to a different one based on a postfix you type after the dot, the type of expression, and its context.
Postfix completion is available for TypeScript, JavaScript, and SQL.
In the Settings dialog (Ctrl+Alt+S), open Editor | General | Postfix Completion and select the Enable postfix completion checkbox.
Select Tab, Space, or Enter to be used for expanding postfix templates.
Enable/disable a particular postfix template for the selected language.
Type an expression and then type a postfix after a dot, for example, .if:
The initial expression gets wrapped with an if statement:
You can edit the predefined postfix templates, for example, to replace a long key with a shorter one, or to expand the list of applicable expression types.
Postfix completion options are shown as part of the basic completion suggestions list. To see a full list of postfix completions applicable in the current context, press Ctrl+J.
Press Ctrl+Alt+S to open the IDE settings and select Editor | General | Postfix Completion.
Click the Add button () on the toolbar.
Specify Key that is a combination of symbols that will invoke the template.
Select which expression types the new template will be applicable to, and type the target expression in the following format: $EXPR$ <target_expression>, for example, $EXPR$ =!null.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。