网页 综合 更新时间 2026-11-14 01:37:29

Auto import | AppCode Documentation

自动蜘蛛 www.jetbrains.com 正文约 2950 字
Auto import | AppCode Documentation
When you start using a class that is not yet imported, or a method from a library that is not yet included, AppCode will suggest adding the corresponding import statement automatically, or on code completion.
Auto-import is not available for Swift.
Type a reference to a non-imported class or function.
Press Alt+Enter. If there are multiple choices, select the desired option from the list.
In TypeScript files, AppCode can automatically add import statements if there is only one option to choose from.
In the Preferences dialog (Ctrl+Alt+S), go to Editor | General | Auto Import | TypeScript/JavaScript.
Select the Add unambiguous imports on the fly checkbox and apply the changes.
When you paste blocks of code that contain references to the symbols that are not yet imported, AppCode will add missing imports automatically.
When tooltips are disabled, unresolved references are underlined and marked with the red bulb icon . To view the list of suggestions, click this icon (or press Alt+Enter) and select Import class.
Hover the mouse over the inspection widget in the top-right corner of the editor, click , and disable the Show Auto-Import Tooltip option.
If you want to completely disable auto-import, make sure that:
All import tooltips are disabled.
The automatic insertion of import statements is disabled.
The Optimize Imports feature helps you remove unused imports and organize import statements in the current file or in all files in a directory at once according to the rules specified in Preferences | Editor | Code Style | <language> | Imports.
You can exclude specific files and folders from import optimization. For more information, refer to Exclude files from reformatting.
Select a file or a directory in the Project tool window (View | Tool Windows | Project).
Do any of the following:
From the main menu, select Code | Optimize Imports (or press Ctrl+Alt+O).
From the context menu, select Optimize Imports.
(If you've selected a directory) Choose whether you want to optimize imports in all files in the directory, or only in locally modified files (if your project is under version control), and click Run.
Place the caret at the import statement and press Alt+Enter or use the icon.
Select Optimize imports.
To optimize imports in a file, you can also press Ctrl+Alt+Shift+L, select Optimize imports, and click Run.
If your project is under version control, you can instruct AppCode to optimize imports in modified files before committing them to VCS.
Press Ctrl+K or select Git | Commit from the main menu.
Click and in the commit message area, select the Optimize imports checkbox.
You can tell AppCode to optimize imports in a file every time it is reformatted.
Open the file in the editor, press Ctrl+Alt+Shift+L, and make sure the Optimize imports checkbox is selected in the Reformat File dialog that opens.
After that every time you press Ctrl+Alt+L in this project, AppCode will optimize its imports automatically.
访问原文 返回搜索 https://www.jetbrains.com/help/objc/creating-and-optimizing-imports.html
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。